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
if source_key is None:
    source_key = factory.project.source
source = factory.getSourceConfig(source_key)

ndfd_config = factory.getSourceConfig('ndfd')

# all regions other than conus need a subset of the forecast area
if source_key != 'conus':
    ndfd_bbox = ndfd_config.get('bbox.%s' % region_key, None)
    if ndfd_bbox is not None:
        ndfd_bbox = stringToBbox(ndfd_bbox)
    else:
        offset = ndfd_config.bbox_offset
        if isinstance(offset, (ndfd_config.__class__, dict)):
            lat_offset = offset.lat
            lon_offset = offset.lon
        elif isinstance(offset, (tuple, list)):
            if offset[0] < 0:
Esempio n. 2
0
    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
    if isinstance(offset, (ndfd_config.__class__, dict)):
        lat_offset = offset.lat
        lon_offset = offset.lon
    elif isinstance(offset, (tuple, list)):
        if offset[0] < 0:
            lon_offset, lat_offset = offset
        else:
            lat_offset, lon_offset = offset
    else:
        lat_offset = lon_offset = offset
print 'using lat offset =', lat_offset
print 'using lon offset =', lon_offset
Esempio n. 3
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

reader = factory.getSourceFileReader(source, target_date.year, region, 'temps')