API Reference
Utilities
- iconspy.convert_tgrid_data(ds_tgrid)
Formats the model grid in the format required by iconspy
- Parameters:
ds_tgrid (xarray.Dataset) – Dataset represention of the raw model grid (e.g. downloaded from “http://icon-downloads.mpimet.mpg.de”)
- Returns:
ds_IsD – Dataset represention of the model grid in the format required by iconspy
- Return type:
xarray.Dataset
Notes
An iconspy dataset (ds_IsD) is similar to but distinct from a pyicon dataset (ds_IcD). I suggest loading the dataset eagerly.
Example
>>> from pathlib import Path >>> import xarray as xr >>> import iconspy as ispy >>> from iconspy.tests.conftest import get_ds_tgrid_lr >>> ds_tgrid = get_ds_tgrid_lr() >>> ds_IsD = convert_tgrid_data(ds_tgrid) >>> ds_IsD = ds_IsD.load()
Target station
- class iconspy.TargetStation(name, lon, lat, boundary=True)
Represents a target station
- Parameters:
name (str) – Name of the target station
lon (float) – Longitude of the target station
lat (float) – Latitude of the target station
boundary (bool, optional) – Whether the station should be sited on a boundary point or not, by default True
- name
Name of the target station
- Type:
_Name
- target_lon
Longitude of the target station
- Type:
float
- target_lat
Latitude of the target station
- Type:
float
- boundary
Whether the station should be sited on a boundary point or not
- Type:
bool
Example
>>> import iconspy as ispy >>> target_station = ispy.TargetStation("My Station", 10.0, 20.0) >>> target_station.plot()
- plot(ax=None, proj=None, extent=None, coastlines=True, gridlines=True)
plot the target station on a map
- Parameters:
ax (matplotlib.axes, optional) – axis to plot on, by default None
proj (ccrs.Projection, optional) – projection of map to be plotted, by default None
extent (arraylike, optional) – extent of plot, by default None
coastlines (bool, optional) – whether to overlay coastlines, by default True
gridlines (bool, optional) – whether to overlay lines of latitude and longitude, by default True
- to_model_station(ds_IsD)
Converts the target station to a model station
- Parameters:
ds_IsD (xarray.Dataset) – A dataset contining the model grid information, having been operated on by iconspy.convert_tgrid_data()
- Returns:
A model station object representing the closest model grid point to the target station
- Return type:
Model stations
- class iconspy.ModelStation(target_station, ds_IsD)
Bases:
__ModelStation
- class iconspy.WetModelStation(target_station, ds_IsD)
Bases:
__ModelStation
- class iconspy.BoundaryModelStation(target_station, ds_IsD)
Bases:
__ModelStation
Sections
- class iconspy.Section(name, model_station_a, model_station_b, ds_IsD, section_type=None, contour_target=None, contour_data=None, weights=None)
Represents a path section between two model stations on an ICON grid.
A
Sectioncomputes the shortest valid path betweenmodel_station_aandmodel_station_bon the providedds_IsDhorizontal grid and stores both vertex- and edge-based representations of that path.- Parameters:
name (str) – Section name.
model_station_a (__ModelStation) – Start model station.
model_station_b (__ModelStation) – End model station.
ds_IsD (xarray.Dataset) – Ispy grid dataset.
section_type (str, optional) – Section construction mode. Can be any of [‘shortest’, ‘isolat’, ‘isolon’, ‘great circle’, ‘rhumb line’, ‘contour’].
contour_target (float, optional) – Target contour value used when
section_type == "contour".contour_data (xarray.DataArray, optional) – One-dimensional data over
edgeused for contour-based path construction.
- vertex_path
Vertex indices along the section path.
- Type:
xarray.DataArray
- edge_path
Edge indices along the section path.
- Type:
xarray.DataArray
- edge_orientation
Orientation/sign convention for each edge along the path.
- Type:
xarray.DataArray
- plot(ax=None, proj=None, extent=None, coastlines=True, gridlines=True)
- reverse_section()
- to_ispy_section(fpath=None, attrs={})
- to_pyicon_section(ds_IsD, fpath=None, attrs={})