ESA.surface.divide_region
index
/home/lfeng/otool/ESA/surface/divide_region.py

Functions to divide the regions into smaller areas 
 
    Authors: L. Feng, Edinburgh University
    History: v0.9, 2012.06.28
    History: v0.95, 2013.01.12
    
    
 
    Functions:
    ==============================================================
    1. divide_region_to_subregion: divide invidual region to sub-regions
    2. divide_region_to_box: divide invidual region to boxes of given sizes.
    3. divide_map: divide selected regions into required sub-region or boxes. 
    
    Classes:
    ==============================================================
    1. reg_op_cl:class for defining actions  to split regions.

 
Modules
       
ESA.util.flux_regrid
ESA.util.geo_constant
ESA.util.gen_plots
ESA.atmosphere.ctm_grid_2d
ESA.util.message_m
ESA.util.otool_ncfile_io
numpy
ESA.util.otool_obj
ESA.util.otool_var_io
pylab

 
Classes
       
reg_op_cl

 
class reg_op_cl
    class for paramter and action to split one region 
 
Members:
------------------------------------------------------
1. reg_id:<int>: region ID for parent region
2. nx: <int>: 
---If split_op=divide_region_to_subregion, nx is sub-region number 
---along longitude.
---If split_op=divide_region_to_box, nx is 
---the number of cells along longitude for each box. 
 
3. ny:<int>:
---If split_op=divide_region_to_subregion, ny is sub-region number 
---along latitude.
---If split_op=divide_region_to_box, ny is 
---the number of cells along latitude for each box. 
 
4. split_op:<func>: actions to split the region
 
 
Functions:
-----------------------------------------
1. __init__: initialization
2. do_split:  split regions as required
 
  Methods defined here:
__init__(self, reg_id, nx, ny, split_op)
Initialization 
 
Inputs:
---------------------------------------
1. reg_id:<int>: region ID for parent region
2. nx: <int>: 
---If split_op=divide_region_to_subregion, nx is sub-region number 
---along longitude.
---If split_op=divide_region_to_box, nx is 
---the number of cells along longitude for each box. 
 
3. ny:<int>:
---If split_op=divide_region_to_subregion, ny is sub-region number 
---along latitude.
---If split_op=divide_region_to_box, ny is 
---the number of cells along latitude for each box. 
4. split_op:<func>: actions to split the region
do_split(self, inmap, lon, lat, **keywords)
split region into sub-regions or boxes
 
Inputs:
----------------------------------------------------
1. inmap:<array, (nlon, lat)>: region map 
2. lon:<array, (nlon)>: longitude 
3. lat:<array, (nlat)>: latitude 
4. keywords:<dict>: dictionary for extra inputs
---reserved keywords
---nx:<int>: replacement for self.nx
---ny:<int>: replacement for self.ny
 
 
Returns:
-------------------------------------------------
1. combine_map:<array, (nlon, nlat)>: map for sub-regions 
2. map_lst:<list, t:array>: layer map for sub-regions
 
 
Notes:
------------------------------------------------------
1. combine_map masks sub-regions from 1 to its total

 
Functions
       
divide_map(type_map, lon, lat, reg_op_lst)
divide regional map into more sub-regions. 
 
Inputs:
-------------------------------------------------------
1. type_map_in:<array, (nlon, nlat)>: the map defining the regions 
2. lon:<array, (nlon,)>: longitude 
3. lat:<array, (nlat,)>: latitude
4. reg_op_lst:<list, t:reg_op_cl>: list for class reg_op_cl on 
---how to divide each regions
 
 
Returns:
---------------------------------------------------------
1. new_map:<array, (nlon, nlat)>: map for more regions
2. pid_lst:<list, t:int>: list  for parent ids of the sub regions
divide_region_to_box(type_map_in, lon, lat, nx_box, ny_box, reg_id)
divide a region into sub-regions defined by (nsb_lon, nsb_lat)
 
Inputs:
--------------------------------------
1. type_map_in:<array, (nlon, nlat)>: ratio  map defining one region. 
 
2. lon:<array, (nlon,)>: longitude 
3. lat:<array, (nlat,)>: latitude
4. nx_box:<integer>: number of longitude grids for one box.   
5. ny_box:<integer>: number of longitude grids for one box.
6. reg_id:<integer>: region id
 
Returns:
--------------------------------------------
1. combine_map:<array, (nlon, nlat)>: new regions masked with sub-region number 
2. new_map_lst:<list, t:array>: the layer map with each layer for each sub-regions
divide_region_to_subregion(type_map_in, lon, lat, nsb_lon, nsb_lat, reg_id)
divide a region into sub-regions defined by (nsb_lon, nsb_lat)
 
Inputs:
--------------------------------------
1. type_map_in:<array, (nlon, nlat)>: the map defining the regions 
2. lon:<array, (nlon,)>: longitude 
3. lat:<array, (nlat,)>: latitude
4. nsb_lon:<integer>: number of sub regions along lon 
5. nsb_lat:<integer>: number of sub regions along lat 
6. reg_id:<integer>: region id
 
Returns:
--------------------------------------------
1. combine_map:<array, (nlon, nlat)>: new 
---regions masked with sub-region number 
2. new_map_lst:<list, t:array>: the layer map 
---with each layer for each sub-regions
 
 
Notes:
-----------------------------------
1.Algorithm for dividing regions 
---> separate regions into (nsub_lat) latitude bands according to 'area'
---> divede each latitude band into (nsub_lon) longitude blocks according to 'area'
 
2. combine_map masks sub-regions from 1 to its total