(ATCScript "AvgAnnualConcs" (Arg aProjectDir "E:\Ch2M\AtlantaMetroNorth\WQCalib\") (Arg aTSerFileDBF) (Arg aLocations (Array "0011204a" "0011103a" "1030107a" "0010904a" "0020208a" "1030406a")) (Arg aScenarios (Array "ptree" "sope" "south" "suwanee" "sweet" "yellow")) (Arg aConstituents (Array "BOD" "DO" "AMMO" "NO23C" "PHOSTC" "FECOLC")) (Arg aStartJdate (JDate 1992 10 1)) (Arg aEndJdate (JDate 1999 10 1)) (LoadLibrary "ATCScriptData" "ATCScriptFile" "ATCScriptGrid") (Set lSpace3 " ") (Set lSpace10 " ") (Set lSpace15 " ") (Set CRLF (+ (Chr 13) (Chr 10))) (Set lCurRow 0) (Grid "ConcentrationsTable" (+ 1 (* (Len aScenarios) 4)) 10) (' hard coded columns for time being) (Grid 1 (++ lCurRow) "Average Annual Simulated and Observed Concentrations") (Set lString "for") (For i = 1 to (Len aConstituents) (+= lString (+ " [" (ArrayItem aConstituents i) "]")) ) (Grid 2 (++ lCurRow) lString) (Set lString "at") (For i = 1 to (Len aScenarios) (If (= i (Len aScenarios)) (+= lString (+ " and " (ArrayItem aScenarios i))) (Else (+= lString (+ " " (ArrayItem aScenarios i) ",")) ) ) ) (Grid 2 (++ lCurRow) lString) (Grid 2 (++ lCurRow) (+ "Time Span: from " (Format aStartJdate "mm/dd/yy") " to " (Format aEndJdate "mm/dd/yy") ) ) (+= lCurRow 2) (' gets us to row with location names) (Set lScenNameRow lCurRow) (' add opening column to grid with constituent titles) (Grid 1 lCurRow (Format lSpace15 lSpace15)) (Grid 1 (+ lCurRow 1) (Format "CONSTITUENTS" lSpace15)) (For i = 1 to (Len aConstituents) (Grid 1 (+ lCurRow 2 i) (Format (ArrayItem aConstituents i) lSpace15)) ) (Set lScenarioCounter 0) (For lCurLocation in aLocations (Increment lScenarioCounter) (Set lCurRow lScenNameRow) (Set lNextRow (+ lScenNameRow 1)) (Set lCurScenario (ArrayItem aScenarios lScenarioCounter)) (' add scenario name and header labels) (DataFile aWDMFileObject Open "WDM" (+ aProjectDir lCurScenario "\" lCurScenario ".wdm")) (Set lCurSimDataSet (DataFile aWDMFileObject Data Location lCurLocation Scenario lCurScenario Constituent "FLOW")) (Set lCurName (Mid (DataTSer lCurSimDataSet Attrib "DESC") 1 30)) (Grid (+ 2 (* (- lScenarioCounter 1) 4)) lCurRow (Format lSpace3 lSpace3)) (Grid (+ 2 (* (- lScenarioCounter 1) 4)) lNextRow (Format lSpace3 lSpace3)) (Grid (+ 3 (* (- lScenarioCounter 1) 4)) lCurRow (Format (Mid lCurName (- (Len lCurName) 29) 10) lSpace10)) (Grid (+ 3 (* (- lScenarioCounter 1) 4)) lNextRow (Format "Observed" lSpace10)) (Grid (+ 4 (* (- lScenarioCounter 1) 4)) lCurRow (Format (Mid lCurName (- (Len lCurName) 19) 10) lSpace10)) (Grid (+ 4 (* (- lScenarioCounter 1) 4)) lNextRow (Format "Simulated" lSpace10)) (Grid (+ 5 (* (- lScenarioCounter 1) 4)) lCurRow (Format (Mid lCurName (- (Len lCurName) 9) 10) lSpace10)) (Grid (+ 5 (* (- lScenarioCounter 1) 4)) lNextRow (Format "Ratio" lSpace10)) (Unset lCurName) (+= lCurRow 2) (For lCurConstituent in aConstituents (+= lCurRow 1) (If (= lCurConstituent "FECOLC") (Set lNumFormat "##########") (Set lNumFormatObs "#####") (Set lMeanType "GEOMETRIC MEAN") (Else (Set lNumFormat "######0.00") (Set lNumFormatObs "#0.00") (Set lMeanType "MEAN") ) ) (Set lCurSimDataSet (DataFile aWDMFileObject Data Location lCurLocation Scenario lCurScenario Constituent lCurConstituent)) ('Set lCurSimDataSet (DataTSer lCurSimDataSet Aggregate "day" 1 "ave")) (Set lCurObsDataSet (DataFile aTSerFileDBF Data Location lCurLocation Scenario "OBSERVED" Constituent lCurConstituent)) ('Set lCurObsDataSet (DataTSer lCurObsDataSet Aggregate "day" 1 "ave")) (Set lCurObsNVal (DataTSer lCurObsDataSet Attrib "NVAL")) (Set lCurObsAvg (DataTSer lCurObsDataSet Attrib lMeanType)) (Set lCurSimAvg (DataTSer lCurSimDataSet Attrib lMeanType)) (Grid (+ 2 (* (- lScenarioCounter 1) 4)) lCurRow (Format lSpace3 lSpace3)) (If (IsNumeric lCurObsAvg) (If (> lCurObsAvg 0) (Grid (+ 3 (* (- lScenarioCounter 1) 4)) lCurRow (Format (+ (Format lCurObsAvg lNumFormatObs) "(" lCurObsNVal ")" ) lSpace10 ) ) (Else (Grid (+ 3 (* (- lScenarioCounter 1) 4)) lCurRow (Format lSpace10 lSpace10)) ) ) (Else (Grid (+ 3 (* (- lScenarioCounter 1) 4)) lCurRow (Format lSpace10 lSpace10)) ) ) (Grid (+ 4 (* (- lScenarioCounter 1) 4)) lCurRow (Format lCurSimAvg lNumFormat)) (If (IsNumeric lCurObsAvg) (If (> lCurObsAvg 0) (Grid (+ 5 (* (- lScenarioCounter 1) 4)) lCurRow (Format (/ lCurSimAvg lCurObsAvg) "######0.00")) (Else (Grid (+ 5 (* (- lScenarioCounter 1) 4)) lCurRow (Format lSpace10 lSpace10)) ) ) (Else (Grid (+ 5 (* (- lScenarioCounter 1) 4)) lCurRow (Format lSpace10 lSpace10)) ) ) (Unset lCurSimAvg) (Unset lCurObsAvg) (Unset lCurSimDataSet) (Unset lCurObsDataSet) ) (DataFile aWDMFileObject Clear) ) (SaveFile (+ aProjectDir "AvgAnnualConcs.txt") (Grid "AsString" "" CRLF lSpace3) ) (Unset lMeanType) (Unset lNumFormat) (Unset lNumFormatObs) (Unset lCurScenario) (Unset lCurConstituent) (Unset lScenarioCounter) (Unset lSpace10) (Unset lSpace15) (Unset lSpace30) (Unset lCurRow) (Unset lString) )