XRadar Data Model#

The data model for the different xradar DataArrays, Datasets and DataTrees is based on NetCDF4/CfRadial2.1. It will be aligned to the upcoming WMO standard FM301.

This module contains several helper functions to create minimal DataArrays and Datasets, as well as Datatrees.

Must read:

Code ported from wradlib.

create_sweep_dataset

Create Sweep Dataset with Coordinates.

get_azimuth_attrs

Get Azimuth CF attributes.

get_latitude_attrs

get_longitude_attrs

get_altitude_attrs

get_elevation_attrs

Get Elevation CF attributes.

get_moment_attrs

Get Radar Moment CF attributes.

get_nyquist_velocity_attrs

get_range_attrs

Get Range CF attributes.

get_time_attrs

get_unambiguous_range_attrs

moment_attrs

required moment attributes, keep order stable for readers.

sweep_vars_mapping

CfRadial 2.1 / FM301 / ODIM_H5 mapping

get_azimuth_dataarray

Create Azimuth DataArray.

get_elevation_dataarray

Create Elevation DataArray.

get_range_dataarray

Create Range DataArray.

get_sweep_dataarray

Create Sweep Moment DataArray.

get_time_dataarray

Create Time DataArray.

required_global_attrs

required global attributes (root-group)

optional_root_attrs

optional global attributes (root-group)

required_root_vars

required global variables (root-group)

optional_root_vars

optional global attributes (root-group)

sweep_coordinate_vars

sweep-group coordinate variables

required_sweep_metadata_vars

required sweep-group metadata variables

optional_sweep_metadata_vars

optional sweep-group metadata variables

sweep_dataset_vars

sweep dataset variable names

non_standard_sweep_dataset_vars

non-standard sweep dataset variable names

determine_cfradial2_sweep_variables

conform_cfradial2_sweep_group

xradar.model.conform_cfradial2_sweep_group(obj, optional, dim0=None, sort=True)[source]#
xradar.model.create_sweep_dataset(**kwargs)[source]#

Create Sweep Dataset with Coordinates.

This function creates a simple Dataset with all needed coordinates.

Radar moment variables can be assigned to this Dataset.

Keyword Arguments:
  • shape (tuple) – tuple with shape of DataArray

  • time (float or numpy.ndarray) – time resolution or array with time values (‘seconds since’-notation).

  • date_str (str) – String with the form ‘YYYY-mm-ddTHH:MM:SS’ depicting the reference time.

  • rng (float or numpy.ndarray) – range resolution or array with range values.

  • azimuth (float or numpy.ndarray) – azimuth resolution or array with azimuth values.

  • direction (int) – 1 - CW/UP, -1 CCW/DOWN

  • a1gate (int) – First measured ray. Defaults to 0. Only used for PPI.

  • elevation (float or numpy.ndarray) – elevation resolution or array with elevation values.

  • sweep (str) – “PPI” or “RHI”.

Returns:

swp_ds (xarray.Dataset) – Sweep Dataset.

xradar.model.determine_cfradial2_sweep_variables(obj, optional, dim0)[source]#
xradar.model.get_altitude_attrs()[source]#
xradar.model.get_azimuth_attrs(azi=None)[source]#

Get Azimuth CF attributes.

Parameters:

azi (numpy.ndarray) – Array with azimuth values

Returns:

az_attrs (dict) – Dictionary with Azimuth CF attributes.

xradar.model.get_azimuth_dataarray(azimuth, nrays=None, a1gate=0)[source]#

Create Azimuth DataArray.

Parameters:

azimuth (float or numpy.ndarray) – Azimuth resolution, fixed azimuth value or array with azimuth values.

Keyword Arguments:
  • nrays (int) – number of rays If int -> set all rays to same azimuth value. If None, given azimuth value is used as resolution.

  • a1gate (int) – First measured ray. Defaults to 0.

Returns:

azi_da (xarray.DataArray) – Azimuth DataArray.

xradar.model.get_elevation_attrs(ele=None)[source]#

Get Elevation CF attributes.

Parameters:

ele (numpy.ndarray) – Array with elevation values

Returns:

el_attrs (dict) – Dictionary with Elevation CF attributes.

xradar.model.get_elevation_dataarray(elevation, nrays=None)[source]#

Create Elevation DataArray.

Parameters:

elevation (float or numpy.ndarray) – elevation resolution or array with elevation values.

Keyword Arguments:

nrays (int) – If int -> set all rays to same elevation value. If None, given elevation value is used as resolution.

Returns:

ele_da (xarray.DataArray) – Elevation DataArray.

xradar.model.get_latitude_attrs()[source]#
xradar.model.get_longitude_attrs()[source]#
xradar.model.get_moment_attrs(moment)[source]#

Get Radar Moment CF attributes.

Parameters:

moment (str) – String describing radar moment.

Returns:

moment_attrs (dict) – Dictionary with Radar Moment CF attributes.

xradar.model.get_nyquist_velocity_attrs(units='m s-1')[source]#
xradar.model.get_range_attrs(rng=None)[source]#

Get Range CF attributes.

Parameters:

rng (numpy.ndarray) – Array with range values.

Returns:

range_attrs (dict) – Dictionary with Range CF attributes.

xradar.model.get_range_dataarray(rng, nbins=None)[source]#

Create Range DataArray.

Parameters:
  • rng (float or numpy.ndarray) – range resolution or array with range values.

  • nbins (int) – number of bins, must be passed if rng is provided as resolution

Returns:

rng_da (xarray.DataArray) – Range DataArray.

xradar.model.get_sweep_dataarray(data, moment, fill=None)[source]#

Create Sweep Moment DataArray.

Parameters:
  • data (tuple or numpy.ndarray) – tuple with shape of DataArray or 2d-array.

  • moment (str) – String describing radar moment.

Keyword Arguments:

fill (float) – Fill Value for new created array. Only used if data is tuple.

Returns:

swp_da (xarray.DataArray) – Sweep Moment DataArray.

xradar.model.get_time_attrs(date_str='1970-01-01T00:00:00Z', date_unit='seconds')[source]#
xradar.model.get_time_dataarray(time, nrays, date_str)[source]#

Create Time DataArray.

Parameters:
  • time (float or numpy.ndarray) – time resolution or array with time values (‘seconds since’-notation).

  • nrays (int) – number of rays

  • date_str (str) – String with the form ‘YYYY-mm-ddTHH:MM:SS’ depicting the reference time.

Returns:

time_da (xarray.DataArray) – Time DataArray.

xradar.model.get_unambiguous_range_attrs(units='meters')[source]#
xradar.model.moment_attrs = ('standard_name', 'long_name', 'units')#

required moment attributes, keep order stable for readers.

xradar.model.non_standard_sweep_dataset_vars = {'DBZ', 'VEL', 'VR'}#

non-standard sweep dataset variable names

xradar.model.optional_root_attrs = {'ray_times_increase': "'true' or 'false', assumed 'true' if missing. This is set to true if ray times increase monotonically throughout all of the sweeps in the volume.", 'scan_id': 'scan strategy id, if applicable. assumed 0 if missing', 'scan_name': 'name of scan strategy used, if applicable', 'simulated': "'true' or 'false', assumed 'false' if missing. data in this file are simulated", 'site_name': 'name of site where data were gathered'}#

optional global attributes (root-group)

xradar.model.optional_root_vars = {'altitude_agl': None, 'frequency': None, 'instrument_type': None, 'platform_type': None, 'primary_axis': None, 'status_str': None, 'status_xml': 'status_str'}#

optional global attributes (root-group)

xradar.model.optional_sweep_metadata_vars = {'antenna_transition', 'calib_index', 'n_samples', 'nyquist_velocity', 'polarization_mode', 'polarization_sequence', 'prt', 'prt_ratio', 'prt_sequence', 'pulse_width', 'qc_procedures', 'rays_angle_resolution', 'rays_are_indexed', 'rx_range_resolution', 'scan_rate', 'target_scan_rate', 'unambiguous_range'}#

optional sweep-group metadata variables

xradar.model.required_global_attrs = {'Conventions': 'Cf/Radial', 'comment': 'miscellaneous information', 'history': 'list of modifications to the original data', 'institution': 'where the original data were produced', 'instrument_name': 'name of radar or lidar', 'node': 'node identifier of the radar site', 'platform_is_mobile': "'true' or 'false', assumed 'false' if missing", 'references': 'references that describe the data or the methods used to produce it', 'source': 'method of production of the original data', 'title': 'short description of file contents', 'version': 'Cf/Radial version number', 'wmo__id': 'the traditional WMO identifier for the observing station/platform', 'wmo__originating_centre': 'the originator of the data according to Common Code Table C–11', 'wmo__wsi': 'the WIGOS station identifier (WSI) for the observing station/platform'}#

required global attributes (root-group)

xradar.model.required_root_vars = {'altitude', 'latitude', 'longitude', 'sweep_fixed_angle', 'sweep_group_name', 'time_coverage_end', 'time_coverage_start', 'volume_number'}#

required global variables (root-group)

xradar.model.required_sweep_metadata_vars = {'azimuth', 'elevation', 'follow_mode', 'prt_mode', 'sweep_fixed_angle', 'sweep_mode', 'sweep_number'}#

required sweep-group metadata variables

xradar.model.sweep_coordinate_vars = {'frequency', 'range', 'time'}#

sweep-group coordinate variables

xradar.model.sweep_dataset_vars = {'DBM', 'DBMHC', 'DBMHX', 'DBMVC', 'DBMVX', 'DBTH', 'DBTV', 'DBZH', 'DBZV', 'KDP', 'LDR', 'LDRH', 'LDRV', 'NCP', 'NCPH', 'NCPV', 'PHIDP', 'PHIHX', 'REC', 'RHOHV', 'RHOHX', 'RHOVX', 'RR', 'SNR', 'SNRHC', 'SNRHX', 'SNRVC', 'SNRVX', 'TH', 'TV', 'VRADH', 'VRADV', 'WRADH', 'WRADV', 'ZDR', 'ZH', 'ZV'}#

sweep dataset variable names

xradar.model.sweep_vars_mapping = {'CCORH': {'long_name': 'Clutter Correction H', 'short_name': 'CCORH', 'standard_name': 'clutter_correction_h', 'units': 'unitless'}, 'CCORV': {'long_name': 'Clutter Correction V', 'short_name': 'CCORV', 'standard_name': 'clutter_correction_v', 'units': 'unitless'}, 'CMAP': {'long_name': 'Clutter Map', 'short_name': 'CMAP', 'standard_name': 'clutter_map', 'units': 'unitless'}, 'DBM': {'long_name': 'Radar Received Signal Power (raw total power)', 'short_name': 'DBM', 'standard_name': 'radar_received_signal_power', 'units': 'dBm'}, 'DBTH': {'long_name': 'Total power H (uncorrected reflectivity)', 'short_name': 'DBTH', 'standard_name': 'radar_equivalent_reflectivity_factor_h', 'units': 'dBZ'}, 'DBTV': {'long_name': 'Total power V (uncorrected reflectivity)', 'short_name': 'DBTV', 'standard_name': 'radar_equivalent_reflectivity_factor_v', 'units': 'dBZ'}, 'DBZ': {'long_name': 'Equivalent reflectivity factor', 'short_name': 'DBZ', 'standard_name': 'radar_equivalent_reflectivity_factor', 'units': 'dBZ'}, 'DBZH': {'long_name': 'Equivalent reflectivity factor H', 'short_name': 'DBZH', 'standard_name': 'radar_equivalent_reflectivity_factor_h', 'units': 'dBZ'}, 'DBZH_CLEAN': {'long_name': 'Equivalent reflectivity factor H', 'short_name': 'DBZH_CLEAN', 'standard_name': 'radar_equivalent_reflectivity_factor_h', 'units': 'dBZ'}, 'DBZV': {'long_name': 'Equivalent reflectivity factor V', 'short_name': 'DBZV', 'standard_name': 'radar_equivalent_reflectivity_factor_v', 'units': 'dBZ'}, 'KDP': {'long_name': 'Specific differential phase HV', 'short_name': 'KDP', 'standard_name': 'radar_specific_differential_phase_hv', 'units': 'degrees per kilometer'}, 'LDR': {'long_name': 'Log-linear depolarization ratio HV', 'short_name': 'LDR', 'standard_name': 'radar_linear_depolarization_ratio', 'units': 'dB'}, 'PHIDP': {'long_name': 'Differential phase HV', 'short_name': 'PHIDP', 'standard_name': 'radar_differential_phase_hv', 'units': 'degrees'}, 'RATE': {'long_name': 'rainfall_rate', 'short_name': 'RATE', 'standard_name': 'rainfall_rate', 'units': 'mm h-1'}, 'RHOHV': {'long_name': 'Correlation coefficient HV', 'short_name': 'RHOHV', 'standard_name': 'radar_correlation_coefficient_hv', 'units': 'unitless'}, 'SNRH': {'long_name': 'Signal Noise Ratio H', 'short_name': 'SNRH', 'standard_name': 'signal_noise_ratio_h', 'units': 'dB'}, 'SNRV': {'long_name': 'Signal Noise Ratio V', 'short_name': 'SNRV', 'standard_name': 'signal_noise_ratio_v', 'units': 'dB'}, 'SQIH': {'long_name': 'Signal Quality H', 'short_name': 'SQIH', 'standard_name': 'signal_quality_index_h', 'units': 'unitless'}, 'SQIV': {'long_name': 'Signal Quality V', 'short_name': 'SQIV', 'standard_name': 'signal_quality_index_v', 'units': 'unitless'}, 'TH': {'long_name': 'Linear total power H (uncorrected reflectivity)', 'short_name': 'TH', 'standard_name': 'radar_linear_equivalent_reflectivity_factor_h', 'units': 'unitless'}, 'TV': {'long_name': 'Linear total power V (uncorrected reflectivity)', 'short_name': 'TV', 'standard_name': 'radar_linear_equivalent_reflectivity_factor_v', 'units': 'unitless'}, 'UPHIDP': {'long_name': 'Differential phase HV', 'short_name': 'UPHIDP', 'standard_name': 'radar_differential_phase_hv', 'units': 'degrees'}, 'URHOHV': {'long_name': 'Correlation coefficient HV', 'short_name': 'URHOHV', 'standard_name': 'radar_correlation_coefficient_hv', 'units': 'unitless'}, 'UWRADH': {'long_name': 'Doppler spectrum width H', 'short_name': 'UWRADH', 'standard_name': 'radar_doppler_spectrum_width_h', 'units': 'meters per seconds'}, 'UZDR': {'long_name': 'Log differential reflectivity H/V', 'short_name': 'UZDR', 'standard_name': 'radar_differential_reflectivity_hv', 'units': 'dB'}, 'VR': {'long_name': 'Radial velocity of scatterers away from instrument', 'short_name': 'VR', 'standard_name': 'radial_velocity_of_scatterers_away_from_instrument', 'units': 'meters per seconds'}, 'VRAD': {'long_name': 'Radial velocity of scatterers away from instrument', 'short_name': 'VRAD', 'standard_name': 'radial_velocity_of_scatterers_away_from_instrument', 'units': 'meters per seconds'}, 'VRADDH': {'long_name': 'Radial velocity of scatterers away from instrument H', 'short_name': 'VRADDH', 'standard_name': 'radial_velocity_of_scatterers_away_from_instrument_h', 'units': 'meters per seconds'}, 'VRADH': {'long_name': 'Radial velocity of scatterers away from instrument H', 'short_name': 'VRADH', 'standard_name': 'radial_velocity_of_scatterers_away_from_instrument_h', 'units': 'meters per seconds'}, 'VRADV': {'long_name': 'Radial velocity of scatterers away from instrument V', 'short_name': 'VRADV', 'standard_name': 'radial_velocity_of_scatterers_away_from_instrument_v', 'units': 'meters per second'}, 'WRAD': {'long_name': 'Doppler spectrum width', 'short_name': 'WRAD', 'standard_name': 'radar_doppler_spectrum_width', 'units': 'meters per second'}, 'WRADH': {'long_name': 'Doppler spectrum width H', 'short_name': 'WRADH', 'standard_name': 'radar_doppler_spectrum_width_h', 'units': 'meters per seconds'}, 'WRADV': {'long_name': 'Doppler spectrum width V', 'short_name': 'WRADV', 'standard_name': 'radar_doppler_spectrum_width_v', 'units': 'meters per second'}, 'ZDR': {'long_name': 'Log differential reflectivity H/V', 'short_name': 'ZDR', 'standard_name': 'radar_differential_reflectivity_hv', 'units': 'dB'}, 'ZH': {'long_name': 'Linear equivalent reflectivity factor H', 'short_name': 'ZH', 'standard_name': 'radar_linear_equivalent_reflectivity_factor_h', 'units': 'unitless'}, 'ZV': {'long_name': 'Linear equivalent reflectivity factor V', 'short_name': 'ZV', 'standard_name': 'radar_equivalent_reflectivity_factor_v', 'units': 'unitless'}}#

CfRadial 2.1 / FM301 / ODIM_H5 mapping