aemon-j / LakeEnsemblR

An R package that facilitates multi-model ensembles for lake thermodynamics. Also includes tools for calibration, sensitivity analysis and data visualization.
GNU General Public License v2.0
32 stars 19 forks source link

Evaporation output #282

Open Bkemanga opened 7 months ago

Bkemanga commented 7 months ago

I was wondering if it would be possible to calibrate the GLM model lakeEnsemblr using observed evaporation.

jorritmesman commented 7 months ago

Hi, No, it's sadly not possible to run an automatic calibration with anything else than temperature in LakeEnsemblR, at least for now. I would recommend to set up a latin hypercube grid with the parameters that you want to calibrate, run GLM iteratively over these parameters, and each step calculate your goodness-of-fit metric(s), so that you can select the best fit in the end. You can partially follow the cali_ensemble.R script, perhaps, but it will be mostly something that you have to create yourself, I'm afraid.

The key function to do this, also used in cali_ensemble, is the Latinhyper function from the FME package.

Bkemanga commented 7 months ago

Thanks very much @jorritmesman
One quick question: is it possible to run Ensemble with GLM only for 1000? also, I have only temperature observation for the lake surface (depth =0m, that is, surface water temperature), Is it possible to calibrate the model using Cali_ensemble?

cali_ensemble(config_file, model = c("GLM"), cmethod = "LHC", num = 1000, out_f = "calibration")

Bkemanga commented 7 months ago

I will appreciate your guidance as am trying to replicate this for mine pit lake.

jorritmesman commented 7 months ago

You are able to run more iterations; there is no maximum limit for the num argument (other than runtime on your computer).

Yes, you should be able to use cali_ensemble to calibrate your lake. However, having only surface water temperature is of course a bit restrictive to get stratification patterns correct, because you have no data on that. But at least theoretically, it should be possible.

Bkemanga commented 7 months ago

Thanks @jorritmesman. Is it possible to run the model for let's say 10yrs but choose only maybe one year for calibration? This is because I have meteorological data for 10 yrs. and only 1 yrs. of observation data. Can I specify the time index in the cali_ensamble function?

jorritmesman commented 7 months ago

Yes, that will work fine. You don't need to specify anything in the cali_ensemble function call, but just make sure that the observation file that you refer to only has observations in the period that you want to use for calibration.

Bkemanga commented 7 months ago

I did manage to set my lakemodel but when i rune the model I get this error

Run ensemble lake models

run_ensemble("NPMEnsemblR.yaml", model = c("GLM")) Loading water temperature observations...[2024-05-02 04:04:54.365859] Finished loading water temperature observations![2024-05-02 04:04:54.367365] Running models... (Have you tried parallelizing?) [2024-05-02 04:04:54.378466] GLM run is complete! [2024-05-02 04:04:54.402798] Error in R_nc4_open: No such file or directory Error in nc_open(file, readunlim = TRUE) : Error in nc_open trying to open file ./GLM/output/output.nc (return_on_error= FALSE )

jorritmesman commented 7 months ago

It looks like GLM crashed (no output file was generated). You can investigate what went wrong by going to your GLM folder and using GLM3r::run_glm(verbose = TRUE)

Bkemanga commented 6 months ago

@jorritmesman I did manged to figure out the error after using GLM3r::run_glm(verbose = TRUE) as you did advice. Now another problem, when using .yaml file to export the the setting using export_config, the exported meteo data does generate longwave radiation data but I would preferer to use Cloud cover direct when run GLM so that i can specify different cloud_mode. In short i don't want the export_config to calculate longwave. image

image as you can see the glm meteo file does have longwave which is calculated but I would prefer Cloud so that i can change cloud mode

robertladwig commented 6 months ago

Hi @Bkemanga, I think the best way forward for you is to manually add your cloud cover data to the generated GLM meteorology file. LER currently tries to set up all hydrodynamic models in a similar way, which is why it uses observed long-wave radiation instead of inferring long-wave from cloud cover. Keep in mind that you would need to change rad_mode in your GLM nml-file to inform the model to not use provided long-wave data (see screenshot).

Skærmbillede 2024-05-07 114122