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

Generic class for coordiante axis
 
    Authors: L. Feng, Edinburgh University
    History: v0.9, 2012.06.28
    History: v0.95, 2012.09.12
    
    this module define axis classes
    
    Classes:
    ======================================================================
    1. gp_axis_cl: class for generic axis

 
Modules
       
ESA.util.interpolate_f
ESA.util.message_m
numpy
ESA.util.otool_obj

 
Classes
       
gp_axis_cl

 
class gp_axis_cl
    class axis 
 
A. Members:
------------------------------------------
1. ax_name:<str>: Name of the axis
2. ax_grid:<array>: centers of grid boxes. 
3. ax_edge:<array>: edges of the grid boxes
4. unit:<str>: units of the axis
5. ax_min, ax_max:<numeric>: ranges of axis
6. attr_dict:<dictionary>: attributes of the axis
7. ax_np:<int>: number of the points
 
B. Functions:
-------------------------------------------
1.  __init__: initialize the class
2.  __getitem__:get values at given index
3.  set_attr:  assign one attribute to axis
4.  get_attr:  get one attribute for axis
5.  set_axis: set/reset axis intervals
6.  get_axis: get axis intervals
7.  set_unit: set axis units 
8.  get_unit: get axis units
9.  set_edge: set axis edge
10. get_edge: get axis edges
11. getpos:get left/right boundaries for given value(s) 
12. getwgt:get boundaries and weighting factors for given value(s) 
13. get_closest_point: find the closest grid point for an array or a point
 
  Methods defined here:
__getitem__(self, idx)
override [],  etc called as axis[id]
 
Inputs:
--------------------------------------------------------------
1. idx:<int/array>: index(es)
 
Returns:
-------------------------------------------------------------
1. vals:<numeric/array>: val(s) for the given index(es)
__init__(self, ax_name, ax_grid=None, ax_edge=None, unit=None, **keywords)
initilialization 
 
Inputs:
--------------------------------------------------------
1. ax_name:<str>: String of the axis
2. ax_grid:<array, (ax_np,)>: Centers of the (ax_np) grid boxes, 
--- assumed to be in ascending order.
3. ax_edge:<array, (ax_np+1,)>: edges of the grid box. 
4. unit: <str>: unit of the grid values
5. keywords:<dict>: attributes
 
Returns:
----------------------------------------------
copy(self)
make a copy of itself without shared instance
copy_attr_dict(self)
get one copy of the attr_dict
get_attr(self, attr_name)
get one attribute for axis
Inputs:
------------------------------------------------
    1. name:<str>: attribute name
 
Returns:
-----------------------------------------------
    1. val: <obj>: attribute value
get_axis(self)
retrieve axis grid 
 
Returns:
--------------------------------------------
1. ax_grid:<array>:axis intervals
get_closest_point(self, xval, mask_val, mask_outsider=False)
get the closet point to given vals
 
Inputs:
----------------------------
 
1. xval:<array, (nx,)>: values to be allocated
2. masl_val:<float/int>: filling for bad or missing values
3. mask_outsider:<T/F>: if True, All the outsider will be filled with mask_val. 
 
Returns:
----------------------------------
1. pt:<array, (nx,)>: the closest grid point
get_edge(self)
get edges of grid boxes
get_unit(self)
get axis unit 
 
Returns:
--------------------------------------
1. unit:<str>:unit
getpos(self, val, mask_val=-999.0, mask_outsider=False)
get left-right node pairs (ie., boundaries) for given value(s) 
 
Inputs: 
----------------------------------------
1. val:<array, nval>: values to be allocated. 
2. mask_outsider:<T/F>: 
if switched on, locations for values outside the axis range will 
be filled with oob.fill_val_int. Otherwise:
---if (val>ax_max): the left-right node pairs are set to the right-most
---if (val<ax_min): the left-right node pairs is set to the left-most
 
Returns:
---------------------------------------
1. lp, rp:<array, (nval,)>: the left and right axis nodes (i.e., boundaries)
around the given value(s)
getwgt(self, val, mask_val=-999.0, mask_outsider=False)
get boundaries and weighting factors for given value(s) 
 
Inputs: 
----------------------------------------
1. val:<array, (nval,)>: values to be allocated. 
2. mask_outsider:<T/F>: 
if switched on, locations for values outside the axis range will 
be filled with mask value. Otherwise:
---if (val>ax_max): the left-right pairs  are set to the right-most
---if (val<ax_min): the left-right pairs is set to the left-most
 
Returns:
---------------------------------------
1. lp, rp:<array, (nval,)>: the left and right axis nodes (i.e., boundaries)
around the given value(s)
 
2. wgt:<array, (nval)>: the weighting factors for the left boundary, being calculated by
wgt=(val-ax_grid[lp])/(ax_grid[rp]-ax_grid[lp]
interpolate(self, f, x, mask_val=-999.0, mask_outsider=False)
interpolate f(x0) given at axis nodes to f(x) 
 
Inputs: 
----------------------------------------
1. f:<array, (ax_np, ...,) >: values at aixs nodes
2. x:<array, nval>: values to be allocated. 
3. mask_val:<float>: filling value for bad or missing values
4. mask_outsider:<T/F>: 
 
if switched on, locations for values outside the axis range will 
---be filled with mask value. Otherwise:
---if (val>ax_max): the left-right node pairs  are set to the right-most
---if (val<ax_min): the left-right node pairs is set to the left-most
 
Returns:
---------------------------------------
1. new_f:<array, (nx, ...,):values at x
set_attr(self, attr_name, value)
assign one attribute to axis
 
Inputs:
-------------------------------------------------------
1. attr_name: <str>: attribute name
2. value: <obj>:attribute value
set_axis(self, ax_grid)
set/reset axis grid 
 
Inputs:
-----------------------------------------------
1. ax_grid:<array>:axis intervals
set_edge(self, vfirst=None, vlast=None)
set edges of grid boxes 
 
Inputs: 
----------------------------------------
1. vfirst: <float>: if given, it will be used to replace ax_edge[0]
2. vlast:  <float>: if given, it will be used to replace ax_edge[self.ax_np]
 
Returns:
----------------------------------------
1. self.ax_edge, <array, (ax_np+1,)>: edges of the grid boxes
set_unit(self, unit)
set axis unit 
 
Inputs:
---------------------------------------
1. unit:<str>:unit
shape(self)
get the shape of the axis)
size(self)
get the size of the axis)