unifhy.LatLonGrid.cell_area
- LatLonGrid.cell_area
The horizontal area for the grid cells of the
Grid
in square metres given as acf.Field
and returned as anumpy.ndarray
.- Parameters
- areas:
cf.Field
The field containing the horizontal grid cell area. The shape of the data array must be the same as the
Grid
. The field data must contain surface area values in square metres.
- areas:
- Returns
numpy.ndarray
The array containing the horizontal grid cell area values in square metres. If not set previously, computed automatically.
Examples
>>> grid = LatLonGrid.from_extent_and_resolution( ... latitude_extent=(51, 55), ... latitude_resolution=1, ... longitude_extent=(-2, 1), ... longitude_resolution=1 ... ) >>> print(grid.cell_area) [[7.69725703e+09 7.69725703e+09 7.69725703e+09] [7.52719193e+09 7.52719193e+09 7.52719193e+09] [7.35483450e+09 7.35483450e+09 7.35483450e+09] [7.18023725e+09 7.18023725e+09 7.18023725e+09]] >>> print(grid) LatLonGrid( shape {Y, X}: (4, 3) Y, latitude (4,): [51.5, ..., 54.5] degrees_north X, longitude (3,): [-1.5, -0.5, 0.5] degrees_east Y_bounds (4, 2): [[51.0, ..., 55.0]] degrees_north X_bounds (3, 2): [[-2.0, ..., 1.0]] degrees_east cell_area (4, 3): [[7697257030.0..., ..., 7180237253.9...]] m2 )
>>> import numpy >>> areas = grid.to_field() >>> areas.set_data(numpy.array([[7.70e+09, 7.70e+09, 7.70e+09], ... [7.53e+09, 7.53e+09, 7.53e+09], ... [7.35e+09, 7.35e+09, 7.35e+09], ... [7.18e+09, 7.18e+09, 7.18e+09]])) >>> areas.units = 'm2' >>> grid.cell_area = areas >>> print(grid.cell_area) [[7.70e+09 7.70e+09 7.70e+09] [7.53e+09 7.53e+09 7.53e+09] [7.35e+09 7.35e+09 7.35e+09] [7.18e+09 7.18e+09 7.18e+09]]