| |
- ESA.util.gp_grid_m.gp_grid_cl
-
- ctm_grid_cl
class ctm_grid_cl(ESA.util.gp_grid_m.gp_grid_cl) |
|
derived class for model grid
It has grid of three axis named as
['lon', 'lat', 'lz']
Members:
---------------------------------------
Added or over-ridden members
1. attr_dict:<dict>: dictionary for attributes
2. vtype: Type of the vertical grid
3. htype: Type of horizontal grid
4. hresolution: resolution of the horizontal grid
5. nlon:<integer>: size of longitude grid
6. nlat:<integer>: size of latitude grid
7. nz:<integer>: size of vertical grid
8. mask_val:<float>: filling for bad or missing data
Functions (overridden and the new ones):
-------------------------------------------
1. __init__: initialize the class
2. set_mask: set mask values
# horizontal
3. get_lon: return longitude grid
4. set_lon: set longitude grid
5. get_lat: return latitude grid
6. set_lat: set longitude grid
#
7. set_lz: set vertical level
8. set_mod_pres: set model pressure
9. compute_mod_pres: compute model pressure and reset the attributes
10. compute_mod_pres_edge: compute model pressures at level edges and reset the attributes
11. get_mod_pres: get model pressure
12. get_mod_pres_edge: get model pressure at level edges
# edges
15. set_lon_edge: set longitude edge
16. set_lat_edge: set latitude edge
17. compute_lat_edge: compute_lat_edge
18. compute_lon_edge: compute_lon_edge
19. get_area: calculate areas of grid boxes
# interploation
20. get_hintpl: construct class for horizontal interpolation
21. get_vintpl: construct class for vertical interpolation
Attributes (reserved):
-----------------------------------------------------
# grid edge
1. lon_edge:<array>: longitude grid
2. lat_edge:<array>: latitude grid
# pressure
3. surf_pres :<array, (nlon, nlat)>: surface pressure
4. ap :<array,(nz+1)>: pressure coefficients
5. bp:<array, (nz+1)>: pressure coefficients
6. mod_pres:<array, (nlon, nlat, nz)>: model pressure in hPa
7. mod_pres_edge:<array, (nlon, nlat, nz+1))>: pressure at model level edges
# filling values
8. mask_val:<float>: filling for bad or missing values.
1. ap: ap coefficients for pressure of hybrid grids
2. bp: bp coefficients for pressure of hybrid grids
3. surf_pres: surface pressures in hPa |
|
Methods defined here:
- __init__(self, lon, lat, lz, vtype='Hybrid', htype='Gaussian', hresolution='4x5', mask_val=-999.0, **keywords)
- initialize grid
Inputs:
---------------------------------------------------
1. lon, lat, lz:<array>: array for model grids.
---their sizes are nlon, nlat, nz, respectively
2. vtype:<string>: type of the vertical grid
3. htype:<string>: type of the horizontal grid
4. hresolution:<string>: type of the horizontal grid
5. mask_val=oob.fill_val,
6. keywords: <dict>: attributes
Reserved words:
--->lon_edgee:<array, (nlon+1,)>: array of model lon edges
--->lat_edgee:<array, (nlat+1,)>: array of model lon edges
--->ap, bp:<array, (nz+1,)>: coefficients for pressure level
--->surf_pres:<array, (nlon, nlat)>: pressures at surface
--->mod_pres:<array,
- compute_lat_edge(self, lat_st=-90.0, lat_end=90)
- Compute latitude box edge, and save it to the dictionary
Inputs:
------------------------------------------
1. lat_st:<float>: Starting point of the latitude
2. lat_end:<float>: End point of the latitude
Returns:
------------------------------------------------------
1. lat_edge:<array, nlat+1>: latitudes of model grid edges
- compute_lon_edge(self, lon_st=-180.0, lon_end=180.0)
- computer lontitude edge, and save it to the dictionary
This function shall be over-ridden
Inputs:
------------------------------------------
1. lon_st:<float>: Starting point of the longitude
2. lon_end:<float>: End point of the longitude
Returns:
------------------------------------------------------
1. lon_edge:<array, nlon+1>: longitudes at model grid edges
- compute_mod_pres(self, sp, ap, bp, mod_pres_f=<function get_mod_pres>)
- Compute model pressure
Inputs:
-----------------------------------------------------------
1. sp:<array, (nlon, nlat)>: surface pressure in hPa
2. ap:<array, (nz+1)>: coefficient for model pressure level
3. bp:<array, (nz+1)>: coefficient for model pressure levels
Returns:
1.mod_pres:<nlon, nlat, nz>: pressure in hPa
Notes:
----------------------------------------
1. In default routine, pressure at level edges are
caculated by
pres_edge=ap+bp*sp
- compute_mod_pres_edge(self, sp, ap, bp, mod_pres_edge_f=<function get_mod_pres_edge>)
- Compute model pressures at level edges
Inputs:
-----------------------------------------------------------
1. sp:<array, (nlon, nlat)>: surface pressure in hPa
2. ap:<array, (nz+1)>: coefficient for model pressure level
3. bp:<array, (nz+1)>: coefficient for model pressure levels
Returns:
1.mod_pres_edge:<nlon, nlat, nz+1>: pressures in hPa
Notes:
----------------------------------------
1. In this routine, pressures at level edges are
caculated by
pres_edge=ap+bp*sp
- copy(self)
- Make a copy of itself
Returns:
---------------------------------------------------
1. new_grid:<ctm_grid_cl>: new grid
- get_area(self, lon_st=-180.0, lon_end=180.0, lat_st=-90.0, lat_end=90)
- Calculate areas for grid box (in m2)
Inputs:
--------------------------------------
1. lon_st:<integer>: left edge of the first X grid box
2. lon_end:<integer>: left edge of the last X grid box
3. lat_st:<integer>: left edge of the first Y grid box
4. lat_end:<integer>: left edge of the last Y grid box
Returns:
------------------------------
1. area:<array, (nx, ny)>: area of grid box in m^2
- get_hintpl(self, olon, olat)
- get weightings and locations for interpolating fields along a track
Inputs:
------------------------------------
1. olon:<array, nob>: longitude of the track
2. olat:<array, nob>: latitude of the track
Returns:
------------------------------------
hintpl:<interp_cl>: interpolation matrix along the track
- get_lat(self)
- retrieve latitude grid
Returns:
-------------------------------------
1. self.lat:<array, (nlat)>: latitudes
- get_lat_edge(self, lat_st=-90.0, lat_end=90)
- Retrieve latitude box edges from dictionary
Returns:
------------------------------------------------------
1. lat_edge:<array, nlat+1>: latitudes at model grid edges
- get_lon(self)
- retrieve longitude grid
Returns:
-------------------------------------
1. self.lon:<array, (nlon)>: longitudes
- get_lon_edge(self, lon_edge)
- Retrieve longitude box edges from dictionary
Returns:
------------------------------------------------------
1. lon_edge:<array, nlon+1>: longitudes at model grid edges
- get_lz(self)
- retrieve lz (vertical) grid
returns:
--------------------------
1. self.lz:<array>: longitudes
- get_mod_pres(self)
- retrieve model pressure from dictionary
Returns
-------------------------------
1. mod_pres:<array, (nz,)>:pressure at model edge
- get_mod_pres_edge(self)
- retrieve model pressure at box edges from dictionary
Returns:
----------------------------------
mod_pres_edge:<array, (nz+1,)>:pressure at model edge
- get_regrid_mtx(self, newlon, newlat)
- get weightings and locations for interpolating fields along a track
Inputs:
------------------------------------
1. newlon:<array, new_nlon>: longitude of the track
2. newlat:<array, new_nlat>: latitude of the track
Returns:
------------------------------------
hintpl:<interp_cl>: interpolation matrix for regridding
- get_vintpl(self, mod_pres, opres, is_in_log, do_reverse, do_ob_reverse)
- get weightings and locations for vertically interpolating fields along a track
Inputs:
------------------------------------
1. mod_pres:<array, (nob, nz, ..)>: model pressure along the track
2. opres:<array, (nob, ob_nz, ...)>: ob pressures to be interpolated to.
3. is_in_log:<T/F>: True, if mod_pres and and opress are in log10
4. do_reverse:<T/F>: True, if mod_pres is given in decending order
5. do_ob_reverse:<T/F>: True, if opress is given in decending order
Returns:
------------------------------------
hintpl:<interp_cl>: vertical interpolation matrix
- set_lat(self, lat)
- set latitude grid
Inputs:
------------------------------------
1. lat:<array>: latitude
------------------------------------
- set_lat_edge(self, lat_edge)
- Save latitude box edge into dictionary
Inputs:
---------------------------------------------------
1. lat_edge:<array, nlat+1>: edge of the latitude boxes
- set_lon(self, lon)
- set longitude grid
Inputs:
-------------------------------------
1. lon:<array, (nlon)>: longitude
Returns:
-------------------------------------
- set_lon_edge(self, lon_edge)
- save longitude box edges to the dictionary
- set_lz(self, lz)
- set latitude grid
Inputs:
------------------------------------
1. lz:<array>: vertical coordinate
returns:
------------------------------------
- set_mask(self, mask)
- set filling value for missing or bad data
- set_mod_pres(self, mod_pres)
Methods inherited from ESA.util.gp_grid_m.gp_grid_cl:
- __getitem__(self, ax_id)
- get axis
Inputs:
--------------------------------
1. ax_id:<integer/str>: Id for the axis to be found
Returns:
----------------------------------
1, gax:<gp_axis_cl>: axis if the ax_id is valid
- allocate_point(self, p)
- find grid points around a given point, and
calculate their weights according to the distances from this point.
Inputs:
----------------------------------------------------------------
1. p:<array, (nax,)>: the coordiantes of the given point.
Returns:
-------------------------------------------------------------------
1. grd_pt_lst: <list, t:tuple>: list of the index of the surrounding grid points.
---If the dimension size nax is n, the length of grd_pt_lst is 2^n,
with each element being an array of size n.
2. grd_wgt_lst: <list, t:float>: Weights of the the surrounding points,
---which are calculated from their distances from the point.
- allocate_point_subspace(self, p, axis_id_lst)
- find grid points around a given point, and
calculate their weights according to the distances from this point.
Inputs:
----------------------------------------------------------------
1. p:<array, (nuse,)>: the coordiantes of the given point.
2. axis_id_lst:<list, t:integer>: the use the index
Returns:
-------------------------------------------------------------------
1. grd_pt_lst: <list, t:tuple>: list of the index of the surrounding grid points.
---If the dimension size nax is n, the length of grd_pt_lst is 2^n,
with each element being an array of size n with coordinate [:] for axis=axis_id
2. grd_wgt_lst: <list, t:float>: Weights of the the surrounding points,
---which are calculated from their distances from the point.
- copy_attr_dict(self)
- get one copy of the attr_dict
- get_attr(self, attr_name)
- find the attribute
Inputs:
----------------------------------
1. attr_name:<str>: name of the attribute
Returns:
------------------------------------------
1. attr: <obj>: if the attribute exists.
- get_axis(self, ax_id)
- wrapper for __getitem__
Inputs:
--------------------------------
1. ax_id:<integer/str>: Id for the axis to be found
Returns:
----------------------------------
1, gax:<gp_axis_cl>: axis if the ax_id is valid
- get_axis_ids(self, axis_name_lst)
- Find id for given names
Inputs:
----------------------------------------------------------------
1. axis_name_lst:<list, t:str>: the names
Returns:
------------------------------------------
1. axis_id_lst:<list,t:integer>: the index
- get_profile(self, p, field, axis_id_lst)
- extract profile at a given 'horizontal location'
Inputs:
----------------------------------------------------------------
1. p:<array, (nuse,)>: the sub coordiantes of the given points.
2. field:<array, dims>: gridded data
3. axis_id_lst:<integer>: index of the axis, where the axises to be used
Returns:
---------------------------------------------------------------
1. profile:<array, ...>: the profile at the locations
- get_value_at_point(self, p, field)
- calculate value at a given p by interpolating the
gridded data (field) at surrounding grid points
Inputs:
----------------------------------------------------------------
1. p:<array, (nax,)>: the coordiantes of the given point.
2. field:<array, (nx, ny, nz, ...)>:gridded data
Returns:
----------------------------------------------------------------
val:<float>: values at point p
- set_attr(self, attr_name, attr_value)
- set attribute
Inputs:
----------------------------
1. attr_name:<str>: name of the attribute
2. attr_value:<obj>: the value of the attribute
- shape(self)
- Return the shape of the grid
- size(self, ax_id=None)
- Return size along one direction or total size of the grid
Inputs:
--------------------------------
1. ax_id:<integer/str>: Id for the axis to be found
Returns:
1. nsize:<integer>: the size of axis if axis_id is provided, or the total size if no ax_id is specified.
- update_axis(self, gp_axis)
- add or replace axis
Inputs:
--------------------------------------------------
1. gp_axis:<gp_axis_cl>: class to be added or replaced
Output:
-------------------------------------------------
2. gax:<gp_axis>: axis if the Id is correct
| |