(ATCScript "OutputConstituentStats" (Arg aInputDir "C:\MNGWPD\ModelWQ\GenScn\outptwdm\") (Arg aConstituents (Array "DO" "Fecal" "WTemp")) (Arg aConsDSNs (Array 31 33 32)) (Arg aStartJdate (JDate 1992 10 1)) (Arg aEndJdate (JDate 1999 10 1)) (Arg aStatusFile "OutputConstituentStats.txt") (LoadLibrary "ATCScriptData" "ATCScriptFile" "ATCScriptGrid") (Set lReportString "") (Set CRLF (+ (Chr 13) (Chr 10))) (Set lSpace8 " ") (Set lSpace12 " ") (Set lSpace15 " ") (Set lCurRow 0) (Grid "StatsTable" (+ (* (Len aConstituents) 4) 1) 10) (' rows will expand as necessary, columns won't) (Set lString "Statistics Table for") (For i = 1 to (Len aConstituents) (+= lString (+ " [" (ArrayItem aConstituents i) "]")) ) (Grid 1 (++ lCurRow) lString) (Grid 2 (++ lCurRow) (+ "Time Span: from " (Format aStartJdate "mm/dd/yy") " to " (Format aEndJdate "mm/dd/yy") ) ) (+= lCurRow 2) (Set lNextRow (+ lCurRow 1)) (Set lNextRow2 (+ lCurRow 2)) (Grid 1 lCurRow (Format "HUC12" lSpace15)) (Grid 1 lNextRow (Format lSpace15 lSpace15)) (For i = 1 to (Len aConstituents) (Select (ArrayItem aConstituents i) (Case "DO" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) (Case "Fecal" (Set lMeanType "Geom. Mean") (Set lCellFormat lSpace12)) (Case "WTemp" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) (Case "TP" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) (Case "TSS" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) (Case "NH3" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) (Case "NO2/NO3" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) (Case "Lead" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) (Case "Zinc" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) (Case "BOD" (Set lMeanType " Mean") (Set lCellFormat lSpace8)) ) (Grid (+ 2 (* (- i 1) 4)) lCurRow (Format lCellFormat lCellFormat)) (Grid (+ 2 (* (- i 1) 4)) lNextRow (Format "Min" lCellFormat)) (Grid (+ 3 (* (- i 1) 4)) lCurRow (Format (ArrayItem aConstituents i) lCellFormat)) (Grid (+ 3 (* (- i 1) 4)) lNextRow (Format "Max" lCellFormat)) (Grid (+ 4 (* (- i 1) 4)) lCurRow (Format lCellFormat lCellFormat)) (Grid (+ 4 (* (- i 1) 4)) lNextRow (Format lMeanType lCellFormat)) (Grid (+ 5 (* (- i 1) 4)) lCurRow (Format lCellFormat lCellFormat)) (Grid (+ 5 (* (- i 1) 4)) lNextRow (Format "Std Dev" lCellFormat)) ) (+= lCurRow 1) (ChDir aInputDir) (Set lFiles (Dir "*.wdm")) ('Set lFiles (Array "03070103.wdm")) (For lFile In lFiles (DataFile aWDMFileObject Open "WDM" (+ aInputDir lFile)) (Set lCount (DataFile aWDMFileObject DataCount)) ('Set Debug "On") (AppendFile (+ lProjectDir aStatusFile) (+ CRLF "Start File " lFile " " lCount " Datasets, at " (Format (JDate "now") "yyyy/mm/dd hh:mm:ss") ) ) (Set lDataCount 0) (For lDSNCounter = 0 to 199 (Set lCurDataSet (DataFile aWDMFileObject Data DSN (+ (* lDSNCounter 50) 1))) (If (> (Len (DataTSer lCurDataSet Values)) 0) (+= lDataCount 1) (+= lCurRow 1) (Grid 1 lCurRow (Format (DataTSer lCurDataSet Attrib "DESC") lSpace15)) (For i = 1 to (Len aConstituents) (Set lCurConstituent (ArrayItem aConstituents i)) (Set lCurDSN (* lDSNCounter 50)) (Set lSkip "False") (Set lDSNExtension (ArrayItem aConsDSNs i)) (Select lCurConstituent (Case "DO" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Case "WTemp" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Case "Fecal" (Set lNumFormat "###########0") (Set lMeanType "GEOMETRIC MEAN")) (Case "TP" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Case "TSS" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Case "NH3" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Case "NO2/NO3" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Case "Lead" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Case "Zinc" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Case "BOD" (Set lNumFormat "####0.00") (Set lMeanType "MEAN")) (Else (Set lSkip "True")) ) (If (= lSkip "False") (+= lCurDSN lDSNExtension) (Set lCurDataSet (DataFile aWDMFileObject Data DSN lCurDSN)) (Set lCurDataSet (DataTSer lCurDataSet Aggregate "day" 1 "ave")) (Set lCurDataSet (DataTSer lCurDataSet Math "max" 0.01)) (Grid (+ 2 (* (- i 1) 4)) lCurRow (Format (DataTSer lCurDataSet Attrib "MIN") lNumFormat)) (Grid (+ 3 (* (- i 1) 4)) lCurRow (Format (DataTSer lCurDataSet Attrib "MAX") lNumFormat)) (Grid (+ 4 (* (- i 1) 4)) lCurRow (Format (DataTSer lCurDataSet Attrib lMeanType) lNumFormat)) (Grid (+ 5 (* (- i 1) 4)) lCurRow (Format (DataTSer lCurDataSet Attrib "STDDEVIATION") lNumFormat)) (Else (Grid (+ 2 (* (- i 1) 4)) lCurRow (Format "No CONS" (* " " (Len lNumFormat)))) (Grid (+ 3 (* (- i 1) 4)) lCurRow (Format "No CONS" (* " " (Len lNumFormat)))) (Grid (+ 4 (* (- i 1) 4)) lCurRow (Format "No CONS" (* " " (Len lNumFormat)))) (Grid (+ 5 (* (- i 1) 4)) lCurRow (Format "No CONS" (* " " (Len lNumFormat)))) ) ) ) ) ) (AppendFile (+ lProjectDir aStatusFile) (+ CRLF "Finish File " lFile ", " lDataCount " locations, at " (Format (JDate "now") "yyyy/mm/dd hh:mm:ss"))) (DataFile aWDMFileObject Clear) ) (Set lReportString (Grid "AsString" (Chr 9) CRLF " ")) (Return lReportString) (Unset lReportString) (Unset lSpace8) (Unset lSpace12) (Unset lSpace15) (Unset lCurRow) (Unset lString) (Unset lCurDataSet) (Unset lNextRow) (Unset lNextRow2) (Unset lFile) (Unset lFiles) )