1 clim_recal.debiasing.debias_wrapper
+clim_recal.debiasing.debias_wrapper
Wrapper for running preprocess_data.py
and run_cmethods.py
1.1 Classes
+Name | +Description | +
---|---|
BaseRunConfig | +Manage creating command line scripts to run debiasing cli . |
+
RunConfig | +Manage creating command line scripts to run debiasing cli . |
+
RunConfigType | +Parameters needed for a model run. | +
1.1.1 BaseRunConfig
+clim_recal.debiasing.debias_wrapper.BaseRunConfig(self, command_dir=COMMAND_DIR_DEFAULT, run_prefix=RUN_PREFIX_DEFAULT, preprocess_data_file=PREPROCESS_FILE_NAME, run_cmethods_file=CMETHODS_FILE_NAME, data_path=DATA_PATH_DEFAULT, mod_folder=MOD_FOLDER_DEFAULT, obs_folder=OBS_FOLDER_DEFAULT, preprocess_out_folder=PREPROCESS_OUT_FOLDER_DEFAULT, cmethods_out_folder=CMETHODS_OUT_FOLDER_DEFAULT, calib_date_start=CALIB_DATE_START_DEFAULT, calib_date_end=CALIB_DATE_END_DEFAULT, valid_date_start=VALID_DATE_START_DEFAULT, valid_date_end=VALID_DATE_END_DEFAULT, processors=PROCESSORS_DEFAULT, date_format_str=CLI_DATE_FORMAT_STR, date_split_str=DATE_FORMAT_SPLIT_STR)
Manage creating command line scripts to run debiasing
cli
.
1.1.2 RunConfig
+clim_recal.debiasing.debias_wrapper.RunConfig(self, command_dir=COMMAND_DIR_DEFAULT, run_prefix=RUN_PREFIX_DEFAULT, preprocess_data_file=PREPROCESS_FILE_NAME, run_cmethods_file=CMETHODS_FILE_NAME, data_path=DATA_PATH_DEFAULT, mod_folder=MOD_FOLDER_DEFAULT, obs_folder=OBS_FOLDER_DEFAULT, preprocess_out_folder=PREPROCESS_OUT_FOLDER_DEFAULT, cmethods_out_folder=CMETHODS_OUT_FOLDER_DEFAULT, calib_date_start=CALIB_DATE_START_DEFAULT, calib_date_end=CALIB_DATE_END_DEFAULT, valid_date_start=VALID_DATE_START_DEFAULT, valid_date_end=VALID_DATE_END_DEFAULT, processors=PROCESSORS_DEFAULT, date_format_str=CLI_DATE_FORMAT_STR, date_split_str=DATE_FORMAT_SPLIT_STR, variable=VariableOptions.default(), run=RunOptions.default(), region=RegionOptions.default(), method=MethodOptions.default())
Manage creating command line scripts to run debiasing
cli
.
1.1.2.1 Attributes
+Name | +Description | +
---|---|
command_path | +Return command path relative to running tests. | +
run_prefix_tuple | +Split self.run_prefix by ’ ’ to a tuple . |
+
1.1.2.2 Methods
+Name | +Description | +
---|---|
calib_dates_to_str | +Return date range as str from calib_date_start to calib_date_end . |
+
cmethods_out_path | +Return path to save cmethods results. | +
mod_path | +Return region estimates path. | +
obs_path | +Return region observations path. | +
preprocess_out_path | +Return path to save results. | +
to_cli_preprocess_str | +Generate a command line interface str as a test example. | +
to_cli_preprocess_tuple | +Generate a tuple of str for a command line command. |
+
to_cli_preprocess_tuple_strs | +Generate a command line interface str tuple a test example. |
+
to_cli_run_cmethods_str | +Generate a command line interface str as a test example. | +
to_cli_run_cmethods_tuple | +Generate a tuple of str for a command line command. |
+
to_cli_run_cmethods_tuple_strs | +Generate a command line interface str tuple a test example. |
+
valid_dates_to_str | +Return date range as str from valid_date_start to valid_date_end . |
+
yield_mod_folder | +Iterable of all Path s in self.mod_folder . |
+
yield_obs_folder | +Iterable of all Path s in self.obs_folder . |
+
yield_preprocess_out_folder | +Iterable of all Path s in self.preprocess_out_folder . |
+
1.1.2.2.1 calib_dates_to_str
+clim_recal.debiasing.debias_wrapper.RunConfig.calib_dates_to_str(start_date, end_date, in_format_str=None, out_format_str=None, split_str=None)
Return date range as str
from calib_date_start
to calib_date_end
.
1.1.2.2.1.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> config.calib_dates_to_str('20100101', '20100330')
+'20100101-20100330'
+>>> config.calib_dates_to_str(date(2010, 1, 1), '20100330')
+'20100101-20100330'
+>>> config.calib_dates_to_str(date(2010, 1, 1), '20100330', split_str="_")
+'20100101_20100330'
1.1.2.2.2 cmethods_out_path
+clim_recal.debiasing.debias_wrapper.RunConfig.cmethods_out_path(region=None, run=None)
Return path to save cmethods results.
+1.1.2.2.2.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> config.cmethods_out_path()
+'/.../ClimateData/Debiased/three.cities.cropped/Manchester/05')
+ PosixPath(>>> config.cmethods_out_path(region='Glasgow', run='07')
+'/.../ClimateData/Debiased/three.cities.cropped/Glasgow/07') PosixPath(
1.1.2.2.3 mod_path
+clim_recal.debiasing.debias_wrapper.RunConfig.mod_path(region=None)
Return region estimates path.
+1.1.2.2.3.1 Examples
+>>> if not is_data_mounted:
+'requires "vmfileshare/ClimateData" mounted')
+ ... pytest.skip(>>> config: RunConfig = RunConfig()
+>>> config.mod_path()
+'/.../ClimateData/Cropped/three.cities/CPM/Manchester')
+ PosixPath(>>> config.mod_path('Glasgow')
+'/.../ClimateData/Cropped/three.cities/CPM/Glasgow') PosixPath(
1.1.2.2.4 obs_path
+clim_recal.debiasing.debias_wrapper.RunConfig.obs_path(region=None)
Return region observations path.
+1.1.2.2.4.1 Examples
+>>> if not is_data_mounted:
+'requires "vmfileshare/ClimateData" mounted')
+ ... pytest.skip(>>> config: RunConfig = RunConfig()
+>>> config.obs_path()
+'/.../ClimateData/Cropped/three.cities/Hads.updated360/Manchester')
+ PosixPath(>>> config.obs_path('Glasgow')
+'/.../ClimateData/Cropped/three.cities/Hads.updated360/Glasgow') PosixPath(
1.1.2.2.5 preprocess_out_path
+clim_recal.debiasing.debias_wrapper.RunConfig.preprocess_out_path(region=None, run=None, variable=None)
Return path to save results.
+1.1.2.2.5.1 Examples
+>>> if not is_data_mounted:
+'requires "vmfileshare/ClimateData" mounted')
+ ... pytest.skip(>>> config: RunConfig = RunConfig()
+>>> config.preprocess_out_path()
+'.../ClimateData/Cropped/three.cities/Preprocessed/Manchester/05/tasmax')
+ PosixPath(>>> config.preprocess_out_path(region='Glasgow', run='07')
+'.../ClimateData/Cropped/three.cities/Preprocessed/Glasgow/07/tasmax') PosixPath(
1.1.2.2.6 to_cli_preprocess_str
+clim_recal.debiasing.debias_wrapper.RunConfig.to_cli_preprocess_str(variable=None, run=None, region=None, calib_start=None, calib_end=None, valid_start=None, valid_end=None)
Generate a command line interface str as a test example.
+1.1.2.2.6.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> config.to_cli_preprocess_str() == CLI_PREPROCESS_DEFAULT_COMMAND_STR_CORRECT
+True
+>>> CLI_PREPROCESS_DEFAULT_COMMAND_STR_CORRECT
+'python preprocess_data.py --mod /.../CPM/Manchester...'
1.1.2.2.7 to_cli_preprocess_tuple
+clim_recal.debiasing.debias_wrapper.RunConfig.to_cli_preprocess_tuple(variable=None, run=None, region=None, calib_start=None, calib_end=None, valid_start=None, valid_end=None)
Generate a tuple
of str
for a command line command.
This will leave Path
objects uncoverted. See self.to_cli_preprocess_tuple_strs
for passing to a terminal.
1.1.2.2.7.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> command_str_tuple: tuple[str, ...] = config.to_cli_preprocess_tuple()
+>>> assert command_str_tuple == CLI_PREPROCESS_DEFAULT_COMMAND_TUPLE_CORRECT
1.1.2.2.8 to_cli_preprocess_tuple_strs
+clim_recal.debiasing.debias_wrapper.RunConfig.to_cli_preprocess_tuple_strs(variable=None, run=None, region=None, calib_start=None, calib_end=None, valid_start=None, valid_end=None)
Generate a command line interface str
tuple
a test example.
1.1.2.2.8.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> command_str_tuple: tuple[str, ...] = config.to_cli_preprocess_tuple_strs()
+>>> assert command_str_tuple == CLI_PREPROCESS_DEFAULT_COMMAND_TUPLE_STR_CORRECT
1.1.2.2.9 to_cli_run_cmethods_str
+clim_recal.debiasing.debias_wrapper.RunConfig.to_cli_run_cmethods_str(region=None, run=None, variable=None, method=None, input_data_path=None, cmethods_out_path=None, processors=None)
Generate a command line interface str as a test example.
+1.1.2.2.9.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> config.to_cli_run_cmethods_str() == CLI_CMETHODS_DEFAULT_COMMAND_STR_CORRECT
+True
+>>> CLI_CMETHODS_DEFAULT_COMMAND_STR_CORRECT
+'python run_cmethods.py...--method quantile_delta_mapping...'
1.1.2.2.10 to_cli_run_cmethods_tuple
+clim_recal.debiasing.debias_wrapper.RunConfig.to_cli_run_cmethods_tuple(region=None, run=None, variable=None, method=None, input_data_path=None, cmethods_out_path=None, processors=None)
Generate a tuple
of str
for a command line command.
This will leave Path
objects uncoverted. See self.to_cli_run_cmethods_tuple_strs
for passing to a terminal.
1.1.2.2.10.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> command_str_tuple: tuple[str, ...] = config.to_cli_run_cmethods_tuple()
+>>> assert command_str_tuple == CLI_CMETHODS_DEFAULT_COMMAND_TUPLE_CORRECT
1.1.2.2.11 to_cli_run_cmethods_tuple_strs
+clim_recal.debiasing.debias_wrapper.RunConfig.to_cli_run_cmethods_tuple_strs(region=None, run=None, variable=None, method=None, input_data_path=None, cmethods_out_path=None, processors=None)
Generate a command line interface str
tuple
a test example.
1.1.2.2.11.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> command_str_tuple: tuple[str, ...] = config.to_cli_run_cmethods_tuple_strs()
+>>> assert command_str_tuple == CLI_CMEHTODS_DEFAULT_COMMAND_TUPLE_STR_CORRECT
1.1.2.2.12 valid_dates_to_str
+clim_recal.debiasing.debias_wrapper.RunConfig.valid_dates_to_str(start_date, end_date, in_format_str=None, out_format_str=None, split_str=None)
Return date range as str
from valid_date_start
to valid_date_end
.
1.1.2.2.12.1 Examples
+>>> config: RunConfig = RunConfig()
+>>> config.valid_dates_to_str('20100101', '20100330')
+'20100101-20100330'
+>>> config.valid_dates_to_str(date(2010, 1, 1), '20100330')
+'20100101-20100330'
+>>> config.valid_dates_to_str(date(2010, 1, 1), '20100330', split_str="_")
+'20100101_20100330'
1.1.2.2.13 yield_mod_folder
+clim_recal.debiasing.debias_wrapper.RunConfig.yield_mod_folder(region=None)
Iterable
of all Path
s in self.mod_folder
.
1.1.2.2.13.1 Examples
+>>> if not is_data_mounted:
+'requires "vmfileshare/ClimateData" mounted')
+ ... pytest.skip(>>> config: RunConfig = RunConfig()
+>>> len(tuple(config.yield_mod_folder())) == MOD_FOLDER_FILES_COUNT_CORRECT
+True
1.1.2.2.14 yield_obs_folder
+clim_recal.debiasing.debias_wrapper.RunConfig.yield_obs_folder(region=None)
Iterable
of all Path
s in self.obs_folder
.
1.1.2.2.14.1 Examples
+>>> if not is_data_mounted:
+'requires "vmfileshare/ClimateData" mounted')
+ ... pytest.skip(>>> config: RunConfig = RunConfig()
+>>> len(tuple(config.yield_obs_folder())) == OBS_FOLDER_FILES_COUNT_CORRECT
+True
1.1.2.2.15 yield_preprocess_out_folder
+clim_recal.debiasing.debias_wrapper.RunConfig.yield_preprocess_out_folder(region=None, run=None, variable=None)
Iterable
of all Path
s in self.preprocess_out_folder
.
1.1.2.2.15.1 Examples
+>>> if not is_data_mounted:
+'requires "vmfileshare/ClimateData" mounted')
+ ... pytest.skip(>>> config: RunConfig = RunConfig()
+>>> (len(tuple(config.yield_preprocess_out_folder())) ==
+
+ ... PREPROCESS_OUT_FOLDER_FILES_COUNT_CORRECT)True
1.1.3 RunConfigType
+clim_recal.debiasing.debias_wrapper.RunConfigType()
Parameters needed for a model run.
+ + +