Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update logic to call assemble_rfc_dataframes() function #692

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions src/troute-network/troute/DataAssimilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,31 +541,34 @@ def __init__(self, network, from_files, value_dict):
self._reservoir_rfc_df = pd.DataFrame()
self._reservoir_rfc_param_df = pd.DataFrame()
else:
# In order to use only RFC python module (not fortran module), create rfc dataframes from reading files
#rfc_parameters = self._data_assimilation_parameters.get('reservoir_da', {}).get('reservoir_rfc_da', {})
lookback_hrs = rfc_parameters.get('reservoir_rfc_forecasts_lookback_hours')
offset_hrs = rfc_parameters.get('reservoir_rfc_forecasts_offset_hours')
start_datetime = network.t0
timeseries_end = start_datetime + timedelta(hours=offset_hrs)
timeseries_start = timeseries_end - timedelta(hours=lookback_hrs)
delta = timedelta(hours=1)
timeseries_dates = []
while timeseries_start <= timeseries_end:
timeseries_dates.append(timeseries_start.strftime('%Y-%m-%d_%H'))
timeseries_start += delta
rfc_forecast_persist_days = rfc_parameters.get('reservoir_rfc_forecast_persist_days')
final_persist_datetime = start_datetime + timedelta(days=rfc_forecast_persist_days)
# RFC Observations
if rfc:
# In order to use only RFC python module (not fortran module), create rfc dataframes from reading files
#rfc_parameters = self._data_assimilation_parameters.get('reservoir_da', {}).get('reservoir_rfc_da', {})
lookback_hrs = rfc_parameters.get('reservoir_rfc_forecasts_lookback_hours')
offset_hrs = rfc_parameters.get('reservoir_rfc_forecasts_offset_hours')
start_datetime = network.t0
timeseries_end = start_datetime + timedelta(hours=offset_hrs)
timeseries_start = timeseries_end - timedelta(hours=lookback_hrs)
delta = timedelta(hours=1)
timeseries_dates = []
while timeseries_start <= timeseries_end:
timeseries_dates.append(timeseries_start.strftime('%Y-%m-%d_%H'))
timeseries_start += delta
rfc_forecast_persist_days = rfc_parameters.get('reservoir_rfc_forecast_persist_days')
final_persist_datetime = start_datetime + timedelta(days=rfc_forecast_persist_days)

# RFC Observations
rfc_timeseries_path = str(rfc_parameters.get('reservoir_rfc_forecasts_time_series_path'))
self._rfc_timeseries_df = _read_timeseries_files(rfc_timeseries_path, timeseries_dates, start_datetime, final_persist_datetime)

self._reservoir_rfc_df, self._reservoir_rfc_param_df = assemble_rfc_dataframes(
self._rfc_timeseries_df,
network.rfc_lake_gage_crosswalk,
network.t0,
rfc_parameters,
)
self._reservoir_rfc_df, self._reservoir_rfc_param_df = assemble_rfc_dataframes(
self._rfc_timeseries_df,
network.rfc_lake_gage_crosswalk,
network.t0,
rfc_parameters,
)
else:
self._reservoir_rfc_df = pd.DataFrame()
self._reservoir_rfc_param_df = pd.DataFrame()

def update_after_compute(self, run_results):
'''
Expand Down