act.io.read_netcdf

act.io.read_netcdf(filenames, concat_dim=None, return_None=False, combine='by_coords', use_cftime=True, cftime_to_datetime64=True, combine_attrs='override', cleanup_qc=False, keep_variables=None, **kwargs)[source]

Returns xarray.Dataset with stored data and metadata from a user-defined query of ARM-standard netCDF files from a single datastream. Has some procedures to ensure time is correctly fomatted in returned Dataset.

Parameters:
  • filenames (str, pathlib.PosixPath or list of str) – Name of file(s) to read.

  • concat_dim (str) – Dimension to concatenate files along. Default value is ‘None’.

  • return_None (bool, optional) – Catch IOError exception when file not found and return None. Default is False.

  • combine (str) – String used by xarray.open_mfdataset() to determine how to combine data files into one Dataset. See Xarray documentation for options.

  • use_cftime (boolean) – Option to use cftime library to parse the time units string and correctly establish the time values with a units string containing timezone offset. This will return the time in cftime format. See cftime_to_datetime64 if don’t want to convert the times in xarray dataset from cftime to numpy datetime64.

  • cftime_to_datetime64 (boolean) – If time is stored as cftime in xarray dataset convert to numpy datetime64. If time precision requried is sub millisecond set decode_times=False but leave cftime_to_datetime64=True. This will force it to use base_time and time_offset to set time.

  • combine_attrs (str) – String indicating how to combine attrs of the objects being merged

  • cleanup_qc (boolean) – Call clean.cleanup() method to convert to standardized ancillary quality control variables. This will not allow any keyword options, so if non-default behavior is desired will need to call clean.cleanup() method on the object after reading the data.

  • keep_variables (str or list of str) – Variable names to read from data file. Works by creating a list of variable names to exclude from reading and passing into open_mfdataset() via drop_variables keyword. Still allows use of drop_variables keyword for variables not listed in first file to read.

  • **kwargs (keywords) – Keywords to pass through to xarray.open_mfdataset().

Returns:

obj (Object (or None)) – ACT dataset (or None if no data file(s) found).

Examples

This example will load the example sounding data used for unit testing.

import act
the_ds, the_flag = act.io.armfiles.read_netcdf(act.tests.sample_files.EXAMPLE_SONDE_WILDCARD)
print(the_ds.attrs._datastream)