예제 #1
0
time_span = options.timespan
verbise = options.verbose or debug

latest_time = datetime.datetime.utcnow()
target_year = latest_time.year

if len(args) == 0:
    fcast_date = datetime.date.today()
elif len(args) == 3:
    fcast_date = datetime.date(int(args[0]), int(args[1]), int(args[2]))
else:
    errmsg = 'Invalid number of command line arguments. Either pass None'
    errmsg += ' for current day or the complete year, month, day to explore.'
    SyntaxError, errmsg

factory = NDFDProjectFactory()
project = factory.getProjectConfig()

region_key = options.region
if region_key is None:
    region_key = factory.project.region
region = factory.getRegionConfig(region_key)
print 'region =', region.description

region_bbox = list(stringToBbox(region.data))
print 'project region bounding box', region_bbox

ndfd_config = factory.getSourceConfig('ndfd')
offset = options.offset
if offset is None:
    offset = ndfd_config.bbox_offset
예제 #2
0
parser.add_option('-v', action='store_true', dest='verbose', default=False)
parser.add_option('-z', action='store_true', dest='debug', default=False)

options, args = parser.parse_args()

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

debug = options.debug
grib_variable = options.grib_variable
message_num = options.message
verbose = options.verbose or debug

fcast_date = datetime.date(int(args[0]), int(args[1]), int(args[2]))
print '\nIndexing forecast for', fcast_date

factory = NDFDProjectFactory()
project = factory.getProjectConfig()

csv_filepath = options.csv_filepath
if csv_filepath is not None:
    csv_filepath = os.path.abspath(csv_filepath)

region_key = options.region
if region_key is None:
    region_key = factory.project.region
region = factory.getRegionConfig(region_key)
print 'region =', region.description
region_bbox = list(stringToBbox(region.data))
print 'project region bounding box', region_bbox

source_key = options.source
        options.filetypes,
    ]

if ',' in options.periods:
    periods = options.periods.split(',')
else:
    periods = [
        options.periods,
    ]

verbose = options.verbose or debug

latest_time = datetime.datetime.utcnow()
target_year = latest_time.year

factory = NDFDProjectFactory()
target_date, filepaths = \
    factory.downloadLatestForecast(filetypes=filetypes, periods=periods,
                                   region=options.region, verbose=verbose)

elapsed_time = elapsedTime(UPDATE_START_TIME, True)
fmt = 'completed download for %s in %s'
print fmt % (target_date.isoformat(), elapsed_time)

transport_dirpath = '/Volumes/Transport/data/app_data'
if os.path.exists(transport_dirpath):
    ndfd_dirpath = os.path.split(filepaths[0])[0]
    dest_dirpath = os.path.join(transport_dirpath, 'shared/forecast/ndfd')
    command = '/usr/bin/rsync -cgloprtuD %s %s' % (ndfd_dirpath, dest_dirpath)
    print command
    os.system(command)
예제 #4
0
debug = options.debug
verbose = options.verbose or debug

var_name_map = {'maxt': 'Maximum temperature', 'mint': 'Minimum temperature'}

source_key = args[0]
region_key = args[1]

if len(args) == 2:
    target_date = datetime.date.today()
else:
    target_date = datetime.date(int(args[2]), int(args[3]), int(args[4]))
target_year = target_date.year

factory = NDFDProjectFactory()
ndfd = factory.getSourceConfig('ndfd')
region = factory.getRegionConfig(region_key)
source = factory.getSourceConfig(source_key)
print 'updating % source file with NDFD forecast' % source.tag

# need indexes from static file for source
reader = factory.getStaticFileReader(source, region)
source_shape = reader.getDatasetShape('ndfd.x_indexes')
ndfd_indexes = [
    reader.getData('ndfd.y_indexes').flatten(),
    reader.getData('ndfd.x_indexes').flatten()
]
reader.close()
del reader
예제 #5
0
                  default=False)
parser.add_option('-n',
                  action='store_true',
                  dest='use_ndfd_cache',
                  default=False)
parser.add_option('-v', action='store_true', dest='verbose', default=False)
parser.add_option('-z', action='store_true', dest='debug', default=False)

options, args = parser.parse_args()

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

debug = options.debug
use_dev_paths = options.use_dev_paths
use_ndfd_cache = options.use_ndfd_cache
verbose = options.verbose or debug

factory = NDFDProjectFactory()
if use_dev_paths: factory.config.dirpaths.update(factory.config.dev_dirpaths)
if use_ndfd_cache: factory.setServerUrl(factory.ndfd_config.cache_server)

target_date, filepaths = factory.downloadLatestForecast(True)
if verbose:
    print 'NDFD grib files downloaded for %s :', str(target_date)
    for filepath in filepaths:
        print '    ', filepath

elapsed_time = elapsedTime(DOWNLOAD_START_TIME, True)
fmt = 'completed download for %s in %s'
print fmt % (target_date.isoformat(), elapsed_time)
예제 #6
0
 def __init__(self, config=CONFIG, registry=REGISTRY):
     NDFDProjectFactory.__init__(self, config, registry)
ndfdStaticFilepath = ndfd_static_factory.ndfdStaticFilepath(source, region)
if os.path.exists(ndfdStaticFilepath):
    response = 'no response given yet'
    while not response in ('yes', 'no'):
        print "\nstatic file for %s region already exists, do you want to replace it ?" % region
        response = raw_input("Enter 'yes' or 'no' : ")
        if response in ('y', 'yes'):
            os.remove(ndfdStaticFilepath)
            print ndfdStaticFilepath, 'exists :', os.path.exists(
                ndfdStaticFilepath)
            break
        elif response in ('n', 'no'):
            print 'Execution ending, will not replace', ndfdStaticFilepath
            exit()

ndfd_factory = NDFDProjectFactory()
ndfd_factory.useDirpathsForMode('dev')

bbox = N.array(
    [float(coord) for coord in ndfd_factory.config[region_path].split(',')])
bbox_lats = bbox[N.where(bbox > 0.)]
bbox_lons = bbox[N.where(bbox < 0.)]
if verbose:
    print 'region lats =', bbox_lats
    print 'region lons =', bbox_lons

print '\nreading lat, lon and elevation from ACIS CONUS file'
static_factory = AcisProjectFactory(CONFIG)
static_factory.useDirpathsForMode('dev')
static_reader = static_factory.staticFileReader('acis5k', 'conus')
acis_lats = static_reader.get2DSlice('lat', bbox[0], bbox[2], bbox[1], bbox[3])
예제 #8
0
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

debug = options.debug
verbose = options.verbose or debug

var_name_map = {'maxt':'Maximum temperature', 'mint':'Minimum temperature'}

source_key = args[0]
region_key = args[1]

if len(args) ==2:
    target_date = datetime.date.today()
else:
    target_date = datetime.date(int(args[2]), int(args[3]), int(args[4]))

ndfd_factory = NDFDProjectFactory()
ndfd = ndfd_factory.sourceConfig('ndfd')

temps_factory = TempextsProjectFactory()
region = temps_factory.regionConfig(region_key)
source = temps_factory.sourceConfig(source_key)
print 'updating % source file with NDFD forecast' % source.tag

# need indexes from static file for source
reader = ndfd_factory.staticFileReader(source, region)
source_shape = reader.datasetShape('ndfd.x_indexes')
ndfd_indexes = [ reader.getData('ndfd.y_indexes').flatten(),
                 reader.getData('ndfd.x_indexes').flatten() ]
reader.close()
del reader
else:
    filetypes = [
        options.filetypes,
    ]

if ',' in options.periods:
    periods = options.periods.split(',')
else:
    periods = [
        options.periods,
    ]

latest_time = datetime.datetime.utcnow()
target_year = latest_time.year

factory = NDFDProjectFactory()
factory.setDownloadAttempts(attempts)
factory.setDownloadWaitTime(wait_time)

target_date, filepaths, failed = \
    factory.downloadLatestForecast(filetypes=filetypes, periods=periods,
                                   debug=debug)

elapsed_time = elapsedTime(UPDATE_START_TIME, True)
fmt = '\ncompleted download for %s in %s'
print fmt % (target_date.isoformat(), elapsed_time)
if len(filepaths) > 0:
    print 'successfully downloaded :'
    for path in filepaths:
        print '    ', path
if len(failed) > 0:
예제 #10
0
latest_time = datetime.datetime.utcnow()
target_year = latest_time.year

variable = args[0]

if len(args) == 1:
    fcast_date = datetime.date.today()
elif len(args) == 4:
    fcast_date = datetime.date(int(args[1]), int(args[2]), int(args[3]))
else:
    errmsg = 'Invalid number of command line arguments. Either pass None'
    errmsg += ' for current day or the complete year, month, day to explore.'
    SyntaxError, errmsg

factory = NDFDProjectFactory()
if dev_mode: factory.useDirpathsForMode('dev')
project = factory.getProjectConfig()
ndfd_config = factory.getSourceConfig('ndfd')

if region_key is None:
    region_key = factory.project.region
grid_region = factory.regionConfig(region_key)
print 'region =', grid_region.description

if source_key is None:
    source_key = factory.project.source
grid_source = factory.sourceConfig(source_key)
print 'source =', grid_source.description

reader = factory.staticFileReader(grid_source, grid_region)