/// <summary> /// Write a list of StateCU_BlaneyCriddle to an opened file. </summary> /// <param name="data_Vector"> A Vector of StateCU_BlaneyCriddle to write. </param> /// <param name="out"> output PrintWriter. </param> /// <param name="props"> Properties to control the output. Currently only the /// optional Precision property can be set, indicating how many digits after the /// decimal should be printed (default is 3). </param> /// <exception cref="IOException"> if an error occurs. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private static void writeVector(java.util.List<StateCU_BlaneyCriddle> data_Vector, java.io.PrintWriter out, RTi.Util.IO.PropList props) throws java.io.IOException private static void writeVector(IList <StateCU_BlaneyCriddle> data_Vector, PrintWriter @out, PropList props) { int i, j; string cmnt = "#>"; // Missing data are handled by formatting all as strings (blank if necessary). bool version10 = false; // Indicate if old Version 10 format is written if (props == null) { props = new PropList("StateCU_BlaneyCriddle"); } string Precision = props.getValue("Precision"); string Version = props.getValue("Version"); if (!string.ReferenceEquals(Version, null) && Version.Equals("10")) { // Version 10 is an older version. version10 = true; } int Precision_int = 3; if ((!string.ReferenceEquals(Precision, null)) && StringUtil.isInteger(Precision)) { Precision_int = StringUtil.atoi(Precision); } @out.println(cmnt); @out.println(cmnt + " StateCU Blaney-Criddle Crop Coefficient (KBC) File"); @out.println(cmnt); @out.println(cmnt + " Record 1 format (a80)"); @out.println(cmnt); @out.println(cmnt + " Title remark: Title"); @out.println(cmnt); @out.println(cmnt + " Record 2 format (free format)"); @out.println(cmnt); @out.println(cmnt + " NumCurves nc: Number of crop coefficient curves"); @out.println(cmnt); @out.println(cmnt + " Record 3 format (free format)"); @out.println(cmnt); @out.println(cmnt + " ID id: Crop number (not used by StateCU)"); @out.println(cmnt + " CropName cropn: Crop name (e.g., ALFALFA)"); @out.println(cmnt + " CurveType flag: Growth curve type"); @out.println(cmnt + " Day = perennial; specify 25 values"); @out.println(cmnt + " for start, middle, end of month"); @out.println(cmnt + " Percent = annual; specify 21 values"); @out.println(cmnt + " for 0, 5, ..., 100% of season"); @out.println(cmnt); if (!version10) { // Include newer format information... @out.println(cmnt + " BCMethod ktsw: Blaney-Criddle Method"); @out.println(cmnt + " 0 = SCS Modified Blaney-Criddle"); @out.println(cmnt + " 1 = Original Blaney-Criddle"); @out.println(cmnt + " 2 = Modifed Blaney-Criddle w/ Elev. Adj."); @out.println(cmnt + " 3 = Original Blaney-Criddle w/ Elev. Adj."); @out.println(cmnt + " 4 = Pochop"); @out.println(cmnt); } @out.println(cmnt + " Record 4 format (free format)"); @out.println(cmnt); @out.println(cmnt + "Position nckca: Percent (0 to 100) of growing season for annual crop"); @out.println(cmnt + " nckcp: Day of year (1 to 366) for perennial crop"); @out.println(cmnt + "Coeff ckca: Crop coefficient for annual crop"); @out.println(cmnt + " OR ckcp: Crop coefficient for perennial crop"); @out.println(cmnt); @out.println(cmnt + "Title..."); @out.println(cmnt + "NumCurves"); @out.println(cmnt + "ID CropName CurveType"); @out.println(cmnt + "Position Coeff"); @out.println(cmnt + "----------------------------"); @out.println(cmnt + "EndHeader"); @out.println("Crop Coefficient Curves for Blaney-Criddle"); int num = 0; if (data_Vector != null) { num = data_Vector.Count; } @out.println(num); StateCU_BlaneyCriddle kbc = null; int[] nckca = null; int[] nckcp = null; double[] ckca = null; double[] ckcp = null; int size = 0; string value_format = "%9." + Precision_int + "f"; for (i = 0; i < num; i++) { kbc = (StateCU_BlaneyCriddle)data_Vector[i]; if (kbc == null) { continue; } // Just get all the data. Null arrays are used as a check // below to know what data to output... nckca = kbc.getNckca(); nckcp = kbc.getNckcp(); ckca = kbc.getCkca(); ckcp = kbc.getCkcp(); // Do not truncate the name to 20 characters if version 10 because // doing so may result in arbitrary cut of the current crop names and // result in different output from old anyhow. string name = kbc.getName(); // Since free format, the ID must always have something. If // we don't know, put -999... string id = "" + (i + 1); // Default to sequential number if (version10) { // Previously used -999 id = "-999"; } if (!StateCU_Util.isMissing(kbc.getID())) { // Changes elsewhere impact this so also use -999 unless it is a number if (StringUtil.isInteger(kbc.getID())) { id = "" + kbc.getID(); } else { id = "-999"; } // Can't use the crop name because StateCU expects a number (?) //id = kbc.getID(); } // Output based on the version because file comparisons may be done when verifying files. if (version10) { // No ktsw... @out.println(id + " " + name + " " + kbc.getFlag()); } else { // With ktsw, but OK if blank. @out.println(id + " " + name + " " + kbc.getFlag() + " " + kbc.getKtsw()); } if (nckca != null) { size = nckca.Length; } else { size = nckcp.Length; } for (j = 0; j < size; j++) { if (nckca != null) { // Print annual curve (Percent)... @out.println(StringUtil.formatString(nckca[j], "%-3d") + StringUtil.formatString(ckca[j], value_format)); } else { // Print perennial curve (Day)... @out.println(StringUtil.formatString((int)nckcp[j], "%-3d") + StringUtil.formatString(ckcp[j], value_format)); } } } }