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_as_coords=True, optional=True, optional_groups=False, incomplete_sweep='drop', lock=None, **kwargs)[source]#
Open a NEXRAD Level2 dataset as
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,bytes,list, orDataStore) – The path or file-like object representing the radar file. Path-like objects are interpreted as local or remote paths. A list or tuple of chunk sources (bytes, file-like, or paths) will be concatenated before reading. When passing chunks, the S file (volume header) must be the first element and I/E chunks must follow in sequence order (.001,.002, …). Out-of-order chunks produce corrupted data or decompression errors.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 (
strorlistofstr, 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 (
intorlistofint, 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 (
boolordict, 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_as_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.optional_groups (
bool, optional) – If True, includes/radar_parameters,/georeferencing_correctionand/radar_calibrationmetadata subgroups in the DataTree. These groups are often empty or sparsely populated. Default is False.incomplete_sweep (
{"drop", "pad"}, optional) – How to handle incomplete sweeps (sweeps that were force-closed because the data ended mid-sweep, e.g. chunk files)."drop"(default) excludes incomplete sweeps and emits a warning."pad"includes them, reindexing to a full azimuth grid with NaN-filled rays for missing positions.kwargs (
dict) – Additional keyword arguments passed to xarray.open_dataset.
- Returns:
dtree (
xarray.DataTree) – An xarray.DataTree representing the radar data organized by sweeps.