print("****************************")
    print("* date parameter malformed *")
    print("****************************")
    printUsage()
    exit(1)

_year  = back_date[:4]
_month = back_date[4:6]
_day   = back_date[6:]
_doy   = getDOY(_year, _month, _day)
DOY = str(_doy).zfill(3)


print("Processing date " + back_date + " (DOY = " + DOY + ").")

modisL2_TSMPath  = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL2_TSMBasePath  + _year) + _month) + _day)
modisL3_TSMPath  = ensureTrailingSlash(ensureTrailingSlash(modisL3_TSMBasePath  + _year) + _month)

print(modisL2_TSMPath, modisL3_TSMPath)

for _path in [modisL3_TSMPath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)

try:
    srcList = listdir(modisL2_TSMPath)
except OSError:
    print("Cannot open ", modisL2_TSMPath+ "! Now exiting...")
    exit(1)
else:

argc = len(argv)
if argc < 2:
    printUsage()
    exit(1)

_date  = str(argv[1])
_year  = _date[:4]
_month = _date[4:6]
_day   = _date[6:]
_doy   = getDOY(_year, _month, _day)

print(_year, _month, _day, _doy)

modisL1A_LACPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1A_LACBasePath + _year) + _month) + _day)
modisGEOPath     = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisGEOBasePath + _year) + _month) + _day)

modisL1B_LACPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1B_LACBasePath + _year) + _month) + _day)
modisL1B_HKMPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1B_HKMBasePath + _year) + _month) + _day)
modisL1B_QKMPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1B_QKMBasePath + _year) + _month) + _day)
modisL1B_OBCPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1B_OBCBasePath + _year) + _month) + _day)

for _path in [modisL1B_LACPath, modisL1B_HKMPath, modisL1B_QKMPath, modisL1B_OBCPath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)

srcList = listdir(modisL1A_LACPath)
listSize = len(srcList)
print(listSize)
Example #3
0
__author__ = 'uwe'

from nasa.modis.seadas_processing.shared.utilities import ensureTrailingSlash
from os.path import exists

from beampy import String
from beampy import Product
from beampy import ProductData
from beampy import ProductIO
from beampy import ProductUtils

inputProductsBaseDir = '/FastBuffer/tsm_computation/L3_products/'
year = '2010'
l3_levels = ['1', '7', '15', '31']

inputProductsDirs = []
for level in l3_levels:
    inputProductsDirs.append(
        ensureTrailingSlash(
            ensureTrailingSlash(inputProductsBaseDir + year) + level))

print(inputProductsDirs)

myDOY = '60'

daily_product = inputProductsDirs[0] + 'A' + year + myDOY.zfill(
    3) + '_' + year + myDOY.zfill(3) + '_L3_nsea_2.0km.dim'
print(daily_product, exists(daily_product))
fallback_prods = []

argc = len(argv)
if argc < 2:
    printUsage()
    exit(1)

_date  = str(argv[1])
_year  = _date[:4]
_month = _date[4:6]
_day   = _date[6:]
_doy   = getDOY(_year, _month, _day)

print(_year, _month, _day, _doy)

modisGEOPath     = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisGEOBasePath + _year) + _month) + _day)
modisL1B_LACPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1B_LACBasePath + _year) + _month) + _day)
modisBrowsePath  = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisBrowseBasePath  + _year) + _month) + _day)

for _path in [modisBrowsePath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)

srcList = listdir(modisL1B_LACPath)
listSize = len(srcList)
print(listSize)

if not listSize:
    print("Nothing to do. Now exiting...")
    exit(1)
    exit(1)

try:
    _num_days_in_l3 = int(argv[2])
except TypeError:
    print("num_days parameter must be of type integer!")
    printUsage()
    print("\nError in parameters. Now exiting...\n")
    exit(1)

_beamBinDir = '/Applications/beam-4.10/bin/'
_l3_binning_processor = _beamBinDir + 'binning.command'

_productsBaseInputPath  = '/Volumes/MODIS_PROC5/MODISA/L2_TSM/STD/NorthSea/'
_productsOutputPath     = '/FastBuffer/tsm_computation/L3_products/' \
                          + ensureTrailingSlash(str(_year)) \
                          + ensureTrailingSlash(str(_num_days_in_l3))
if not exists(_productsOutputPath):
    makedirs(_productsOutputPath)
_requestsOutputPath     = _productsOutputPath.replace('L3_products', 'L3_requests')
if not exists(_requestsOutputPath):
    makedirs(_requestsOutputPath)

_productRegExp = '??????.L2_TSM.dim'

_l3_lat_min, _l3_lat_max, _l3_lon_min, _l3_lon_max = 47.0, 64.0, -15.0, 12.0
_l3_binning_db_path = '/Volumes/SpeedDisk/l3_database_' + str(_num_days_in_l3) + 'd.bindb'
_l3_out_prod_type = 'BEAM-DIMAP' # possible other types: CSV, GeoTIFF, HDF5, NetCDF-BEAM, NetCDF-CF, NetCDF4-BEAM
_l3_out_prod_ext  = '.dim'       # possible other types: .csv, .tiff, .hdf5, .nc, .nc, .nc  # TODO check nc extensions
_l3_xml_type_str = '<?xml version="1.0" encoding="ISO-8859-1"?>\n'
__author__ = 'uwe'

from nasa.modis.seadas_processing.shared.utilities import ensureTrailingSlash
from os.path import exists

from beampy import String
from beampy import Product
from beampy import ProductData
from beampy import ProductIO
from beampy import ProductUtils


inputProductsBaseDir = '/FastBuffer/tsm_computation/L3_products/'
year = '2010'
l3_levels = ['1', '7', '15', '31']

inputProductsDirs = []
for level in l3_levels:
    inputProductsDirs.append(ensureTrailingSlash(ensureTrailingSlash(inputProductsBaseDir+year)+level))

print(inputProductsDirs)

myDOY = '60'

daily_product = inputProductsDirs[0] + 'A' + year + myDOY.zfill(3) + '_' + year + myDOY.zfill(3) + '_L3_nsea_2.0km.dim'
print(daily_product, exists(daily_product))
fallback_prods = []
Example #7
0
__author__ = 'uwe'

from nasa.modis.seadas_processing.conf.params import _processing, _site
from nasa.modis.seadas_processing.shared.utilities import ensureTrailingSlash

modisBaseInputPath = '/Volumes/tank/EOdata/MODISA/' # bcmacpro1 (development)

modisGEOBasePath     = modisBaseInputPath + 'GEO/'     + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)
modisGEO_subBasePath = modisBaseInputPath + 'GEO_sub/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)

modisL1A_LACBasePath = modisBaseInputPath + 'L1A_LAC/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)
modisL1A_subBasePath = modisBaseInputPath + 'L1A_sub/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)

modisL1B_HKMBasePath = modisBaseInputPath + 'L1B_HKM/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)
modisL1B_QKMBasePath = modisBaseInputPath + 'L1B_QKM/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)

modisL1B_LACBasePath = modisBaseInputPath + 'L1B_LAC/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)
modisL1B_subBasePath = modisBaseInputPath + 'L1B_sub/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)

modisL1B_OBCBasePath = modisBaseInputPath + 'L1B_OBC/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)
modisBrowseBasePath  = modisBaseInputPath + 'L1B_RGB/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)

modisL2_LACBasePath  = modisBaseInputPath + 'L2_LAC/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)
modisL2_subBasePath  = modisBaseInputPath + 'L2_sub/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)

# modisL2_TSMBasePath  = modisBaseInputPath + 'L2_TSM/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)
modisL2_TSMBasePath  = '/Volumes/MODISA/MODISA/L2_TSM/'
# modisL2_TSMBasePath  = '/Volumes/fs14/EOservices/OutputPool/MODISA/L2_TSM/'
#
# modisL3_TSMBasePath  = modisBaseInputPath + 'L3_TSM/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)     # L3 binned products, large area. Name e.g. cb_ns_20130603_eo_bc_lat_lon.dim
modisL3_TSMBasePath  = '/Volumes/MODIS_PROC8/MODISA/L3_TSM/' + ensureTrailingSlash(ensureTrailingSlash(_processing) + _site)     # L3 binned products, large area. Name e.g. cb_ns_20130603_eo_bc_lat_lon.dim
_t0 = time()

beamBinDir  = beamHomeDir + 'bin/'
gptProcessor = beamBinDir + 'gpt.command'

num_days_in_l3 = 7
_year  = int(back_date[:4])
_month = int(back_date[4:6])
_day   = int(back_date[6:])
proc_datetime = date(_year, _month, _day)
delta_days = (date.today() - proc_datetime).days
day_list = [getBackDate(day) for day in range(delta_days, delta_days + num_days_in_l3)]

srcList = []
for item in day_list:
    modisL2_TSMPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL2_TSMBasePath  + str(item.year))
                                                              + str(item.month).zfill(2)) + str(item.day).zfill(2))
    srcList += glob(modisL2_TSMPath+'A' + str(item.year) + '*.L2_TSM.dim')

exit_on_empty_list(srcList)
srcList.sort()
srcList = ",".join(srcList)

modisWeeklyPath  = ensureTrailingSlash(ensureTrailingSlash(modisWeeklyBasePath + str(_year)) + str(_month).zfill(2))
dateRangeString = str(day_list[6].year) + str(day_list[6].month).zfill(2) + str(day_list[6].day).zfill(2) + '_' + \
                  str(day_list[0].year) + str(day_list[0].month).zfill(2) + str(day_list[0].day).zfill(2)

outputProductPath = modisWeeklyPath + dateRangeString + regionDestID + parameters + '_bc_mod_1200.dim'

for _path in [modisWeeklyPath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
if argc < 2:
    printUsage()
    exit(1)

_date  = str(argv[1])
_year  = _date[:4]
_month = _date[4:6]
_day   = _date[6:]
_doy   = getDOY(_year, _month, _day)

unzipped_extension = '.L1A_LAC.x.hdf'
zipped_extension = unzipped_extension + '.bz2'

print(_year, _month, _day, _doy)

modisL1A_LACPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1A_LACBasePath + _year) + _month) + _day)
modisL1A_subPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1A_subBasePath + _year) + _month) + _day)
modisGEOPath     = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisGEOBasePath     + _year) + _month) + _day)
modisGEO_subPath = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisGEO_subBasePath + _year) + _month) + _day)

for _path in [modisL1A_subPath, modisGEOPath, modisGEO_subPath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)

srcList = listdir(modisL1A_LACPath)
listSize = len(srcList)
print(listSize)

if not listSize:
    print("Nothing to do. Now exiting...")
back_date = argv[1]
if len(back_date)!=8:
    print("****************************")
    print("* date parameter malformed *")
    print("****************************")
    printUsage()
    exit(1)

_year  = back_date[:4]
_month = back_date[4:6]
_day   = back_date[6:]
_doy   = getDOY(_year, _month, _day)
print("Processing date " + back_date + " (DOY = " + str(_doy)+ ").")

modisL3_TSMPath  = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL3_TSMBasePath  + _year) + _month) + _day)

modisL3_DeM_FinePath  = ensureTrailingSlash(modisL3_TSMDemarine_FineGrid_Path  + _year)
modisL3_DeM_CoarsePath  = ensureTrailingSlash(modisL3_TSMDemarine_CoarseGrid_Path  + _year)


for _path in [modisL3_DeM_FinePath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)

for _path in [modisL3_DeM_CoarsePath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)
try:
Example #11
0
argc = len(argv)
if argc < 2:
    printUsage()
    exit(1)

_date = str(argv[1])
_year = _date[:4]
_month = _date[4:6]
_day = _date[6:]
_doy = getDOY(_year, _month, _day)

print(_year, _month, _day, _doy)

modisGEOPath = ensureTrailingSlash(
    ensureTrailingSlash(
        ensureTrailingSlash(modisGEOBasePath + _year) + _month) + _day)
modisL1B_LACPath = ensureTrailingSlash(
    ensureTrailingSlash(
        ensureTrailingSlash(modisL1B_LACBasePath + _year) + _month) + _day)
modisBrowsePath = ensureTrailingSlash(
    ensureTrailingSlash(
        ensureTrailingSlash(modisBrowseBasePath + _year) + _month) + _day)

for _path in [modisBrowsePath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)

srcList = listdir(modisL1B_LACPath)
listSize = len(srcList)
back_date = argv[1]
if len(back_date)!=8:
    print("****************************")
    print("* date parameter malformed *")
    print("****************************")
    printUsage()
    exit(1)

_year  = back_date[:4]
_month = back_date[4:6]
_day   = back_date[6:]
_doy   = getDOY(_year, _month, _day)
print("Processing date " + back_date + " (DOY = " + str(_doy)+ ").")

modisL3_TSMPath  = ensureTrailingSlash(ensureTrailingSlash(modisL3_TSMBasePath  + _year) + _month)
modisL3_UTMPath  = ensureTrailingSlash(ensureTrailingSlash(modisL3_TSM_UTMPath  + _year) + _month)
modisL3_UTM_QLPath = ensureTrailingSlash(modisL3_TSM_UTM_QLPath  + _year)

for _path in [modisL3_UTMPath, modisL3_UTM_QLPath]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)

try:
    srcList = listdir(modisL3_TSMPath)
except OSError:
    print("Cannot open ", modisL3_TSMPath+ "! Now exiting...")
    exit(1)
else:
    listSize = exit_on_empty_list(srcList)
if argc < 2:
    printUsage()
    exit(1)

_date = str(argv[1])
_year = _date[:4]
_month = _date[4:6]
_day = _date[6:]
_doy = getDOY(_year, _month, _day)

#unzippedInputProductExtension = 'L1B_LAC.x.hdf'
unzippedInputProductExtension = 'L1B_LAC.hdf'
zippedInputProductExtension = unzippedInputProductExtension + '.bz2'

modisL1B_Path = ensureTrailingSlash(
    ensureTrailingSlash(
        ensureTrailingSlash(modisL1B_LACBasePath + _year) + _month) + _day)
modisGEO_Path = ensureTrailingSlash(
    ensureTrailingSlash(
        ensureTrailingSlash(modisGEOBasePath + _year) + _month) + _day)
modisL2_Path = ensureTrailingSlash(
    ensureTrailingSlash(
        ensureTrailingSlash(modisL2_LACBasePath + _year) + _month) + _day)

print(_year, _month, _day, _doy)
print(l2gen_const_params)
print(modisL1B_Path, modisGEO_Path, modisL2_Path)

for _path in [modisL2_Path]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
argc = len(argv)
if argc < 2:
    printUsage()
    exit(1)

_date  = str(argv[1])
_year  = _date[:4]
_month = _date[4:6]
_day   = _date[6:]
_doy   = getDOY(_year, _month, _day)

#unzippedInputProductExtension = 'L1B_LAC.x.hdf'
unzippedInputProductExtension = 'L1B_LAC.hdf'
zippedInputProductExtension = unzippedInputProductExtension + '.bz2'

modisL1B_Path = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL1B_LACBasePath + _year) + _month) + _day)
modisGEO_Path = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisGEOBasePath + _year) + _month) + _day)
modisL2_Path  = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL2_LACBasePath  + _year) + _month) + _day)

print(_year, _month, _day, _doy)
print(l2gen_const_params)
print(modisL1B_Path, modisGEO_Path, modisL2_Path)

for _path in [modisL2_Path]:
    if not exists(_path):
        print("Making directory: ", _path, " ...")
        makedirs(_path)

srcList = listdir(modisL1B_Path)
listSize = len(srcList)
print(listSize)