nowcast-verification-cell-tracking
Code for the manuscript Ritvanen et al. "Cell tracking -based framework for assessing nowcasting model skill in reproducing growth and decay of convective rainfall"
https://github.com/fmidev/nowcast-verification-cell-tracking
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.4%) to scientific vocabulary
Repository
Code for the manuscript Ritvanen et al. "Cell tracking -based framework for assessing nowcasting model skill in reproducing growth and decay of convective rainfall"
Basic Info
- Host: GitHub
- Owner: fmidev
- License: mit
- Language: Jupyter Notebook
- Default Branch: main
- Size: 3.5 MB
Statistics
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Code for the manuscript "Cell tracking -based framework for assessing nowcasting model skill in reproducing growth and decay of convective rainfall" by Ritvanen et al.
This repository contains code for the manuscript
Ritvanen, J., Pulkkinen, S., Moisseev, D., Nerini, D. (2024): Cell tracking -based framework for assessing nowcasting model skill in reproducing growth and decay of convective rainfall
submitted to the Geoscientific Model Development journal.
Python environment
For installing the conda environment for running the pysteps nowcasts and cell tracking analysis, run
bash
conda env create -f environment_proc.yml
For installing the conda environment for plotting the figures with the notebooks, run
bash
conda env create -f environment_jupyter.yml
Replicating pysteps nowcasts
- Create a section in the
pystepsrcfile for your data source. For more information, refer to the existing sections or the pysteps documentation. - Update configuration files in
config/swiss-data/pystepsdirectoryhdf5_pathto the output filepathdatelist_pathto the file containing the list of dates to processdata_source_nameto the name of the data source in thepystepsrcfile- as required, the attributes that are written to output file under
save:what_attrs
- Run the nowcasting script with the configuration file folder as an argument
```bash conda activate proc export PYTHONPATH=$PYTHONPATH:. export OMPNUMTHREADS=1
python scripts/runpystepsswap_predictions.py swiss-data/pysteps-predictions ```
The script will run the nowcasts for all configuration files in the provided folder. If necessary, move the configuration files to another folder to run only a subset of the configurations.
Storing the measurement data
- Create a section in the
pystepsrcfile for your data source. For more information, refer to the existing sections or the pysteps documentation. - Update the paths in the
config/swiss-data/save_measurements.yamlfilehdf5_pathto the output filepathdatelist_pathto the file containing the list of dates to processdata_source_nameto the name of the data source in thepystepsrcfile- as required, the attributes that are written to output file under
save:what_attrs
- Run the script to save the measurements
```bash conda activate proc
export PYTHONPATH=$PYTHONPATH:. export OMPNUMTHREADS=1
python scripts/savemeasurements.py config/swiss-data/savemeasurements.yaml ```
For both the nowcasts and measurements, the values are packed into an 8-bit format using a lookup table. The lookup table is stored in the verif/metranet_lookup.py file. If you wish to disable this behaviour and instead pack using a specified gain and offset values, set use_metranet_lookup to False in the configuration file and instead provide the gain and offset values.
Running the cell tracking verification framework
The cell tracking verification expects input data in the HDF5 format. The data should have the following structure for the observation files:
txt
├YYYY-mm-dd HH:MM:SS
│ └measurements
│ ├data [uint8: HEIGHT × WIDTH]
│ │ └2 attributes:
│ │ ├CLASS: b'IMAGE'
│ │ └IMAGE_VERSION: b'1.2'
│ └what
│ └N attributes:
│ ...
where the <YYYY-mm-dd HH:MM:SS>/data is the dataset containing the rainrate values in mm/h.
The data should be stored as an 8-bit integer with a lookup table to convert the values to the original scale. If the data is instead stored in 8-bit format with gain and offset, make sure that the gain and offset values are provided as attributes in <YYYY-mm-dd HH:MM:SS>/data/what and that <YYYY-mm-dd HH:MM:SS>/data/what/use_metranet_lookup attribute is false.
The nowcasts are expected to be stored in the following structure:
txt
├YYYY-mm-dd HH:MM:SS
<model-name>
├<leadtime-index>
│ ├data [uint8: WIDTH × HEIGHT]
│ │ └2 attributes:
│ │ ├CLASS: b'IMAGE'
│ │ └IMAGE_VERSION: b'1.2'
│ └what
│ N attributes:
│ ....
├<leadtime-index>
│ ├data [uint8: WIDTH × HEIGHT]
│ │ └2 attributes:
│ │ ├CLASS: b'IMAGE'
│ │ └IMAGE_VERSION: b'1.2'
│ └what
│ N attributes:
...
where the <YYYY-mm-dd HH:MM:SS>/data/<i> is the dataset containing the nowcast for leadtime step <i> values in mm/h.
The data should be stored as an 8-bit integer with a lookup table to convert the values to the original scale. If the data is instead stored in 8-bit format with gain and offset, make sure that the gain and offset values are provided as attributes in <YYYY-mm-dd HH:MM:SS>/data/<i>/what and that <YYYY-mm-dd HH:MM:SS>/data/<i>/what/use_metranet_lookup attribute is false.
Next, update the configuration file config/swiss-data/calculate_metrics_objects.yaml:
exp_idto the experiment identifierpath:rootto the output directory rootpath:metrics: to the output file location for the metricspath:states: to the output file location for the verification statepath:timestamps: to the list of timestamps to processpath:done: the path to the CSV file recording which metrics have been calculatedpath:config_copy: the path to the configuration file copypath:logging: the path to the log filemethodsitems for each nowcast method with the structure
yaml
<model-name>:
path: <path-to-hdf5-file>
measurementswith the following structure
yaml
measurements:
name: measurements
path: <path-to-hdf5-file>
- if required, update the cell tracking parameters in the
metrics:OBJECTS:init_kwargssection:leadtimesto the list of leadtimes to processprev_obs_times: the number of previous timesteps to load (i.e, t-1, t-2, ...)zr_aandzr_bto the Z-R relationship parameters used to transform to reflectivity valuesdist_limit_matchingto the maximum distance for matching cells in the Hungarian algorithm, in pixel unitstdating_kwargsto the parameters for the t-dating algorithm. For more information, refer to pysteps documentation
After that, run the script to calculate the metrics
```bash conda activate proc
export PYTHONPATH=$PYTHONPATH:.
python scripts/calculatemetrics.py config/swiss-data/calculatemetrics_objects.yaml ```
Plotting the figures
To plot the results, first set the configuration file config/swiss-data/plot_metrics_objects.yaml:
exp_idto the experiment identifierpath:result_dirto the output directory rootstylefilepath to the stylefile for the plotslegend_ordera list specifying the order of the models in figure legendsmetric_conffor each metric specify e.g. the y axis limits and label namesmethodseach model to be plotted in the following structure
yaml
<model-name>:
color: "<model-color-name-or-hex-code"
label: "<model-label>"
linestyle: "<model-linestyle>"
For running the notebooks, use the jupyter conda environment. The notebooks are located in the notebooks directory. It is recommended to start the jupyter server in the root directory of the repository, otherwise some paths to stylefiles and configuration files need to be updated in the notebooks.
```bash conda activate jupyter export PYTHONPATH=$PYTHONPATH:.
jupyter lab ```
The figures can be plotted with the following notebooks:
notebooks/cell_verification_article_figures.ipynbfor all result figures in the article, except Figure 12 (number of splits and merges)notebooks/cell_verification_article_splits_merges.ipynbfor Figure 12 (number of splits and merges)notebooks/cell_verification_article_supplementary_figures.ipynbfor supplementary figuresnotebooks/plot_domain_figure.ipynbfor plotting the domain figure. Update the path to the topography data in the 4th cell in the notebook.notebooks/plot_pixel_csi_rmse.ipynbfor plotting the pixel-wise CSI and RMSE figures. Note that this notebook uses the
The nowcast figure can be plotted with the script scripts/plot_nowcast_figures.py that uses the configuration file config/swiss-data/plot_nowcast_figs.yaml. To update the configuration file, refer to the comments in the file. The script can be run with
```bash conda activate proc
export PYTHONPATH=$PYTHONPATH:.
python scripts/plotnowcastfigures.py config/swiss-data/plotnowcastfigs.yaml
where <YYYYMMMDDHHMM> is the timestamp to plot.
Note that, as the configuration file is provided here, the observations are read from the original metranet data file, so plotting the nowcasts requires the original metranet data file to be available and the py-radlib package to be installed.
Also ODIM compliant HDF5 files are supported; in this case, change the input_data:RATE:reader_func to h5_to_dataset.
License
The code is licensed under the MIT license. See the LICENSE file for more information.
Owner
- Name: FMI Open Development
- Login: fmidev
- Kind: organization
- Email: beta@fmi.fi
- Location: Helsinki, Finland
- Website: https://ilmatieteenlaitos.fi
- Repositories: 280
- Profile: https://github.com/fmidev
Finnish Meteorological Institute
Citation (CITATION.cff)
cff-version: 1.2.0
title: Cell tracking -based verification framework for nowcasts
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Jenna
family-names: Ritvanen
email: jenna.ritvanen@fmi.fi
affiliation: Finnish Meteorological Institute
orcid: 'https://orcid.org/0000-0002-0662-0839'
repository-code: >-
https://github.com/fmidev/nowcast-verification-cell-tracking
abstract: >-
Code for the manuscript
Ritvanen, J., Pulkkinen, S., Moisseev, D., Nerini, D.
(2024): Cell tracking -based framework for assessing
nowcasting model skill in reproducing growth and decay of
convective rainfall
submitted to the Geoscientific Model Development journal.
keywords:
- rainfall nowcasting
- cell tracking
- nowcast verification
license: MIT
GitHub Events
Total
- Release event: 2
- Delete event: 1
- Push event: 7
- Pull request event: 2
- Create event: 3
Last Year
- Release event: 2
- Delete event: 1
- Push event: 7
- Pull request event: 2
- Create event: 3