pysteps.io#
Methods for browsing data archives, reading 2d precipitation fields and writing forecasts into files.
pysteps.io.interface#
Interface for the io module.
|
Return a callable function for the method corresponding to the given name. |
pysteps.io.archive#
Utilities for finding archived files that match the given criteria.
|
List input files whose timestamp matches the given date. |
pysteps.io.importers#
Methods for importing files containing two-dimensional radar mosaics.
The methods in this module implement the following interface:
import_xxx(filename, optional arguments)
where xxx is the name (or abbreviation) of the file format and filename is the name of the input file.
The output of each method is a three-element tuple containing a two-dimensional radar mosaic, the corresponding quality field and a metadata dictionary. If the file contains no quality information, the quality field is set to None. Pixels containing missing data are set to nan.
The metadata dictionary contains the following recommended key-value pairs:
Key |
Value |
|---|---|
projection |
PROJ.4-compatible projection definition |
x1 |
x-coordinate of the lower-left corner of the data raster |
y1 |
y-coordinate of the lower-left corner of the data raster |
x2 |
x-coordinate of the upper-right corner of the data raster |
y2 |
y-coordinate of the upper-right corner of the data raster |
xpixelsize |
grid resolution in x-direction |
ypixelsize |
grid resolution in y-direction |
cartesian_unit |
the physical unit of the cartesian x- and y-coordinates: e.g. ‘m’ or ‘km’ |
yorigin |
a string specifying the location of the first element in the data raster w.r.t. y-axis: ‘upper’ = upper border ‘lower’ = lower border |
institution |
name of the institution who provides the data |
unit |
the physical unit of the data: ‘mm/h’, ‘mm’ or ‘dBZ’ |
transform |
the transformation of the data: None, ‘dB’, ‘Box-Cox’ or others |
accutime |
the accumulation time in minutes of the data, float |
threshold |
the rain/no rain threshold with the same unit, transformation and accutime of the data. |
zerovalue |
the value assigned to the no rain pixels with the same unit, transformation and accutime of the data. |
zr_a |
the Z-R constant a in Z = a*R**b |
zr_b |
the Z-R exponent b in Z = a*R**b |
# XR: Move this to appropriate place # XR: Add means, stds cascade level and decomposition attributes The data and metadata is then postprocessed into an xarray dataset. This dataset will always contain an x and y dimension, but can be extended with a time dimension and/or an ensemble member dimension over the course of the process.
The dataset can contain the following coordinate variables:
Coordinate |
Description |
|---|---|
y |
y-coordinate in Cartesian system, with units determined by |
x |
x-coordinate in Cartesian system, with units determined by |
lat |
latitude coordinate in degrees |
lon |
longitude coordinate in degrees |
time |
forecast time in seconds since forecast start time |
ens_number |
ensemble member number (integer) |
direction |
used by proesmans to return the forward and backward advection and consistency fields |
The time, x and y dimensions all MUST be regularly spaced, with the stepsize included
in a stepsize attribute. The stepsize is given in the unit of the dimension (this
is alwyas seconds for the time dimension).
The dataset can contain the following data variables:
Variable |
Description |
|---|---|
precip_intensity, precip_accum or reflectivity |
precipitation data, based on the unit the data has it is stored in one of these 3 possible variables
precip_intensity if unit is |
velocity_x |
x-component of the advection field in cartesian_unit per timestep |
velocity_y |
y-component of the advection field in cartesian_unit per timestep |
quality |
value between 0 and 1 denoting the quality of the precipitation data, currently not used for anything |
velocity_quality |
value between 0 and 1 denoting the quality of the velocity data, currently only returned by proesmans |
Some of the metadata in the metadata dictionary is not explicitely stored in the dataset,
but is still implicitly present. For example x1 can easily be found by taking the first
value from the x coordinate variable. Metadata that is not implicitly present is explicitly
stored either in the datasets global attributes or as attributes of the precipitation variable.
Data that relates to the entire dataset is stored in the global attributes. The following data
is stored in the global attributes:
Key |
Value |
|---|---|
projection |
PROJ.4-compatible projection definition |
institution |
name of the institution who provides the data |
precip_var |
the name of the precipitation variable in this dataset |
The following data is stored as attributes of the precipitation variable:
Key |
Value |
|---|---|
units |
the physical unit of the data: ‘mm/h’, ‘mm’ or ‘dBZ’ |
threshold |
the rain/no rain threshold with the same unit, transformation and accutime of the data. |
zerovalue |
the value assigned to the no rain pixels with the same unit, transformation and accutime of the data. |
transform (optional) |
the transformation of the data: None, ‘dB’, ‘Box-Cox’ or others |
accutime (optional) |
the accumulation time in minutes of the data, float |
zr_a (optional) |
the Z-R constant a in Z = a*R**b |
zr_b (optional) |
the Z-R exponent b in Z = a*R**b |
The following data is stored as attributes of the coordinate variables:
Key |
Value |
|---|---|
units |
the unit e.g. ‘m’ or ‘km’ for the cartesian coordinates |
stepsize |
the stepsize of the data (in minutes in case of the time coordinate), this stepsize should be exactly the difference between every value of this coordinate and the next |
Furthermore the dataset can contain some additional metadata to make the dataset CF-compliant.
Available Importers#
|
Import a NetCDF radar rainfall product from the BoM Rainfields3. |
|
Import a reflectivity field (dBZ) from an FMI GeoTIFF file. |
|
Import a 8-bit PGM radar reflectivity composite from the FMI archive. |
|
Import a precipitation or reflectivity field (and optionally the quality field) from a HDF5 file conforming to the KNMI Data Centre specification. |
|
Import a 8-bit gif radar reflectivity composite from the MeteoSwiss archive. |
|
Import a precipitation field (and optionally the quality field) from a MeteoSwiss HDF5 file conforming to the ODIM specification. |
|
Import a 8-bit bin radar reflectivity composite from the MeteoSwiss archive. |
|
Importer for NSSL's Multi-Radar/Multi-Sensor System ([MRMS](https://www.nssl.noaa.gov/projects/mrms/)) rainrate product (grib format). |
|
Import a precipitation field (and optionally the quality field) from a HDF5 file conforming to the ODIM specification. |
|
Wrapper to |
|
Import a NetCDF radar rainfall product from the Convective Rainfall Rate Intensity (CRRI) product from the Satellite Application Facilities (SAF). |
|
Import a DWD precipitation product field (and optionally the quality field) from an HDF5 file conforming to the ODIM specification. |
|
Import a RADOLAN precipitation product from a binary file. |
pysteps.io.nowcast_importers#
Methods for importing nowcast files.
The methods in this module implement the following interface:
import_xxx(filename, optional arguments)
where xxx is the name (or abbreviation) of the file format and filename is the name of the input file.
The output of each method is a two-element tuple containing the nowcast array and a metadata dictionary.
The metadata dictionary contains the following mandatory key-value pairs:
Key |
Value |
|---|---|
projection |
PROJ.4-compatible projection definition |
x1 |
x-coordinate of the lower-left corner of the data raster |
y1 |
y-coordinate of the lower-left corner of the data raster |
x2 |
x-coordinate of the upper-right corner of the data raster |
y2 |
y-coordinate of the upper-right corner of the data raster |
xpixelsize |
grid resolution in x-direction |
ypixelsize |
grid resolution in y-direction |
yorigin |
a string specifying the location of the first element in the data raster w.r.t. y-axis: ‘upper’ = upper border ‘lower’ = lower border |
institution |
name of the institution who provides the data |
timestep |
time step of the input data (minutes) |
unit |
the physical unit of the data: ‘mm/h’, ‘mm’ or ‘dBZ’ |
transform |
the transformation of the data: None, ‘dB’, ‘Box-Cox’ or others |
accutime |
the accumulation time in minutes of the data, float |
threshold |
the rain/no rain threshold with the same unit, transformation and accutime of the data. |
zerovalue |
it is the value assigned to the no rain pixels with the same unit, transformation and accutime of the data. |
Available Nowcast Importers#
|
Read a nowcast or an ensemble of nowcasts from a NetCDF file conforming to the CF 1.7 specification. |
pysteps.io.exporters#
Methods for exporting forecasts of 2d precipitation fields into various file formats.
Each exporter method in this module has its own initialization function that implements the following interface:
initialize_forecast_exporter_xxx(outpath, outfnprefix, startdate, timestep,
n_timesteps, shape, metadata,
n_ens_members=1,
incremental=None, **kwargs)
where xxx specifies the file format.
This function creates the output files and writes the metadata. See the
documentation of the initialization methods for the format of the output files
and their names. The datasets are written by calling
pysteps.io.exporters.export_forecast_dataset(), and the files are
closed by calling pysteps.io.exporters.close_forecast_files().
The arguments of initialize_forecast_exporter_xxx are described in the following table:
Argument |
Type/values |
Description |
|---|---|---|
outpath |
str |
output path |
outfnprefix |
str |
prefix of output file names |
startdate |
datetime.datetime |
start date of the forecast |
timestep |
int |
length of the forecast time step (minutes) |
n_timesteps |
int |
number of time steps in the forecast this argument is ignored if incremental is set to ‘timestep’. |
shape |
tuple |
two-element tuple defining the shape (height,width) of the forecast grids |
metadata |
dict |
metadata dictionary containing the projection,x1,x2,y1,y2 and unit attributes described in the documentation of pysteps.io.importers |
n_ens_members |
int |
number of ensemble members in the forecast this argument is ignored if incremental is set to ‘member’ |
incremental |
{None, ‘timestep’, ‘member’} |
allow incremental writing of datasets the available options are: ‘timestep’ = write a forecast or a forecast ensemble for a given time step ‘member’ = write a forecast sequence for a given ensemble member |
Optional exporter-specific arguments are passed with kwargs.
The return value is a dictionary containing an exporter object.
This can be used with pysteps.io.exporters.export_forecast_dataset()
to write the datasets to the output files.
Available Exporters#
|
Initialize a GeoTIFF forecast exporter. |
|
Initialize a KINEROS2 format exporter for the rainfall ".pre" files specified in https://www.tucson.ars.ag.gov/kineros/. |
|
Initialize a netCDF forecast exporter. |
Generic functions#
|
Write a forecast array into a file. |
|
Close the files associated with a forecast exporter. |
pysteps.io.readers#
Module with the reader functions.
|
Read a time series of input files using the methods implemented in the |