xradar.io.backends.nexrad_level2.open_nexradlevel2_datatree#

xradar.io.backends.nexrad_level2.open_nexradlevel2_datatree(filename_or_obj, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, use_cftime=None, decode_timedelta=None, sweep=None, first_dim='auto', reindex_angle=False, fix_second_angle=False, site_coords=True, optional=True, **kwargs)[source]#

Open a NEXRAD Level2 dataset as an xarray.DataTree.

This function loads NEXRAD Level2 radar data into a DataTree structure, which organizes radar sweeps as separate nodes. Provides options for decoding time and applying various transformations to the data.

Parameters:
  • filename_or_obj (str, Path, file-like, or DataStore) – The path or file-like object representing the radar file. Path-like objects are interpreted as local or remote paths.

  • mask_and_scale (bool, optional) – If True, replaces values in the dataset that match _FillValue with NaN and applies scale and offset adjustments. Default is True.

  • decode_times (bool, optional) – If True, decodes time variables according to CF conventions. Default is True.

  • concat_characters (bool, optional) – If True, concatenates character arrays along the last dimension, forming string arrays. Default is True.

  • decode_coords (bool, optional) – If True, decodes the “coordinates” attribute to identify coordinates in the resulting dataset. Default is True.

  • drop_variables (str or list of str, optional) – Specifies variables to exclude from the dataset. Useful for removing problematic or inconsistent variables. Default is None.

  • use_cftime (bool, optional) – If True, uses cftime objects to represent time variables; if False, uses np.datetime64 objects. If None, chooses the best format automatically. Default is None.

  • decode_timedelta (bool, optional) – If True, decodes variables with units of time (e.g., seconds, minutes) into timedelta objects. If False, leaves them as numeric values. Default is None.

  • sweep (int or list of int, optional) – Sweep numbers to extract from the dataset. If None, extracts all sweeps into a list. Default is the first sweep.

  • first_dim ({"time", "auto"}, optional) – Defines the first dimension for each sweep. If “time,” uses time as the first dimension. If “auto,” determines the first dimension based on the sweep type (azimuth or elevation). Default is “auto.”

  • reindex_angle (bool or dict, optional) – Controls angle reindexing. If True or a dictionary, applies reindexing with specified settings (if given). Only used if decode_coords=True. Default is False.

  • fix_second_angle (bool, optional) – If True, corrects errors in the second angle data, such as misaligned elevation or azimuth values. Default is False.

  • site_coords (bool, optional) – Attaches radar site coordinates to the dataset if True. Default is True.

  • optional (bool, optional) – If True, suppresses errors for optional dataset attributes, making them optional instead of required. Default is True.

  • kwargs (dict) – Additional keyword arguments passed to xarray.open_dataset.

Returns:

dtree (xarray.DataTree) – An xarray.DataTree representing the radar data organized by sweeps.