From ceff8684dd2287ef87bc236abac98c053ac6de28 Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Sat, 30 Sep 2023 09:54:46 +0200 Subject: [PATCH 01/10] selected options moved to hidden config --- smoderp2d/.config.ini | 29 +++++++++++++++++- smoderp2d/providers/base/__init__.py | 36 ++++++++++------------- smoderp2d/providers/profile1d/__init__.py | 9 ------ tests/gistest.ini | 26 ---------------- tests/profile1d.ini | 14 --------- tests/quicktest_rill.ini | 27 ----------------- tests/test_rill.ini | 27 ----------------- 7 files changed, 44 insertions(+), 124 deletions(-) diff --git a/smoderp2d/.config.ini b/smoderp2d/.config.ini index 9d9257db3..7771c124c 100644 --- a/smoderp2d/.config.ini +++ b/smoderp2d/.config.ini @@ -1,7 +1,34 @@ -[outputs] +[output] # if extraout is eq yes the model will provide more detailed results - will # show more variables in hydrographs point***.csv. It is usefull for debuging # model development or more stientific applications. For regular use the # extraout=no, which will provide the regural output. # yes or no extraout = yes +# experimental times when rasters will be printed +# default: empty value for off +printtimes: + +[logging] +# logging level +# - CRITICAL +# - ERROR +# - WARNING +# - INFO +# - DEBUG +# - NOTSET +# default: INFO +level: DEBUG + +[processes] +# type of processes involved +# - sheet_only +# - rill +# - stream_rill +# - subflow_rill +# - stream_subflow_rill +# Default: stream_rill +typecomp: rill +# Mfda enabled +# default: False +mfda: False diff --git a/smoderp2d/providers/base/__init__.py b/smoderp2d/providers/base/__init__.py index 35a380bb4..de3fb8158 100644 --- a/smoderp2d/providers/base/__init__.py +++ b/smoderp2d/providers/base/__init__.py @@ -173,8 +173,12 @@ def __load_hidden_config(self): config = ConfigParser() config.read(_path) - if not config.has_option('outputs', 'extraout'): - raise ConfigError('Section "outputs" or option "extraout" is not set properly in file {}'.format( _path)) + # set logging level + Logger.setLevel(config.get('logging', 'level', fallback=logging.INFO)) + # sys.stderr logging + self.add_logging_handler( + logging.StreamHandler(stream=sys.stderr) + ) return config @@ -190,13 +194,6 @@ def _load_config(self): config.read(self.args.config_file) try: - # set logging level - Logger.setLevel(config.get('logging', 'level', fallback=logging.INFO)) - # sys.stderr logging - self.add_logging_handler( - logging.StreamHandler(stream=sys.stderr) - ) - # must be defined for _cleanup() method Globals.outdir = config.get('output', 'outdir') except (NoSectionError, NoOptionError) as e: @@ -236,15 +233,9 @@ def _load_roff(self): # some variables configs can be changes after loading from # pickle.dump such as end time of simulation - if self._config.get('time', 'endtime'): data['end_time'] = self._config.getfloat('time', 'endtime') - # time of flow algorithm - data['mfda'] = self._config.getboolean('processes', 'mfda', fallback=False) - # type of computing - data['type_of_computing'] = CompType()[self._config.get('processes', 'typecomp', fallback='stream_rill')] - # rainfall data can be saved if self._config.get('data', 'rainfall'): try: @@ -254,16 +245,21 @@ def _load_roff(self): except TypeError: raise ProviderError('Invalid rainfall file') - # some self._configs are not in pickle.dump - data['extraOut'] = self._config.getboolean('output', 'extraout', fallback=False) - # rainfall data can be saved - data['prtTimes'] = self._config.get('output', 'printtimes', fallback=None) data['maxdt'] = self._config.getfloat('time', 'maxdt') # ensure that dx and dy are defined data['dx'] = data['dy'] = math.sqrt(data['pixel_area']) + # load hidden config + data['prtTimes'] = self._hidden_config.get('output', 'printtimes', fallback=None) + data['extraout'] = self._hidden_config.getboolean('output', 'extraout', fallback=False) + data['mfda'] = self._hidden_config.getboolean('processes', 'mfda', fallback=False) + # type of computing + data['type_of_computing'] = CompType()[ + self._hidden_config.get('processes', 'typecomp', fallback='stream_rill') + ] + return data def load(self): @@ -313,7 +309,7 @@ def _set_globals(self, data): Globals.isRill = comp_type['rill'] Globals.isStream = comp_type['stream_rill'] Globals.prtTimes = data.get('prtTimes', None) - Globals.extraOut = self._hidden_config.getboolean('outputs','extraout') + Globals.extraOut = data.get('extraout', False) Globals.end_time *= 60 # convert min to sec # If profile1d provider is used the values diff --git a/smoderp2d/providers/profile1d/__init__.py b/smoderp2d/providers/profile1d/__init__.py index 07856a6c8..6241571e4 100644 --- a/smoderp2d/providers/profile1d/__init__.py +++ b/smoderp2d/providers/profile1d/__init__.py @@ -163,15 +163,6 @@ def _load_roff(self): # Logger.progress(10) # general settings - # some self._configs are not in pickle.dump - data['extraOut'] = self._config.getboolean( - 'output', 'extraout', fallback=False - ) - # rainfall data can be saved - data['prtTimes'] = self._config.get( - 'output', 'printtimes', fallback=None - ) - resolution = self._config.getfloat('domain', 'res') data['r'] = self._compute_rows(joint_data['horizontalProjection[m]'], resolution) diff --git a/tests/gistest.ini b/tests/gistest.ini index 9e05d1a27..0cad6557d 100644 --- a/tests/gistest.ini +++ b/tests/gistest.ini @@ -20,29 +20,3 @@ endtime: 40 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output -# experimental times when rasters will be printed -# default: empty value for off -printtimes: - -[logging] -# logging level -# - CRITICAL -# - ERROR -# - WARNING -# - INFO -# - DEBUG -# - NOTSET -# default: INFO -level: DEBUG - -[processes] -# type of processes involved -# 0 - sheet runoff -# 1 - sheet and rill runoff -# 2 - sheet, rill and subsurface runoff -# 3 - sheet, rill and stream runoff -# Default: 3 -typecomp: 1 -# Mfda enabled -# default: False -mfda: False diff --git a/tests/profile1d.ini b/tests/profile1d.ini index 85c5d77b3..f87e912b1 100644 --- a/tests/profile1d.ini +++ b/tests/profile1d.ini @@ -21,17 +21,3 @@ endtime: 60 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output -# experimental times when rasters will be printed -# default: empty value for off -printtimes: - -[logging] -# logging level -# - CRITICAL -# - ERROR -# - WARNING -# - INFO -# - DEBUG -# - NOTSET -# default: INFO -level: DEBUG diff --git a/tests/quicktest_rill.ini b/tests/quicktest_rill.ini index c9a6ee79b..76f92c07c 100644 --- a/tests/quicktest_rill.ini +++ b/tests/quicktest_rill.ini @@ -20,30 +20,3 @@ endtime: 60 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output -# experimental times when rasters will be printed -# default: empty value for off -printtimes: - -[logging] -# logging level -# - CRITICAL -# - ERROR -# - WARNING -# - INFO -# - DEBUG -# - NOTSET -# default: INFO -level: DEBUG - -[processes] -# type of processes involved -# - sheet_only -# - rill -# - stream_rill -# - subflow_rill -# - stream_subflow_rill -# Default: stream_rill -typecomp: rill -# Mfda enabled -# default: False -mfda: False diff --git a/tests/test_rill.ini b/tests/test_rill.ini index ac0f131ce..1ed387d71 100644 --- a/tests/test_rill.ini +++ b/tests/test_rill.ini @@ -20,30 +20,3 @@ endtime: 60 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output -# experimental times when rasters will be printed -# default: empty value for off -printtimes: - -[logging] -# logging level -# - CRITICAL -# - ERROR -# - WARNING -# - INFO -# - DEBUG -# - NOTSET -# default: INFO -level: DEBUG - -[processes] -# type of processes involved -# - sheet_only -# - rill -# - stream_rill -# - subflow_rill -# - stream_subflow_rill -# Default: stream_rill -typecomp: rill -# Mfda enabled -# default: False -mfda: False From 32ed4c296aec40e687d0c0c4bb783419a490d77a Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Sun, 1 Oct 2023 10:13:17 +0200 Subject: [PATCH 02/10] load_data_from_hidden_config --- smoderp2d/providers/base/__init__.py | 29 +++++++++++++++++------ smoderp2d/providers/profile1d/__init__.py | 4 ++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/smoderp2d/providers/base/__init__.py b/smoderp2d/providers/base/__init__.py index de3fb8158..15c60f8fc 100644 --- a/smoderp2d/providers/base/__init__.py +++ b/smoderp2d/providers/base/__init__.py @@ -183,6 +183,26 @@ def __load_hidden_config(self): return config + def _load_data_from_hidden_config(self, config, ignore=[]): + """Load data from hidden config. + + :param ConfigParser config: loaded config file + :param list ignore: list of options to me ignored + + :return dict + """ + data = {} + data['prtTimes'] = self._hidden_config.get('output', 'printtimes', fallback=None) + data['extraout'] = self._hidden_config.getboolean('output', 'extraout', fallback=False) + if 'mfda' not in ignore: + data['mfda'] = self._hidden_config.getboolean('processes', 'mfda', fallback=False) + if 'type_of_computing' not in ignore: + data['type_of_computing'] = CompType()[ + self._hidden_config.get('processes', 'typecomp', fallback='stream_rill') + ] + + return data + def _load_config(self): # load configuration if not os.path.exists(self.args.config_file): @@ -252,13 +272,8 @@ def _load_roff(self): data['dx'] = data['dy'] = math.sqrt(data['pixel_area']) # load hidden config - data['prtTimes'] = self._hidden_config.get('output', 'printtimes', fallback=None) - data['extraout'] = self._hidden_config.getboolean('output', 'extraout', fallback=False) - data['mfda'] = self._hidden_config.getboolean('processes', 'mfda', fallback=False) - # type of computing - data['type_of_computing'] = CompType()[ - self._hidden_config.get('processes', 'typecomp', fallback='stream_rill') - ] + data.update(self._load_data_from_hidden_config( + self._hidden_config)) return data diff --git a/smoderp2d/providers/profile1d/__init__.py b/smoderp2d/providers/profile1d/__init__.py index 6241571e4..2898a5ecd 100644 --- a/smoderp2d/providers/profile1d/__init__.py +++ b/smoderp2d/providers/profile1d/__init__.py @@ -249,6 +249,10 @@ def _load_roff(self): slope_width = float(self._config.get('domain', 'slope_width')) data['slope_width'] = slope_width + # load hidden config + data.update(self._load_data_from_hidden_config( + self._hidden_config, ignore=['mfda', 'type_of_computing'])) + return data @staticmethod From 4ce2d313f9b61958b8b546a65976ba1cfc43cf8c Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Thu, 5 Oct 2023 16:18:16 +0200 Subject: [PATCH 03/10] typecomp moved back to cmd ini --- smoderp2d/.config.ini | 8 -------- smoderp2d/providers/base/__init__.py | 8 ++++---- smoderp2d/providers/profile1d/__init__.py | 2 +- tests/gistest.ini | 10 ++++++++++ tests/quicktest_rill.ini | 10 ++++++++++ tests/quicktest_sheet.ini | 17 ----------------- tests/test_rill.ini | 10 ++++++++++ tests/test_sheet.ini | 17 ----------------- 8 files changed, 35 insertions(+), 47 deletions(-) diff --git a/smoderp2d/.config.ini b/smoderp2d/.config.ini index 7771c124c..c69987776 100644 --- a/smoderp2d/.config.ini +++ b/smoderp2d/.config.ini @@ -21,14 +21,6 @@ printtimes: level: DEBUG [processes] -# type of processes involved -# - sheet_only -# - rill -# - stream_rill -# - subflow_rill -# - stream_subflow_rill -# Default: stream_rill -typecomp: rill # Mfda enabled # default: False mfda: False diff --git a/smoderp2d/providers/base/__init__.py b/smoderp2d/providers/base/__init__.py index 15c60f8fc..8c83653c5 100644 --- a/smoderp2d/providers/base/__init__.py +++ b/smoderp2d/providers/base/__init__.py @@ -196,10 +196,6 @@ def _load_data_from_hidden_config(self, config, ignore=[]): data['extraout'] = self._hidden_config.getboolean('output', 'extraout', fallback=False) if 'mfda' not in ignore: data['mfda'] = self._hidden_config.getboolean('processes', 'mfda', fallback=False) - if 'type_of_computing' not in ignore: - data['type_of_computing'] = CompType()[ - self._hidden_config.get('processes', 'typecomp', fallback='stream_rill') - ] return data @@ -256,6 +252,10 @@ def _load_roff(self): if self._config.get('time', 'endtime'): data['end_time'] = self._config.getfloat('time', 'endtime') + data['type_of_computing'] = CompType()[ + self._config.get('processes', 'typecomp', fallback='stream_rill') + ] + # rainfall data can be saved if self._config.get('data', 'rainfall'): try: diff --git a/smoderp2d/providers/profile1d/__init__.py b/smoderp2d/providers/profile1d/__init__.py index 2898a5ecd..f215471e4 100644 --- a/smoderp2d/providers/profile1d/__init__.py +++ b/smoderp2d/providers/profile1d/__init__.py @@ -251,7 +251,7 @@ def _load_roff(self): # load hidden config data.update(self._load_data_from_hidden_config( - self._hidden_config, ignore=['mfda', 'type_of_computing'])) + self._hidden_config, ignore=['mfda'])) return data diff --git a/tests/gistest.ini b/tests/gistest.ini index 0cad6557d..6b00bc69b 100644 --- a/tests/gistest.ini +++ b/tests/gistest.ini @@ -20,3 +20,13 @@ endtime: 40 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output + +[processes] +# type of processes involved +# - sheet_only +# - rill +# - stream_rill +# - subflow_rill +# - stream_subflow_rill +# Default: stream_rill +typecomp: rill diff --git a/tests/quicktest_rill.ini b/tests/quicktest_rill.ini index 76f92c07c..a72d016cc 100644 --- a/tests/quicktest_rill.ini +++ b/tests/quicktest_rill.ini @@ -20,3 +20,13 @@ endtime: 60 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output + +[processes] +# type of processes involved +# - sheet_only +# - rill +# - stream_rill +# - subflow_rill +# - stream_subflow_rill +# Default: stream_rill +typecomp: rill diff --git a/tests/quicktest_sheet.ini b/tests/quicktest_sheet.ini index 9adbdce85..681a77172 100644 --- a/tests/quicktest_sheet.ini +++ b/tests/quicktest_sheet.ini @@ -20,20 +20,6 @@ endtime: 60 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output -# experimental times when rasters will be printed -# default: empty value for off -printtimes: - -[logging] -# logging level -# - CRITICAL -# - ERROR -# - WARNING -# - INFO -# - DEBUG -# - NOTSET -# default: INFO -level: DEBUG [processes] # type of processes involved @@ -44,6 +30,3 @@ level: DEBUG # - stream_subflow_rill # Default: stream_rill typecomp: sheet_only -# Mfda enabled -# default: False -mfda: False diff --git a/tests/test_rill.ini b/tests/test_rill.ini index 1ed387d71..ecf54465a 100644 --- a/tests/test_rill.ini +++ b/tests/test_rill.ini @@ -20,3 +20,13 @@ endtime: 60 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output + +[processes] +# type of processes involved +# - sheet_only +# - rill +# - stream_rill +# - subflow_rill +# - stream_subflow_rill +# Default: stream_rill +typecomp: rill diff --git a/tests/test_sheet.ini b/tests/test_sheet.ini index 0985d66c3..23d466e97 100644 --- a/tests/test_sheet.ini +++ b/tests/test_sheet.ini @@ -20,20 +20,6 @@ endtime: 60 # output directory # content of the directory is erased at the beginning of the program outdir: tests/data/output -# experimental times when rasters will be printed -# default: empty value for off -printtimes: - -[logging] -# logging level -# - CRITICAL -# - ERROR -# - WARNING -# - INFO -# - DEBUG -# - NOTSET -# default: INFO -level: DEBUG [processes] # type of processes involved @@ -44,6 +30,3 @@ level: DEBUG # - stream_subflow_rill # Default: stream_rill typecomp: sheet_only -# Mfda enabled -# default: False -mfda: False From 89e4e8fe1d49d07c4e8d803fe595051470a4b81a Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Thu, 5 Oct 2023 17:10:14 +0200 Subject: [PATCH 04/10] arcgis tool: first step to add typecomp param --- bin/arcgis/SMODERP2D.pyt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bin/arcgis/SMODERP2D.pyt b/bin/arcgis/SMODERP2D.pyt index 59aad3e28..6e9d70b32 100644 --- a/bin/arcgis/SMODERP2D.pyt +++ b/bin/arcgis/SMODERP2D.pyt @@ -29,8 +29,9 @@ PARAMETER_SOILVEGTABLE_TYPE = 10 PARAMETER_STREAM = 11 PARAMETER_CHANNEL_TYPE = 12 PARAMETER_CHANNEL_PROPS_TABLE = 13 -PARAMETER_DATAPREP_ONLY = 14 -PARAMETER_PATH_TO_OUTPUT_DIRECTORY = 15 +PARAMETER_TYPECOMP = 14 +PARAMETER_DATAPREP_ONLY = 15 +PARAMETER_PATH_TO_OUTPUT_DIRECTORY = 16 class Toolbox(object): def __init__(self): @@ -187,6 +188,17 @@ class SMODERP2D(object): ) dataprepOnly.value = False + typeComp = arcpy.Parameter( + displayName="Type of computation", + name="typeComp", + datatype="GPValueTable", + parameterType="Optional", + direction="Input", + category="Settings" + ) + typeComp.values = ['sheet_only', 'rill', 'stream_rill', 'subflow_rill', 'stream_subflow_rill'] + typeComp.value = "stream_rill" + outDir = arcpy.Parameter( displayName="Output folder", name="outDir", @@ -201,7 +213,7 @@ class SMODERP2D(object): inputLUPolygons, LUtypeFieldName, inputRainfall, maxTimeStep, totalRunTime, inputPoints, soilvegPropertiesTable, soilvegIDfieldName, streamNetwork, streamChannelShapeIDfieldName, - channelPropertiesTable, dataprepOnly, outDir, + channelPropertiesTable, typeComp, dataprepOnly, outDir, ] def updateParameters(self, parameters): @@ -250,5 +262,6 @@ class SMODERP2D(object): 'streams': parameters[PARAMETER_STREAM].valueAsText, 'streams_channel_type_fieldname': parameters[PARAMETER_CHANNEL_TYPE].valueAsText, 'channel_properties_table': parameters[PARAMETER_CHANNEL_PROPS_TABLE].valueAsText, + 'typecomp': parameters[PARAMETER_TYPECOMP].valueAsText, 'output': parameters[PARAMETER_PATH_TO_OUTPUT_DIRECTORY].valueAsText, } From 1373f5b1ad93791474484e37f01ad7f349b87ad5 Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Mon, 9 Oct 2023 16:44:09 +0200 Subject: [PATCH 05/10] simplify comp type detection in base provider --- smoderp2d/providers/base/data_preparation.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/smoderp2d/providers/base/data_preparation.py b/smoderp2d/providers/base/data_preparation.py index 088cad3c8..dfb7d7721 100644 --- a/smoderp2d/providers/base/data_preparation.py +++ b/smoderp2d/providers/base/data_preparation.py @@ -604,6 +604,7 @@ def run(self): Logger.info("Processing stream network:") if self._input_params['streams'] and self._input_params['channel_properties_table'] and self._input_params['streams_channel_type_fieldname']: + self.data['type_of_computing'] = CompType.stream_rill self._prepare_streams( self._input_params['streams'], self._input_params['channel_properties_table'], @@ -703,18 +704,6 @@ def _get_points_dem_coords(self, x, y): def _prepare_streams(self, stream, stream_shape_tab, stream_shape_code, dem_aoi, aoi_polygon): - self.data['type_of_computing'] = CompType.rill - - # pocitam vzdy s ryhama pokud jsou zadane vsechny vstupy pro - # vypocet toku, streams se pocitaji a type_of_computing je 3 - listin = [self._input_params['streams'], - self._input_params['channel_properties_table'], - self._input_params['streams_channel_type_fieldname']] - tflistin = [len(i) > 1 for i in listin] # TODO: ??? - - if all(tflistin): - self.data['type_of_computing'] = CompType.stream_rill - if self.data['type_of_computing'] in (CompType.stream_rill, CompType.stream_subflow_rill): Logger.info("Clipping stream to AoI outline ...") stream_aoi = self._stream_clip(stream, aoi_polygon) From ae231c3c48f5440b48c556800006dfd6b70afe2a Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Mon, 9 Oct 2023 20:12:04 +0200 Subject: [PATCH 06/10] Revert "arcgis tool: first step to add typecomp param" This reverts commit 89e4e8fe1d49d07c4e8d803fe595051470a4b81a. --- bin/arcgis/SMODERP2D.pyt | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/bin/arcgis/SMODERP2D.pyt b/bin/arcgis/SMODERP2D.pyt index 6e9d70b32..59aad3e28 100644 --- a/bin/arcgis/SMODERP2D.pyt +++ b/bin/arcgis/SMODERP2D.pyt @@ -29,9 +29,8 @@ PARAMETER_SOILVEGTABLE_TYPE = 10 PARAMETER_STREAM = 11 PARAMETER_CHANNEL_TYPE = 12 PARAMETER_CHANNEL_PROPS_TABLE = 13 -PARAMETER_TYPECOMP = 14 -PARAMETER_DATAPREP_ONLY = 15 -PARAMETER_PATH_TO_OUTPUT_DIRECTORY = 16 +PARAMETER_DATAPREP_ONLY = 14 +PARAMETER_PATH_TO_OUTPUT_DIRECTORY = 15 class Toolbox(object): def __init__(self): @@ -188,17 +187,6 @@ class SMODERP2D(object): ) dataprepOnly.value = False - typeComp = arcpy.Parameter( - displayName="Type of computation", - name="typeComp", - datatype="GPValueTable", - parameterType="Optional", - direction="Input", - category="Settings" - ) - typeComp.values = ['sheet_only', 'rill', 'stream_rill', 'subflow_rill', 'stream_subflow_rill'] - typeComp.value = "stream_rill" - outDir = arcpy.Parameter( displayName="Output folder", name="outDir", @@ -213,7 +201,7 @@ class SMODERP2D(object): inputLUPolygons, LUtypeFieldName, inputRainfall, maxTimeStep, totalRunTime, inputPoints, soilvegPropertiesTable, soilvegIDfieldName, streamNetwork, streamChannelShapeIDfieldName, - channelPropertiesTable, typeComp, dataprepOnly, outDir, + channelPropertiesTable, dataprepOnly, outDir, ] def updateParameters(self, parameters): @@ -262,6 +250,5 @@ class SMODERP2D(object): 'streams': parameters[PARAMETER_STREAM].valueAsText, 'streams_channel_type_fieldname': parameters[PARAMETER_CHANNEL_TYPE].valueAsText, 'channel_properties_table': parameters[PARAMETER_CHANNEL_PROPS_TABLE].valueAsText, - 'typecomp': parameters[PARAMETER_TYPECOMP].valueAsText, 'output': parameters[PARAMETER_PATH_TO_OUTPUT_DIRECTORY].valueAsText, } From 20a0ff3584efe73f9de6cad09fb8ddeff9081038 Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Sat, 14 Oct 2023 11:52:58 +0200 Subject: [PATCH 07/10] fix GRASS test --- smoderp2d/.config.ini | 5 +++-- smoderp2d/providers/base/__init__.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/smoderp2d/.config.ini b/smoderp2d/.config.ini index c69987776..48401817f 100644 --- a/smoderp2d/.config.ini +++ b/smoderp2d/.config.ini @@ -2,9 +2,10 @@ # if extraout is eq yes the model will provide more detailed results - will # show more variables in hydrographs point***.csv. It is usefull for debuging # model development or more stientific applications. For regular use the -# extraout=no, which will provide the regural output. +# extraout: no, which will provide the regural output. # yes or no -extraout = yes +# default: no +extraout: yes # experimental times when rasters will be printed # default: empty value for off printtimes: diff --git a/smoderp2d/providers/base/__init__.py b/smoderp2d/providers/base/__init__.py index aaa8a785b..2a1dd640c 100644 --- a/smoderp2d/providers/base/__init__.py +++ b/smoderp2d/providers/base/__init__.py @@ -326,8 +326,18 @@ def _set_globals(self, data): Globals.subflow = comp_type['subflow_rill'] Globals.isRill = comp_type['rill'] Globals.isStream = comp_type['stream_rill'] - Globals.prtTimes = data.get('prtTimes', None) - Globals.extraOut = data.get('extraout', False) + + # hidden config + hidden_config = self._load_data_from_hidden_config(self._hidden_config) + if 'prtTimes' in data: + Globals.prtTimes = data['prtTimes'] + else: + Globals.prtTimes = hidden_config.get('prtTimes', None) + if 'extraout' in data: + Globals.extraOut = data['extraout'] + else: + Globals.extraOut = hidden_config.get('extraout', False) + Globals.end_time *= 60 # convert min to sec # If profile1d provider is used the values From 53747db15b4c036aa42cf28f44303adf08b9ccf2 Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Sun, 22 Oct 2023 20:09:44 +0200 Subject: [PATCH 08/10] cosmetics --- smoderp2d/providers/base/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smoderp2d/providers/base/__init__.py b/smoderp2d/providers/base/__init__.py index 95cbba717..a2e7d5b19 100644 --- a/smoderp2d/providers/base/__init__.py +++ b/smoderp2d/providers/base/__init__.py @@ -260,6 +260,7 @@ def _load_roff(self): if self._config.get('time', 'endtime'): data['end_time'] = self._config.getfloat('time', 'endtime') + # type of computing data['type_of_computing'] = CompType()[ self._config.get('processes', 'typecomp', fallback='stream_rill') ] @@ -331,7 +332,7 @@ def _set_globals(self, data): Globals.isRill = comp_type['rill'] Globals.isStream = comp_type['stream_rill'] - # hidden config + # load hidden config hidden_config = self._load_data_from_hidden_config(self._hidden_config) if 'prtTimes' in data: Globals.prtTimes = data['prtTimes'] From 1cc3ff14020ba48a5e35e67743ae978e1e9c2b50 Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Mon, 23 Oct 2023 09:26:23 +0200 Subject: [PATCH 09/10] fix __load_hidden_config --- smoderp2d/providers/base/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/smoderp2d/providers/base/__init__.py b/smoderp2d/providers/base/__init__.py index a2e7d5b19..2c7518cd6 100644 --- a/smoderp2d/providers/base/__init__.py +++ b/smoderp2d/providers/base/__init__.py @@ -169,9 +169,11 @@ def add_logging_handler(handler, formatter=None): # avoid duplicated handlers (e.g. in case of ArcGIS) Logger.addHandler(handler) - @staticmethod - def __load_hidden_config(): - # load hidden configuration with advanced settings + def __load_hidden_config(self): + """Load hidden configuration with advanced settings. + + return ConfigParser: object + """ _path = os.path.join( os.path.dirname(__file__), '..', '..', '.config.ini' ) From 150031e0120a0b2cb4b797c481d03cb4c740b2b7 Mon Sep 17 00:00:00 2001 From: Martin Landa Date: Mon, 23 Oct 2023 09:31:01 +0200 Subject: [PATCH 10/10] maxdt --- smoderp2d/providers/base/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/smoderp2d/providers/base/__init__.py b/smoderp2d/providers/base/__init__.py index 2c7518cd6..ec079683e 100644 --- a/smoderp2d/providers/base/__init__.py +++ b/smoderp2d/providers/base/__init__.py @@ -276,6 +276,7 @@ def _load_roff(self): except TypeError: raise ProviderError('Invalid rainfall file') + data['maxdt'] = self._config.getfloat('time', 'maxdt') # ensure that dx and dy are defined data['dx'] = data['dy'] = math.sqrt(data['pixel_area'])