/// <summary> /// Main constructor for this class /// </summary> /// <param name="idNumber"></param> public UsgsRatingTable(string idNumber) { this.idNumber = idNumber; // Get and assign RDB file from the web string nwisURL = "https://waterdata.usgs.gov/nwisweb/get_ratings?site_no=XXXXXXXX&file_type=exsa"; downloadURL = nwisURL.Replace("XXXXXXXX", idNumber); var newData = Web.GetPage(nwisURL.Replace("XXXXXXXX", idNumber)); if (newData.Count() == 0) { throw new Exception("NWIS data not found. Check inputs or retry later."); } webRdbTable = new TextFile(newData); webRdbTable.DeleteLine(webRdbTable.Length - 1); //last line from web is blank and the exisitng RDB does not have an empty last line // Get and assign RDB file properties this.units = webRdbTable.ReadString("LABEL=").Replace("\"", ""); this.stationName = webRdbTable.ReadString("STATION NAME=").Replace("\"", ""); this.timeZone = webRdbTable.ReadString("TIME_ZONE=").Replace("\"", ""); this.ratingTableVersion = webRdbTable.ReadString("RATING ID=").Replace("\"", ""); this.ratingTableComments = webRdbTable.ReadString("COMMENT=").Replace("\"", ""); this.ratingTableExpansion = webRdbTable.ReadString("RATING EXPANSION=").Replace("\"", ""); }
private static void RemoveExtraRows(TextFile tf) { for (int i = 0; i < tf.Length; i++) { var line = tf[i]; if (line.IndexOf("-----") >= 0 || line.Trim() == "") { tf.DeleteLine(i); } } //Station Parm Code Years for (int i = 0; i < tf.Length; i++) { var line = tf[i]; if (line.IndexOf("Parm Code") >= 0) { tf.DeleteLine(i); } } }
/// <summary> /// OwrdRatingTables constructor /// </summary> /// <param name="idNumber"></param> /// <param name="ratingTablePath"></param> public OwrdRatingTables(string idNumber) { this.stationNumber = idNumber; // Get and assign rating table file from the web string owrdURL = "http://apps.wrd.state.or.us/apps/sw/hydro_near_real_time/" + "hydro_download.aspx?dataset=RatingCurve&format=tsv&station_nbr=XXXXXXXX"; downloadURL = owrdURL.Replace("XXXXXXXX", idNumber); var newData = Web.GetPage(owrdURL.Replace("XXXXXXXX", idNumber)); if (newData.Count() == 0) { throw new Exception("OWRD data not found. Check inputs or retry later."); } rawTable = new TextFile(newData); rawTable.DeleteLine(rawTable.Length - 1); //last line from web is blank and the exisitng RDB does not have an empty last line ReadProperties(); CreateFullRatingTable(this.rawTable); }