xcdat.open_dataset(path, data_var=None, add_bounds=True, decode_times=True, center_times=False, lon_orient=None, **kwargs)[source]#

Wraps xarray.open_dataset() with post-processing options.

  • path (str) – Path to Dataset.

  • data_var (Optional[str], optional) – The key of the non-bounds data variable to keep in the Dataset, alongside any existing bounds data variables, by default None.

  • add_bounds (bool, optional) – If True, add bounds for supported axes (X, Y, T) if they are missing in the Dataset, by default True. Bounds are required for many xCDAT features.

  • decode_times (bool, optional) – If True, attempt to decode times encoded in the standard NetCDF datetime format into cftime.datetime objects. Otherwise, leave them encoded as numbers. This keyword may not be supported by all the backends, by default True.

  • center_times (bool, optional) – If True, attempt to center time coordinates using the midpoint between its upper and lower bounds. Otherwise, use the provided time coordinates, by default False.

  • lon_orient (Optional[Tuple[float, float]], optional) – The orientation to use for the Dataset’s longitude axis (if it exists). Either (-180, 180) or (0, 360), by default None.

    Supported options:

    • None: use the current orientation (if the longitude axis exists)

    • (-180, 180): represents [-180, 180) in math notation

    • (0, 360): represents [0, 360) in math notation

  • kwargs (Dict[str, Any]) – Additional arguments passed on to xarray.open_dataset. Refer to the [1] xarray docs for accepted keyword arguments.


xr.Dataset – Dataset after applying operations.


xarray.open_dataset opens the file with read-only access. When you modify values of a Dataset, even one linked to files on disk, only the in-memory copy you are manipulating in xarray is modified: the original file on disk is never touched.