ESA.util.horizontal_interp_m
index
/home/lfeng/otool/ESA/util/horizontal_interp_m.py

Class for horizontal (lon-lat) interpolations of model fields
 
 
Authors: L. Feng, Edinburgh University
History: v0.9, 2012.06.30
History: v0.95, 2012.09.30
 
 
 
1. Functions:
===============================================
1. is_the_same_array: whether two arrays are identical.
 
 
2. Classes:
==============================================
1. hinterp_cl: class for horizontal interpolation

 
Modules
       
ESA.util.gp_axis_m
ESA.util.sample_model_field
ESA.util.message_m
numpy
ESA.util.otool_obj

 
Classes
       
hinterp_cl

 
class hinterp_cl
    horizontal interpolation class
 
Members:
----------------------------------------
1.  ax_lon:<gp_axis>:longitude axis
2.  ax_lat:<gp_axis>:latitude axis
3.  dims:<tuple>: shape of [ax_lon, ax_lat]
4.  lon:<array>: x value
5.  lat:<array>: y value
6.  nlon:<integer>: number of longitude
7.  nlat:<integer>: number of latitude
8.  mask_val:<float>: filling value for missing or bad data
9. attr_dict:<dict>: attribute dictionary
 
 
# ob (target) grid 
 
10.  olon:<array>:  longitudes to be interploated to
11.  olat:<array>: latitudes to be interploated to
12.  ob_only_1d:<T/F>: if true, olon and olat are along observation tracks,  
---otherwise olon and olat form another (target) grid 
 
# variables for saving interpolation coefficients.
 
13.  lonp1:<array>: longitude index for left corners of the encircling boxes.
14.  lonp2:<array>: longitude index for right corners of the encircling boxes.
15.  latp1:<array>: latitude index for lower corners of the encircling boxes.
16.  latp2:<array>: latitude index for upper corners of the encircling boxes.
17.  lonwgt:<array>: weighting factor for left corner
18.  latwgt:<array>: weighting factor for lower corner
 
19  w1, w2, w3, w4:<array> aggregated weighting factor for the 4 corners. 
20. is_ready: <T/F>: True if interpolation has been initilzed. 
 
Functions:
--------------------------------------------------------
1.  __init__: initialization
2. set_attr: set attribute
3. get_attr: get_attribute
4. set_mask: set mask values
 
5. init_interp: set parameters for interoplation 
6. get_profile: get the profiles at given locations (or regridding field when  ob_only_1d=False
7. get_wgt: Interpolation weight along lon or lat
 
  Methods defined here:
__init__(self, ax_lon, ax_lat, mask_val=-999.0)
initialize horizontal interpolation class 
Inputs:
 
1. ax_lon:<gp_axis>: longitude axis 
2. ax_lat:<gp_axis>: latitude  axis 
3. mask_val: <float>: filling value for missing or bad data
get_attr(self, name)
check attribute
Inputs:
---------------------------------------------
1. name:<str>: attribute name
 
Returns:
----------------------------------------------
1. val:<obj>: value of the attribute
get_profile(self, gp_fld)
Get profiles at the given horizontal locations
Inputs:
------------------------------
1. gp_fld:<array, (nlon, nlat, nl, ...>: 2D (or more)  gridded data. 
 
Outputs:
1. prof:<array, (ob_nlon, nl, ...): if ob_only_1d is true. or
--- prof:<array, (ob_nlon, ob_nlat, ...): if ob_only_1d is False
get_wgt(self, xval, ax_id=0)
get interpolation weight
A wrap for getwgt for each axis
 
Inputs:
-----------------------------------------------------
1.xval:<array, (nob,)>: values 
2. ax_id:<integer/string>: axid =0 or 1 or ax_id='lon', 'lat'
 
 
Returns:
-----------------------------------------------------
1. pl:<array, (nob,)>: left boundaries
2. pr:<array, (nob,)>: right boundaries
3. wgt:<array, (nob,)>: weighting factor for left boundaries
init_interp(self, olon, olat, ob_only_1d=True)
initialize interpolation coefficients 
 
Inputs:
--------------------------------------------------
1. olon:<array>: longitudes to be projected to 
2. olat:<array>: latitudes to be projected to 
3. ob_only_1d:<T/F>: True if points are along tracks
set_attr(self, name, val)
add or replace attributes
 
Inputs
---------------------------------
1. name:<str>: attribute name
2. val: <obj>: value of the attribute
set_mask(self, mask)
set values for data mask 
 
Inputs:
------------------------------------------
1. mask:<float>: new mask values

 
Functions
       
is_the_same_array(a, b)
check whether two arrays are identical. 
Inputs:
1. a: <array>: array of a
2. b: <array>: array of b
Outputs: 
1. is_same:<T/F>: True if a==b