-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Which is the current status of the tool? #7
Comments
Dear Josias Lisflood calibration tool is now compatible with python 3.7. However unfortunately the Readme file is outdated. Cheers |
Thanks for the quick reply, Carlo! Great to hear the tool is already fully available in Python 3. Luckily the codes are quite well commented (thanks!) so I have been able to prepare all inputs and setting files and I advanced up to the start of the actual calibration (CAL_7_PERFORM_CAL.py). First, a couple of questions to make sure I have been on the right track up to here:
When I now try to run the calibration (CAL_7_PERFORM_CAL.py), I immediately get the below error at the first calibration station, then the code advances to the next station and is stuck running without progress:
I understand that some software that includes qsub for queuing jobs is missing on my system. Do I need this software if I am running the calibration locally? And if so, how do I install it? I am running the calibration on a macOS Catalina with 8 cores. Thanks a lot for your help! Josias |
Dear Josias CAL_4_EXTRACT_STATION.py performs some checks and prepare (generates) the station_data.csv file and the observations file for each catchment in its dedicated "station" directory. Then you will need to call the the script CAL_7A_CALIBRATION.py and CAL_7B_LONGTERM_RUN.py on each single catchment, OR the script CAL_7_PERFORM_CAL.py on a list of catchments. CAL_6_CUT_MAPS_list.py: you should include also the climate forcing into the same input directory to be cut. "qsub" command is used to submit a job on our cluster of nodes, but you don't need it. You can just run the generated script "/Users/ritterj1/PythonProjects/lisflood-calibration/scripts/runLF_on_10501.sh" Hope this helps |
Dear Carlo @doc78, I am trying to use the calibration tool, but I got confused with the names of the python scripts on the documentation and release 0.2. After reading the comments above I understood that the readme is outdated, so I decide to follow the documentation with the python scrips, for example, using the script CAL_1_FILTER_STATIONS.py following the explanation of CAL_1_CAL_VAL_PERIODS.py in the documentation but I got some errors
I would appreciate some guidelines for calibration. Thank you very much! |
Dear Edgar CAL_1_FILTER_STATION.py takes 3 arguments:
You can find in the "integration" folder some LisfloodSettings xml example files. The structure of the xml is the same used by Lisflood, so you can get info from the Lisflood 4.0.0 documentation (that is updated). This file will be used from the calib tool to tell the Deap Algorithm which modules should be used and the map paths (or fixed values) for the variables. Yes, you need to install the lisflood package into your conda environment to use the calibration. You can install it using the command "pip install lislflood-model" or compile it from source code and then install it using the command "pip install ." in the lisflood-code folder runLF_linux_cut.sh is an old script. You should instead use the CAL_4 and CAL_7 scripts in the actual master branch to execute the cutmaps and the calibration. The readme will be updated as soon as possible with further details on all the new steps. In the meantime I hope this helps. Best Regards |
Dear Carlo, Thank you for your explanation, and quick reply. I am still having one error How Spinup_days are defined? Is it defined in the station.csv file? And I supposed that Best regards, |
Yes, you are right, the station.csv file needs to be updated as well. You should add the Spinup_days column to the station.csv file as well as Min_calib_days. Furthermore, you should update the column "CAL_TYPE" with values "6" and "24" instead of the current "NRT_6h" and "HIST_24h" values.
Min_calib_day is used to exclude stations that do not have enough days of observations for the calibration. Best Regards |
Dear @EdgarEspitia, By browsing through the code and looking at the inputs requirements of the scripts, I prepared my station.csv file as seen in the screenshot below. With this station.csv file, all the preprocessing scripts worked (up to including CAL_6_CUT_MAPS_list.py). Hope it helps! Josias |
Dear @josiasritter and @doc78 Thank you very much for your help! Now, in the script CAL_3_PREP_MISC.py, I got the error:
I think the error is related to the coordinates of the outlet. Am I right? Best regards, |
I am looking at what is wrong with the maps or coordinates. For using a |
nc2pcr should work without clone.map in latest lisflood-utilities v0.12.19. (clone.map is only used to get coordinates to generate the ldd.map file in this case). |
I found the source of errors, there were two mistakes, the first one was the coordinates, they were not the same in all CSV files, and the second was related to the After solving these errors, new ones arose:
Thanks! |
The new issue is related to the ldd map that is "unsound", that means not all the downstream paths end in a pit cell. |
Thanks for your help!
I continued the next steps, I ran And I supposed that When I tried to run |
Dear Edgar CAL_6_CUT_MAPS_list.py: yes, you should just add the list of the stations in one column in a text file and use the text filename as a parameter of the python script: python CAL_6_CUT_MAPS_list.py <settings_file> <path_maps> <list_of_stations.txt> If you get the error "wrong input mask file", you should check the subcatchment_path in your settings_file and the mask.map file in your maps folder of the subcatchment_path. You need to provide a valid "mask.map" pcraster file to cut the maps. CAL_7A_CALIBRATION.py: The seed is an optional parameter. You can just omit it or, if you want to use it, you should write the following command: python CAL_7A_CALIBRATION.py /my_system/settings.txt 633 1 --seed=2 |
Dear Edgar. |
Dear Carlo, I think the error is related to the paths in the settings file for the calibration or in the settings-Run.xml defining the outputs (lzavin.nc, and dis.tss). The error happens because the calibration algorithm cannot read the outputs of lisflood, so I think the problem is related to the structure of subcatchments (links and files structure ) and the paths in the settings files for calibration (for example: subcatchment_path, inlets, and interstation_regions). If you manually copy the outputs of the pre-run and run ( the files lzavin.nc, avgdis.nc, chanqWin.tss, and dis.tss) to the path reported in the error log, the calibration starts, but in the next iteration the error shows up. Thanks for your help! |
This is an example of the link structure The link stations_links.csv looks like this: 6337350 Is it right? |
Dear Edgar. I think the issue is in the xml file. You should check that pathOut and pathRoot are in the format:
And variables are in the format:
The old style of these path are instead in the format:
And this format is not compatible with the previous. Please note that "%run_rand_id" will be replaced at runtime by the numeration of the generation and the run of the current step of the calibration, e.g. for generation "0" run nr 1 you will get "0_1", thus the output folder of this run will be: /lisflood-calibration/tests/my_catchment/CATCHMENTS_DIR/633/out/0_1/" If you still have the issue or have any doubt please send me your xml file and I will give it a look. Carlo |
Dear Carlo, I am still having issues trying to run the script CAL_7A_CALIBRATION.py. I think, there is something wrong in the settings.txt in the section of path, exactly with: I would appreciate it if you have any comments on the attached setup. Thanks for your help. Best regards, |
Dear Edgar. ID IDs of directly connected nested subcatchments While it should be: Please note that you should have at least 3 commas, and at least in the first row (the header), so that pandas will know that has to take 4 columns. Otherwise the pandas parser reading csv file will fail. Best Regards |
Dear Carlo, I fixed the
Thanks a lot! Best regards, |
Can you send me your updated csv file? Please note that catchments IDs should be just numbers, no letters nor special chars. Please check also for tabs or spaces. |
You are right, at the end of the lines in the file stations_links.csv was a tab, so I deleted it, and ran it again, but now the problems related to the subcatchments inflows. Look at the error log.
|
Ok, this is fine. You just have to calibrate the catchment number "100" before the "200", since "200" need the "100" time series (as you wrote 200,100,508,509 in your stations_links.csv file). |
Yes, correct. There is also a script to run all catchments automatically in the correct order "CAL_7_PERFORM_CAL.py", that takes as input the full o a partial list of catchments, but it is build to submit jobs on our Cluster system, so you need to make some changes to use it on your system. |
I have tried , but I got an error. can be it related with the general inflow.map? what are the caracteristics of the general inflow.map?
|
I think the general inflow.map is just missing. You should copy it to /my_system/lisflood-calibration/my_catchment/data/subcatchments/508/inflow/inflow.map |
I see in your setting file another issue. You have:
while it should be:
Because the calibration will generate initialization (prerun) settings files updating this variable. https://github.com/ec-jrc/lisflood-calibration/blob/master/integration/settings_EFAS5.xml This one is a working setting file, so you should keep all the variables and style of this one also in yours, just changing options, paths and filenames of your maps. |
Dear Carlo, I fixed the issues with the variables names, so the calibration script works with the stations that are not nested. I tried to run for station 100 (see the figure ) but I got some errors (see the error log file). |
Is this just because the row for the catchment '100' is missing in the stations_links file? It should be 100,508 |
Thanks! It works fine. Do you have any advice for choosing the parameters of the optimization algorithm? For example:
|
You should set these parameters according to the system on which you will run the calibration. |
Dear Developers, I am trying to use the calibration tool, according to the comments, I noticed that the readme is not updated. Is static data including meteo variables not defined for calibration test? Thank you, |
Dear @MehdiHosseinipour what you mean for "not defined for calibration test"? If you get any error can you please share details about the error? Carlo |
Dear @doc78 When I run the CAL_1_FILTER_STATIONS code, it cannot find the cfg.observed_discharges file and it gives the following error: Found 14 calibration stations to check |
Dear @MehdiHosseinipour We will release the updated documentation soon. In the meantime to solve your issue you should replace "OBS" with the filename and path to your observation file in the settings.txt file. Cheers |
Dear developers, I'm currently working on calibrating my basin using your calibration codes. While running
From previous responses in this issue, I gathered that to run the script for multiple stations, I need to create a text file listing the stations and then use this file as a parameter for the script. I've followed these instructions and created a file stations_code.txt containing the list of stations. Could you please assist me in identifying what might be causing this error? Any guidance or insights you can provide would be greatly appreciated. Thank you, |
Dear @Nooshdokht-Bayatafshary (lis3.8) python CAL_4_EXTRACT_STATION.py ../SettingFiles/settings.txt 21105 Cheers |
Dear @doc78, Thank you for clarifying the usage of the script. Just to confirm, I understand that I need to run the script separately for each station, as exemplified by the command you provided for station "21105". Considering I have around 50 stations, is there any way to streamline this process to avoid running the script individually for each station? Your guidance on a more efficient approach would be greatly appreciated. Best regards, |
Dear @Nooshdokht-Bayatafshary |
Dear Developers, Thank you for your earlier advice. To run Additionally, I'm encountering an error when running CAL_6_CUT_MAPS.py to cut maps that include a time dimension (e.g., climate forcing maps, water use maps). The code throws the following error:
Or for climate forcing maps:
Best regards, |
Dear @Nooshdokht-Bayatafshary |
Dear @doc78,
Here is my settings file (settings.txt):
It seems the error occurs because the path to LISFLOODSettings is not being correctly resolved. The relevant line in template.py is: Thank you for your assistance. |
Yes, you will just need to put the template XML setting file into the "templates" folder. Carlo |
Dear @doc78 and other developers, I encountered a segmentation fault while running CAL_7A_CALIBRATION.py. After backtracking, I found that the error occurs when reading NetCDF files using the xarray package for meteorological data in netcdf.py. When MapsCaching is set to true, the error occurs at line 334: When MapsCaching is set to false, the error occurs at line 181:
I am working with split meteorological files (7 files in total for each parameter). Do you have any suggestions or ideas on how to resolve this issue? Best regards, |
Can you please provide further info about this issue? Please attach the full log of the error. Carlo |
Dear @doc78, Thank you for your response. I have also included the tp files in the data.zip attachment. The code encounters a segmentation fault when attempting to open these files at the line I mentioned in my previous comment. Best regards, |
It seems there is something wrong with one of your map. Can you please check if there is any corrupted NC file in the maps folder? Carlo |
Dear @doc78, Thank you very much for your time and assistance.
I haven't been able to identify any problems with the files. If you have any suggestions on what else I should check, I would greatly appreciate your guidance. Best regards, |
Dear @doc78, I wanted to let you know that after extensive research and testing, I was able to identify the cause of the segmentation fault error. By thoroughly backtracing the code, I discovered that the issue originates from the xarray package, specifically in dataset.py at line 211 where
I wanted to share this solution in case anyone else encounters a similar issue. Best regards, |
Dear @doc78, I am running CAL_7A_CALIBRATION.py and encountered the following error. It seems to be related to Lisflood, so I'm unsure whether I should raise this issue here or in the Lisflood section. Please let me know if I should post it there instead.
The error appears to be connected to the settings file, but I couldn't find the related key for OutputMapsDataType in the manual. I based my settings file on the GLOFAS example and only changed the input paths (settings_calibration.zip). I would greatly appreciate any assistance you can provide. This is the full error log (log.txt). Best regards, |
Dear @Nooshdokht-Bayatafshary in lfuser section: in lfbinding section: you can now choose between float64 and float32 as data type for the outputs: this is a feature of the new Lisflood versions. |
Dear Developers, I am seeking clarification on the next steps following the execution of CAL_7B_LONGTERM_RUN.py. I'm unsure about which code should be run next. I see that the LISCal codes are being updated in the develop branch, and up to CAL_7B_LONGTERM_RUN.py, everything seems consistent, except for the file names. For CAL_9, I am uncertain whether to use CAL_9_PARAMETER_MAPS.py or CAL_9_basic_mosaickedparameterspcrastermaps.py from the master branch, or CAL_8_POSTPROCESSING.py from the develop branch. If the correct code is in the master branch, could you also provide the order in which the CAL_9 scripts should be executed? Are there specific commands or steps that I should follow? Additionally, I have questions regarding the GwLossStations.txt and soilmoisture_stations.txt files referenced in lines 106 and 111 of CAL_9_PARAMETER_MAPS.py. Could you please clarify their roles and where I can find them? Thank you for your assistance. Best regards, |
Dear @Nooshdokht-Bayatafshary, after the execution of https://github.com/ec-jrc/lisflood-calibration/blob/master/bin/CAL_7B_LONGTERM_RUN.py, We hope that our answer helps, |
Dear @doc78 and @StefaniaGrimaldi, I hope this message finds you well. I would like to request some clarification regarding the validation and calibration periods in the latest version of LISCAL. In a previous version, it appeared that if the record length was at least twice the MinQlength, the available streamflow record was split into equally long validation and calibration periods. If the record length was shorter than twice the MinQlength, the calibration period used MinQlength, with the remaining data allocated to validation (Reference). Could you please explain how the streamflow data is now split between the validation and calibration periods in the new version? Additionally, I would appreciate it if you could inform me where the validation criteria, such as KGE and correlation, are saved. I noticed that the KGE for the calibration period is saved in the paramsHistory.csv file for each generation. Thank you for your assistance. Best regards, |
Dear @Nooshdokht-Bayatafshary , thank you for your inquiry. The current version of the tool implements the following rules (https://github.com/ec-jrc/lisflood-calibration/blob/master/liscal/stations.py#L60):
Number of years, and temporal interval of the data used for calibration are computed individually for each station. Depending on discharge data availability, two calibration points in the same river might use different calibration years. You are correct, paramsHistory.csv, and pHistoryWRanks.csv show the scores for the calibration period. We hope that our answer clarifies some of your doubts, |
Dear Developers,
I would like to use this tool to calibrate my Lisflood model setup for the Mekong Basin. Reading the information in the Readme and on the Lisflood homepage, it is unclear to me which is the current version of the tool and what are the requirements.
When I clone the repository, I see that some work has been done to migrate the code to Python3, which is great! Is the migration close to being finished? Or will the development still take time and I should meanwhile use the original codes with Python 2.7?
A quick update on which is currently the best way to use the tool would be hugely appreciated.
Cheers and thanks for sharing this resource!
Josias
The text was updated successfully, but these errors were encountered: