pysteps.io

Methods for browsing data archives, reading 2d precipitation fields and writing forecasts into files.

pysteps.io.interface

Interface for the io module.

get_method(name, method_type) 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.

find_by_date(date, root_path, path_fmt, …) List input files whose timestamp matches the given date.

pysteps.io.importers

Methods for importing files containing 2d precipitation fields.

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 precipitation field, 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 mandatory key-value pairs:

Key Value
projection PROJ.4-compatible projection definition
x1 x-coordinate of the lower-left corner of the data raster (meters)
y1 y-coordinate of the lower-left corner of the data raster (meters)
x2 x-coordinate of the upper-right corner of the data raster (meters)
y2 y-coordinate of the upper-right corner of the data raster (meters)
xpixelsize grid resolution in x-direction (meters)
ypixelsize grid resolution in y-direction (meters)
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 the value assigned to the no rain pixels with the same unit, transformation and accutime of the data.

Available Importers

import_bom_rf3(filename, **kwargs) Import a NetCDF radar rainfall product from the BoM Rainfields3.
import_fmi_pgm(filename, **kwargs) Import a 8-bit PGM radar reflectivity composite from the FMI archive.
import_mch_gif(filename, product, unit, accutime) Import a 8-bit gif radar reflectivity composite from the MeteoSwiss archive.
import_mch_hdf5(filename, **kwargs) Import a precipitation field (and optionally the quality field) from a HDF5 file conforming to the ODIM specification.
import_mch_metranet(filename, product, unit, …) Import a 8-bit bin radar reflectivity composite from the MeteoSwiss archive.
import_odim_hdf5(filename, **kwargs) Import a precipitation field (and optionally the quality field) from a HDF5 file conforming to the ODIM specification.
import_knmi_hdf5(filename, **kwargs) Import a precipitation field (and optionally the quality field) from a HDF5 file conforming to the KNMI Data Centre specification.

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 (meters)
y1 y-coordinate of the lower-left corner of the data raster (meters)
x2 x-coordinate of the upper-right corner of the data raster (meters)
y2 y-coordinate of the upper-right corner of the data raster (meters)
xpixelsize grid resolution in x-direction (meters)
ypixelsize grid resolution in y-direction (meters)
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

import_netcdf_pysteps(filename, **kwargs) Read a nowcast or a nowcast ensemble from a NetCDF file conforming to the CF 1.7 specification.

pysteps.io.exporter

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(filename, startdate, timestep,
                                 num_timesteps, shape, num_ens_members,
                                 metadata, incremental=None)

where xxx is the name (or abbreviation) of the file format.

This function creates the file and writes the metadata. The datasets are written by calling pysteps.io.exporters.export_forecast_dataset(), and the file is closed by calling pysteps.io.exporters.close_forecast_file().

The arguments in the above are defined as follows:

Argument Type/values Description
filename str name of the output file
startdate datetime.datetime start date of the forecast
timestep int time step of the forecast (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
n_ens_members int number of ensemble members in the forecast. This argument is ignored if incremental is set to ‘member’
metadata dict metadata dictionary containing the projection,x1,x2,y1,y2 and unit attributes described in the documentation of pysteps.io.importers
incremental {None, ‘timestep’, ‘member’} Allow incremental writing of datasets into the netCDF file 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

The return value is a dictionary containing an exporter object. This can be used with pysteps.io.exporters.export_forecast_dataset() to write datasets into the given file format.

Available Exporters

initialize_forecast_exporter_kineros(…[, …]) Initialize a KINEROS2 Rainfall .pre file as specified in https://www.tucson.ars.ag.gov/kineros/.
initialize_forecast_exporter_netcdf(…[, …]) Initialize a netCDF forecast exporter.

Generic functions

export_forecast_dataset(F, exporter) Write a forecast array into a file.
close_forecast_file(exporter) Close the file associated with a forecast exporter.

pysteps.io.readers

Module with the reader functions.

read_timeseries(inputfns, importer, **kwargs) Read a time series of input files using the methods implemented in the pysteps.io.importers module and stack them into a 3d array of shape (num_timesteps, height, width).