epygram.geometries.ProjectedGeometry
— Projected Geometry class¶
Contains the classes for 3D geometries of fields.
- class epygram.geometries.ProjectedGeometry.ProjectedGeometry(name, grid, dimensions, vcoordinate, projection, position_on_horizontal_grid='__unknown__', geoid=None)[source]¶
Bases:
epygram.geometries.AbstractGeometry.RectangularGridGeometry
Handles the geometry for a Projected 3-Dimensions Field.
- Parameters
name –
Name of geometrical type of representation of points on the Globe. Name must be among [‘lambert’, ‘mercator’, ‘polar_stereographic’,
’space_view’]
grid – Handles description of the horizontal grid.
dimensions – Handles grid dimensions.
vcoordinate – Handles vertical geometry parameters.
position_on_horizontal_grid –
Position of points w/r to the horizontal. among: [‘upper-right’, ‘upper-left’,
’lower-left’, ‘lower-right’, ‘center-left’, ‘center-right’, ‘lower-center’, ‘upper-center’, ‘center’, ‘__unknown__’]
geoid – To specify geoid shape.
- compass_grid(subzone=None, position=None)[source]¶
Get the compass grid, i.e. the angle between Y-axis and North for each gridpoint.
- Parameters
subzone –
optional, among (‘C’, ‘CI’), for LAM grids only, returns the grid resp. for the C or C+I zone off the C+I+E zone.
Default is no subzone, i.e. the whole field.
position – position of lonlat grid with respect to the model cell. Defaults to self.position_on_horizontal_grid.
- default_cartopy_CRS()¶
Note
Requires plugin: with_cartopy (config.activate_plugins)
Create a cartopy.crs appropriate to the Geometry.
- distance(end1, end2)[source]¶
Computes the distance between two points along a straight line in the geometry.
- Parameters
end1 – must be a tuple (lon, lat) in degrees.
end2 – must be a tuple (lon, lat) in degrees.
- get_cartopy_extent(subzone=None)¶
Note
Requires plugin: with_cartopy (config.activate_plugins)
Gets the extension of the geometry in the default crs :param subzone: defines the LAM subzone to be included, in LAM case,
among: ‘C’, ‘CI’.
- Returns
(xmin, xmax, ymin, ymax) as expected by matplotlib’s ax.set_extent
- getcenter()[source]¶
Returns the coordinate of the grid center as a tuple of Angles (center_lon, center_lat).
- ij2ll(i, j, position=None)[source]¶
Return the (lon, lat) coordinates of point (i,j), in degrees.
- Parameters
i – X index of point in the 2D matrix of gridpoints
j – Y index of point in the 2D matrix of gridpoints
position – lat lon position to return with respect to the model cell. Defaults to self.position_on_horizontal_grid.
- ij2xy(i, j, position=None)[source]¶
Return the (x, y) coordinates of point (i,j), in the projection.
- Parameters
i – X index of point in the 2D matrix of gridpoints
j – Y index of point in the 2D matrix of gridpoints
position – position to return with respect to the model cell. Defaults to self.position_on_horizontal_grid.
Note that origin of coordinates in projection is the center of the C+I domain.
- linspace(end1, end2, num)[source]¶
Returns evenly spaced points over the specified interval. Points are lined up in the geometry.
- Parameters
end1 – must be a tuple (lon, lat) in degrees.
end2 – must be a tuple (lon, lat) in degrees.
num – number of points, including point1 and point2.
- ll2ij(lon, lat, position=None)[source]¶
Return the (i, j) indexes of point (lon, lat) in degrees, in the 2D matrix of gridpoints.
- Parameters
lon – longitude of point in degrees
lat – latitude of point in degrees
position – lat lon position to return with respect to the model cell. Defaults to self.position_on_horizontal_grid.
Caution: (i,j) are float.
- ll2xy(lon, lat)[source]¶
Return the (x, y) coordinates of point (lon, lat) in degrees.
- Parameters
lon – longitude of point in degrees
lat – latitude of point in degrees
Note that origin of coordinates in projection is the center of the C+I domain.
- make_section_geometry(end1, end2, points_number=None, resolution=None, position=None)[source]¶
Returns a projected Geometry.
- Parameters
end1 – must be a tuple (lon, lat) in degrees.
end2 – must be a tuple (lon, lat) in degrees.
points_number – defines the total number of horizontal points of the section (including ends). If None, defaults to a number computed from the ends and the resolution.
resolution – defines the horizontal resolution to be given to the field. If None, defaults to the horizontal resolution of the field.
position – defines the position of data in the grid (defaults to ‘center’)
- map_factor_field(position=None)[source]¶
Returns a new field whose data is the map factor over the field.
- Parameters
position – grid position with respect to the model cell. Defaults to self.position_on_horizontal_grid.
- mesh_area_field(position=None)[source]¶
Returns a new field whose data is the mesh area of gridpoints, i.e. X_resolution x Y_resolution / m^2, where m is the local map factor.
- Parameters
position – grid position with respect to the model cell. Defaults to self.position_on_horizontal_grid.
- plane_azimuth(end1, end2)[source]¶
Initial bearing from end1 to end2 points in plane local referential geometry.
- Parameters
end1 – must be a tuple (lon, lat) in degrees.
end2 – must be a tuple (lon, lat) in degrees.
- reproject_wind_on_lonlat(u, v, lon=None, lat=None, map_factor_correction=True, reverse=False)[source]¶
Reprojects a wind vector (u, v) on the grid onto real axes, i.e. with components on true zonal/meridian axes.
- Parameters
u – the u == zonal-on-the-grid component of wind
v – the v == meridian-on-the-grid component of wind
lon – longitudes of points in degrees, if u/v are not vectors on the whole grid
lat – latitudes of points in degrees, if u/v are not vectors on the whole grid
- :param map_factor_correction:, applies a correction of magnitude due
to map factor.
- Parameters
reverse – if True, apply the reverse reprojection.
- resolution_ij(i, j)[source]¶
Returns the distance to the nearest point of (i,j) point.
- Parameters
i – X index of point in the 2D matrix of gridpoints
j – Y index of point in the 2D matrix of gridpoints
- resolution_ll(lon, lat)[source]¶
Returns the local resolution at the nearest point of lon/lat. It’s the distance between this point and its closest neighbour.
- Parameters
lon – longitude of the point in degrees
lat – latitude of the point in degrees
- property secant_projection¶
Is the projection secant to the sphere ? (or tangent)
- select_subzone(subzone)[source]¶
If a LAMzone defines the geometry, select only the subzone from it and return a new geometry object.
- Parameters
subzone – among (‘C’, ‘CI’).
- tolerant_equal(other, tolerance=2.220446049250313e-16)[source]¶
Test of equality by recursion on the object’s attributes, with a tolerance.
- xy2ij(x, y, position=None)[source]¶
Return the (i, j) indexes of point (x, y), in the 2D matrix of gridpoints.
- Parameters
x – X coordinate of point in the projection
y – Y coordinate of point in the projection
position – position to return with respect to the model cell. Defaults to self.position_on_horizontal_grid.
Caution: (i,j) are float (the nearest grid point is the nearest integer).
Note that origin of coordinates in projection is the center of the C+I domain.