ec-jrc / lisflood-lisvap

Lisflood OS (LISVAP)
https://ec-jrc.github.io/lisflood-lisvap/
European Union Public License 1.2
8 stars 6 forks source link

Error with raster dimensions in readmeteo (numpy2pcraster) #47

Closed josiasritter closed 2 years ago

josiasritter commented 2 years ago

Hi,

I am using Docker to run LISVAP and successfully tested it on the GloFAS use case. Now, for my application, I am applying GloFAS settings with ERA5 data as meteo inputs. I preprocessed the ERA5 data to have exactly the same structure and attributes as the GloFAS netcdf files from the use case, the only difference being that my layers cover a different area.

The error seems to happen in the conversion of the first meteo input (Tavg) from numpy to pcraster format. Please see below a screenshot of the error.

Screenshot 2022-04-22 at 14 57 37

As I interpret the error message “RuntimeError: Size mismatch: Number of array elements is 298, number of raster cells is 150490”, pcraster somehow does not understand that my raster has 298 columns and 505 rows (resulting in the number of raster cells 150490). Do you have any hints how I can solve this? I am thankful for any advice!

Josias

gnrgomes commented 2 years ago

Dear @josiasritter , You need to clip the ERA5 data using your area.nc map, so you can guarantee that your data have the exact dimensions of your base maps. If you need, you can check how one of my colleagues did this for the same dataset, but first he regridded ERA5 from 0.1 degrees to 1arcmin. In the following script between lines 225 and 238: https://github.com/Alowis/lisflood-meteo-forcing/blob/main/main_ERA5land_reanalysis.py

josiasritter commented 2 years ago

Dear @gnrgomes , Thanks a lot for your quick reply! I already had clipped the ERA5 data with my area.nc map before the error occurred. However, I figured out the problem: I found that the error was due to an inverted y-axis (latitudes) that originated from the regridding procedure I applied to the era5 data. So in short, this issue is solved now. Unfortunately, I then encountered a similar error in the writing of the output files:

Screenshot 2022-04-27 at 11 30 54

The error only occurs when the "writeNetcdfStack" setting is on; otherwise, valid output files with plausible content are generated for each timestep. Interestingly, the error is related to writing the longitude coordinate vector into the netcdf output files. The latitude coordinates seem to work (they are written right before the line causing the error). I played around with the axis definitions and replicated in my area.nc the structure of the area.nc in the GloFAS use case, but the error remains.

Would you have any other ideas about the cause of the error? Thanks a lot for your help!

josiasritter commented 2 years ago

Here is a quick follow-up (@gnrgomes): I did not solve the issue described above but instead did the following workaround: Using the repository you linked in your reply (https://github.com/Alowis/lisflood-meteo-forcing), I started from scratch to generate the meteo inputs for Lisvap. This worked very well; I suggest you advertise this repository here and on the Lisvap webpage. After preparing the inputs, I nevertheless had to clone the Lisvap repository to make the following change in the source code:

The tool readmeteo.py works only if either GloFAS, EFAS, or CORDEX settings are activated in the settings file. So far so good. But this does not give any flexibility if a different combination of input maps is used. For instance, the ERA5-land inputs pre-processed with the above repository provide a slightly different set of input maps than required by the GloFAS default setting: the total wind maps are used instead of the UV-wind component maps. In the current form, having GloFAS settings "on" overwrites other input options such as ". In my opinion, it would be very useful to add to readmeteo.py an option to use a fully user-defined set of input maps that allows to switch off all of the three default settings and just uses the user-defined maps specifically activated in the settings file.

gnrgomes commented 2 years ago

Hi @josiasritter, Did you clip also the lat.nc file that is configured in the settings file? This map contains the latitude of each pixel and is used in several formulas.

Regarding the readmeteo.py, it reads the input variables that will be used in the several formulas for the evapo transpiration calculation. If you have different formulas, please feel free to insert your own rules to load different variables than the ones used for EFAS, GLOFAS or CORDEX. You will have to change the readmeteo.py, default_options.py and lisvapdynamic.py files to include your own formulas. Like in the image bellow. Basically search for 'EFAS' in all files and implement your own code snippet that loads different variables than the ones used and implement the new formulas based in the variables you loaded.

lisvapdynamic_final_formulas

josiasritter commented 2 years ago

Hi @gnrgomes, Yes, I had clipped all input grids to the exact same spatial extent and resolution. Thanks for your explanation on how to customise the code to user-defined sets of inputs. I believe this issue is solved so I will proceed and close it. Thanks again for your help!