Skip to content

Commit

Permalink
implemnted cro au exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
meronmi committed Oct 28, 2024
1 parent ad6d4a4 commit ee036c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions A_config/a10_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def __init__(self, full_path_config, run_name, run_type=None):
#self.forecastingMonths = jdict['forecastingMonths'] obsolete, now %
self.crops = jdict['crops']
self.afi = jdict['afi']
if "crop_au_exclusions" in jdict:
self.crop_au_exclusions = jdict['crop_au_exclusions']
else:
self.crop_au_exclusions = {}

self.root_dir = jdict['root_dir']
self.data_dir = os.path.join(self.root_dir, jdict['data_dir'])
Expand Down
10 changes: 10 additions & 0 deletions D_modelling/d100_modeller.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def preprocess(self, config, runType, run2get_mres_only=False):
# [opeForecast] run the operational yield

stats = pd.read_csv(os.path.join(config.models_dir, config.AOI + '_stats.csv'))

# if working on a ML model and there is some crop-au combination to exclude, do it here upfront
if not(self.uset['algorithm'] == 'Null_model' or self.uset['algorithm'] == 'Trend' or self.uset['algorithm'] == 'PeakNDVI'):
if bool(config.crop_au_exclusions):
for key_crop, value_au_list in config.crop_au_exclusions.items():
for value_au in value_au_list:
mask = (stats['Crop_name'] == key_crop) & (stats['adm_name'] == value_au)
stats = stats[~mask]


# # rescale Production units for better graphic and better models (if production is avail)
# if 'Production' in stats.columns:
# stats['Production'] = stats['Production'].div(config.production_scaler)
Expand Down
2 changes: 1 addition & 1 deletion manager_0_user_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#############################
# 1. Config file, run type, name, and where to tune
#############################
run_name = '20241004_75_100_maize_sunflower_soybeans'# '20241016_75_100_maize_sunflower_soybeans_NorthernCape' #'20241004_75_100_maize_sunflower_soybeans'
run_name = '20241004_75_100_test_exclusion'# '20241016_75_100_maize_sunflower_soybeans_NorthernCape' #'20241004_75_100_maize_sunflower_soybeans'
runType = 'fast_tuning' # this is fixed for tuning ['tuning', 'fast_tuning', 'opeForecast']

if 'win' in sys.platform:
Expand Down

0 comments on commit ee036c2

Please sign in to comment.