# Path: parse_fname_trmm.py
# def parse_fname_trmm(fName, ATTR):
#     '''
#     fName   : TRMM HDF filename
#     ATTR    : list of attributes (i.e., 'sDTime' and/or 'eDTime')
#     '''
# 
#     sDTime  = datetime.strptime( re.findall(r'\d{8}', fName)[0], '%Y%m%d' )
# 
#     offset  = timedelta( seconds=86400 )
# 
#     dictFunc= {'sDTime': sDTime,
#                'eDTime': sDTime+offset,
#                }
# 
#     return [dictFunc[attr] for attr in ATTR]
# 
# Path: parse_fname_gpm.py
# def parse_fname_gpm(fName, ATTR):
#     '''
#     fName   : GPM HDF path
#     ATTR    : list of attributes (i.e., 'sDTime' and/or 'eDTime')
#     '''
# 
#     fName   = fName.split('_')
# 
#     dictFunc= {'sDTime': datetime.strptime(fName[2], '%y%m%d%H%M'),
#                'eDTime': datetime.strptime(fName[2][:6]+fName[3], '%y%m%d%H%M')
#                }
# 
#     if dictFunc['eDTime'] < dictFunc['sDTime']:
#         dictFunc['eDTime'] += timedelta( days=1 )
# 
#     return [dictFunc[attr] for attr in ATTR]


import  os,sys
from    optparse        import OptionParser
from    parse_fname_trmm    import parse_fname_trmm
from    parse_fname_gpm     import parse_fname_gpm
#! /usr/bin/python
#--------------------------------------------------------------------
# PROGRAM    : get_path.py
# CREATED BY : hjkim @IIS.2015-07-13 13:02:05.942756
# MODIFED BY :
#
# USAGE      : $ ./get_path.py
#
# DESCRIPTION:
#------------------------------------------------------cf0.2@20120401





def get_path(srcDir, sDTime, eDTime):
    '''
    select GPM(hdf5) and TRMM(hdf4) files and return their paths)
    '''

    prjName, prdLv, prdVer  = srcDir.split(os.path.sep)[-3:]

    parse_fname     = {'TRMM': parse_fname_trmm,

# Path: parse_fname_trmm.py
# def parse_fname_trmm(fName, ATTR):
#     '''
#     fName   : TRMM HDF filename
#     ATTR    : list of attributes (i.e., 'sDTime' and/or 'eDTime')
#     '''
# 
#     sDTime  = datetime.strptime( re.findall(r'\d{8}', fName)[0], '%Y%m%d' )
# 
#     offset  = timedelta( seconds=86400 )
# 
#     dictFunc= {'sDTime': sDTime,
#                'eDTime': sDTime+offset,
#                }
# 
#     return [dictFunc[attr] for attr in ATTR]
# 
# Path: parse_fname_gpm.py
# def parse_fname_gpm(fName, ATTR):
#     '''
#     fName   : GPM HDF path
#     ATTR    : list of attributes (i.e., 'sDTime' and/or 'eDTime')
#     '''
# 
#     fName   = fName.split('_')
# 
#     dictFunc= {'sDTime': datetime.strptime(fName[2], '%y%m%d%H%M'),
#                'eDTime': datetime.strptime(fName[2][:6]+fName[3], '%y%m%d%H%M')
#                }
# 
#     if dictFunc['eDTime'] < dictFunc['sDTime']:
#         dictFunc['eDTime'] += timedelta( days=1 )
# 
#     return [dictFunc[attr] for attr in ATTR]


# Path: get_path.py
import  os,sys
from    optparse        import OptionParser
from    parse_fname_trmm    import parse_fname_trmm
from    parse_fname_gpm     import parse_fname_gpm

#! /usr/bin/python
#--------------------------------------------------------------------
# PROGRAM    : get_path.py
# CREATED BY : hjkim @IIS.2015-07-13 13:02:05.942756
# MODIFED BY :
#
# USAGE      : $ ./get_path.py
#
# DESCRIPTION:
#------------------------------------------------------cf0.2@20120401





def get_path(srcDir, sDTime, eDTime):
    '''
    select GPM(hdf5) and TRMM(hdf4) files and return their paths)
    '''

    prjName, prdLv, prdVer  = srcDir.split(os.path.sep)[-3:]

    parse_fname     = {'TRMM': parse_fname_trmm,

                       'GPM' : parse_fname_gpm}[ prjName.split('.')[0] ]