From: <rit...@us...> - 2010-06-21 04:56:54
|
Revision: 13 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=13&view=rev Author: ritacsiro Date: 2010-06-21 04:56:47 +0000 (Mon, 21 Jun 2010) Log Message: ----------- ANDSWRON-663 - Rename of lat and lon variables plus add a long_name. Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-18 05:23:03 UTC (rev 12) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-21 04:56:47 UTC (rev 13) @@ -147,22 +147,24 @@ private static final String TIME_BOUNDS = "time_bnds"; // longitude constants - private static final String LONG = "long"; + private static final String LONG = "longitude"; private static final int LONG_COLUMN_INDEX = 1; private static final String LONG_RANGE = "0-296"; private static final int LONG_SIZE = 297; private static final String LONG_UNITS = "degrees_east"; private static final String LONG_STANDARD_NAME = "longitude"; private static final String LONG_AXIS = "X"; + private static final String LONG_LONG_NAME = "longitude"; // latitude constants - private static final String LAT = "lat"; + private static final String LAT = "latitude"; private static final int LAT_COLUMN_INDEX = 2; private static final String LAT_RANGE = "0-278"; private static final int LAT_SIZE = 279; private static final String LAT_UNITS = "degrees_north"; private static final String LAT_STANDARD_NAME = "latitude"; private static final String LAT_AXIS = "Y"; + private static final String LAT_LONG_NAME = "latitude"; // elevation constants private static String ELEVATION = "elev"; @@ -570,10 +572,10 @@ NcDefineVariable command = new NcDefineVariable(); command.execute(new File(outputFileName), LAT, DataType.FLOAT, Arrays.asList(new Attribute("units", LAT_UNITS), - new Attribute("standard_name", LAT_STANDARD_NAME), new Attribute("axis", LAT_AXIS)), LAT, + new Attribute("long_name", LAT_LONG_NAME), new Attribute("standard_name", LAT_STANDARD_NAME), new Attribute("axis", LAT_AXIS)), LAT, false /* isLargeFileSupport */, false/* fillValue */); command.execute(new File(outputFileName), LONG, DataType.FLOAT, Arrays.asList( - new Attribute("units", LONG_UNITS), new Attribute("standard_name", LONG_STANDARD_NAME), new Attribute( + new Attribute("long_name", LONG_LONG_NAME), new Attribute("units", LONG_UNITS), new Attribute("standard_name", LONG_STANDARD_NAME), new Attribute( "axis", LONG_AXIS)), LONG, false /* isLargeFileSupport */, false/* fillValue */); command.execute(new File(outputFileName), TIME, DataType.INT, Arrays.asList(new Attribute("units", TIME_UNITS), new Attribute("long_name", TIME_LONG_NAME), new Attribute("standard_name", TIME_STANDARD_NAME), Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-18 05:23:03 UTC (rev 12) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-21 04:56:47 UTC (rev 13) @@ -137,23 +137,25 @@ private static final String TIME_BOUNDS = "time_bnds"; // longitude constants - private static final String LONG = "long"; + private static final String LONG = "longitude"; private static final int LONG_COLUMN_INDEX = 1; private static final String LONG_RANGE = "0-296"; private static final int LONG_SIZE = 297; private static final String LONG_UNITS = "degrees_east"; private static final String LONG_STANDARD_NAME = "longitude"; private static final String LONG_AXIS = "X"; + private static final String LONG_LONG_NAME = "longitude"; // latitude constants - private static final String LAT = "lat"; + private static final String LAT = "latitude"; private static final int LAT_COLUMN_INDEX = 2; private static final String LAT_RANGE = "0-278"; private static final int LAT_SIZE = 279; private static final String LAT_UNITS = "degrees_north"; private static final String LAT_STANDARD_NAME = "latitude"; private static final String LAT_AXIS = "Y"; - + private static final String LAT_LONG_NAME = "latitude"; + // elevation constants private static String ELEVATION = "elev"; private static int ELEVATION_COLUMN_INDEX = 3; @@ -570,10 +572,10 @@ NcDefineVariable command = new NcDefineVariable(); command.execute(new File(outputFileName), LAT, DataType.FLOAT, Arrays.asList(new Attribute("units", LAT_UNITS), - new Attribute("standard_name", LAT_STANDARD_NAME), new Attribute("axis", LAT_AXIS)), LAT, + new Attribute("long_name", LAT_LONG_NAME), new Attribute("standard_name", LAT_STANDARD_NAME), new Attribute("axis", LAT_AXIS)), LAT, false /* isLargeFileSupport */, false/* fillValue */); command.execute(new File(outputFileName), LONG, DataType.FLOAT, Arrays.asList( - new Attribute("units", LONG_UNITS), new Attribute("standard_name", LONG_STANDARD_NAME), new Attribute( + new Attribute("long_name", LONG_LONG_NAME), new Attribute("units", LONG_UNITS), new Attribute("standard_name", LONG_STANDARD_NAME), new Attribute( "axis", LONG_AXIS)), LONG, false /* isLargeFileSupport */, false/* fillValue */); command.execute(new File(outputFileName), TIME, DataType.INT, Arrays.asList(new Attribute("units", TIME_UNITS), new Attribute("long_name", TIME_LONG_NAME), new Attribute("standard_name", TIME_STANDARD_NAME), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2010-06-23 00:02:19
|
Revision: 21 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=21&view=rev Author: ritacsiro Date: 2010-06-23 00:02:13 +0000 (Wed, 23 Jun 2010) Log Message: ----------- ANDSWRON-667 - Update file naming scheme. Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-22 23:14:22 UTC (rev 20) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-23 00:02:13 UTC (rev 21) @@ -211,7 +211,7 @@ */ @SuppressWarnings("static-access") public static void main(String[] args) throws Exception - { + { Options options = new Options(); try { @@ -1215,7 +1215,7 @@ { filename += CASE + "."; } - filename += "Latitude-(" + latitudeDegree + ")S-" + variable + NETCDF_FILE_EXTENSION; + filename += "Latitude-" + latitudeDegree + "S.S-" + variable + NETCDF_FILE_EXTENSION; return filename; } @@ -1230,7 +1230,7 @@ { filename += CASE + "."; } - filename += "Decade-(" + decadeStr + ")-" + variable + NETCDF_FILE_EXTENSION; + filename += "Decade-" + decadeStr + "S.S-" + variable + NETCDF_FILE_EXTENSION; return filename; } Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-22 23:14:22 UTC (rev 20) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-23 00:02:13 UTC (rev 21) @@ -1213,7 +1213,7 @@ { filename += CASE + "."; } - filename += "Latitude-(" + latitudeDegree + ")S-" + variable + NETCDF_FILE_EXTENSION; + filename += "Latitude-" + latitudeDegree + "S.S-" + variable + NETCDF_FILE_EXTENSION; return filename; } @@ -1228,7 +1228,7 @@ { filename += CASE + "."; } - filename += "Decade-(" + decadeStr + ")-" + variable + NETCDF_FILE_EXTENSION; + filename += "Decade-" + decadeStr + "S.S-" + variable + NETCDF_FILE_EXTENSION; return filename; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2010-06-23 06:17:14
|
Revision: 26 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=26&view=rev Author: jdempsey Date: 2010-06-23 06:17:07 +0000 (Wed, 23 Jun 2010) Log Message: ----------- ANDSWRON-662 - Correct type of _FillValue and missing_value variable attributes Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-23 05:14:03 UTC (rev 25) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-23 06:17:07 UTC (rev 26) @@ -623,11 +623,12 @@ command .execute(new File(outputFileName), variableNames[variableIndex], variableDataTypes[variableIndex], Arrays.asList(new Attribute("units", variableUnits[variableIndex]), new Attribute("long_name", - variableLongNames[variableIndex]), new Attribute("missing_value", - variableMissingValues[variableIndex]), new Attribute("_FillValue", - variableFillValues[variableIndex]), new Attribute("valid_min", - variableMinValues[variableIndex]), new Attribute("valid_max", - variableMaxValues[variableIndex])), dimensions, false /* isLargeFileSupport */, false/* fillValue */); + variableLongNames[variableIndex]), new Attribute("missing_value", Float + .valueOf(variableMissingValues[variableIndex])), new Attribute("_FillValue", Float + .valueOf(variableFillValues[variableIndex])), new Attribute("valid_min", Float + .valueOf(variableMinValues[variableIndex])), new Attribute("valid_max", Float + .valueOf(variableMaxValues[variableIndex]))), dimensions, + false /* isLargeFileSupport */, false/* fillValue */); } /** Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-23 05:14:03 UTC (rev 25) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-23 06:17:07 UTC (rev 26) @@ -620,12 +620,12 @@ throws IllegalArgumentException, IOException, ParseException { NcDefineVariable command = new NcDefineVariable(); - command - .execute(new File(outputFileName), variableNames[variableIndex], variableDataTypes[variableIndex], - Arrays.asList(new Attribute("units", variableUnits[variableIndex]), new Attribute("long_name", - variableLongNames[variableIndex]), new Attribute("missing_value", - variableMissingValues[variableIndex]), new Attribute("_FillValue", - variableFillValues[variableIndex])), dimensions, false /* isLargeFileSupport */, false/* fillValue */); + command.execute(new File(outputFileName), variableNames[variableIndex], variableDataTypes[variableIndex], + Arrays.asList(new Attribute("units", variableUnits[variableIndex]), new Attribute("long_name", + variableLongNames[variableIndex]), new Attribute("missing_value", Float + .valueOf(variableMissingValues[variableIndex])), new Attribute("_FillValue", Float + .valueOf(variableFillValues[variableIndex]))), dimensions, false /* isLargeFileSupport */, + false/* fillValue */); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2010-06-25 11:30:18
|
Revision: 61 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=61&view=rev Author: jdempsey Date: 2010-06-25 11:30:12 +0000 (Fri, 25 Jun 2010) Log Message: ----------- ANDSWRON-664 - Add time_bnds variable Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-25 04:37:57 UTC (rev 60) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-25 11:30:12 UTC (rev 61) @@ -368,7 +368,7 @@ for (int i = 0; i < filenames.length; i++) { filenames[i] = this.generateLatitudeFilename(latitudeDegree, variableNames[i]); - this.createVariableFile(filenames[i], Arrays.asList(LAT, LONG, TIME, NV), i, TIME_SIZE, blockLatSize, + this.createVariableFile(filenames[i], Arrays.asList(LAT, LONG, TIME), i, TIME_SIZE, blockLatSize, blockLongSize); this.fillCoordinateVariables(filenames[i], sortedLongitudes, sortedLatitudes, dates, blockLatRange, blockLongRange, TIME_RANGE); @@ -425,6 +425,10 @@ int blockTimeSize = dates.size(); String blockTimeRange = "0-" + String.valueOf(dates.size() - 1); +// if (decadeKey > 189) +// { +// continue; +// } // create file names String decadeStr = String.valueOf(decadeKey + "0"); @@ -435,7 +439,7 @@ filenames[i] = this.generateDecadeFilename(decadeStr, variableNames[i]); if ("".equals(startingLatitude)) { - this.createVariableFile(filenames[i], Arrays.asList(TIME, LAT, LONG, NV), i, blockTimeSize, + this.createVariableFile(filenames[i], Arrays.asList(TIME, LAT, LONG), i, blockTimeSize, LAT_SIZE, LONG_SIZE); this.fillCoordinateVariables(filenames[i], sortedLongitudes, sortedLatitudes, dates, blockLatRange, blockLongRange, blockTimeRange); @@ -562,11 +566,10 @@ { command.execute(outputFileName, LONG, blockLongSize, false /* isUnlimited */, false/* fillValue */); } - else if (dimName.equals(NV)) - { - command.execute(outputFileName, NV, NV_SIZE, false /* isUnlimited */, false/* fillValue */); - } } + + // Add NV as the final dimension + command.execute(outputFileName, NV, NV_SIZE, false /* isUnlimited */, false/* fillValue */); } /** @@ -707,7 +710,7 @@ .toString().getBytes(ENCODING)), false); // /////////////////////////////////////////////////////////////////////////////////////////// - // File time_bnds variable + // Fill time_bnds variable StringBuffer timeBoundsStringBuffer = new StringBuffer(); timeBoundsStringBuffer.append(dates.get(0)).append(System.getProperty("line.separator")); timeBoundsStringBuffer.append(dates.get(dates.size()-1)).append(System.getProperty("line.separator")); Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-25 04:37:57 UTC (rev 60) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-25 11:30:12 UTC (rev 61) @@ -155,7 +155,12 @@ private static final String LAT_STANDARD_NAME = "latitude"; private static final String LAT_AXIS = "Y"; private static final String LAT_LONG_NAME = "latitude"; - + + // num values constants + private static final String NV = "nv"; + private static final String NV_RANGE = "0-1"; + private static final int NV_SIZE = 2; + // elevation constants private static String ELEVATION = "elev"; private static int ELEVATION_COLUMN_INDEX = 3; @@ -556,6 +561,9 @@ command.execute(outputFileName, LONG, blockLongSize, false /* isUnlimited */, false/* fillValue */); } } + + // Add NV as the final dimension + command.execute(outputFileName, NV, NV_SIZE, false /* isUnlimited */, false/* fillValue */); } /** @@ -581,6 +589,9 @@ new Attribute("long_name", TIME_LONG_NAME), new Attribute("standard_name", TIME_STANDARD_NAME), new Attribute("axis", TIME_AXIS), new Attribute("calendar", TIME_CALENDAR), new Attribute("bounds", TIME_BOUNDS)), TIME, false /* isLargeFileSupport */, false/* fillValue */); + command.execute(new File(outputFileName), TIME_BOUNDS, DataType.INT, Arrays.asList(new Attribute("units", + TIME_UNITS), new Attribute("calendar", TIME_CALENDAR)), NV, false /* isLargeFileSupport */, + false/* fillValue */); } /** @@ -688,6 +699,17 @@ // call command to actually perform fill the file command.execute(new File(outputFileName), TIME, timeRange, new ByteArrayInputStream(dateStringBuffer .toString().getBytes(ENCODING)), false); + + // /////////////////////////////////////////////////////////////////////////////////////////// + // Fill time_bnds variable + StringBuffer timeBoundsStringBuffer = new StringBuffer(); + timeBoundsStringBuffer.append(dates.get(0)).append(System.getProperty("line.separator")); + timeBoundsStringBuffer.append(dates.get(dates.size()-1)).append(System.getProperty("line.separator")); + + // call command to actually perform fill the file + command.execute(new File(outputFileName), TIME_BOUNDS, NV_RANGE, new ByteArrayInputStream( + timeBoundsStringBuffer.toString().getBytes(ENCODING)), false); + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2010-06-25 11:58:51
|
Revision: 62 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=62&view=rev Author: jdempsey Date: 2010-06-25 11:58:44 +0000 (Fri, 25 Jun 2010) Log Message: ----------- ANDSWRON-715 - Add indicator for Variable in file name Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-25 11:30:12 UTC (rev 61) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-25 11:58:44 UTC (rev 62) @@ -1244,7 +1244,16 @@ { filename += CASE + "."; } - filename += "Latitude-" + latitudeDegree + "S.S-" + variable + NETCDF_FILE_EXTENSION; + filename += "Latitude-"; + if (latitudeDegree.startsWith("-")) + { + filename += latitudeDegree.substring(1) + "S."; + } + else + { + filename += latitudeDegree + "N"; + } + filename += "Var-" + variable + NETCDF_FILE_EXTENSION; return filename; } @@ -1259,7 +1268,7 @@ { filename += CASE + "."; } - filename += "Decade-" + decadeStr + "S.S-" + variable + NETCDF_FILE_EXTENSION; + filename += "Decade-" + decadeStr + ".Var-" + variable + NETCDF_FILE_EXTENSION; return filename; } Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-25 11:30:12 UTC (rev 61) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-25 11:58:44 UTC (rev 62) @@ -1235,7 +1235,16 @@ { filename += CASE + "."; } - filename += "Latitude-" + latitudeDegree + "S.S-" + variable + NETCDF_FILE_EXTENSION; + filename += "Latitude-"; + if (latitudeDegree.startsWith("-")) + { + filename += latitudeDegree.substring(1) + "S."; + } + else + { + filename += latitudeDegree + "N"; + } + filename += "Var-" + variable + NETCDF_FILE_EXTENSION; return filename; } @@ -1250,7 +1259,7 @@ { filename += CASE + "."; } - filename += "Decade-" + decadeStr + "S.S-" + variable + NETCDF_FILE_EXTENSION; + filename += "Decade-" + decadeStr + ".Var-" + variable + NETCDF_FILE_EXTENSION; return filename; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rob...@us...> - 2010-06-28 00:23:06
|
Revision: 63 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=63&view=rev Author: robertbridle Date: 2010-06-28 00:22:57 +0000 (Mon, 28 Jun 2010) Log Message: ----------- ANDSWRON-664 - Review - Add period after degrees "N" when creating filenames for split by latitude. Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-25 11:58:44 UTC (rev 62) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-28 00:22:57 UTC (rev 63) @@ -1251,7 +1251,7 @@ } else { - filename += latitudeDegree + "N"; + filename += latitudeDegree + "N."; } filename += "Var-" + variable + NETCDF_FILE_EXTENSION; return filename; Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-25 11:58:44 UTC (rev 62) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-06-28 00:22:57 UTC (rev 63) @@ -1242,7 +1242,7 @@ } else { - filename += latitudeDegree + "N"; + filename += latitudeDegree + "N."; } filename += "Var-" + variable + NETCDF_FILE_EXTENSION; return filename; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2010-07-07 00:21:50
|
Revision: 65 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=65&view=rev Author: jdempsey Date: 2010-07-07 00:21:41 +0000 (Wed, 07 Jul 2010) Log Message: ----------- ANDSWRON-668 - Update metadata to match CF Conventions Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-07-05 04:25:18 UTC (rev 64) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-07-07 00:21:41 UTC (rev 65) @@ -14,9 +14,6 @@ * limitations under the License. */ -/** - * - */ package au.csiro.netcdf.wron; import java.io.BufferedReader; @@ -30,7 +27,9 @@ import java.io.RandomAccessFile; import java.io.StringWriter; import java.io.UnsupportedEncodingException; +import java.text.DateFormat; import java.text.NumberFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -138,7 +137,7 @@ // time constants private static final String TIME = "time"; private static final String TIME_RANGE = "0-43097"; - private static final int TIME_SIZE = 43098; + private static final int TIME_SIZE = 43098; // 365 private static final String TIME_LONG_NAME = "reference time"; private static final String TIME_STANDARD_NAME = "time"; private static final String TIME_UNITS = "days since 1889-01-01 0:0:0"; @@ -174,18 +173,22 @@ // elevation constants private static String ELEVATION = "elev"; private static int ELEVATION_COLUMN_INDEX = 3; - private static final String ELEVATION_UNITS = "metres above Sea level"; - private static final String ELEVATION_STANDARD_NAME = "Elevation"; + private static final String ELEVATION_UNITS = "m"; + private static final String ELEVATION_STANDARD_NAME = "altitude"; + private static final String ELEVATION_LONG_NAME = "Elevation above sea level"; + private static final float ELEVATION_MISSING_VALUE = -999.99f; // catchment id constants private static String CATCHMENT_ID = "catchmentId"; private static int CATCHMENT_ID_COLUMN_INDEX = 4; - private static final String CATCHMENT_ID_STANDARD_NAME = "MDB Catchment Id"; + private static final String CATCHMENT_ID_LONG_NAME = "MDB Catchment Id"; + private static final float CATCHMENT_ID_MISSING_VALUE = 0f; // reporting region id constants private static String REPORTING_REGION = "repRegionId"; private static int REPORTING_REGION_ID_COLUMN_INDEX = 5; - private static String REPORTING_REGION_STANDARD_NAME = "MDB Reporting Region Id"; + private static String REPORTING_REGION_LONG_NAME = "MDB Reporting Region Id"; + private static final float REPORTING_REGION_MISSING_VALUE = 0f; // cell id private static final int CELL_ID_COLUMN_INDEX = 0; @@ -520,8 +523,9 @@ this.defineSpatialVariables(outputFileName); // Add attributes - Attribute converter = new Attribute("Converted to netCDF by", - "$Id: MdbsyScenarioAConverter.java 7155 2010-06-10 02:51:25Z dem040 $"); + DateFormat utcDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + Attribute converter = new Attribute("History", utcDateTime.format(new Date()) + " Converted to netCDF by " + + "$Id: MdbsyScenarioAConverter.java 7155 2010-06-10 02:51:25Z dem040 $"); List<Attribute> globalAttrs = new ArrayList<Attribute>(); globalAttrs.add(converter); if (METADATA_FILE.length() > 0) @@ -595,9 +599,8 @@ new Attribute("long_name", TIME_LONG_NAME), new Attribute("standard_name", TIME_STANDARD_NAME), new Attribute("axis", TIME_AXIS), new Attribute("calendar", TIME_CALENDAR), new Attribute("bounds", TIME_BOUNDS)), TIME, false /* isLargeFileSupport */, false/* fillValue */); - command.execute(new File(outputFileName), TIME_BOUNDS, DataType.INT, Arrays.asList(new Attribute("units", - TIME_UNITS), new Attribute("calendar", TIME_CALENDAR)), NV, false /* isLargeFileSupport */, - false/* fillValue */); + command.execute(new File(outputFileName), TIME_BOUNDS, DataType.INT, new ArrayList<Attribute>(), TIME + " " + + NV, false /* isLargeFileSupport */, false/* fillValue */); } /** @@ -614,14 +617,14 @@ String spatialDim = LAT + " " + LONG; command.execute(new File(outputFileName), ELEVATION, DataType.FLOAT, Arrays.asList(new Attribute("units", - ELEVATION_UNITS), new Attribute("standard_name", ELEVATION_STANDARD_NAME)), spatialDim, - false /* isLargeFileSupport */, false/* fillValue */); + ELEVATION_UNITS), new Attribute("standard_name", ELEVATION_STANDARD_NAME), new Attribute("long_name", + ELEVATION_LONG_NAME), new Attribute("missing_value", ELEVATION_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); command .execute(new File(outputFileName), CATCHMENT_ID, DataType.FLOAT, Arrays.asList(new Attribute( - "standard_name", CATCHMENT_ID_STANDARD_NAME)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); + "long_name", CATCHMENT_ID_LONG_NAME), new Attribute("missing_value", CATCHMENT_ID_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); command .execute(new File(outputFileName), REPORTING_REGION, DataType.FLOAT, Arrays.asList(new Attribute( - "standard_name", REPORTING_REGION_STANDARD_NAME)), spatialDim, false /* isLargeFileSupport */, + "long_name", REPORTING_REGION_LONG_NAME), new Attribute("missing_value", REPORTING_REGION_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); } @@ -698,25 +701,30 @@ .toString().getBytes(ENCODING)), false); // /////////////////////////////////////////////////////////////////////////////////////////// - // fill time variable + // fill time and time_bnds variables + StringBuffer timeBoundsStringBuffer = new StringBuffer(); StringBuffer dateStringBuffer = new StringBuffer(); + boolean first = true; for (String date : dates) { dateStringBuffer.append(date).append(System.getProperty("line.separator")); + if (!first) + { + timeBoundsStringBuffer.append(date).append(System.getProperty("line.separator")); + } + timeBoundsStringBuffer.append(date).append(System.getProperty("line.separator")); + first = false; } + int dayAfterLastDay = Integer.parseInt(dates.get(dates.size()-1)) +1; + String finalString = String.valueOf(dayAfterLastDay); + timeBoundsStringBuffer.append(finalString).append(System.getProperty("line.separator")); // call command to actually perform fill the file command.execute(new File(outputFileName), TIME, timeRange, new ByteArrayInputStream(dateStringBuffer .toString().getBytes(ENCODING)), false); - // /////////////////////////////////////////////////////////////////////////////////////////// - // Fill time_bnds variable - StringBuffer timeBoundsStringBuffer = new StringBuffer(); - timeBoundsStringBuffer.append(dates.get(0)).append(System.getProperty("line.separator")); - timeBoundsStringBuffer.append(dates.get(dates.size()-1)).append(System.getProperty("line.separator")); - // call command to actually perform fill the file - command.execute(new File(outputFileName), TIME_BOUNDS, NV_RANGE, new ByteArrayInputStream( + command.execute(new File(outputFileName), TIME_BOUNDS, timeRange+","+NV_RANGE, new ByteArrayInputStream( timeBoundsStringBuffer.toString().getBytes(ENCODING)), false); } Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-07-05 04:25:18 UTC (rev 64) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-07-07 00:21:41 UTC (rev 65) @@ -14,9 +14,6 @@ * limitations under the License. */ -/** - * - */ package au.csiro.netcdf.wron; import java.io.BufferedReader; @@ -30,7 +27,9 @@ import java.io.RandomAccessFile; import java.io.StringWriter; import java.io.UnsupportedEncodingException; +import java.text.DateFormat; import java.text.NumberFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -75,7 +74,7 @@ * Copyright 2010, CSIRO Australia * All rights reserved. * - * @author $Author: dem040 $ on 17/04/2010 + * @author Robert Bridle on 17/04/2010 * @version $Revision: 7155 $ $Date: 2010-06-10 12:51:25 +1000 (Thu, 10 Jun 2010) $ */ public class MdbsyScenarioCConverter @@ -164,18 +163,19 @@ // elevation constants private static String ELEVATION = "elev"; private static int ELEVATION_COLUMN_INDEX = 3; - private static final String ELEVATION_UNITS = "metres above Sea level"; - private static final String ELEVATION_STANDARD_NAME = "Elevation"; + private static final String ELEVATION_UNITS = "m"; + private static final String ELEVATION_STANDARD_NAME = "altitude"; + private static final String ELEVATION_LONG_NAME = "Elevation above sea level"; // catchment id constants private static String CATCHMENT_ID = "catchmentId"; private static int CATCHMENT_ID_COLUMN_INDEX = 4; - private static final String CATCHMENT_ID_STANDARD_NAME = "MDB Catchment Id"; + private static final String CATCHMENT_ID_LONG_NAME = "MDB Catchment Id"; // reporting region id constants private static String REPORTING_REGION = "repRegionId"; private static int REPORTING_REGION_ID_COLUMN_INDEX = 5; - private static String REPORTING_REGION_STANDARD_NAME = "MDB Reporting Region Id"; + private static String REPORTING_REGION_LONG_NAME = "MDB Reporting Region Id"; // cell id private static final int CELL_ID_COLUMN_INDEX = 0; @@ -514,8 +514,9 @@ this.defineSpatialVariables(outputFileName); // Add attributes - Attribute converter = new Attribute("Converted to netCDF by", - "$Id: MdbsyScenarioCConverter.java 7155 2010-06-10 02:51:25Z dem040 $"); + DateFormat utcDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + Attribute converter = new Attribute("History", utcDateTime.format(new Date()) + " Converted to netCDF by " + + "$Id: MdbsyScenarioCConverter.java 7155 2010-06-10 02:51:25Z dem040 $"); List<Attribute> globalAttrs = new ArrayList<Attribute>(); globalAttrs.add(converter); if (METADATA_FILE.length() > 0) @@ -589,9 +590,8 @@ new Attribute("long_name", TIME_LONG_NAME), new Attribute("standard_name", TIME_STANDARD_NAME), new Attribute("axis", TIME_AXIS), new Attribute("calendar", TIME_CALENDAR), new Attribute("bounds", TIME_BOUNDS)), TIME, false /* isLargeFileSupport */, false/* fillValue */); - command.execute(new File(outputFileName), TIME_BOUNDS, DataType.INT, Arrays.asList(new Attribute("units", - TIME_UNITS), new Attribute("calendar", TIME_CALENDAR)), NV, false /* isLargeFileSupport */, - false/* fillValue */); + command.execute(new File(outputFileName), TIME_BOUNDS, DataType.INT, new ArrayList<Attribute>(), TIME + " " + + NV, false /* isLargeFileSupport */, false/* fillValue */); } /** @@ -608,14 +608,14 @@ String spatialDim = LAT + " " + LONG; command.execute(new File(outputFileName), ELEVATION, DataType.FLOAT, Arrays.asList(new Attribute("units", - ELEVATION_UNITS), new Attribute("standard_name", ELEVATION_STANDARD_NAME)), spatialDim, - false /* isLargeFileSupport */, false/* fillValue */); + ELEVATION_UNITS), new Attribute("standard_name", ELEVATION_STANDARD_NAME), new Attribute("long_name", + ELEVATION_LONG_NAME)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); command .execute(new File(outputFileName), CATCHMENT_ID, DataType.FLOAT, Arrays.asList(new Attribute( - "standard_name", CATCHMENT_ID_STANDARD_NAME)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); + "long_name", CATCHMENT_ID_LONG_NAME)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); command .execute(new File(outputFileName), REPORTING_REGION, DataType.FLOAT, Arrays.asList(new Attribute( - "standard_name", REPORTING_REGION_STANDARD_NAME)), spatialDim, false /* isLargeFileSupport */, + "long_name", REPORTING_REGION_LONG_NAME)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); } @@ -689,25 +689,30 @@ .toString().getBytes(ENCODING)), false); // /////////////////////////////////////////////////////////////////////////////////////////// - // fill time variable + // fill time and time_bnds variables + StringBuffer timeBoundsStringBuffer = new StringBuffer(); StringBuffer dateStringBuffer = new StringBuffer(); + boolean first = true; for (String date : dates) { dateStringBuffer.append(date).append(System.getProperty("line.separator")); + if (!first) + { + timeBoundsStringBuffer.append(date).append(System.getProperty("line.separator")); + } + timeBoundsStringBuffer.append(date).append(System.getProperty("line.separator")); + first = false; } + int dayAfterLastDay = Integer.parseInt(dates.get(dates.size()-1)) +1; + String finalString = String.valueOf(dayAfterLastDay); + timeBoundsStringBuffer.append(finalString).append(System.getProperty("line.separator")); // call command to actually perform fill the file command.execute(new File(outputFileName), TIME, timeRange, new ByteArrayInputStream(dateStringBuffer .toString().getBytes(ENCODING)), false); - // /////////////////////////////////////////////////////////////////////////////////////////// - // Fill time_bnds variable - StringBuffer timeBoundsStringBuffer = new StringBuffer(); - timeBoundsStringBuffer.append(dates.get(0)).append(System.getProperty("line.separator")); - timeBoundsStringBuffer.append(dates.get(dates.size()-1)).append(System.getProperty("line.separator")); - // call command to actually perform fill the file - command.execute(new File(outputFileName), TIME_BOUNDS, NV_RANGE, new ByteArrayInputStream( + command.execute(new File(outputFileName), TIME_BOUNDS, TIME_RANGE+","+NV_RANGE, new ByteArrayInputStream( timeBoundsStringBuffer.toString().getBytes(ENCODING)), false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2010-07-07 00:40:06
|
Revision: 66 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=66&view=rev Author: jdempsey Date: 2010-07-07 00:40:00 +0000 (Wed, 07 Jul 2010) Log Message: ----------- ANDSWRON-668 - Update metadata to match CF Conventions Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-07-07 00:21:41 UTC (rev 65) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-07-07 00:40:00 UTC (rev 66) @@ -219,7 +219,7 @@ */ @SuppressWarnings("static-access") public static void main(String[] args) throws Exception - { + { Options options = new Options(); try { @@ -618,13 +618,13 @@ String spatialDim = LAT + " " + LONG; command.execute(new File(outputFileName), ELEVATION, DataType.FLOAT, Arrays.asList(new Attribute("units", ELEVATION_UNITS), new Attribute("standard_name", ELEVATION_STANDARD_NAME), new Attribute("long_name", - ELEVATION_LONG_NAME), new Attribute("missing_value", ELEVATION_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); + ELEVATION_LONG_NAME), new Attribute("_FillValue", ELEVATION_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); command .execute(new File(outputFileName), CATCHMENT_ID, DataType.FLOAT, Arrays.asList(new Attribute( - "long_name", CATCHMENT_ID_LONG_NAME), new Attribute("missing_value", CATCHMENT_ID_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); + "long_name", CATCHMENT_ID_LONG_NAME), new Attribute("_FillValue", CATCHMENT_ID_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); command .execute(new File(outputFileName), REPORTING_REGION, DataType.FLOAT, Arrays.asList(new Attribute( - "long_name", REPORTING_REGION_LONG_NAME), new Attribute("missing_value", REPORTING_REGION_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, + "long_name", REPORTING_REGION_LONG_NAME), new Attribute("_FillValue", REPORTING_REGION_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); } @@ -1136,6 +1136,10 @@ for (CellData triple : triples) { latitudes.add(triple.getLatitude()); +// if (latitudes.size() >= LAT_SIZE) +// { +// break; +// } } return latitudes; } @@ -1152,6 +1156,10 @@ for (CellData triple : triples) { longitudes.add(triple.getLongitude()); +// if (longitudes.size() >= LONG_SIZE) +// { +// break; +// } } return longitudes; } Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-07-07 00:21:41 UTC (rev 65) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-07-07 00:40:00 UTC (rev 66) @@ -166,16 +166,19 @@ private static final String ELEVATION_UNITS = "m"; private static final String ELEVATION_STANDARD_NAME = "altitude"; private static final String ELEVATION_LONG_NAME = "Elevation above sea level"; + private static final float ELEVATION_MISSING_VALUE = -999.99f; // catchment id constants private static String CATCHMENT_ID = "catchmentId"; private static int CATCHMENT_ID_COLUMN_INDEX = 4; private static final String CATCHMENT_ID_LONG_NAME = "MDB Catchment Id"; + private static final float CATCHMENT_ID_MISSING_VALUE = 0f; // reporting region id constants private static String REPORTING_REGION = "repRegionId"; private static int REPORTING_REGION_ID_COLUMN_INDEX = 5; private static String REPORTING_REGION_LONG_NAME = "MDB Reporting Region Id"; + private static final float REPORTING_REGION_MISSING_VALUE = 0f; // cell id private static final int CELL_ID_COLUMN_INDEX = 0; @@ -609,13 +612,13 @@ String spatialDim = LAT + " " + LONG; command.execute(new File(outputFileName), ELEVATION, DataType.FLOAT, Arrays.asList(new Attribute("units", ELEVATION_UNITS), new Attribute("standard_name", ELEVATION_STANDARD_NAME), new Attribute("long_name", - ELEVATION_LONG_NAME)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); + ELEVATION_LONG_NAME), new Attribute("_FillValue", ELEVATION_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); command .execute(new File(outputFileName), CATCHMENT_ID, DataType.FLOAT, Arrays.asList(new Attribute( - "long_name", CATCHMENT_ID_LONG_NAME)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); + "long_name", CATCHMENT_ID_LONG_NAME), new Attribute("_FillValue", CATCHMENT_ID_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); command .execute(new File(outputFileName), REPORTING_REGION, DataType.FLOAT, Arrays.asList(new Attribute( - "long_name", REPORTING_REGION_LONG_NAME)), spatialDim, false /* isLargeFileSupport */, + "long_name", REPORTING_REGION_LONG_NAME), new Attribute("_FillValue", REPORTING_REGION_MISSING_VALUE)), spatialDim, false /* isLargeFileSupport */, false/* fillValue */); } @@ -712,7 +715,7 @@ .toString().getBytes(ENCODING)), false); // call command to actually perform fill the file - command.execute(new File(outputFileName), TIME_BOUNDS, TIME_RANGE+","+NV_RANGE, new ByteArrayInputStream( + command.execute(new File(outputFileName), TIME_BOUNDS, timeRange+","+NV_RANGE, new ByteArrayInputStream( timeBoundsStringBuffer.toString().getBytes(ENCODING)), false); } @@ -1124,6 +1127,10 @@ for (CellData triple : triples) { latitudes.add(triple.getLatitude()); +// if (latitudes.size() >= LAT_SIZE) +// { +// break; +// } } return latitudes; } @@ -1140,6 +1147,10 @@ for (CellData triple : triples) { longitudes.add(triple.getLongitude()); +// if (longitudes.size() >= LONG_SIZE) +// { +// break; +// } } return longitudes; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2010-07-26 05:52:00
|
Revision: 79 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=79&view=rev Author: jdempsey Date: 2010-07-26 05:51:53 +0000 (Mon, 26 Jul 2010) Log Message: ----------- ANDSWRON-791 - By latitude files do not have out of region areas set to fill values Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-07-24 06:23:13 UTC (rev 78) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-07-26 05:51:53 UTC (rev 79) @@ -383,6 +383,8 @@ this.fillCoordinateVariables(filenames[i], sortedLongitudes, sortedLatitudes, dates, blockLatRange, blockLongRange, TIME_RANGE); this.fillSpatialVariables(filenames[i], triples); + this.fillDataForLatitude(filenames[i], i, sortedLongitudes, sortedLatitudes, dates, Arrays.asList(LAT, + LONG, TIME)); } // for each cellId csv file we read, we will have available the values for both rainFall and PVET, therefore @@ -847,6 +849,39 @@ } /** + * Populate the data variable with fill values. Used to ensure cells within + * the rectangular bounds but for which we have no data are set to the fill value. + * + * @param varIndex The variable being filled + * @param sortedLongitudes The longitudes to fill. + * @param sortedLatitudes The latitudes to fill + * @param dates The dates to fill + * @param dimensionOrdering The order of the dimensions in the files + * @throws IOException If the data cannot be written + */ + private void fillDataForLatitude(String filename, int varIndex, Set<String> sortedLongitudes, Set<String> sortedLatitudes, + List<String> dates, List<String> dimensionOrdering) throws IOException + { + StringBuffer fillBlock = new StringBuffer(); + String fillLine = variableFillValues[varIndex] + "\n"; + for (int i = 0; i < dates.size(); i++) + { + fillBlock.append(fillLine); + } + + NcWriteVariable writeVarCmd = new NcWriteVariable(); + for (String latitude : sortedLatitudes) + { + for (String longitude : sortedLongitudes) + { + String fillRange = this.constructFillRange(dimensionOrdering, latitude, longitude, dates.size()); + writeVarCmd.execute(new File(filename), variableNames[varIndex], fillRange, + new ByteArrayInputStream(fillBlock.toString().getBytes(ENCODING)), false); + } + } + } + + /** * Fills the variables with data for a particular latitude. * * @param variableFileNames The filenames for this latitude for each of the variables Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-07-24 06:23:13 UTC (rev 78) +++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioCConverter.java 2010-07-26 05:51:53 UTC (rev 79) @@ -410,6 +410,8 @@ this.fillCoordinateVariables(filenames[i], sortedLongitudes, sortedLatitudes, dates, blockLatRange, blockLongRange, TIME_RANGE); this.fillSpatialVariables(filenames[i], triples); + this.fillDataForLatitude(filenames[i], i, sortedLongitudes, sortedLatitudes, dates, Arrays.asList(LAT, + LONG, TIME)); } // for each cellId csv file we read, we will have available the values for both rainFall and PVET, therefore @@ -868,6 +870,39 @@ } /** + * Populate the data variable with fill values. Used to ensure cells within + * the rectangular bounds but for which we have no data are set to the fill value. + * + * @param varIndex The variable being filled + * @param sortedLongitudes The longitudes to fill. + * @param sortedLatitudes The latitudes to fill + * @param dates The dates to fill + * @param dimensionOrdering The order of the dimensions in the files + * @throws IOException If the data cannot be written + */ + private void fillDataForLatitude(String filename, int varIndex, Set<String> sortedLongitudes, Set<String> sortedLatitudes, + List<String> dates, List<String> dimensionOrdering) throws IOException + { + StringBuffer fillBlock = new StringBuffer(); + String fillLine = variableFillValues[varIndex] + "\n"; + for (int i = 0; i < dates.size(); i++) + { + fillBlock.append(fillLine); + } + + NcWriteVariable writeVarCmd = new NcWriteVariable(); + for (String latitude : sortedLatitudes) + { + for (String longitude : sortedLongitudes) + { + String fillRange = this.constructFillRange(dimensionOrdering, latitude, longitude, dates.size()); + writeVarCmd.execute(new File(filename), variableNames[varIndex], fillRange, + new ByteArrayInputStream(fillBlock.toString().getBytes(ENCODING)), false); + } + } + } + + /** * Fills the variables with data for a particular latitude. * * @param variableFileNames The filenames for this latitude for each of the variables This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |