ESA.atmosphere.gc_grid_2d
index
/home/lfeng/otool/ESA/atmosphere/gc_grid_2d.py

Class for (lon, lat) grid used by GEOS-Chem CTM.  
 
Authors: L. Feng, Edinburgh University
History: v0.9, 2012.06.30
History: v0.95, 2012.09.30
 
Classes:
-----------------------------------------------------
1.  gc_grid_2d: derived class for 2D model grid.

 
Modules
       
ESA.atmosphere.compute_gc_grid
ESA.atmosphere.ctm_grid_2d
ESA.util.message_m
numpy
ESA.util.otool_obj
ESA.util.pres_m

 
Classes
       
ESA.atmosphere.ctm_grid_2d.ctm_grid_2d(ESA.util.gp_grid_m.gp_grid_cl)
gc_grid_2d

 
class gc_grid_2d(ESA.atmosphere.ctm_grid_2d.ctm_grid_2d)
    derived class for 2D model grid 
 
Members (overrided and newly added):
---------------------------------------
# window definitition
 
1. ix: longitude  size 
2. jx: latitude size  
4. ifirst: longitude shift 
5. jfirst: latitude shift 
6. halfpolar: polar configuration/ 
7. centre180: =1, if longitudes are represented in (0 to 360) degrees. 
 
#   global H-grid (important for nested model)
 
8.  glb_ix: global x size
9. glb_jx: global y size
10. glb_lon: global longitude centers
11. glb_lat: global latitude  centers
12. glb_lon_edge:  global longitude edges 
13. glb_lat_edge:  global latitude edges 
 
 
# global V-vertical 
 
14. is_nested: whether it is nested 
 
15. lonres: longitude resolutions
16. latres: latitude resolutions 
 
17. geos_ver: geos-chem version 
 
 
# initialization control
18. resize_use_mod_res
 
 
 
 
 
Functions: (new or overridden functions)
 
---------------------------------------------------------------------
    
1. __init__: initialize the class
2. get_lon: return longitude grid 
3. set_lon: set longitude grid 
4. get_lat: return latitude grid 
5. set_lat: set longitude grid 
 
 
# edges 
6. set_lon_edge: set longitude edge
7. set_lat_edge: set latitude edge
8. compute_lat_edge: compute_lat_edge
9. compute_lon_edge: compute_lon_edge 
10. get_area: calculate areas of grid boxes 
 
# global grid 
11.get_glb_lon: return global longitude grid 
12.get_glb_lon_edge: return global longitude grid at box edges
 
13.get_glb_lat: return global latitude grid 
14.get_glb_lat_egde: return global latitude grid 
 
 
 
 
Attributes (Added for resevered keywords):
-------------------------------------------------------------
 
 
Method resolution order:
gc_grid_2d
ESA.atmosphere.ctm_grid_2d.ctm_grid_2d
ESA.util.gp_grid_m.gp_grid_cl

Methods defined here:
__init__(self, ix, jx, ifirst=1, jfirst=1, halfpolar=0, centre180=0, lonres=None, latres=None, is_nested=0, use_reduced=1, geos_ver=5, mod_res=None, resize_use_mod_res=True, mask_val=-999.0, **keywords)
Initialize the class 
Input:
----------------------------------
1. ix, jx, lx:<nteger> : the sizes of lon, lat, z 
2. ifirst, jfirst, lfirst:<integer> the start point for the data to store. 
3. halfpolar, centre180:<integer>: 0 or 1 for the type of lon 
4. lonres, latres:  <float>: the resolution of the lat and lon
compute_lat_edge(self)
Returns:
-----------------------------------------
1. lats:<array, (jx+1,)>: longitude at grid edges
compute_lon_edge(self)
Returns:
1. lons:<array, (ix+1,)>: longitude at grid edges
copy(self)
Make a copy of itself
 
Returns:
---------------------------------------------------
1. new_grid:<ctm_grid_cl>: new grid
get_area(self)
calculate area for grid box
Returns:
1. area:<array, (nx, ny)>: areas for grid boxes in m^2
get_glb_lat(self)
get global latitude grid
Returns
-----------------------------------------
 
1. glb_lat:<array, (glb_jx)>: global latitudes
get_glb_lat_edge(self)
get global latitude grid
 
Returns
-----------------------------------------
1. glb_lat_edge:<array, (glb_jx+1)>: global latitudes
get_glb_lon(self)
get global longitude grid
Returns
-----------------------------------------
 
1. glb_lon:<array, (glb_ix)>: global longitudes
get_glb_lon_edge(self)
get global longitude grid
Returns
-----------------------------------------
 
1. glb_lon_edge:<array, (glb_ix+1)>: global longitudes
get_lat_edge(self)
Returns:
------------------------------------------
1. lats:<array, (jx+1,)>: longitude at grid edges
get_lon_edge(self)
Returns:
----------------------------------------
1. lons:<array, (ix+1,)>: longitude at grid edges
init_lat(self, jx=None, jfirst=None, latres=None, is_nested=None, resize_use_mod_res=True)
initialize latitude grid 
Inputs:
-------------------------------------
1. jx:<integer>: size of longitude
2. jfirst:<integer>: poistion of first longitude in global grid
3. latres:<float>: longitude resolution
4. is_nested:<integer>: 0==not nested grid 
5. resize_use_mod_res:<T/F>: if Ture, jx will be calculated from latres when it is not 
provided.
 
 
Returns:
-------------------------------------
lats:<array, (ix,)>: longitudes
init_lon(self, ix=None, ifirst=None, lonres=None, centre180=None, is_nested=None, resize_use_mod_res=True)
initialize longitude grid 
 
Inputs:
-------------------------------------
1. ix:<integer>: size of longitude
2. ifirst:<integer>: poistion of first longitude in global grid
3. lonres:<float>L: longitude resolution
4. centre180:<integer>: 0==centerred around 0
5. is_nested:<integer>: 0==not using nested grid 
6. resize_use_mod_res:<T/F>: True, ix will be calculated from lonres, if it is not 
provided. 
 
 
Returns:
------------------------------------------
1. lons:<array, (ix,)>: longitudes
 
-------------------------------------
set_lat(self, jx=None, jfirst=None, latres=None, is_nested=None)
set latitude  grid (over-riding function 
 
Inputs:
-------------------------------------
1. jx:<integer>: size of latitude
2. jfirst:<integer>: poistion of first latitude in global grid
3. latres:<float>: latitude resolution
 
 
Returns:
-----------------------------------------
1. lats:<array, (ix,)>: longitudes
------------------------------------
set_lon(self, ix=None, ifirst=None, lonres=None, centre180=None, is_nested=None)
Re-set longitude  grid (over-riding function)
 
Inputs:
-------------------------------------
1. ix:<integer>: size of longitude
2. ifirst:<integer>: poistion of first longitude in global grid
3. lonres:<float>L: longitude resolution
4. centre180:<integer>: 0==centerred around 0
5. is_nested:<integer>: 0==not using nested grid 
 
 
Returns:
--------------------------------------
1. lons:<array, (ix,)>: longitudes
 
-------------------------------------

Methods inherited from ESA.atmosphere.ctm_grid_2d.ctm_grid_2d:
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: 
------------------------------------
1. hintpl:<interp_cl>: interpolation matrix along the track
get_lat(self)
retrieve latitude grid 
 
Returns: 
-------------------------------------
1. self.lat:<array, (nlat)>: latitudes
get_lon(self)
retrieve longitude grid 
 
Returns: 
-------------------------------------
1. self.lon:<array, (nlon)>: longitudes
get_regrid_mtx(self, newlon, newlat)
construct interpolation classes for regridding fields to a new (lon, lat) grid
 
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
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_edge(self, lon_edge)
save longitude box edges to the dictionary
set_mask(self, mask)
set filling value for missing or bad data
 
Inputs:
-----------------------------------------
1. mask:<float>: mask for missing or bad data

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