from frost.factory import FrostGridFactory

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

from optparse import OptionParser
parser = OptionParser()

parser.add_option('-v', action='store_true', dest='verbose', default=False)
parser.add_option('-x', action='store_true', dest='test_file', default=False)
parser.add_option('-z', action='store_true', dest='debug', default=False)

options, args = parser.parse_args()

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

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

target_year = int(args[0])

frost_factory = FrostGridFactory()

temp_manager = frost_factory.getTempGridManager(target_year, 'a')
bbox = temp_manager.getFileAttribute('search_bbox')
temp_manager.setFileAttribute('data_bbox', bbox)
temp_manager.deleteFileAttribute('search_bbox')
temp_manager.close()

Example #2
0
if debug: print 'dates', target_year, start_date

season_start = datetime(target_year-1, *fromConfig('crops.apple.start_day'))
season_end = datetime(target_year, *fromConfig('crops.apple.end_day'))
temp_end = season_end + ONE_DAY
if start_date > temp_end and start_date < season_start: exit()

# get a temperature data file manger
filepath = factory.getTempGridFilePath(target_year, test_file)
if debug:
    print 'temp filepath', os.path.exists(os.path.normpath(filepath)), filepath
if not os.path.exists(os.path.normpath(filepath)):
    manager = factory.newTempGridManager(target_year, None, verbose,
                                         test_file)
else: manager = factory.getTempGridManager(target_year, 'r', test_file)
if debug:
    print 'temp manager', manager
    print 'temp manager file', manager.filepath

# download current ACIS mint,maxt for current date
acis_grid = manager.getDatasetAttribute('reported.maxt', 'acis_grid')
manager.close()
data = factory.getAcisGridData('mint,maxt', start_date, None, None, 
                                manager.data_bbox, int(acis_grid),
                                debug=debug)
if debug: print 'temp data\n', data

manager.open('a')
manager.updateTemp('reported.maxt', data['maxt'], start_date)
manager.updateTemp('reported.mint', data['mint'], start_date)
Example #3
0
#! /Volumes/projects/venvs/frost/bin/python

from frost.factory import FrostGridFactory

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

from optparse import OptionParser
parser = OptionParser()

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()

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

factory = FrostGridFactory()

target_year = int(args[0])
dataset_path = args[1]
attribute = args[2]
new_value = args[3]

manager = factory.getTempGridManager(target_year, 'a')
manager.setDatasetAttribute(dataset_path, attribute, new_value)
manager.close()

manager.open('r')
print dataset_path, attribute, manager.datasetAttribute(
    dataset_path, attribute)
manager.close()