Load data#

pylawr package offers several possibilities to load data as RadarField (see also Radar fields) in post and online processing.

Datahandler#

The DataHandler is responsible for a single opened file and has methods to decode the data, i.a. radar reflectivity and grid, from the file. Some file types, e.g. .txt or .hdf5, make implementations of DataHandler necessary.

data_handler = LawrHandler(file_handler)
reflectivity = data_handler.get_reflectivity()
reflectivity = reflectivity.lawr.set_grid_coordinates(PolarGrid())
reflectivity.lawr.add_tag(TAG_BEAM_EXPANSION_CORR)
  • The DWDHDF5Handler is constructed to read in DWD HDF5 files for single radar sites. DWD’s HDF5 files are following the OPERA Data Information Model (ODIM) such that it should be possible to read in any ODIM HDF5 file. All methods are written to extract horizontal reflectivity from DWD radars, except get_datasets().

data_handler = DWDHDF5Handler(file_handler)
read_refl = data_handler.get_reflectivity()
grid = data_handler.grid
read_refl = read_refl.lawr.set_grid_coordinates(grid)
read_refl.lawr.add_tag(TAG_BEAM_EXPANSION_CORR)

There is no need for a netCDF file handler, see netCDF.

pylawr.datahandler.base.DataHandler(fh)

The data handler is responsible for a single opened file.

pylawr.datahandler.DWDHDF5Handler(fh)

The HDF5Handler is constructed to read in DWD HDF5 files for single radar sites.

pylawr.datahandler.LawrHandler(fh)

The LawrHandler is constructed to read in LawrText files.

netCDF#

As netCDF is the recommended binary serialization format for xarray object, it’s easy to read netCDF files to RadarField, which is a modified xarray.DataArray. Please remind to close netCDF files after usage.

The following example deals with loading a netCDF file written and processed by our pylawr package, which does not need big effort.

dataset = xr.open_dataset(file_path, engine='netcdf4')
reflectivity = dataset['dbz']
reflectivity = reflectivity.lawr.set_grid_coordinates(PolarGrid)

The following example deals with loading a netCDF file written and processed by another package or software, in this case our old python 2 radar package. To load other netCDF you need to rename the units and variable names according to our Naming Conventions.

dataset = xr.open_dataset(file_path, engine='netcdf4')

coordinates = dict(
    time=dataset.Time.values,
    azimuth=dataset.Azimuth.values,
    range=dataset["Att_Corr_Cband_Reflectivity"].dist.values)

attrs = dict(unit='dBZ')
attrs.update(dataset.attrs)

read_refl = xr.DataArray(
    data=dataset["Att_Corr_Cband_Reflectivity"].values,
    coords=coordinates,
    dims=['time', 'azimuth', 'range'],
    attrs=attrs)

read_refl = read_refl.lawr.set_variable('dbz')

read_refl.lawr.add_tag(TAG_BEAM_EXPANSION_CORR)

read_refl.lawr.add_tag('old algorithms: ' + dataset.used_algorithms)

grid = PolarGrid(center=(float(dataset.latitude[:-1]),
                         float(dataset.longitude[:-1]),
                         height),
                 beam_ele=float(dataset.elevation),
                 )

read_refl = read_refl.lawr.set_grid_coordinates(grid)

Functional API#

The pylawr package simplifies the input of all common file types in this project. Our X-Band data is commonly distributed in ascii-data (online) and netCDF format. Unfortunately, there are more than one netCDF file standards from our radar software, because of older software versions. The DWD C-Band data is commonly in HDF5 format. The functions take an opened file or a file path and a grid suitable for the data.

pylawr.functions.input.read_lawr_ascii(...)

Read in ascii-data from X-band local area weather radars of the University Hamburg.

pylawr.functions.input.read_lawr_nc_level0(...)

Read in NETCDF level 0 data from X-band local area weather radars of the University Hamburg.

pylawr.functions.input.read_lawr_nc_old(...)

Read in NETCDF level 1 data from X-band local area weather radars of the University Hamburg.

pylawr.functions.input.read_lawr_nc_new(...)

Read in LAWR data in NetCDF format.

pylawr.functions.input.read_dwd_hdf5(...[, grid])

Read in DWD data in HDF5 format.