ec-jrc / lisflood-code

Lisflood OS - LISFLOOD
https://ec-jrc.github.io/lisflood
European Union Public License 1.2
120 stars 48 forks source link

Reservoir Output Data Not Generated #171

Open Nooshdokht-Bayatafshary opened 1 month ago

Nooshdokht-Bayatafshary commented 1 month ago

Dear @StefaniaGrimaldi,

I am currently running LISFLOOD for a basin that contains one reservoir. In my configuration, I have specified the necessary keys in the XML file (Settings.zip) to export reservoir outputs such as inflow and outflow. However, these outputs are not being generated as expected.

<setoption choice="1" name="simulateReservoirs"/>
<setoption choice="1" name="repsimulateReservoirs"/>

I’ve double-checked the XML setup, but I’m unsure what might be causing this issue. I’ve attached my setup data for the basin for further inspection (data).

Could you please advise on what might be going wrong or if there are any additional steps required to enable reservoir output generation?

Thank you for your time and assistance!

Best regards, Nooshdokht

StefaniaGrimaldi commented 1 month ago

Dear @Nooshdokht-Bayatafshary,

thank you for your enquiry.

The option "repsimulateReservoirs" allows to print the time series (.tss format) of the level of filling, inflow, and outflow for each reservoir included in the computational domain ( https://github.com/ec-jrc/lisflood-code/blob/fe94c33b6bd9fe09fa7be43a6dd4fdc8a11f744c/src/lisflood/global_modules/default_options.py#L1363, https://github.com/ec-jrc/lisflood-code/blob/fe94c33b6bd9fe09fa7be43a6dd4fdc8a11f744c/src/lisflood/global_modules/default_options.py#L1367, https://github.com/ec-jrc/lisflood-code/blob/fe94c33b6bd9fe09fa7be43a6dd4fdc8a11f744c/src/lisflood/global_modules/default_options.py#L1371).

In the xml file "settings_calibration_daily2001Runlong_term_run.xml", "repsimulateReservoirs" is set to 1 in line 72, but then to 0 in line 87 (this latter setting switches off the printing function). Could you please confirm that I am looking at the correct xml file?

In case you wished to print netcdf gridded outputs of the level of filling of reservoirs, you would need to activate "repStateMaps". Inflow and outflows in netcdf gridded format can be extracted from dis.nc ("repDischargeMaps").

I hope that this answer helps, kind regards, Stefania

Nooshdokht-Bayatafshary commented 1 month ago

Dear @StefaniaGrimaldi,

Thank you for your detailed response. You were absolutely right—the issue was caused by the conflicting setting in the XML file. I removed the second occurrence of repsimulateReservoirs in line 87, as you suggested. However, I am now encountering a new error:

Traceback (most recent call last):
  File "/home/n.bayatafshary74.student.sharif/.conda/envs/lis3.8/bin/lisflood", line 41, in <module>
    sys.exit(main())
  File "/home/n.bayatafshary74.student.sharif/.conda/envs/lis3.8/lib/python3.8/site-packages/lisflood/main.py", line 226, in main
    lisfloodexe(lissettings)
  File "/home/n.bayatafshary74.student.sharif/.conda/envs/lis3.8/lib/python3.8/site-packages/lisflood/main.py", line 90, in lisfloodexe
    Lisflood = LisfloodModel()
  File "/home/n.bayatafshary74.student.sharif/.conda/envs/lis3.8/lib/python3.8/site-packages/lisflood/Lisflood_initial.py", line 236, in __init__
    self.output_module.initial()
  File "/home/n.bayatafshary74.student.sharif/.conda/envs/lis3.8/lib/python3.8/site-packages/lisflood/global_modules/output.py", line 535, in initial
    self.var.Tss[tss] = TimeoutputTimeseries(str(binding[tss]), self.var, outpoints, noHeader=flags['noheader'])
  File "/home/n.bayatafshary74.student.sharif/.conda/envs/lis3.8/lib/python3.8/site-packages/lisflood/global_modules/zusatz.py", line 374, in __init__
    outlet_idx = np.where(codesId == outlet_code)[0][0]
IndexError: index 0 is out of bounds for axis 0 with size 0

It seems to be related to the ReservoirFillTS key based on the output when I printed binding[tss]. I'm not quite sure what’s causing the problem. Could you kindly help me troubleshoot this?

Thanks again for your assistance!

Best regards, Nooshdokht

StefaniaGrimaldi commented 1 month ago

Dear @Nooshdokht-Bayatafshary,

I am sorry for the delay. @doc78 and I finally found some time to explore your issue.

The problem is a consequence of missing metadata in your input netcdf maps (e.g. res.nc).

Specifically, the function that writes .tss files crashes because missing_value is not set. This explains the error when you activate repsimulateReservoirs. Furthermore, output files in netcdf format are regularly written but they do not have any reference system.

To solve the issue, you need to set the metadata in your input maps, particularly important are missing_value, _FillValue, and reference system.

We hope that this message helps, we are at your disposal for further discussions, kind regards, Carlo and Stefania