2323
2424*Usage pre adapter:*
2525
26- **wflow_adapt** -M Pre -t InputTimeseriesXml -I inifile -T timestepInSeconds
26+ **wflow_adapt** -M Pre -t InputTimeseriesXml -I inifile
2727
2828*Usage postadapter:*
2929
3030**wflow_adapt**-M Post -t InputTimeseriesXml -s inputStateFile -I inifile
31- -o outputStateFile -r runinfofile -w workdir -C case -T timestepInSeconds [-R runId]
31+ -o outputStateFile -r runinfofile -w workdir -C case [-R runId]
3232
3333Issues:
3434
@@ -497,11 +497,10 @@ def pre_adapter(INxmlTimeSeries,logger):
497497 #writeNrTimesteps()
498498
499499def usage ():
500- print "wflow_adapter -M Pre -t InputTimeseriesXml -I inifile"
501- print "wflow_adapter -M run -I inifile -r runinfofile"
500+ print "wflow_adapter -M Pre -t InputTimeseriesXml -I inifile"
502501 print "wflow_adapter -M Post -t InputTimeseriesXml -s inputStateFile -I inifile"
503502 print " -o outputStateFile -r runinfofile -w workdir -C case"
504- print " Options: -T timestepInSeconds"
503+
505504
506505
507506def main ():
@@ -516,7 +515,7 @@ def main():
516515 logfname = "wflow.log"
517516
518517 try :
519- opts , args = getopt .getopt (sys .argv [1 :], "-T:- M:-t:-s:-o:-r:-w:-C:-I:R:" )
518+ opts , args = getopt .getopt (sys .argv [1 :], "-M:-t:-s:-o:-r:-w:-C:-I:R:" )
520519 except getopt .GetoptError , err :
521520 # print help information and exit:
522521 print str (err )
@@ -532,8 +531,6 @@ def main():
532531 verbose = True
533532 elif o in ("-t" ):
534533 xmlTimeSeries = a
535- elif o in ("-T" ):
536- timestepsecs = int (a )
537534 elif o in ("-R" ):
538535 runId = a
539536 elif o in ("-o" ):
@@ -560,7 +557,7 @@ def main():
560557 config .read (workdir + "/" + case + "/" + iniFile )
561558
562559 # get timestep from wflow ini use comand-line as default
563- timestepsecs = int (wflow_lib .configget (config ,"model " ,"timestepsecs" ,str (timestepsecs )))
560+ timestepsecs = int (wflow_lib .configget (config ,"run " ,"timestepsecs" ,str (timestepsecs )))
564561
565562
566563 logger = setlogger (logfile ,"wflow_adapt" )
@@ -570,33 +567,36 @@ def main():
570567 pre_adapter (xmlTimeSeries ,logger )
571568 logger .info ("Ending preadapter" )
572569 sys .exit (0 )
573- elif mode == "Run" :
574- logger .info ("Run adapter not implemented..." ) # Not implemented -> se pcraster adapter
575- sys .exit (1 )
576570 elif mode == "Post" :
577-
578571 logger .info ("Starting postadapter" )
572+
573+ # Step1: update the state xml files
574+ # TODO: Remove fewsrun=1 stuff
579575 pixml_state_updateTime (inputStateFile ,stateFile ,getEndTimefromRuninfo (runinfofile ))
580576
581-
582- # Get outpumapstacks from wflow ini
577+
578+ # Step 2: make XML files to go with the output mapstacks
579+ # Get outputmapstacks from wflow ini
583580 mstacks = config .options ('outputmaps' )
584-
585-
581+
582+ #TODO: Add support for netcdf files
583+ # Create XML files for all mapstacks
586584 for a in mstacks :
587585 var = config .get ("outputmaps" ,a )
588586 logger .debug ("Creating mapstack xml: " + workdir + "/" + case + "/" + runId + "/" + var + ".xml" )
589587 mapstackxml (workdir + "/" + case + "/" + runId + "/outmaps/" + var + ".xml" ,var + "?????.???" ,var ,var ,getStartTimefromRuninfo (runinfofile ),getEndTimefromRuninfo (runinfofile ),timestepsecs )
590588
591589
592590 # Back hack to work around the 0 based FEWS problem and create a double timestep zo that we have connection between subsequent runs in FEWS
593- #TODO: do the copy for all variable that wflow saves.This hack only works for variable that are saved as states
591+ #TODO: do the copy for all variable that wflow saves.This hack only works for variables that are saved as states
592+ #TODO: remove this hack!!! And switch to XML
594593 try :
595594 shutil .copy (workdir + "/" + case + "/instate/SurfaceRunoff.map" ,workdir + "/" + case + "/" + runId + "/outmaps/run00000.000" )
596595 shutil .copy (workdir + "/" + case + "/instate/WaterLevel.map" ,workdir + "/" + case + "/" + runId + "/outmaps/lev00000.000" )
597596 except :
598597 logger .warn ("Cannot copy Surfacerunoff and/or level" )
599-
598+
599+ # Step 3:
600600 # now check for tss files and convert to XML
601601 stop = 0
602602 secnr = 0
@@ -614,7 +614,6 @@ def main():
614614 tssFile = workdir + "/" + case + "/" + runId + "/" + config .get (thissection ,aa )
615615 logger .debug ("Creating xml from tss: " + tssFile + "==> " + tssFile + ".xml" )
616616 tss_topixml (tssFile ,tssFile + ".xml" ,"wflow" ,config .get (thissection ,aa ),sDate ,timestepsecs )
617-
618617 except :
619618 stop = 1
620619
0 commit comments