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. |