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

Bug correction in samir model : fixed parameter rasterization.

parent 43560b3d
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ Usage of the SAMIR model in the Modspa framework.
import os # os management
import xarray as xr # to manage datasets
import rioxarray # to better manage dataset projections
from numba import njit, float32, int8, boolean, set_num_threads # to compile functions in nopython mode for faster calculation
from numba import njit, float32, boolean, set_num_threads # to compile functions in nopython mode for faster calculation
import numpy as np # for vectorized maths
import pandas as pd # to manage dataframes
from typing import List, Tuple, Dict # to declare argument types
......@@ -195,7 +195,7 @@ def rasterize_samir_parameters(csv_param_file: str, land_cover_raster: str, irri
# Parameter values are multiplied by the scale factor in order to store all values as int16 types
# These values are then rounded to make sure there isn't any decimal point issues when casting the values to int16
value = np.where(value == class_val, round(param_value * scale_factor), value).astype(dtype)
value = np.where(land_cover == class_val, round(param_value * scale_factor), value).astype(dtype)
# Assign parameter value
# Parameters have an underscore (_) behind their name for recognition
......@@ -1164,7 +1164,7 @@ def samir_daily(NDVI: np.ndarray, ET0: np.ndarray, Rain: np.ndarray, Wfc: np.nda
frac_Kcb_stop_irrig_ = params['frac_Kcb_stop_irrig_']
Lame_max_ = params['Lame_max_']
Lame_min_ = params['Lame_min_']
REW_ = params['REW_'] # used in eval function to calculate Kri and Krp
REW_ = params['REW_']
Ze_ = params['Ze_']
Zsoil_ = params['Zsoil_']
maxZr_ = params['maxZr_']
......@@ -1441,17 +1441,17 @@ def run_samir(csv_param_file: str, ndvi_cube_path: str, weather_path: str, soil_
else:
nb_outputs = 6 # DP, E, Irr, SWCe, SWCr, Tr
nb_variables = 38 # calculation variables (e.g: Dd, Diff_rei, FCov, etc.)
np_params = (len(params) - 1)/2 # One scalar parameter
nb_params = (len(params))/2 - 1 # One scalar parameter
# Get total memory requirement
total_memory_requirement = calculate_memory_requirement(x_size, y_size, time_size, nb_inputs, nb_outputs, nb_variables, np_params, nb_bytes)
total_memory_requirement = calculate_memory_requirement(x_size, y_size, time_size, nb_inputs, nb_outputs, nb_variables, nb_params, nb_bytes)
# Determine how many time slices can be loaded in memory at once
# This will allow faster I/O operations and a faster runtime
time_slice, remainder_to_load, already_loaded = calculate_time_slices_to_load(x_size, y_size, time_size, nb_inputs, nb_outputs, nb_variables, np_params, nb_bytes, available_ram)
time_slice, remainder_to_load, already_loaded = calculate_time_slices_to_load(x_size, y_size, time_size, nb_inputs, nb_outputs, nb_variables, nb_params, nb_bytes, available_ram)
# Get actual memory requirement
actual_memory_requirement = calculate_memory_requirement(x_size, y_size, time_slice, nb_inputs, nb_outputs, nb_variables, np_params, nb_bytes)
actual_memory_requirement = calculate_memory_requirement(x_size, y_size, time_slice, nb_inputs, nb_outputs, nb_variables, nb_params, nb_bytes)
print_size1, print_unit1 = format_Byte_size(total_memory_requirement, decimals = 1)
print_size2, print_unit2, = format_Byte_size(actual_memory_requirement, decimals = 1)
......
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