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

Class for GEOS-Chem profiles 
 
Authors: L. Feng, Edinburgh University
History: v0.5, 2012.06.28
History: v0.95, 2012.10.28
 
Classes:
--------------------------------------------
1. enr_slice_cl:  class derived from ctm_slice_cl to read and store GEOS-Chem ensemble run outputs

 
Modules
       
ESA.atmosphere.ctm_field_m
ESA.atmosphere.ctm_grid_3d
ESA.atmosphere.ctm_profile_m
ESA.atmosphere.gc_grid_3d
ESA.util.message_m
numpy
ESA.util.otool_gcfile_io
ESA.util.otool_obj
ESA.util.pres_m
ESA.atmosphere.ctm_slice_m
ESA.util.gc_ts_file_m
ESA.util.vertical_interp_m

 
Classes
       
ESA.atmosphere.ctm_slice_m.ctm_slice_cl
enr_slice_cl

 
class enr_slice_cl(ESA.atmosphere.ctm_slice_m.ctm_slice_cl)
    class derived from ctm_slice_cl to read and store ensemble run outputs
 
Members (overridden or new) 
--------------------------------------------------------
 
 
 1.  fdesc: <gcfdesc_cl>: file access
 2.  fopen: <func>:  open file to read
 3.  fread:<func>: function to read data to fdesc and self.data_lst
 4.  fget:<func>: function to get selected profile 
 5.  fpres:<func>: function to calculate or fetch model pressure
 6.  flnm:<str>: file name (template) for GEOS-Chem outputs
 7.  datapath:<str>: path for GEOS-Chem outputs
 8.  fdiaginfo:<str>: file name (template) for diaginfo file
 9.  ftracerinfo:<str>:file name (template) for tracerinfo file
 10. yyyy:<int>: year
 11  mm:<int>: monthq
 12. dd:<int>: day
 
 
    
 
Functions (new or overridden)
---------------------------------------
 
1. __init__: initialization
2. load_mod_output:read GEOS-Chem outputs from ensemble run into self.data_lst
3. get_sel_profile: select data according to name, id, and time
4. compute_mod_pres: calculate model pressures from surface pressure 
   or model pressure read in from disk file 
5. set_mod_pres: set pressure grid from given pressure or data read in from disk file
 
  Methods defined here:
__init__(self, datapath, filename, ftracerinfo, fdiaginfo, name, fopen=<function open_enr_file>, fread=<function setup_enr_daily_profile>, fget=<function get_mod_gp>, fpres=<function get_mod_pres>, **keywords)
Initialize 
 
Inputs:
--------------------------------
 
1. datapath:<str>: path 
2. flnm:<str>: file name
3, ftracerinfo:<str>: name for tracerinfo file
4. fdiaginfo:<str>: name for diaginfo file
5. geos_ver:<int>:geos-chem version (4 or 5)
6. use_reduced:<int>: 1 if reduced vertical grid is used
 
7. fopen: <func>:  open file to read
8. fread:<func>: function to read data to fdesc and self.data_lst
9. fget:<funct>: function to get selected profile 
10. keywords: <dict>: dictionary for attributes
compute_mod_pres(self, **keywords)
calculate or fetch model pressure
 
Inputs:
--------------------------------------------
get_sel_profile(self, name, sel_id, time, **keywords)
select data according to name, id, and time
 
Inputs:
 
======================================================
1.name:<str>: name of the profile
2.sel_id:<int>: index for selected profile (see Notes). 
3.time:<array>: time (not used for GEOS-Chem outputs)
4.keywords:<dict>: extra inputs
 
Returns:
======================================================
1. out_lst:<list/array>: select data set (Note 1)
 
Notes:
===================================================
1. When sel_id is set, out_lst could be:
---if cprof.data is in shape of [nobs, nlvl, ntracer (nem)], out_lst=cprof.data[:,:, sel_id].
---if cprof.data is given as [nobs, nlvl],  out_lst is cprof.data when
load_mod_output(self, yyyy, mm, dd, enr_yst_lst, enr_dst_lst, enr_step_lst, enr_em_st_lst, enr_em_end_lst, olon=None, olat=None, gpname_lst=['PSURF', 'CO2'], append_data=False, **keywords)
read outputs from ensemble run into self.data_lst
 
Input:
============================================================
1. yyyy, mm, dd:<int>: year month day 
2. enr_yyyy_lst:<int>: year for ensemble run start.
3. enr_doy_lst:<int>:  doy for ensemble run start.
4. enr_step_lst:<int>: step for ensemble run.
5. enr_em_st_st:<int>: firt one in the ensemble. 
6. enr_em_end_lst:<int>: last one in the ensemble.
7. olon:<array>: longitude
8. olat:<array>:latitude 
9. spname:<str>: tracer name for surface pressure outputs
10.spcategory:<str>: tracer category for surface pressure outputs
11. gpname_lst:<list, t:str>: name of tracers to be read in 
12. append_data:<T/F>: if True, read data will be appended to list end
 
13. keywords:<dict>: extra inputs:
---reserved keywords:
--->1. categorys: <list, t:str>: category for variables to be read 
--->2. tracers:<list, t:int>: list for tracer ID 
--->3. taus: <list, t:float>: list for starting time 
 
 
 
Returns:
==========================================================
 
 
Notes:
----------------------------------------
1. if olon and olat are not given, self.lon, and self.lat will be used 
--- if olon and olat are given, self.lon, and self.lat will be replaced
set_mod_pres(self, mod_pres=None, is_in_log=False, do_reverse=True, **keywords)
set up pressure grid 
Inputs:
---------------------------------------------
1. mod_pres:<array>: model pressure
2. is_in_log:<T/F>: True if model pressure if given as log 
3. do_reverse:<T/F>: True if model pressure is in descending order

Methods inherited from ESA.atmosphere.ctm_slice_m.ctm_slice_cl:
__delitem__(self, index)
del item given at index
Inputs: 
1. index: <integer/string>: index or name of the data to be deleted 
 
Returns:
 
1. ndel:<integer>: number of the data have been deleted
__getitem__(self, index)
retrieve data given at index
Inputs: 
1. index: <integer/string>: index or name of the data to be retrieve 
        
Returns:
 
1.data_lst:<list, t:ctm_profile_cl>: list of profiles with index and name
add_attr(self, name, val)
add or replace attributes
Inputs
---------------------------------
1. name:<str>: attribute name
2. val: <obj>: value of the attribute
add_data(self, data)
Add data (ctm_field_cl) into the class 
Inputs:
------------------------------
1. data:<ctm_field_cl>: class for ctm data
find_profile_cl(self, **keywords)
find the data meeting the requirements 
 
Inputs:
----------------------------------------
 
1. keywords:<dict>: list of criteria 
 
Returns:
------------------------------------------
1. found_data:<list, t:ctm_field_cl>: datasets meeting the criteria
get_attr(self, name)
check attribute
Inputs:
---------------------------------------------
1. name:<str>: attribute name
 
Returns:
----------------------------------------------
1. val:<obj>: value of the attribute
get_lat(self)
get lat
Returns:
----------------------------------------------------------------------------------
1. lat:<array, (nob,)>: latitude
get_lon(self)
get lon
Returns:
1. lon:<array, (nob,)>: longitude
get_pressure(self)
get pressure
Returns:
-------------------------------------------------------------------------------------------------
1. pressure:<array, (nob, nz)>: longitude
init_veritcal_interp(self, opres, is_in_log, do_ob_reverse)
initialize vertical interpolation
 
Inputs
----------------------------------------------------------------------------------------------------
1. opres:<array, (nlon, ob_nz)>: ob pressure grid to be projected. 
2. is_in_log:<T/F>: optional. Ture if opres is given in log10 space
3. do_ob_reverse:<T/F>: optional. True of opres is given at descending order
is_data_in_list(self, data, keys)
check whether a data is already in the self.data_lst 
 
 
Inputs:
-----------------------------------------------------------------------------
1. data:<ctm_profile_cl>: profile fileds
2. keys:<list, t:string>: a list of key should be checked. 
 
Returns:
----------------------------------------------------------------------------------------
1. is_found:<integer>: if a data set with the same attributes of data input  
is found in the list, its index will be given; 
Otherwise, oob.fill_val_int will be given
set_lat(self, olat)
set_lon(self, olon)
set_pressure(self, pressure, is_in_log, do_reverse, mask_val)
define the grid pressure level
 
Inputs: 
1.pressure:<array, (nob,nz)>: pressure at each level
2. is_in_log:<T/F>: True when pressure is given in log10
3. do_reverse:<T/F>: True when pressure is given at decending order