ESA.enkf.read_em_cfg
index
/home/lfeng/otool/ESA/enkf/read_em_cfg.py

Functions for reading  configuration of emission ensemble   
 
Functions
=================================================
 
1. open_ens_cfg_file: set up class file_desc_cl for file access
2. read_ens_cfg_file: read ens_cfg   data into class file_desc_cl
3. close_ens_cfg_file: delete class file_desc_cl
4. get_data: get ens_cfg data at given locations

 
Modules
       
ESA.util.message_m
numpy
ESA.util.otool_descfile_io
ESA.util.otool_obj
ESA.util.otool_var_io
ESA.util.time_module

 
Functions
       
add_ems_cfg_data(fdesc, ref, **keywords)
add table for ensemble configurations  to data_lst in fdesc
 
Inputs:
=====================================
1. fdesc:<grdfile_io_cl>: class for file access
2. ref:<str/numeric>: reference for data sets read from file 
3. keywords:<dict>: extra parameters
 
Returns:
=====================================
1. idx:<int>: index of the data set with reference =ref.
close_ens_cfg_file(fdesc)
Close fdesc file 
 
Inputs:
--------------------------------------------------
1. fdesc:<file_desc_cl>: class for file access
 
Returns:
1. None
get_ems_cfg_data(fdesc, oyyyy, omm, odd, **keywords)
read enr_cfg data at given point 
Inputs:
---------------------------------------
1. fdesc:<grdfile_io_cl>: file access 
2. oyyyy:<int>: year
3. omm: <int>: month 
4. odd:<int>: day (for future use)
 
6. keywords:<dict>: extra inputs
---Reserved Entries
 
Returns:
 
================================================
 
1. cur_ems_cfg:<recarray>: data for configuations
get_ems_cfg_file_ref(yyyy, mm, dd, **keywords)
check file reference
 
for emsemble configuration. By default 
the reference number is year 
 
Inputs:
----------------------------------------------------
1. yyyy:<array, (ntime,)>: year
2. mm: <array, (ntime,)>: month
3. dd:<array, (ntime,)>: dd
4. keywords:<dict>: extra information
 
Returns:
------------------------------------------------------
1. ref:<int>: reference number 
--- by default, the reference number is year
open_ems_cfg_file(flnm, datapath, yyyy, mm, dd, **fio_keywords)
construct fdesc to read ensemble  configurations data
 
 
Inputs:
==============================================
1. flnm:<str>: filename (reserved)
2. datapath:<str>: file path
3. yyyy:<array, (ntime,)>: year
4. mm: <array, (ntime,)>: month
5. dd:<array, (ntime,)>: dd
6. fio_keywords:<dict>: extra inputs 
---Reserved keywords:
--->fl_colnm_lst: <list>:  list of all column names in the file 
--->sel_colnm_lst: <list>: list of the names for column to be read
--->colnm_dict:<dict>: dictionary for translating column names
--->delim: <str>: separator. 
--->data_start:<int>: starting line number of the data section 
--->header_start:<int>: line number of header section
 
 
Returns:
=============================================
1. fdesc:<file_desc_cl>: class for file access
read_ems_cfg_file(fdesc, **fio_keywords)
Read ensemble configurations as table into fdesc.data_lst
    
Inputs:
--------------------------------------------------
1. fdesc:<file_desc_cl>: class for file access
2. fio_keywords:<dict>: extra inputs for file read write
---Reserved words:
--->fl_colnm_lst: list of all column names in the file 
--->sel_colnm_lst: list of the names for column to be read
--->colnm_dict:<dict>: dictionary for translating column names
 
Returns:
-------------------------------------
1. ndata:<int>: length of fdesc.dtable 
 
 
Notes:
-------------------------------------
1. data will be stored as recarray by fdesc.dtable
translate_column_names(colnm_lst, **keywords)
translate column names to the names used to access data 
 
Inputs:
-------------------------------
1. colnm_lst:<list, t:str>: list of column names
2. keywords:<dict>: extra inputs:
---reversed keywords:
---colnm_dict:<dict>: column name dictionary
 
Returns:
--------------------
1. new_column_lst: <list, t:str>:New column names:

 
Data
        def_delim = ','
def_ems_data_start = '200'
def_ems_header_start = 0
ems_cfg_colnm_dict = {'co2flnm': 'ems_flnm', 'doy': 'doy', 'npb': 'npb', 'year': 'year'}
ems_cfg_coltype_lst = ['i4', 'i4', 'i4', 'S40']
ems_cfg_column_lst = ['doy', 'year', 'npb', 'co2flnm']
ems_cfg_flnm_format = 'cfg_em_reg_144.XYYYYX'
ems_datapath = '../surface/'