Skip to content

Commit fa8771a

Browse files
committed
Removed missings from res_reg_mask and generalized the usage of the @random_seed! macro
1 parent fa230ae commit fa8771a

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/Regions/fr/src/Res/Get_data.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ function make_reg_res_mask(settings,mask)
7373
#Rasters.metadata(reg_raster)["missed_geometries"]
7474

7575
resampled_raster = Rasters.resample(reg_raster,to=mask,method=:average)
76+
# this solves the problem that 0 is signaled as missingval, but is instead real 0/false
77+
resampled_raster = Rasters.replace_missing(resampled_raster, missingval=-9999)
78+
resampled_raster = map(i -> i == -9999 ? 0 : 1, resampled_raster[:,:])
79+
7680
write(mask_destpath, resampled_raster ,force=true)
7781
rm(adm_borders_dl_path,recursive=true)
7882
return mask_destpath

src/Regions/fr/src/Res/Init.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ function _init!!(pixels,settings,global_mask)
2121
isdir(cache_path) || mkpath(cache_path)
2222
isdir(output_path) || mkpath(output_path)
2323
settings["res"]["fr"]["mask"] = make_reg_res_mask(settings,global_mask)
24-
reg_res_mask = Rasters.Raster(settings["res"]["fr"]["mask"])
25-
24+
reg_res_mask = Rasters.Raster(settings["res"]["fr"]["mask"]) # still the inner matrix is an Union{Missing,Int62}
25+
reg_res_mask = map(i -> i == 0 ? 0 : 1, reg_res_mask[:,:])
2626
get_data!(settings,reg_res_mask)
2727
#println(settings)
2828

src/Regions/fr/src/Res/Prepare_data.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ end
499499

500500

501501
function train_autoencode_clim(settings, mask, ign_growth)
502+
@random_seed!
502503
# This function trains the autoencoder for climatic data
503504
# It returns the autoencoded climatic data.
504505

@@ -632,7 +633,7 @@ end
632633

633634

634635
function predict_autoencoder_clim(settings, mask, scaler_clim_m, ae_clim_m)
635-
636+
@random_seed!
636637
settings["verbosity"] >= STD && @info("- predicting autoencoded future climatic data for scenario $(settings["scenario"])")
637638

638639
force_other = settings["res"]["fr"]["force_other"]
@@ -697,6 +698,7 @@ end
697698

698699

699700
function trainpredict_autoencode_fixedpxdata(settings, mask)
701+
@random_seed!
700702
# function trainpredict_autoencode_fixedpxdata(settings, mask)
701703
# Note: we put together here both soil and elevation data.. perhaps it is better to separate them, as dtm is not really a soil variable, but rather a topographic variable, and the ae doesn't work supergood with it.
702704
verbosity = settings["verbosity"]
@@ -875,6 +877,8 @@ function train_growth_model(settings, ign_growth, xclimh_reduced, xfixedpx_reduc
875877
# - the climate var are those of y2
876878
# - the co2 is the average of the y1:y2 years
877879

880+
@random_seed!
881+
878882
# -----------------------------------------------------------------------------
879883
# Getting options....
880884

@@ -1110,4 +1114,5 @@ end
11101114
function define_state(settings, mask)
11111115
# This function defines the state of the region based on the prepared data
11121116
# It is called after the growth model has been trained.
1117+
@random_seed!
11131118
end

0 commit comments

Comments
 (0)