Example #1
0
 def getTargetYear(self, date, variety=None):
     return FrostGridFactory.getTargetYear(self, date, 'apple', variety)
Example #2
0
num_args = len(args)
if num_args == 0:
    start_date = datetime.now()
elif num_args == 3:
    year = int(args[0])
    month = int(args[1])
    day = int(args[2])
    start_date = datetime(year,month,day)
else:
    errmsg = 'Invalid number of arguments (%d).' % num_args
    raise SyntaxError, errmsg

factory = FrostGridFactory()
# target year is the year that we want to predict frost damage
target_year = factory.getTargetYear(start_date)
if target_year is None: exit()

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,