|
53 | 53 | from metsim import io |
54 | 54 | from metsim.datetime import date_range |
55 | 55 | from metsim.disaggregate import disaggregate |
56 | | -from metsim.methods import mtclim |
| 56 | +from metsim.methods import mtclim, passthrough |
57 | 57 | from metsim.physics import solar_geom |
58 | 58 | from metsim.units import converters |
59 | 59 |
|
|
104 | 104 | 'rel_humid': {'units': '%', 'long_name': 'relative humidity', |
105 | 105 | 'standard_name': 'relative_humidity', |
106 | 106 | 'missing_value': np.nan, 'fill_value': np.nan}, |
| 107 | + 'daylength': {'units': 's', 'long_name': 'daylength', |
| 108 | + 'standard_name': 'length of day', |
| 109 | + 'missing_value': np.nan, 'fill_value': np.nan}, |
107 | 110 | 'spec_humid': {'units': 'g g-1', 'long_name': 'specific humidity', |
108 | 111 | 'standard_name': 'specific_humidity', |
109 | 112 | 'missing_value': np.nan, 'fill_value': np.nan}, |
@@ -131,7 +134,7 @@ class MetSim(object): |
131 | 134 | """ |
132 | 135 |
|
133 | 136 | # Class variables |
134 | | - methods = {'mtclim': mtclim} |
| 137 | + methods = {'mtclim': mtclim, 'passthrough': passthrough} |
135 | 138 | params = { |
136 | 139 | "period_ending": False, |
137 | 140 | "is_worker": False, |
@@ -474,7 +477,6 @@ def run_slice(self): |
474 | 477 | locs = {d: i for d, i in zip(self.domain['mask'].dims, index)} |
475 | 478 | else: |
476 | 479 | continue |
477 | | - |
478 | 480 | df, state = wrap_run_cell(self.method.run, params, |
479 | 481 | self.met_data.isel(**locs), |
480 | 482 | self.state.isel(**locs), |
@@ -654,7 +656,7 @@ def _validate_setup(self): |
654 | 656 |
|
655 | 657 | # Check output variables are valid |
656 | 658 | daily_out_vars = ['t_min', 't_max', 't_day', 'prec', 'vapor_pressure', |
657 | | - 'shortwave', 'tskc', 'pet', 'wind'] |
| 659 | + 'shortwave', 'tskc', 'pet', 'wind', 'daylength'] |
658 | 660 | out_var_check = ['temp', 'prec', 'shortwave', 'vapor_pressure', |
659 | 661 | 'air_pressure', 'rel_humid', 'spec_humid', |
660 | 662 | 'longwave', 'tskc', 'wind'] |
@@ -778,7 +780,13 @@ def wrap_run_cell(func: callable, params: dict, |
778 | 780 | # If we're outputting daily values, we dont' need to |
779 | 781 | # change the output dates - see inside of `if` condition |
780 | 782 | # above for more explanation |
781 | | - new_times = out_times |
| 783 | + start = out_times.values[0] |
| 784 | + stop = (out_times.values[-1] + pd.Timedelta('1 days') - |
| 785 | + pd.Timedelta("{} minutes".format(params['time_step']))) |
| 786 | + new_times = date_range( |
| 787 | + start, stop, freq='{}T'.format(params['time_step']), |
| 788 | + calendar=params['calendar']) |
| 789 | + df_base.index = new_times |
782 | 790 | df_complete = df_base |
783 | 791 |
|
784 | 792 | # Cut the returned data down to the correct time index |
|
0 commit comments