pixcdust.readers.netcdf¶
Pre-conversion SWOT Pixel Cloud Netcdf reader.
Classes¶
Class setting defaults values in SWOT pixel cloud files such as name of attributes and variables |
|
Class configuring how a SWOT pixel cloud files is expected to be structured. |
|
Class for reading SWOT Pixel cloud official format files. |
Module Contents¶
- class pixcdust.readers.netcdf.NcSimpleConstants[source]¶
Class setting defaults values in SWOT pixel cloud files such as name of attributes and variables
- class pixcdust.readers.netcdf.NcFormatCfg[source]¶
Class configuring how a SWOT pixel cloud files is expected to be structured.
- constants: NcSimpleConstants[source]¶
- class pixcdust.readers.netcdf.NcSimpleReader(path: str | Iterable[str] | pathlib.Path | Iterable[pathlib.Path], variables: list[str] | None = None, area_of_interest: geopandas.GeoDataFrame | None = None, format_cfg: NcFormatCfg | None = None, conditions: dict[str, dict[str, str | float]] | None = None)[source]¶
Bases:
pixcdust.readers.base_reader.BaseReader- Class for reading SWOT Pixel cloud official format files.
It’s for simple uses cases as it only reads the pixel_cloud group.
- Attributes:
path: Path or list of path to read. variables: Optionally only read these variables. area_of_interest: Optionally only read points in area_of_interest. MULTI_FILE_SUPPORT: True, this class can read multiple netcdf. conditions: Optionally pass conditions to filter variables. Example: { “sig0”:{‘operator’: “ge”, ‘threshold’: 20}, “classification”:{‘operator’: “ge”, ‘threshold’: 3}, }
- static extract_info_from_nc_attrs(filename: str) Tuple[str, datetime.datetime, int, int, int, str][source]¶
Extracts orbit information from global attributes in a SWOT pixel cloud netcdf.
- Args:
filename: path of SWOT PIXC Netcdf file
- Returns:
(time of granule start as string, time of granule start as datetime, cycle number, pass number, tile number, swath size)
- filter_variable() None[source]¶
Filters xarray dataset based on operator and threshold on specific variables.
- Raises:
IOError: If the variable provided in conditions is not in the dataset. ValueError: If ‘operator’ or ‘threshold’ keys are not in conditions. AttributeError: If operator is not the function name of the operator module.
- read(orbit_info: bool = False) None[source]¶
Load self.path file(s). You can then access from data or with methods like to_xarray, to_dataframe or to_geodataframe.
See self.open_mfdataset for more details on how multiple files are merged.
- Args:
- orbit_info: Option to extract the orbit information.
Only used if multiple files are read.
- open_dataset() None[source]¶
Load the self.path file (need only one file in self.path). You can then access from data or with methods like to_xarray, to_dataframe or to_geodataframe.
- open_mfdataset(orbit_info: bool = False) None[source]¶
Load self.path file(s) as a nested array. You can then access from data or with methods like to_xarray, to_dataframe or to_geodataframe.
Variables that are not one-dimensional along points dimension are not allowed and will be dropped:
‘pixc_line_qual’,
‘pixc_line_to_tvp’,
‘interferogram’
etc.
- Args:
orbit_info: option to extract the orbit information.
- to_h3(variables: str | list[str] | None = None, resolution: int = 8, interp: bool = False, method: str = 'linear') xarray.Dataset[source]¶
Convert a Dataset with latitude and longitude coordinates into an H3-indexed grid.
- Args:
variables: The variables you want to convert into the H3 grid, all variables by default. resolution: The resolution of the H3 grid. Valid values are from 0 (coarse) to 15 (fine). interp: True for interpolate data, could be more precise but take a lot of time, default is False. method: (‘nearest’, ‘linear’, ‘cubic’) The interpolation method used by`scippy.interpolate.griddata`.
- Returns:
A new dataset with data variables interpolated onto the H3 grid
- to_healpix(variables: str | list[str] | None = None, resolution: int = 8, interp: bool = False, method: str = 'linear') xarray.Dataset[source]¶
Convert a Dataset with latitude and longitude coordinates into an HEALPix-indexed grid.
- Args:
variables: The variables you want to convert into the HEALpix grid, all by default. resolution: The resolution of the HEALPix grid. interp: True for interpolate data, could be more precise but take a lot of time, default is False. method: (‘nearest’, ‘linear’, ‘cubic’) The interpolation method used by`scippy.interpolate.griddata`.
- Returns:
A new dataset with data variables interpolated onto the HEALPix grid.
- __postprocess_points() None[source]¶
Adds a points coordinates containing shapely.Points (longitude, latitude) Useful for compatibility with xvec package and geographic manipulation.
- __preprocess_types(ds: xarray.Dataset) xarray.Dataset[source]¶
Preprocessing function changing types in pixc dataset.
It cast the lon and lat to float32.
- Args:
ds: pixc dataset read by xarray.open_dataset to preprocess
- Returns:
dataset with cast types
- __preprocess_types_and_add_orbit_info(ds: xarray.Dataset) xarray.Dataset[source]¶
Preprocessing function adding orbit information in pixc dataset.
It cast the lon and lat to float32.
- Args:
ds: pixc dataset read by xarray.open_dataset to preprocess
- Returns:
dataset augmented with orbit information for each index and with cast types