Skip to content
Snippets Groups Projects
Commit e92db881 authored by Jérémy AUCLAIR's avatar Jérémy AUCLAIR
Browse files

Small config file change, added possibility to compress output file.

parent 98fb78f5
No related branches found
No related tags found
No related merge requests found
File added
......@@ -22,22 +22,24 @@ class config:
- end_date: ``str``
- mode: ``str``
- run_name: ``str``
- path_to_config_file: ``str``
- path_to_eodag_config_file: ``str``
- preferred_provider: ``str``
- cloud_cover_limit: ``int``
- minimum_overlap: ``str``
- data_path: ``str``
- output_path: ``str``
- soil_path: ``str``
- landcover_path: ``str``
- irrigation_mask_path: ``str``
- shapefile_path: ``str``
- param_csv_file: ``str``
- init_RU_path: ``str``
- resolution: ``int``
- ndvi_overwrite: ``bool``
- weather_overwrite: ``bool``
- open_browser: ``bool``
- max_cpu: ``int``
- max_ram: ``int``
- compress_outputs: ``bool``
- additional_output: ``dict``
- parcel_shapefile_vars: ``list``
"""
......
......@@ -62,6 +62,9 @@
"_comment": "Max amount of RAM memory (in GiB) to use for calculations",
"max_ram": 16,
"_comment": "Choice to compress output netCDF file (takes less space but longer to write)",
"compress_outputs": false,
"_comment": "Dictionnary containing the name of additionnal variables to write in output and the integer scaling factor. Equal to null if no additionnal output is required.",
"additional_output": null,
......
......@@ -82,7 +82,7 @@ if __name__ == '__main__':
output_shapefile_dir = os.path.join(data_path, 'SHP', run_name)
# Run SAMIR
run_samir(param_csv_file, ndvi_path, weather_path, soil_path, land_cover_path, irrigation_mask_path, init_RU_path, Kcb_max_obs_path, output_save_path, additional_outputs = config_params.additional_output, available_ram = max_ram, available_cpu = max_cpu)
run_samir(param_csv_file, ndvi_path, weather_path, soil_path, land_cover_path, irrigation_mask_path, init_RU_path, Kcb_max_obs_path, output_save_path, additional_outputs = config_params.additional_output, available_ram = max_ram, available_cpu = max_cpu, compress_outputs = config_params.compress_outputs)
# Convert output dataset to dataframe and shapefile for parcel mode
if mode == 'parcel':
......
......@@ -1289,7 +1289,7 @@ def samir_daily(NDVI: np.ndarray, ET0: np.ndarray, Rain: np.ndarray, Wfc: np.nda
return DP, Dd, Dei, Dep, Dr, E, Irrig, Irrig_test, SWCe, SWCr, Tr, Zr
def run_samir(csv_param_file: str, ndvi_cube_path: str, weather_path: str, soil_params_path: str, land_cover_path: str, irrigation_raster: str, init_RU_path: str, Kcb_max_obs_path: str, save_path: str, scaling_dict: Dict[str, int] = {'E': 1000, 'Tr': 1000, 'SWCe': 1000, 'SWCr': 1000, 'DP': 100, 'Irr': 100}, additional_outputs: Dict[str, int] = None, available_ram: int = 8, available_cpu: int = 4) -> None:
def run_samir(csv_param_file: str, ndvi_cube_path: str, weather_path: str, soil_params_path: str, land_cover_path: str, irrigation_raster: str, init_RU_path: str, Kcb_max_obs_path: str, save_path: str, scaling_dict: Dict[str, int] = {'E': 1000, 'Tr': 1000, 'SWCe': 1000, 'SWCr': 1000, 'DP': 100, 'Irr': 100}, additional_outputs: Dict[str, int] = None, available_ram: int = 8, available_cpu: int = 4, compress_outputs: bool = False) -> None:
"""
Run the *SAMIR* model on the prepared inputs. Calls the ``samir_daily()`` in a time loop.
Maximizes memory usage with given limits to run faster.
......@@ -1326,6 +1326,8 @@ def run_samir(csv_param_file: str, ndvi_cube_path: str, weather_path: str, soil_
available RAM in **GiB** for the model
12. available_cpu: ``int`` ``default = 4``
number of available **physical** CPU cores
12. compress_outputs: ``bool`` ``default = False``
choice to compress output file (takes longer)
Returns
=======
......@@ -1407,6 +1409,9 @@ def run_samir(csv_param_file: str, ndvi_cube_path: str, weather_path: str, soil_
encod['dtype'] = 'u2'
# TODO: figure out optimal file chunk size
encod['chunksizes'] = (1, y_size, x_size)
if compress_outputs:
encod['zlib'] = True
encod['complevel'] = 1
encoding_dict[variable] = encod
# Save empty output
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment