# Liste bereinigen:
for a in range(listSize):
    for item in srcList:
        _remove = False
        if not item.startswith('A' + _year +str(_doy)) or not item.find('.L1A_LAC'):
            _remove=True

        if item.endswith('L1A_LAC') or item.endswith('L1A_LAC.bz2'):
            _remove = False
        else:
            _remove=True

        if _remove:
            srcList.remove(item)

exit_on_empty_list(srcList)
srcList.sort()

# Now processing can start...

if not exists(modisGEOPath):
    makedirs(modisGEOPath)

modisGEOscript        = seadasScriptsDir + 'modis_GEO.py'
modisL1AextractScript = seadasScriptsDir + 'modis_L1A_extract.py'

def process_modisGEO(l1a_productPath, GEO_productPath):
    processing_call = modisGEOscript + ' ' + l1a_productPath + ' -o ' + GEO_productPath
    print("Executing: ",processing_call)
    system(processing_call)
    if exists(GEO_productPath):
    ensureTrailingSlash(
        ensureTrailingSlash(modisL3_TSM_UTMPath + _year) + _month) + _day)
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)
    print(listSize)

# Liste bereinigen:
for a in range(listSize):
    for item in srcList:
        if not item.startswith('cb_ns_' +
                               back_date) or not item.endswith('.dim'):
            srcList.remove(item)

listSize = exit_on_empty_list(srcList)
srcList.sort()

outputProductPath = modisL3_UTMPath + 'cb_' + _site + '_' + back_date + '_9999_eo_bc.dim'

print(srcList, outputProductPath)
from os.path import exists
from os import chdir, getcwd, makedirs

ftp_server = 'samoa.gsfc.nasa.gov'
ftp_user = '******'
ftp_pass = '******'

subscription = '2439'   # NorthSeaBalticSea region (http://oceancolor.gsfc.nasa.gov/sdpscgi/registered/subscriptions_manager.cgi)
user = '******'       # Subscription user: bconsult  password: volcano:vie

ftp_dir = '/subscriptions/VIIRS/XM/' + user + '/' + subscription
print(ftp_dir)
ftp_connection = FTP(host=ftp_server, user=ftp_user, passwd=ftp_pass)
ftp_connection.cwd(ftp_dir)
ftp_listing = ftp_connection.nlst()
exit_on_empty_list(ftp_listing)
listing = filter_list(ftp_listing, extension='.hdf')
listing.sort()
# print(listing)

for product_name in listing:
    acq_year = product_name[1:5]
    acq_doy = product_name[5:8]
    acq_date = getDateFromDOY(_year=acq_year, DOY=acq_doy)
    download_dir = viirsL2_SubsBasePath + ensureTrailingSlash(str(acq_year)) + ensureTrailingSlash(str(acq_date.month).zfill(2)) + ensureTrailingSlash(str(acq_date.day).zfill(2))
    if not exists(download_dir):
        makedirs(download_dir)
    chdir(download_dir)
    if not exists(product_name):
        print("Downloading " + product_name + " to " + download_dir + "...")
        ftp_connection.retrbinary('RETR '+product_name, open(product_name, 'wb').write)
示例#4
0
for a in range(listSize):
    for item in srcList:
        _remove = False
        if not item.startswith('A' + _year +
                               str(_doy)) or not item.find('.L1A_LAC'):
            _remove = True

        if item.endswith('L1A_LAC') or item.endswith('L1A_LAC.bz2'):
            _remove = False
        else:
            _remove = True

        if _remove:
            srcList.remove(item)

exit_on_empty_list(srcList)
srcList.sort()

# Now processing can start...

if not exists(modisGEOPath):
    makedirs(modisGEOPath)

modisGEOscript = seadasScriptsDir + 'modis_GEO.py'
modisL1AextractScript = seadasScriptsDir + 'modis_L1A_extract.py'


def process_modisGEO(l1a_productPath, GEO_productPath):
    processing_call = modisGEOscript + ' ' + l1a_productPath + ' -o ' + GEO_productPath
    print("Executing: ", processing_call)
    system(processing_call)
_month = _date[4:6]
_day   = _date[6:]
_doy   = getDOY(_year, _month, _day)

viirsL1_Path = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(viirsL1A_BasePath + _year) + _month) + _day)
viirsL2_Path = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(viirsL2_BasePath  + _year) + _month) + _day)
if not exists(viirsL2_Path):
    makedirs(viirsL2_Path)

try:
    srcPathList=glob(viirsL1_Path + 'V' + _year + str(_doy) + '*tar.bz2')
except OSError:
    print("Cannot open ", viirsL1_Path + "! Now exiting...")
    exit(1)
else:
    exit_on_empty_list(srcPathList)

srcList=[basename(item) for item in srcPathList]
srcList.sort()
del srcPathList

# Now processing can start...

l2genBinary  = seadasBinDir + 'l2gen'
getancScript = seadasScriptsDir + 'getanc.py'

print l2genBinary, "Exists="+str(exists(l2genBinary)), getancScript, "Exists="+str(exists(getancScript))

def process_VIIRS_L2_OC(viirsL1_ProductArchive, forceReprocess):
    print("Processing", viirsL1_ProductArchive, "...")
    viirsL2_Product = viirsL1_ProductArchive[:22].replace('L1A_NPP', 'L2_NPP')  # V2014159100026.L2_NPP
modisL3_TSMPath  = ensureTrailingSlash(ensureTrailingSlash(ensureTrailingSlash(modisL3_TSMBasePath  + _year) + _month) + _day)
modisL3_ECOHAMPath  = ensureTrailingSlash(modisL3_ECOHAMBasePath  + _year)

for _path in [modisL3_TSMPath, modisL3_ECOHAMPath]:
    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)
    print(listSize)

# Liste bereinigen:
for a in range(listSize):
    for item in srcList:
        if not item.startswith('cb_' + _site + '_' + back_date) or not item.endswith('.dim'):
            srcList.remove(item)

listSize = exit_on_empty_list(srcList)
srcList.sort()

# reprojected L3 products,        Name e.g. cb_ns_20130603_eo_ecoham.dim
outputProductPath = modisL3_ECOHAMPath + 'cb_' + _site + '_' + back_date + '_eo_bc_lat_lon_ecoham.dim'

print(srcList, outputProductPath)
示例#7
0
viirsL1_Path = ensureTrailingSlash(
    ensureTrailingSlash(
        ensureTrailingSlash(viirsL1A_BasePath + _year) + _month) + _day)
viirsL2_Path = ensureTrailingSlash(
    ensureTrailingSlash(
        ensureTrailingSlash(viirsL2_BasePath + _year) + _month) + _day)
if not exists(viirsL2_Path):
    makedirs(viirsL2_Path)

try:
    srcPathList = glob(viirsL1_Path + 'V' + _year + str(_doy) + '*tar.bz2')
except OSError:
    print("Cannot open ", viirsL1_Path + "! Now exiting...")
    exit(1)
else:
    exit_on_empty_list(srcPathList)

srcList = [basename(item) for item in srcPathList]
srcList.sort()
del srcPathList

# Now processing can start...

l2genBinary = seadasBinDir + 'l2gen'
getancScript = seadasScriptsDir + 'getanc.py'

print l2genBinary, "Exists=" + str(
    exists(l2genBinary)), getancScript, "Exists=" + str(exists(getancScript))


def process_VIIRS_L2_OC(viirsL1_ProductArchive, forceReprocess):
示例#8
0
from os.path import exists
from os import chdir, getcwd, makedirs

ftp_server = 'samoa.gsfc.nasa.gov'
ftp_user = '******'
ftp_pass = '******'

subscription = '2439'  # NorthSeaBalticSea region (http://oceancolor.gsfc.nasa.gov/sdpscgi/registered/subscriptions_manager.cgi)
user = '******'  # Subscription user: bconsult  password: volcano:vie

ftp_dir = '/subscriptions/VIIRS/XM/' + user + '/' + subscription
print(ftp_dir)
ftp_connection = FTP(host=ftp_server, user=ftp_user, passwd=ftp_pass)
ftp_connection.cwd(ftp_dir)
ftp_listing = ftp_connection.nlst()
exit_on_empty_list(ftp_listing)
listing = filter_list(ftp_listing, extension='.hdf')
listing.sort()
# print(listing)

for product_name in listing:
    acq_year = product_name[1:5]
    acq_doy = product_name[5:8]
    acq_date = getDateFromDOY(_year=acq_year, DOY=acq_doy)
    download_dir = viirsL2_SubsBasePath + ensureTrailingSlash(
        str(acq_year)) + ensureTrailingSlash(str(
            acq_date.month).zfill(2)) + ensureTrailingSlash(
                str(acq_date.day).zfill(2))
    if not exists(download_dir):
        makedirs(download_dir)
    chdir(download_dir)