<s> """<STR_LIT>""" <EOL> import ensemble <EOL> import config <EOL> import shutil <EOL> import sys <EOL> from assimilation import assimilate <EOL> from datetime import date <EOL> import dssat <EOL> import rpath <EOL> import raster <EOL> def runVIC ( dbname , options ) : <EOL> """<STR_LIT>""" <EOL> startyear , startmonth , startday = map ( <EOL> int , options [ '<STR_LIT>' ] [ '<STR_LIT>' ] . split ( '<STR_LIT:->' ) ) <EOL> endyear , endmonth , endday = map ( <EOL> int , options [ '<STR_LIT>' ] [ '<STR_LIT>' ] . split ( '<STR_LIT:->' ) ) <EOL> res = config . getResolution ( options [ '<STR_LIT>' ] ) <EOL> vicexe = "<STR_LIT>" . format ( rpath . bins ) <EOL> basin = config . getBasinFile ( options [ '<STR_LIT>' ] ) <EOL> saveto , savevars = config . getVICvariables ( options ) <EOL> name = options [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] . lower ( ) <EOL> nens = int ( options [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> method = options [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> name = options [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] . lower ( ) <EOL> models = ensemble . Ensemble ( nens , dbname , res , startyear , <EOL> startmonth , startday , endyear , endmonth , endday , name ) <EOL> if '<STR_LIT>' in options [ '<STR_LIT>' ] and options [ '<STR_LIT>' ] [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> init_method = options [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> else : <EOL> init_method = "<STR_LIT>" <EOL> if '<STR_LIT>' in options [ '<STR_LIT>' ] : <EOL> init_method = "<STR_LIT>" <EOL> models . initialize ( options , basin , init_method , vicexe , <EOL> saveindb = True , saveto = saveto , saveargs = savevars , skipsave = - <NUM_LIT:1> ) <EOL> data , alat , alon , agid = assimilate ( options , date ( <EOL> models . startyear , models . startmonth , models . startday ) , models ) <EOL> models . updateStateFiles ( data , alat , alon , agid ) <EOL> else : <EOL> models . initialize ( options , basin , init_method , vicexe , <EOL> saveindb = True , saveto = saveto , saveargs = savevars ) <EOL> models . writeParamFiles ( ) <EOL> models . writeForcings ( method , options ) <EOL> models . run ( vicexe ) <EOL> models . setDates ( startyear , startmonth , startday , endyear , endmonth , endday ) <EOL> models . save ( saveto , savevars ) <EOL> for varname in savevars : <EOL> raster . stddev ( models . dbname , "<STR_LIT>" . format ( <EOL> models . name , varname ) ) <EOL> for e in range ( nens ) : <EOL> shutil . rmtree ( models [ e ] . model_path ) <EOL> def runDSSAT ( dbname , options ) : <EOL> """<STR_LIT>""" <EOL> startyear , startmonth , startday = map ( <EOL> int , options [ '<STR_LIT>' ] [ '<STR_LIT>' ] . split ( '<STR_LIT:->' ) ) <EOL> endyear , endmonth , endday = map ( <EOL> int , options [ '<STR_LIT>' ] [ '<STR_LIT>' ] . split ( '<STR_LIT:->' ) ) <EOL> res = float ( options [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> nens = int ( options [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> name = options [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] . lower ( ) <EOL> dssatexe = "<STR_LIT>" . format ( rpath . bins ) <EOL> if '<STR_LIT>' in options [ '<STR_LIT>' ] : <EOL> shapefile = options [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> else : <EOL> shapefile = None <EOL> model = dssat . DSSAT ( dbname , name , res , startyear , startmonth , startday , <EOL> endyear , endmonth , endday , nens , options [ '<STR_LIT>' ] , shapefile ) <EOL> model . run ( dssatexe ) <EOL> def execute ( dbname , options ) : <EOL> """<STR_LIT>""" <EOL> forecast_options = options [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in forecast_options : <EOL> if '<STR_LIT>' in forecast_options [ '<STR_LIT>' ] : <EOL> if '<STR_LIT>' in options : <EOL> runVIC ( dbname , options ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> sys . exit ( ) <EOL> if '<STR_LIT>' in forecast_options [ '<STR_LIT>' ] : <EOL> if '<STR_LIT>' in options : <EOL> runDSSAT ( dbname , options ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> sys . exit ( ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> sys . exit ( ) </s>
