Commit 2800f15f authored by Cynthia Crowley's avatar Cynthia Crowley

Fix forcing so that directory includes a time integration window, rather than...

Fix forcing so that directory includes a time integration window, rather than looking for 3mo Pr sum in generic forcing file
parent a0274adb
......@@ -37,9 +37,11 @@ from .step import Step
def create_forcing_file(workspace: DefaultWorkspace,
data: Union[ObservedForcing, ForecastForcing],
*,
window: int,
yearmon: str,
target: Optional[str]=None,
member: Optional[str]=None) -> List[Step]:
member: Optional[str]=None,
) -> List[Step]:
precip = data.precip_monthly(yearmon=yearmon, target=target, member=member)
temp = data.temp_monthly(yearmon=yearmon, target=target, member=member)
......@@ -60,7 +62,7 @@ def create_forcing_file(workspace: DefaultWorkspace,
'Pr:units',
'Pr:standard_name'
])),
output=workspace.forcing(yearmon=yearmon, target=target, member=member, window=1)
output=workspace.forcing(yearmon=yearmon, target=target, member=member, window=window)
)
]
......@@ -175,6 +177,7 @@ def time_integrate(workspace: DefaultWorkspace,
def compute_return_periods(workspace: DefaultWorkspace, *,
forcing_vars: Optional[List[str]]=None,
result_vars: Optional[List[str]]=None,
state_vars: Optional[List[str]]=None,
yearmon: str,
window: int,
target: Optional[str]=None,
......@@ -195,6 +198,9 @@ def compute_return_periods(workspace: DefaultWorkspace, *,
if basis:
assert not forcing_vars
if state_vars:
assert window==1
return [
wsim_anom(
fits=[workspace.fit_obs(var=var,
......@@ -205,7 +211,8 @@ def compute_return_periods(workspace: DefaultWorkspace, *,
read_vars(workspace.results(**args), *result_vars)
if result_vars else None,
read_vars(workspace.forcing(yearmon=yearmon, target=target, window=window, member=member), *forcing_vars)
if forcing_vars else None
if forcing_vars else None,
read_vars(workspace.state(yearmon=yearmon), *state_vars) if state_vars else None
],
rp=workspace.return_period(**args),
sa=workspace.standard_anomaly(**args)
......
......@@ -427,7 +427,7 @@ class DefaultWorkspace:
window: int,
member: Optional[str]=None,
target: Optional[str]=None) -> str:
return self.make_path('forcing', yearmon=yearmon, member=member, target=target, window=None)
return self.make_path('forcing', yearmon=yearmon, member=member, target=target, window=window)
def results(self, *,
sector: Optional[Sector]=None,
......
......@@ -40,7 +40,7 @@ def spinup(config, meta_steps):
for yearmon in config.historical_yearmons():
steps += config.observed_data().prep_steps(yearmon=yearmon)
steps += create_forcing_file(config.workspace(), config.observed_data(), yearmon=yearmon)
steps += create_forcing_file(config.workspace(), config.observed_data(), yearmon=yearmon, window=1)
steps += run_lsm_from_final_norm_state(config)
......@@ -82,8 +82,8 @@ def spinup(config, meta_steps):
for window in [1] + config.integration_windows():
for yearmon in config.historical_yearmons()[window-1:]:
steps += compute_return_periods(config.workspace(),
result_vars=config.lsm_rp_vars() + config.forcing_rp_vars() if window == 1 else config.lsm_integrated_var_names() + config.forcing_integrated_var_names(),
forcing_vars=config.forcing_rp_vars() if window == 1 else None,
result_vars=config.lsm_rp_vars() + config.forcing_rp_vars() if window == 1 else config.lsm_integrated_var_names(),
forcing_vars=config.forcing_rp_vars() if window == 1 else config.forcing_integrated_var_names(),
yearmon=yearmon,
window=window)
......@@ -317,8 +317,7 @@ def time_integrate_forcing(config:Config, window: int, *, basis: Optional[Basis]
config.workspace().tag('{}spinup_1mo_forcing'.format((basis.value + '_') if basis else '')))
return [
integrate,
*tag_steps
integrate
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment