Ejemplo n.º 1
0
threat_datasets = tuple([
    dsname for dsname in CONFIG.filetypes[threat_key].datasets
    if dsname not in ('lat', 'lon')
])

num_args = len(args)
if num_args > 1:
    if args[1].isdigit():  # target year passed
        target_year = int(args[1])
        if num_args == 3:  # a single period was also passed
            periods = (args[2], )
    else:  # a single period was passed
        periods = (args[1], )

# get reguired information from static file
factory = SeasonalStaticFileFactory()
if dev_mode: factory.useDirpathsForMode('dev')
region = factory.regionConfig(region_key)
source = factory.sourceConfig(source_key)
reader = factory.staticFileReader(source, region)
lats = reader.getData('lat')
lons = reader.getData('lon')
reader.close()
del reader, factory

# create a factory for disease file access
factory = TurfThreatGridFileFactory(CONFIG)
if dev_mode: factory.useDirpathsForMode('dev')
region = factory.regionConfig(region_key)
source = factory.sourceConfig(source_key)
threat = factory.threatConfig(threat_key)
Ejemplo n.º 2
0
num_args = len(args)
if num_args == 0:
    today = datetime.date.today()
    if today.month == 12 and today.day >= 30:
        target_year = today.year + 1
    else:
        target_year = today.year
else:
    target_year = int(args[0])

temps_factory = TempextsProjectFactory()
if dev_mode: temps_factory.useDirpathsForMode('dev')
project = temps_factory.projectConfig()

static_factory = SeasonalStaticFileFactory(temps_factory.config,
                                           temps_factory.registry)
if dev_mode: static_factory.useDirpathsForMode('dev')

region = temps_factory.regionConfig(region)
source = temps_factory.sourceConfig(options.source)

if options.forecast_days is not None:
    forecast_days = int(options.forecast_days)
else:
    forecast_days = project.get('forecast_days', 0)
if debug: print 'forecast_days :', forecast_days

start_date = datetime.date(target_year, 1, 1)
end_date = datetime.date(target_year, 12, 31)
if forecast_days > 0: end_date += datetime.timedelta(days=forecast_days)
Ejemplo n.º 3
0
if debug:
    print 'region_path =', region_path
    print 'lat/lon tolerance =', tolerance
    print '\n', CONFIG.regions[region], '\n'

num_date_args = len(args) - 1
if num_date_args == 0:
    fcast_date = datetime.date.today()
elif num_date_args == 3:
    date = [int(arg) for arg in args[1:4]]
    fcast_date = datetime.date(date[0], date[1], date[2])
else:
    errmsg = 'Invalid date passed to script.\nYear, Month & Day are required.'
    raise RuntimeError, errmsg

static_factory = SeasonalStaticFileFactory(CONFIG)
static_factory.useDirpathsForMode('dev')
conus_filepath = static_factory.staticGridFilepath('acis5k', 'conus')
del static_factory

ndfd_static_factory = NdfdStaticFileFactory(CONFIG)
if dev_mode: ndfd_static_factory.useDirpathsForMode('dev')
ndfd_filepath = ndfd_static_factory.ndfdStaticFilepath(source, region)
if os.path.exists(ndfd_filepath):
    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(ndfd_filepath)
            print ndfd_filepath, 'exists :', os.path.exists(ndfd_filepath)