| |
- gp_data_cl
class gp_data_cl |
|
general container for gridded geo-physical variables
Members:
------------------------------------------------------------------------------
1. name: <str>: name of variable
2. category:<str>:category of variable
3. id: <numberic>:id of variable
4. group:<str>: group name of the variable
4. grid:<gp_grid_cl>:grid
5. __attr_dict:<dict>: dictionary for name and ndim
6. data
Functions:
==================================================================
# Interpolation and index
1. gp_interp:interpolation data set to a given location
2. gp_get_prof:get profile at given locations
3. gp_interp_2d: a fast version for interpolate 2-D data set to given locations
4. gp_axis_transform_2d: bilinear interoplation
5. interp_along_axis:get (n-1)-Dimensional fields at locations along one chosen axis.
6. mylice: get indexes to access chosen elements of the data.
7. get_slice:
8. save_to_netcdf:save data to a given netcdf file
9. set_global_attr: set one global attribute
10. get_global_attr: get one global attribute
11. remove_global_attr:remove one global attribute
# disk IO
11. save_gp_to_netcdf: save selected data set to one netcdf
12. load_gp_from_file: virtual function to be overrided |
|
Methods defined here:
- __getitem__(self, idx)
- Inputs:
------------------------------------------------------------------------
1. idx:<tuple>: coordinate
Returns:
-------------------------------------------------------------------------
1. val: <obj>: value of the attribute
- __init__(self, data, name='', axis_set=[], id=0, category='', unit='', data_attr={})
- initialization
Inputs:
----------------------------------------------------------
1. data:<array>: array of the data set
2. axis_set:<list>: list of (gp_)axis for grid
3. name:<str>: name of the data set
3. category:<str>: category of the data set
4. unit:<str>:unit of the data set
5. data_id:<obj>:id of the data set
7. attr:<dict>: dictionary of the attributes
- get_attr(self, attr_name)
- Inputs:
------------------------------------------------------------------------
1. attr_name:<str>: name of attribute to be retrieved.
Returns:
-------------------------------------------------------------------------
1. val: <obj>: value of the attribute
- get_gp(self, xcor, fill_val=None, threshold=0.0)
- Interpolate data to a given location
Inputs:
1.xcor: <array>: coordinates of the location
2. fill_val:<float>:Optional. If data[idx] ==fill_val,
--- the weight of value at the axis point will be equal to zero
3. threshold:<float>: if the total weight for xocs is smaller <threshold, its value
will be set to fill value
Returns:
1. gp: variable value at the given locations
2. wgt: weight information as (lp, rp, wgt) for every axis
- get_prof(self, xpos, xaxis=0)
- interpolate the data to a given locations [xvalx, yvals]
Inputs:
------------------------------------------------------------------
1. xpos: <array>: coordinate of the point. Its size is equal to ndim-1, where ndim is the dimension size of the data set.
2. xaxis:<integer>: id of the axis for the profile to be retrieved
Returns:
------------------------------------------------------------------
1. ref_x:<array>: grid along the chosen x
2. gp_prof:<array>: profiles at the given locations
Notes:
-------------------------------------------------------------------
1. the stored data set is assumed to have a dimension size of
ndim equal to len(xpos)+1
- interp_2d(self, cor_lst)
- Interpolate variable at 2D-grid values to a given locations in a two dimensional grid
Inputs:
1. cor_lst: <list>: coordinate of the set of locations
(i.e., [[P0], [P1],...]
Returns:
1. gpv:<array>: variable values at the locations
2. loc_info:<list>: list of weighs and locations of the corners information :
[[lpx, rpx, wgx,lpy, rpy, wgy], ...]
- myslice(self, pos_xl, idx, pos_xr)
- return a set of index to access elements of n-d array
Inputs:
-------------------------------------------------
1. pos_xl, pos_xr: <tuple>: Tuple of index at the left and right sides of the chosen axis
2. idx:<list>: list of indexs along the the axis
Returns:
-------------------------------------------------
ps: <list>: a list of tuple of the n-d index
- myslice_sgl(self, pos_xl, id, pos_xr)
- Form a myslice to access element of n-dimension array
Inputs:
--------------------------------------------------------------------
1. pos_xl, pos_xr:<tuple>: the tuple of index at the left and right
---side of the chosen axis 2. id: <integer/None>: the location along the chosen axis
Returns:
-----------------------------------------------------
1. sl: <tuple>: the tuple of the n-Dimension index. n=len(pos_xl)+len(pos_xr)+1
If id==None, sl=tuple([pos_xl, :, pos_xr]). If not, sl=tuple([pos_x, id, pos_xr])
- remove_attr(self, attr_name)
- remove attribute
1. Inputs
attr_name:<str>: the name of the attribute to be removed
- save_gp_to_netcdf(self, gpfile)
- dump chosen data to a netcdf file
Inputs:
1. gpfile:<str>:file name
2. gpname:<str>:variable name to be save
Returns:
- set_attr(self, attr_name, val)
- Inputs:
------------------------------------------------------------------------
1. attr_name:<str>: name of attribute to be retrieved.
2. val: <obj>: value of the attribute
- set_grid(self, axis_list)
| |