Exemplo n.º 1
0
 def mapFilepath(self,
                 date,
                 model,
                 map_group,
                 map_type,
                 lo_gdd_th,
                 hi_gdd_th,
                 test_file=False):
     # get the map directory path and the template for the map file name
     map_dirpath = mapWorkingDir(self.target_year, self.variety.name,
                                 model.name, map_group, map_type, lo_gdd_th,
                                 hi_gdd_th, test_file)
     filename_template = mapFilename('%s', self.variety.name, model.name,
                                     map_group, map_type, lo_gdd_th,
                                     hi_gdd_th, test_file)
     filepath_template = map_dirpath + os.sep + filename_template
     return filepath_template % asAcisQueryDate(date)
Exemplo n.º 2
0
    if args[2] == 'chill':
        map_group = 'chill'
        map_type = 'accumulated'
    else: map_group, map_type = args[2].split('.')

    # generate a set of parameters for each plot
    plots = [ ]
    for model_name in model_names:
        plots.append( (None, model_name, map_group, map_type) )

for variety, model_name, map_group, map_type in plots:
    if debug:
        print '\nanimating', variety, model_name, map_group, map_type
    map_filepath = \
    mapFilename('date', variety, model_name, map_group, map_type)
    if map_type == 'gdd': plot_key = 'GDD'
    else: plot_key = nameToFilepath(map_type)
    png_path = '*%s' % map_filepath[map_filepath.find(plot_key):]

    anim_filepath = \
    animationFilepath(target_year, variety, model_name, map_group, map_type)

    working_dir = \
    mapWorkingDir(target_year, variety, model_name, map_group, map_type)
    os.chdir(working_dir)

    _cmd_ = _cmd_tmpl_ % (png_path, anim_filepath)
    if debug: print _cmd_
    os.system(_cmd_)

        end_date = datetime(year, month, day)
    else:
        errmsg = 'Invalid number of date arguments (%d).' % date_args
        raise ValueError, errmsg
else:
    errmsg = 'Invalid number of date arguments (%d).' % date_args
    raise ValueError, errmsg

if end_date is None: past_date = start_date + ONE_DAY
else: past_date = end_date + ONE_DAY

factory = AppleGridFactory()
target_year = factory.getTargetYear(start_date)

# get the map directory path and the template for the map file name
map_dirpath = mapWorkingDir(target_year, variety.name, model.name, 'chill',
                            dataset, None, None, test_file)
filename_template = mapFilename('%s', variety.name, model.name, 'chill',
                                dataset, None, None, test_file)
filepath_template = map_dirpath + os.sep + filename_template

# get the map title template and initialize the map title
title_template = fromConfig('crops.apple.chill.maps.titles.accumulated')
title = title_template % {
    'model': model.description,
}

# get GDD map options
map_options = fromConfig('crops.apple.chill.maps.options.accumulated.attrs')

# get date indepenedent attributes and grids from the stage grid manager
manager = factory.getChillGridManager(target_year, 'r', test_file)
Exemplo n.º 4
0
        end_date = datetime(year, month, day)
    else:
        errmsg = 'Invalid number of date arguments (%d).' % date_args
        raise ValueError, errmsg
else:
    errmsg = 'Invalid number of date arguments (%d).' % date_args
    raise ValueError, errmsg

if end_date is None: past_date = start_date + ONE_DAY
else: past_date = end_date + ONE_DAY

factory = AppleGridFactory()
target_year = factory.getTargetYear(start_date)

# get the map directory path and the template for the map file name
map_dirpath = mapWorkingDir(target_year, variety.name, model_1.name,
                            'stage.diff', None, None, test_file)

filename_template = '%%s-Frost-Apple-%s-%s-%s-Stage-Diff.png'
filename_template = filename_template % (nameToFilepath(
    variety.name), nameToFilepath(model_1.name), nameToFilepath(model_2.name))
filepath_template = map_dirpath + os.sep + filename_template

title = '%s\nPhenological Stage Difference\n%s - %s' % (
    variety.description, model_1.name.title(), model_2.name.title())

manager = factory.getVarietyGridManager(target_year, variety.name, 'r',
                                        test_file)
gdd_thresholds = manager.gddThresholds(model_1.name)
lats = manager.lats
lons = manager.lons