arctichoke.dataset.latlon_type

Functions

get_latlon_names(dataset)

Get the latitude and longitude variable names of the dataset.

determine_lon_type(lon_min, lon_max)

Determine the longitude type based on the minimum and maximum values.

get_lon_type(dataset)

Get the longitude type of the dataset.

Module Contents

arctichoke.dataset.latlon_type.get_latlon_names(dataset: str, xarray.DataArray, xarray.Dataset)

Get the latitude and longitude variable names of the dataset.

Opens the given dataset, checks the coordinates, and determines the name of the latitude and longitude variables. This will be either lat/lon or latitude/longitude.

Parameters:

dataset (str, xarray.DataArray, xarray.Dataset) – The dataset for which to determine the latitude and longitude names.

Returns:

  • lat_var (str) – The name of latitude variable in the dataset. This will be either lat or latitude.

  • lon_var (str) – The name of longitude variable in the dataset. This will be either lon or longitude.

Examples

>>> from arctichoke.dataset.grid_type import get_latlon_names
>>> get_latlon_names('/arctichoke_data/bergybits/data/CMIP6/HighResMIP/MOHC/HadGEM3-GC31-MM/hist-1950/r1i1p1f1/SImon/siconc/gn/v20170928/siconc_SImon_HadGEM3-GC31-MM_hist-1950_r1i1p1f1_gn_201401-201412.nc')
('lat', 'lon')
>>> get_latlon_names('/arctichoke_data/bergybits/data/CMIP6/HighResMIP/MOHC/HadGEM3-GC31-MM/hist-1950/r1i1p1f1/SImon/sithick/gn/v20170928/sithick_SImon_HadGEM3-GC31-MM_hist-1950_r1i1p1f1_gn_201401-201412.nc')
('latitude', 'longitude')
arctichoke.dataset.latlon_type.determine_lon_type(lon_min: int, float, lon_max: int, float)

Determine the longitude type based on the minimum and maximum values.

Given the minimum and maximum longitude values of a dataset, tries to determines the type of longitude: Prime Meridian centered (0 to 360), International Date Line centered (-180 to 180), or other.

Parameters:
  • lon_min (int, float) – The minimum longitude value.

  • lon_max (int, float) – The maximum longitude value.

Returns:

lon_type – The type of longitude that the dataset has which will be ‘PM_centered’, ‘IDL_centered’, or ‘other’.

Return type:

str

Examples

>>> from arctichoke.dataset.grid_type import determine_lon_type
>>> determine_lon_type(lon_min = 0, lon_max = 360)
PM_centered
>>> determine_lon_type(lon_min = -180, lon_max = 180)
IDL_centered
arctichoke.dataset.latlon_type.get_lon_type(dataset: str, xarray.DataArray, xarray.Dataset)

Get the longitude type of the dataset.

Opens the given dataset, checks the coordinates, and determines the type of longitude: Prime Meridian centered (0 to 360), International Date Line centered (-180 to 180), or other.

Parameters:

dataset (str, xarray.DataArray, xarray.Dataset) – The dataset for which to determine the longitude type.

Returns:

lon_type – The type of longitude that the dataset has which will be ‘PM_centered’, ‘IDL_centered’, or ‘other’.

Return type:

str

Examples

>>> from arctichoke.dataset.grid_type import get_lon_type
>>> get_lon_type('/arctichoke_data/bergybits/data/CMIP6/HighResMIP/EC-Earth-Consortium/EC-Earth3P-HR/hist-1950/r1i1p2f1/SImon/siconc/gn/v20181212/siconc_SImon_EC-Earth3P-HR_hist-1950_r1i1p2f1_gn_201401-201412.nc')
IDL_centered