(ATCScript "MonthlyRunoff.spt" (Arg "DataFileObject") (Arg "Locations") (Arg "CurScenario") (LoadLibrary "ATCScriptGrid" "ATCScriptData" "ATCScriptMisc") (Unset Report) ('get rid off possible old grid) (Set CRLF (+ (Chr 13) (Chr 10))) (Set Space8 " ") (Set Space14 " ") (Set ReportString "") (If (= CurScenario "CurScenario") (Warn "CurScenario must be set before calling AnnualRunoff script." "Monthly Flow Report") (Else (Set LocCounter 0) (+= ReportString (+ "Comparison of Monthly Observed and Simulated Flow for '" CurScenario "' scenario." CRLF " Run Made " (Format (FileAttribute (+ InputDir CurScenario ".hbn") "date") "yyyy-mm-dd hh:mm") CRLF " " gHspfRunInfo CRLF " (Units:Inches)" CRLF CRLF ) ) (For CurLocation in Locations (Increment LocCounter) ('Get monthly observed flow) (Set ObsDataSet (DataFile DataFileObject Data Location CurLocation Scenario "OBSERVED" Constituent "Flow")) (Set ObsDataSet (DataTSer ObsDataSet SubSetByDate SDate EDate)) (Set ObsDataSet (DataTSer ObsDataSet Aggregate 5 1 "Aver")) (Set ObsDataSet (DataTSer ObsDataSet Values)) ('Get monthly simulated flow) (Set SimDataSet (DataFile DataFileObject Data Location CurLocation Scenario CurScenario Constituent "Flow")) (Set SimDataSet (DataTSer SimDataSet SubSetByDate SDate EDate)) (Set SimDataSet (DataTSer SimDataSet Aggregate 5 1 "Aver")) (Set SimDataSet (DataTSer SimDataSet Values)) (+= ReportString (+ (ArrayItem Locations LocCounter) CRLF CRLF)) (+= ReportString (+ (Format "" Space8) (Format "Average" Space14) (Format "Average" Space14) (Format "Average" Space14) (Format "Percent" Space14) CRLF ) ) (+= ReportString (+ (Format "Month" Space8) (Format "Simulated" Space14) (Format "Observed" Space14) (Format "Residual" Space14) (Format "Error" Space14) CRLF ) ) (Set TotObs 0) (Set TotSim 0) (Set BasinArea (AreaFromEXS CurLocation (+ InputDir CurScenario ".exs"))) (For MonthCounter = 1 to 12 (Select MonthCounter (Case 3 (Set MonthName "Mar")) (Case 4 (Set MonthName "Apr")) (Case 5 (Set MonthName "May")) (Case 6 (Set MonthName "Jun")) (Case 7 (Set MonthName "Jul")) (Case 8 (Set MonthName "Aug")) (Case 9 (Set MonthName "Sep")) (Case 10 (Set MonthName "Oct")) (Case 11 (Set MonthName "Nov")) (Case 12 (Set MonthName "Dec")) (Case 1 (Set MonthName "Jan")) (Case 2 (Set MonthName "Feb")) ) (Set ObsVal 0) (Set SimVal 0) (Set YearCounter 0) (Set CurJDate (JDateAdd SDate "mon" 1 (- MonthCounter 1))) (While (< curJDate EDate) (+= ObsVal (ArrayItem ObsDataSet (+ (* YearCounter 12) MonthCounter))) (+= SimVal (ArrayItem SimDataSet (+ (* YearCounter 12) MonthCounter))) (Set CurJDate (JDateAdd CurJDate "yr" 1 1)) (Increment YearCounter) ) (Set ObsVal (/ ObsVal YearCounter)) (Set SimVal (/ SimVal YearCounter)) ('Convert values from cfs to in/yr) (Set ObsVal (/ (* ObsVal 23.8 (JDateDiff CurJDate (JDateAdd CurJDate "mon" 1 1) 4 1)) BasinArea)) (Set SimVal (/ (* SimVal 23.8 (JDateDiff CurJDate (JDateAdd CurJDate "mon" 1 1) 4 1)) BasinArea)) (Set FlowDif (- SimVal ObsVal)) (If (> ObsVal 0) (Set PerDif (/ (- SimVal ObsVal) ObsVal)) (Else (Set PerDif 0)) ) (+= ReportString (+ (Format MonthName Space8) (Format SimVal "##########0.00") (Format ObsVal "##########0.00") (Format FlowDif "##########0.00") (Format PerDif "#########0.00%") CRLF ) ) (+= TotObs ObsVal) (+= TotSim SimVal) ) ('Totals Line) (If (> TotObs 0) (Set PerDif (/ (- TotSim TotObs) TotObs)) (Else (Set PerDif 0)) ) (+= ReportString (+ (Format "Totals" Space8) (Format TotSim "##########0.00") (Format TotObs "##########0.00") (Format FlowDif "##########0.00") (Format PerDif "#########0.00%") CRLF ) ) (+= ReportString CRLF) ) ) ) (Return ReportString) (Unset ReportString) (Unset ObsDataSet) (Unset SimDataSet) (Unset LocCounter) (Unset MonthCounter) (Unset YearCounter) (Unset ObsVal) (Unset SimVal) (Unset FlowDif) (Unset PerDif) (Unset CurJdate) (Unset TotObs) (Unset TotSim) )