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

Fixed issues with base flow and added the Xinanjiang routine #63

Open
wants to merge 1 commit into
base: bmi-python
Choose a base branch
from
Open
Show file tree
Hide file tree
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
24 changes: 14 additions & 10 deletions bmi_cfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def __init__(self, cfg_file=None):
# since the input variable names could come from any forcing...
#------------------------------------------------------
self._var_name_units_map = {
'land_surface_water__runoff_volume_flux':['streamflow_cfs','ft3 s-1'],
'land_surface_water__runoff_depth':['total_discharge','m'],
'land_surface_water__runoff_volume_flux':['streamflow_cms','m3 s-1'],
'land_surface_water__runoff_depth':['total_discharge','m s-1'],
#-------------- Dynamic inputs --------------------------------
'atmosphere_water__time_integral_of_precipitation_mass_flux':['timestep_rainfall_input_m','kg m-2'],
'water_potential_evaporation_flux':['potential_et_m_per_s','m s-1'],
Expand Down Expand Up @@ -184,7 +184,7 @@ def initialize(self, current_time_step=0):
# ________________________________________________
# Subsurface reservoirs
self.gw_reservoir = {'is_exponential':True,
'storage_max_m':1.0,
'storage_max_m':self.max_gw_storage,
'coeff_primary':self.gw_coeff_primary,
'exponent_primary':self.gw_exponent_primary,
'storage_threshold_primary_m':0.0,
Expand All @@ -196,8 +196,9 @@ def initialize(self, current_time_step=0):
self.vol_in_gw_start = self.gw_reservoir['storage_m']

self.soil_reservoir = {'is_exponential':False,
'wilting_point_m':self.soil_params['wltsmc'] * self.soil_params['D'],
'storage_max_m':self.soil_params['smcmax'] * self.soil_params['D'],
'coeff_primary':self.soil_params['satdk'] * self.soil_params['slop'] * 3600.0,
'coeff_primary':self.soil_params['satdk'] * self.soil_params['slop'] * self.time_step_size,
'exponent_primary':self.soil_params['exponent_primary'],
'storage_threshold_primary_m':self.soil_params['smcmax'] * storage_thresh_pow_term*
(upper_lim-lower_lim),
Expand Down Expand Up @@ -267,6 +268,8 @@ def finalize(self,print_mass_balance=False):
# Mass balance tracking
def reset_volume_tracking(self):
self.volstart = 0
self.vol_et_from_soil = 0
self.vol_et_from_rain = 0
self.vol_sch_runoff = 0
self.vol_sch_infilt = 0
self.vol_out_giuh = 0
Expand Down Expand Up @@ -324,6 +327,7 @@ def config_from_json(self):
self.gw_exponent_primary = data_loaded['gw_exponent_primary']
self.gw_coeff_secondary = data_loaded['gw_coeff_secondary']
self.gw_exponent_secondary = data_loaded['gw_exponent_secondary']
self.surface_partitioning_scheme= data_loaded['scheme']

# OPTIONAL CONFIGURATIONS
if 'stand_alone' in data_loaded.keys():
Expand Down Expand Up @@ -351,10 +355,10 @@ def finalize_mass_balance(self, verbose=True):
self.vol_soil_end = self.soil_reservoir['storage_m']

self.global_residual = self.volstart + self.volin - self.volout - self.volend -self.vol_end_giuh
self.schaake_residual = self.volin - self.vol_sch_runoff - self.vol_sch_infilt
self.schaake_residual = self.volin - self.vol_sch_runoff - self.vol_sch_infilt - self.vol_et_from_rain
self.giuh_residual = self.vol_sch_runoff - self.vol_out_giuh - self.vol_end_giuh
self.soil_residual = self.vol_soil_start + self.vol_sch_infilt - \
self.vol_soil_to_lat_flow - self.vol_soil_end - self.vol_to_gw
self.vol_soil_to_lat_flow - self.vol_soil_end - self.vol_to_gw - self.vol_et_from_soil
self.nash_residual = self.vol_in_nash - self.vol_out_nash - self.vol_in_nash_end
self.gw_residual = self.vol_in_gw_start + self.vol_to_gw - self.vol_from_gw - self.vol_in_gw_end
if verbose:
Expand Down Expand Up @@ -454,11 +458,11 @@ def run_unit_test(self, plot_lims=list(range(490, 550)), plot=False, print_fluxe
#------------------------------------------------------------
def scale_output(self):

self.surface_runoff_m = self.total_discharge
self._values['land_surface_water__runoff_depth'] = self.surface_runoff_m/1000
self.streamflow_cms = self._values['land_surface_water__runoff_depth'] * self.output_factor_cms
self.surface_runoff_m = self.flux_Qout_m
self._values['land_surface_water__runoff_depth'] = self.surface_runoff_m
self.streamflow_cms = self.total_discharge

self._values['land_surface_water__runoff_volume_flux'] = self.streamflow_cms * (1/35.314)
self._values['land_surface_water__runoff_volume_flux'] = self.streamflow_cms

self._values["DIRECT_RUNOFF"] = self.surface_runoff_depth_m
self._values["GIUH_RUNOFF"] = self.flux_giuh_runoff_m
Expand Down
1 change: 1 addition & 0 deletions cat_58_config_cfe.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"forcing_file":"./cat58_01Dec2015.csv",
"catchment_area_km2":15.617167355002097,
"alpha_fc":0.33,
"scheme":"Schaake",
"soil_params":{
"depth":2.0,
"bb":4.05,
Expand Down
36 changes: 36 additions & 0 deletions cat_58_config_cfe_x.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"forcing_file":"./cat58_01Dec2015.csv",
"catchment_area_km2":15.617167355002097,
"alpha_fc":0.33,
"scheme":"Xinanjiang",
"soil_params":{
"depth":2.0,
"bb":4.05,
"mult":1000.0,
"satdk":0.00000338,
"satpsi":0.355,
"slop":1.0,
"smcmax":0.439,
"wltsmc":0.066,
"D":2.0,
"exponent_primary":1.0,
"coeff_secondary":0.01,
"exponent_secondary":1.0
},
"gw_coeff_primary":0.01,
"gw_exponent_primary":6.0,
"gw_coeff_secondary":0.0,
"gw_exponent_secondary":1.0,
"max_gw_storage":16.0,
"Cgw":0.01,
"expon":6.0,
"gw_storage":0.50,
"soil_storage":0.667,
"K_lf":0.01,
"K_nash":0.03,
"nash_storage":[0.0,0.0],
"giuh_ordinates":[0.1,0.35,0.2,0.14,0.1,0.06,0.05],
"stand_alone":1,
"unit_test":1,
"compare_results_file":"test_compare.csv"
}
Loading