You can subscribe to this list here.
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(56) |
Jul
(15) |
Aug
(7) |
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: <rob...@us...> - 2010-06-25 01:51:34
|
Revision: 35
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=35&view=rev
Author: robertbridle
Date: 2010-06-25 01:51:28 +0000 (Fri, 25 Jun 2010)
Log Message:
-----------
[maven-scm] copy for tag netcdf-tools-1.0.0
Added Paths:
-----------
tags/netcdf-tools-1.0.0/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-25 01:51:04
|
Revision: 34
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=34&view=rev
Author: robertbridle
Date: 2010-06-25 01:50:57 +0000 (Fri, 25 Jun 2010)
Log Message:
-----------
[maven-release-plugin] prepare release netcdf-tools-1.0.0
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-24 10:06:59 UTC (rev 33)
+++ trunk/pom.xml 2010-06-25 01:50:57 UTC (rev 34)
@@ -49,7 +49,7 @@
<groupId>net.sourceforge.netcdftools</groupId>
<artifactId>netcdf-tools</artifactId>
<packaging>jar</packaging>
- <version>0.1.4-SNAPSHOT</version>
+ <version>1.0.0</version>
<name>netcdf-tools</name>
<description>A set of tools for creating netCDF files.</description>
<url>http://netcdftools.sourceforge.net/</url>
@@ -58,9 +58,9 @@
<url>https://sourceforge.net/apps/trac/netcdftools/</url>
</issueManagement>
<scm>
- <connection>scm:svn:https://netcdftools.svn.sourceforge.net/svnroot/netcdftools/trunk</connection>
- <developerConnection>scm:svn:https://netcdftools.svn.sourceforge.net/svnroot/netcdftools/trunk/</developerConnection>
- <url>http://netcdftools.svn.sourceforge.net/viewvc/netcdftools/trunk</url>
+ <connection>scm:svn:https://netcdftools.svn.sourceforge.net/svnroot/netcdftools/tags/netcdf-tools-1.0.0</connection>
+ <developerConnection>scm:svn:https://netcdftools.svn.sourceforge.net/svnroot/netcdftools/tags/netcdf-tools-1.0.0</developerConnection>
+ <url>http://netcdftools.svn.sourceforge.net/viewvc/netcdftools/tags/netcdf-tools-1.0.0</url>
</scm>
<distributionManagement>
<site>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jde...@us...> - 2010-06-24 10:07:06
|
Revision: 33
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=33&view=rev
Author: jdempsey
Date: 2010-06-24 10:06:59 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
ANDSWRON-664 - Add time_bnds variable
Modified Paths:
--------------
trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java
Modified: trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-24 01:53:22 UTC (rev 32)
+++ trunk/src/main/java/au/csiro/netcdf/wron/MdbsyScenarioAConverter.java 2010-06-24 10:06:59 UTC (rev 33)
@@ -166,6 +166,11 @@
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;
@@ -363,7 +368,8 @@
for (int i = 0; i < filenames.length; i++)
{
filenames[i] = this.generateLatitudeFilename(latitudeDegree, variableNames[i]);
- this.createVariableFile(filenames[i], Arrays.asList(LAT, LONG, TIME), i, TIME_SIZE, blockLatSize, blockLongSize);
+ this.createVariableFile(filenames[i], Arrays.asList(LAT, LONG, TIME, NV), i, TIME_SIZE, blockLatSize,
+ blockLongSize);
this.fillCoordinateVariables(filenames[i], sortedLongitudes, sortedLatitudes, dates, blockLatRange,
blockLongRange, TIME_RANGE);
this.fillSpatialVariables(filenames[i], triples);
@@ -429,7 +435,8 @@
filenames[i] = this.generateDecadeFilename(decadeStr, variableNames[i]);
if ("".equals(startingLatitude))
{
- this.createVariableFile(filenames[i], Arrays.asList(TIME, LAT, LONG), i, blockTimeSize, LAT_SIZE, LONG_SIZE);
+ this.createVariableFile(filenames[i], Arrays.asList(TIME, LAT, LONG, NV), i, blockTimeSize,
+ LAT_SIZE, LONG_SIZE);
this.fillCoordinateVariables(filenames[i], sortedLongitudes, sortedLatitudes, dates, blockLatRange,
blockLongRange, blockTimeRange);
this.fillSpatialVariables(filenames[i], triples);
@@ -555,6 +562,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 */);
+ }
}
}
@@ -581,6 +592,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 */);
}
/**
@@ -691,6 +705,17 @@
// call command to actually perform fill the file
command.execute(new File(outputFileName), TIME, timeRange, new ByteArrayInputStream(dateStringBuffer
.toString().getBytes(ENCODING)), false);
+
+ // ///////////////////////////////////////////////////////////////////////////////////////////
+ // File 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: <rob...@us...> - 2010-06-24 01:53:28
|
Revision: 32
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=32&view=rev
Author: robertbridle
Date: 2010-06-24 01:53:22 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
ANDSWRON-659 - Use exec-maven-plugin to perform automatic upload of generated project site to SourceForge.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-24 01:51:23 UTC (rev 31)
+++ trunk/pom.xml 2010-06-24 01:53:22 UTC (rev 32)
@@ -1,3 +1,49 @@
+<!--
+
+This pom.xml has been configured with the following dependencies:
+
+1.) plink.exe has been installed - you can specify the path to the plink.exe if its not on your system path, e.g.
+
+ mvn deploy site-deploy -Dexec.executable="C:\Program Files\PLink\plink.exe"
+ mvn release:prepare release:perform -Darguments="-Dexec.executable=C:\\Program Files\\PLink\\plink.exe"
+
+2.) Our Maven settings.xml contains the credentials for: accessing SCM; running GPG (not currently used); site deployment to SourceForge; and deploying to repositories, e.g.
+
+<settings>
+ <servers>
+ <server>
+ <id>snapshots</id>
+ <username>-insert username here-</username>
+ <password>-insert password here-</password>
+ </server>
+ <server>
+ <id>release-sonatype</id>
+ <username>-insert username here-</username>
+ <password>-insert password here-</password>
+ </server>
+ <server>
+ <id>sourceforge.net</id>
+ <username>-insert username here-</username>
+ <password>-insert password here-</password>
+ </server>
+ </servers>
+ <profiles>
+ <profile>
+ <id>activeProfile</id>
+ <properties>
+ <scm.username>-insert username here-</scm.username>
+ <scm.password>-insert password here-</scm.password>
+ <gpg.keyname>-insert keyname here-</gpg.keyname>
+ <gpg.passphrase>-insert passphrase here-</gpg.passphrase>
+ </properties>
+ </profile>
+ </profiles>
+ <activeProfiles>
+ <activeProfile>activeProfile</activeProfile>
+ </activeProfiles>
+</settings>
+
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.netcdftools</groupId>
@@ -185,8 +231,8 @@
</executions>
</plugin>
- <!-- WE NO LONGER COPY THESE TO THE GENERATED SITE, WE NOW POINT THE SITE TO THE SOURCEFORGE DOWNLOAD URL -->
- <!-- Include the created artifacts in the site -->
+ <!-- WE NOW PERFORM A MANUAL FILE RELEASE TO SOURECFORGE -->
+ <!-- Include the created software artifacts in the site -->
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -249,41 +295,57 @@
</executions>
</plugin>
- <!-- WE NOW MANUALLY PERFORM A SITE DEPLOY -->
<!-- Run script to create SourceForge shell so that site can be uploaded via SCP -->
- <!-- <plugin>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
+ <!-- create a shell on SourceForge -->
<execution>
+ <id>create_shell_on_sourceforge</id>
<phase>pre-site</phase>
<goals>
<goal>exec</goal>
</goals>
+ <configuration>
+ <arguments>
+ <argument>-ssh</argument>
+ <argument>-pw</argument>
+ <argument>${scm.password}</argument>
+ <argument>-P</argument>
+ <argument>22</argument>
+ <argument>${scm.username},net...@sh...</argument>
+ <argument>create</argument>
+ </arguments>
+ </configuration>
</execution>
+ <!-- Change ownership of htdocs directory so that site can be unploaded -->
+ <execution>
+ <id>change_htdocs_ownership</id>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <arguments>
+ <argument>-ssh</argument>
+ <argument>-pw</argument>
+ <argument>${scm.password}</argument>
+ <argument>-P</argument>
+ <argument>22</argument>
+ <argument>${scm.username},net...@sh...</argument>
+ <argument>chown ${scm.username} /home/groups/n/ne/netcdftools/htdocs</argument>
+ </arguments>
+ </configuration>
+ </execution>
</executions>
- <configuration>
- <executable>plink</executable>
- <arguments>
- <argument>-ssh</argument>
- <argument>-pw</argument>
- <argument>${scm.password}</argument>
- <argument>-P</argument>
- <argument>22</argument>
- <argument>${scm.username},net...@sh...</argument>
- <argument>create</argument>
- </arguments>
- </configuration>
- </plugin> -->
+ </plugin>
<!-- 2.0-beta-9 used to overcome bug when tagging a release (http://jira.codehaus.org/browse/SCM-406) -->
<plugin>
<artifactId>maven-release-plugin</artifactId>
- <version>2.0-beta-9</version>
- <configuration>
- <goal>deploy</goal> <!-- Because we have a populated <site> element, the site-deploy goal will execute. We specify that only the deploy goal should execute, since we will perform site-deploys manually -->
- </configuration>
+ <version>2.0-beta-9</version>
</plugin>
</plugins>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-24 01:51:30
|
Revision: 31
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=31&view=rev
Author: robertbridle
Date: 2010-06-24 01:51:23 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
Removed "System.out.println" since it causes issues when running test locally.
Modified Paths:
--------------
trunk/src/test/java/au/csiro/netcdf/wron/ConversionUtilsTest.java
Modified: trunk/src/test/java/au/csiro/netcdf/wron/ConversionUtilsTest.java
===================================================================
--- trunk/src/test/java/au/csiro/netcdf/wron/ConversionUtilsTest.java 2010-06-24 01:17:12 UTC (rev 30)
+++ trunk/src/test/java/au/csiro/netcdf/wron/ConversionUtilsTest.java 2010-06-24 01:51:23 UTC (rev 31)
@@ -69,7 +69,8 @@
File testFolder = computeTestDataRoot(ConversionUtilsTest.class);
boolean result = testFolder.mkdirs();
String path = testFolder.getCanonicalPath() + File.separator;
- System.out.println("Path is " + path + " created:" + result);
+ // Removed "System.out.println" since it causes issues when running test locally.
+ //System.out.println("Path is " + path + " created:" + result);
convUtils = new ConversionUtils();
sortedLatitudes.addAll(Arrays.asList(lats));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rit...@us...> - 2010-06-24 01:17:18
|
Revision: 30
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=30&view=rev
Author: ritacsiro
Date: 2010-06-24 01:17:12 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
ANDSWRON-682 - updated code based on review comment.
Modified Paths:
--------------
trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java
Modified: trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java
===================================================================
--- trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java 2010-06-24 00:29:08 UTC (rev 29)
+++ trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java 2010-06-24 01:17:12 UTC (rev 30)
@@ -628,35 +628,46 @@
"-" + OUTPUT_FILE, NC_FILE_NAME,
"-" + ATTRIBUTES, ATTR3_NAME + "=" + ATTR3_DATA,
"-t", "float"};
+ NetcdfFile netcdfFile = null;
+ File ncFile = null;
- File ncFile = new File(NC_FILE_NAME);
- if (ncFile.exists())
+ try
{
- ncFile.delete();
+ ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ ncDefineAttr.execute(args);
+ assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
+
+ netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+ Attribute attr = netcdfFile.findGlobalAttribute(ATTR3_NAME);
+ assertTrue("The Attribute was not defined: " + ATTR3_NAME, (attr != null));
+ assertEquals("The Attrbute " + ATTR3_NAME + " had a string value. ",
+ null, attr.getStringValue());
+ assertEquals("The Attrbute had the wrong data: " + ATTR3_NAME,
+ Float.parseFloat(ATTR3_DATA), (Float)attr.getNumericValue(), 0.01f);
+
+ netcdfFile.close();
+
+ // now delete the attribute
+ args[4] = ATTR3_NAME+"="+"null";
+ ncDefineAttr.execute(args);
+ netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+
+ attr = netcdfFile.findGlobalAttribute(ATTR3_NAME);
+ assertTrue("The Attribute was not deleted: " + ATTR3_NAME, (attr == null));
}
-
- ncDefineAttr.execute(args);
- assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
-
- NetcdfFile netcdfFile = NetcdfFile.open(NC_FILE_NAME);
- Attribute attr = netcdfFile.findGlobalAttribute(ATTR3_NAME);
- assertTrue("The Attribute was not defined: " + ATTR3_NAME, (attr != null));
- assertEquals("The Attrbute " + ATTR3_NAME + " had a string value. ",
- null, attr.getStringValue());
- assertEquals("The Attrbute had the wrong data: " + ATTR3_NAME,
- Float.parseFloat(ATTR3_DATA), (Float)attr.getNumericValue(), 0.01f);
-
- netcdfFile.close();
-
- // now delete the attribute
- args[4] = ATTR3_NAME+"="+"null";
- ncDefineAttr.execute(args);
- netcdfFile = NetcdfFile.open(NC_FILE_NAME);
-
- attr = netcdfFile.findGlobalAttribute(ATTR3_NAME);
- assertTrue("The Attribute was not deleted: " + ATTR3_NAME, (attr == null));
- netcdfFile.close();
- ncFile.delete();
+ finally
+ {
+ if(netcdfFile != null && ncFile != null)
+ {
+ netcdfFile.close();
+ ncFile.delete();
+ }
+ }
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jde...@us...> - 2010-06-24 00:29:14
|
Revision: 29
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=29&view=rev
Author: jdempsey
Date: 2010-06-24 00:29:08 +0000 (Thu, 24 Jun 2010)
Log Message:
-----------
ANDSWRON-657 - Allow defineAttributes to manipulate multiple files
- Update to address review feedback and only a single file matching the pattern
Modified Paths:
--------------
trunk/USAGE.txt
trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
trunk/src/main/java/au/csiro/netcdf/util/Util.java
Added Paths:
-----------
trunk/src/test/java/au/csiro/netcdf/util/UtilTest.java
Modified: trunk/USAGE.txt
===================================================================
--- trunk/USAGE.txt 2010-06-23 08:29:49 UTC (rev 28)
+++ trunk/USAGE.txt 2010-06-24 00:29:08 UTC (rev 29)
@@ -1,19 +1,3 @@
-====
- Copyright 2010, CSIRO Australia.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-====
-
ncextractcsv
Extract a block of data from a CSV file. The data can then be piped into the
ncwritevar command to add the data to a variable in a netCDF file.
@@ -47,7 +31,7 @@
-------------------------------------
-usage: ncdefineAtt
+ncdefineAtt
Define an attribute in a netCDF file.
-o,--outputFileName <file> 1: the filename of the netCDF file to be
created.
@@ -69,10 +53,16 @@
-p,--pattern <filename pattern> 6: OPTIONAL, a pattern to match multiple
existing files, where multiple files should be
processed. If this option is present the
- outptuFilename is expected to be a direcotry
- containing the files to be processed.
+ outputFilename is expected to be a directory
+ containing the files to be processed. The
+ wildcard characters * and ? are supported but
+ may need to be escaped by a \ to avoid
+ processing by the shell. e.g. \*.nc
-v,--variable <text> 7: OPTIONAL, the variable to assign attribute(s)
to, set to define variable attribute.
+-t,--attributeDataType <text> 8: OPTIONAL, the data type of the attribute(s),
+ e.g. [byte, short, String, float, double, int,
+ char]
Example: ncdefineatt -outputFileName ABC.nc -attributes
"netCDF-Java=4.0,Conventions=value with a space,toDelete=null"
@@ -93,8 +83,8 @@
that text containing '=' or ',' characters are
delimited by a backslash.
-v,--variableName <text> 4: the name to be given to the variable.
--t,--variableDataType <text> 5: the data type of the variable, e.g. [int,
- double, char, float, short, byte]
+-t,--variableDataType <text> 5: the data type of the variable, e.g. [byte,
+ short, float, double, int, char]
-a,--variableAttributes <text> 6: a comma separated list of attribute-value
pairs, OPTIONAL, e.g. "units=mm", ensure that
text containing '=' or ',' characters are
Modified: trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-23 08:29:49 UTC (rev 28)
+++ trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-24 00:29:08 UTC (rev 29)
@@ -168,17 +168,21 @@
.getOptionValue(VARIABLE_NAME) : "";
String attributeDataTypeArg = (parsedCommandLine.hasOption(ATTRIBUTE_DATA_TYPE)) ? parsedCommandLine
.getOptionValue(ATTRIBUTE_DATA_TYPE) : "String";
+
+ List<String> targetFileNames = Util.getListOfTargetFiles(outputFilenameArg, pattern);
// check whether large file support is needed
- if (Util.fileExists(outputFilenameArg)
- && Util.getExistingFile(outputFilenameArg).length() >= MAX_32BIT_OFFSET_FILE_SIZE
- && !isLargeFileSupport)
+ for (String outputFileName : targetFileNames)
{
- throw new IllegalArgumentException("The netCDF file will be too large, please use " + IS_LARGE_FILE
- + " flag.");
+ if (Util.fileExists(outputFileName)
+ && Util.getExistingFile(outputFileName).length() >= MAX_32BIT_OFFSET_FILE_SIZE
+ && !isLargeFileSupport)
+ {
+ throw new IllegalArgumentException("The netCDF file " + outputFileName
+ + " will be too large, please use " + IS_LARGE_FILE + " flag.");
+ }
}
- List<String> targetFileNames = Util.getListOfTargetFiles(outputFilenameArg, pattern);
// check that if an input file is specified then it actually exists.
if (!inputFilenameArg.isEmpty())
@@ -217,6 +221,7 @@
for (String outputFileName : targetFileNames)
{
+ LOG.debug("Processing file : " + outputFileName);
this.execute(outputFileName, attributes, isLargeFileSupport, variableNameArg);
}
}
@@ -465,9 +470,10 @@
Option pattern = OptionBuilder.withArgName("filename pattern").hasArg().withDescription(
"6: OPTIONAL, a pattern to match multiple existing files, where multiple files should be "
- + "processed. If this option is present the outptuFilename is expected to be a direcotry "
- + "containing the files to be processed.").isRequired(false).withLongOpt(FILENAME_PATTERN)
- .create("p");
+ + "processed. If this option is present the outputFilename is expected to be a directory "
+ + "containing the files to be processed. The wildcard characters * and ? are supported but "
+ + "may need to be escaped by a \\ to avoid processing by the shell. e.g. \\*.nc ").isRequired(
+ false).withLongOpt(FILENAME_PATTERN).create("p");
Option variableName = OptionBuilder
.withArgName("text")
.hasArg()
Modified: trunk/src/main/java/au/csiro/netcdf/util/Util.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/util/Util.java 2010-06-23 08:29:49 UTC (rev 28)
+++ trunk/src/main/java/au/csiro/netcdf/util/Util.java 2010-06-24 00:29:08 UTC (rev 29)
@@ -220,6 +220,7 @@
*/
public static List<String> getListOfTargetFiles(String foldername, String pattern)
{
+ String cleanPat = pattern.replaceAll("\\\\\\*", "*").replaceAll("\\\\\\?", "?");
List<String> fileNameList = new ArrayList<String>();
if (pattern == null || pattern.length() == 0)
{
@@ -233,7 +234,7 @@
return Collections.emptyList();
}
- FileFilter patternFilter = new WildcardFileFilter(pattern);
+ FileFilter patternFilter = new WildcardFileFilter(cleanPat);
File[] files = dir.listFiles(patternFilter);
for (int i = 0; i < files.length; i++)
{
Added: trunk/src/test/java/au/csiro/netcdf/util/UtilTest.java
===================================================================
--- trunk/src/test/java/au/csiro/netcdf/util/UtilTest.java (rev 0)
+++ trunk/src/test/java/au/csiro/netcdf/util/UtilTest.java 2010-06-24 00:29:08 UTC (rev 29)
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2010, CSIRO Australia.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package au.csiro.netcdf.util;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Check the function of the Util class.
+ *
+ * @author James Dempsey on 23/06/2010
+ * @version $Revision$ $Date$
+ */
+public class UtilTest extends TestCase
+{
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ /**
+ * Test method for {@link au.csiro.netcdf.util.Util#getListOfTargetFiles(java.lang.String, java.lang.String)}.
+ */
+ public final void testGetListOfTargetFiles()
+ {
+ List<String> files = Util.getListOfTargetFiles(".", "*.txt");
+ assertNotNull("Files should be a non-empty list", files);
+ assertTrue("Files should be a non-empty list", files.size()>1);
+ boolean hasUsage = false;
+ for (String string : files)
+ {
+ if (string.endsWith("USAGE.txt"))
+ {
+ hasUsage = true;
+ }
+ }
+ assertTrue("Expected to find USAGE.txt in result set.", hasUsage);
+
+ }
+
+ /**
+ * Test method for {@link au.csiro.netcdf.util.Util#getListOfTargetFiles(java.lang.String, java.lang.String)}.
+ */
+ public final void testGetListOfTargetFilesEscaped()
+ {
+ List<String> files = Util.getListOfTargetFiles(".", "\\*.txt");
+ assertNotNull("Files should be a non-empty list", files);
+ assertTrue("Files should be a non-empty list", files.size()>1);
+ boolean hasUsage = false;
+ for (String string : files)
+ {
+ if (string.endsWith("USAGE.txt"))
+ {
+ hasUsage = true;
+ }
+ }
+ assertTrue("Expected to find USAGE.txt in result set.", hasUsage);
+
+ }
+
+}
Property changes on: trunk/src/test/java/au/csiro/netcdf/util/UtilTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Revision Date Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-23 08:29:56
|
Revision: 28
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=28&view=rev
Author: robertbridle
Date: 2010-06-23 08:29:49 +0000 (Wed, 23 Jun 2010)
Log Message:
-----------
ANDSWRON-618 - Tell release:perform to only run deploy goal instead of site-deploy.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-23 07:42:03 UTC (rev 27)
+++ trunk/pom.xml 2010-06-23 08:29:49 UTC (rev 28)
@@ -281,6 +281,9 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-9</version>
+ <configuration>
+ <goal>deploy</goal> <!-- Because we have a populated <site> element, the site-deploy goal will execute. We specify that only the deploy goal should execute, since we will perform site-deploys manually -->
+ </configuration>
</plugin>
</plugins>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-23 07:42:12
|
Revision: 27
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=27&view=rev
Author: robertbridle
Date: 2010-06-23 07:42:03 +0000 (Wed, 23 Jun 2010)
Log Message:
-----------
ANDSWRON-618 - Removed unused buildType property from pom.xml. Note: Hudson has been updated to no longer pass this property, i.e. "-DbuildType=dev"
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-23 06:17:07 UTC (rev 26)
+++ trunk/pom.xml 2010-06-23 07:42:03 UTC (rev 27)
@@ -31,7 +31,6 @@
</snapshotRepository>
</distributionManagement>
<properties>
- <buildType>dev</buildType>
<targetJdk>1.6</targetJdk>
<jar.outputDirectory>
${project.build.directory}
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: <rob...@us...> - 2010-06-23 05:14:10
|
Revision: 25
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=25&view=rev
Author: robertbridle
Date: 2010-06-23 05:14:03 +0000 (Wed, 23 Jun 2010)
Log Message:
-----------
ANDSWRON-618 - REVIEW - Fixed issue management URL and commented out maven-changes-plugin for time-being since it does not support SourceForge's Trac.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-23 05:09:11 UTC (rev 24)
+++ trunk/pom.xml 2010-06-23 05:14:03 UTC (rev 25)
@@ -9,7 +9,7 @@
<url>http://netcdftools.sourceforge.net/</url>
<issueManagement>
<system>SourceForge Trac</system>
- <url>http://sourceforge.net/tracker/?group_id=328958</url>
+ <url>https://sourceforge.net/apps/trac/netcdftools/</url>
</issueManagement>
<scm>
<connection>scm:svn:https://netcdftools.svn.sourceforge.net/svnroot/netcdftools/trunk</connection>
@@ -369,6 +369,8 @@
<range>60</range>
</configuration>
</plugin>
+ <!-- Maven changes plugin does not currently support SourceForge's Trac -->
+ <!--
<plugin>
<artifactId>maven-changes-plugin</artifactId>
<version>2.1</version>
@@ -385,6 +387,7 @@
</issueLinkTemplate>
</configuration>
</plugin>
+ -->
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.3</version>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-23 05:09:19
|
Revision: 24
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=24&view=rev
Author: robertbridle
Date: 2010-06-23 05:09:11 +0000 (Wed, 23 Jun 2010)
Log Message:
-----------
ANDSWRON-681 - 1.) Updated maven-release-plugin 2.0-beta-9 to overcome bug when tagging a release (http://jira.codehaus.org/browse/SCM-406) 2.) Updated scm plugin to 1.3 see point 1. 3.) Tidy up - removed commented out commands.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-23 02:55:17 UTC (rev 23)
+++ trunk/pom.xml 2010-06-23 05:09:11 UTC (rev 24)
@@ -35,9 +35,6 @@
<targetJdk>1.6</targetJdk>
<jar.outputDirectory>
${project.build.directory}
- <!--
- \\junk-yf\autobuild_website\netcdf-tools\dist\${buildType}
- -->
</jar.outputDirectory>
</properties>
<licenses>
@@ -74,6 +71,7 @@
<target>1.6</target>
</configuration>
</plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@@ -224,7 +222,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
- <version>1.1</version>
+ <version>1.3</version>
<configuration>
<username>${scm.username}</username>
<password>${scm.password}</password>
@@ -278,7 +276,13 @@
<argument>create</argument>
</arguments>
</configuration>
- </plugin> -->
+ </plugin> -->
+
+ <!-- 2.0-beta-9 used to overcome bug when tagging a release (http://jira.codehaus.org/browse/SCM-406) -->
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-9</version>
+ </plugin>
</plugins>
</build>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rit...@us...> - 2010-06-23 02:55:23
|
Revision: 23
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=23&view=rev
Author: ritacsiro
Date: 2010-06-23 02:55:17 +0000 (Wed, 23 Jun 2010)
Log Message:
-----------
ANDSWRON-682 - Update test cases for defineAttribute.
Modified Paths:
--------------
trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java
Modified: trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java
===================================================================
--- trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java 2010-06-23 02:23:03 UTC (rev 22)
+++ trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java 2010-06-23 02:55:17 UTC (rev 23)
@@ -29,8 +29,12 @@
import org.apache.commons.cli.Options;
+import ucar.ma2.DataType;
import ucar.nc2.Attribute;
+import ucar.nc2.Dimension;
import ucar.nc2.NetcdfFile;
+import ucar.nc2.NetcdfFileWriteable;
+import ucar.nc2.Variable;
import au.csiro.netcdf.cli.Command;
import au.csiro.netcdf.util.NetCDFUtils;
@@ -58,6 +62,19 @@
* The name of the command line option used for specifying the global attributes of a netCDF file.
*/
private static final String ATTRIBUTES = "attributes";
+
+ /**
+ * The name of the command line option used for specifying the name of the variable.
+ */
+ private static final String VARIABLE_NAME = "variable";
+
+ /** Data for the variable */
+ private static final String VARIABLE_NAME_VALUE = "myVar";
+
+ /**
+ * The testing value for the dimension option.
+ */
+ private static final String DIM_NAME = "myDimension";
/**
* The name of the netCDF file to write to.
@@ -600,4 +617,234 @@
}
}
}
+
+ /**
+ * Test delete a global attribute
+ * @throws Exception
+ */
+ public final void testDeleteGlobalAttribute() throws Exception
+ {
+ String[] args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME,
+ "-" + ATTRIBUTES, ATTR3_NAME + "=" + ATTR3_DATA,
+ "-t", "float"};
+
+ File ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ ncDefineAttr.execute(args);
+ assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
+
+ NetcdfFile netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+ Attribute attr = netcdfFile.findGlobalAttribute(ATTR3_NAME);
+ assertTrue("The Attribute was not defined: " + ATTR3_NAME, (attr != null));
+ assertEquals("The Attrbute " + ATTR3_NAME + " had a string value. ",
+ null, attr.getStringValue());
+ assertEquals("The Attrbute had the wrong data: " + ATTR3_NAME,
+ Float.parseFloat(ATTR3_DATA), (Float)attr.getNumericValue(), 0.01f);
+
+ netcdfFile.close();
+
+ // now delete the attribute
+ args[4] = ATTR3_NAME+"="+"null";
+ ncDefineAttr.execute(args);
+ netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+
+ attr = netcdfFile.findGlobalAttribute(ATTR3_NAME);
+ assertTrue("The Attribute was not deleted: " + ATTR3_NAME, (attr == null));
+ netcdfFile.close();
+ ncFile.delete();
+ }
+
+ /**
+ * Test delete a variable attribute
+ * @throws IOException
+ */
+ public final void testDeleteVariableAttribute() throws IOException
+ {
+ String[] args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME,
+ "-" + ATTRIBUTES,
+ ATTR1_NAME+"="+ATTR1_DATA,
+ "-"+VARIABLE_NAME,
+ VARIABLE_NAME_VALUE};
+ NetcdfFile netcdfFile = null;
+ File ncFile = null;
+
+ try
+ {
+ ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ // create dummy netCDF file with content.
+ createDummyNCFile(NC_FILE_NAME, DataType.CHAR);
+ assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
+
+ ncDefineAttr.execute(args);
+ netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+
+ Variable variable = netcdfFile.findVariable(VARIABLE_NAME_VALUE);
+ assertTrue("The Variable was not defined: " + VARIABLE_NAME_VALUE, (variable != null));
+
+ Attribute attr = variable.findAttribute(ATTR1_NAME);
+ assertTrue("The Attribute was not defined: " + ATTR1_NAME, (attr != null));
+ assertTrue("The Attrbute had the wrong data: " + ATTR1_NAME, attr.getStringValue().contains(
+ ATTR1_DATA));
+
+ netcdfFile.close();
+
+ // now delete the attribute
+ args[4] = ATTR1_NAME+"="+"null";
+ ncDefineAttr.execute(args);
+ netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+ variable = netcdfFile.findVariable(VARIABLE_NAME_VALUE);
+ assertTrue("The Variable was not defined: " + VARIABLE_NAME_VALUE, (variable != null));
+
+ attr = variable.findAttribute(ATTR1_NAME);
+ assertTrue("The Attribute was not deleted: " + ATTR1_NAME, (attr == null));
+
+ }catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ finally
+ {
+ if(netcdfFile != null && ncFile != null)
+ {
+ netcdfFile.close();
+ ncFile.delete();
+ }
+ }
+ }
+
+ /**
+ * Test adding attributes to an existing variable
+ *
+ * @throws IOException
+ */
+ public final void testVariableAttribute() throws IOException
+ {
+ String[] args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME,
+ "-" + ATTRIBUTES,
+ ATTR1_NAME+"="+ATTR1_DATA,
+ "-"+VARIABLE_NAME,
+ VARIABLE_NAME_VALUE};
+ NetcdfFile netcdfFile = null;
+ File ncFile = null;
+
+ try
+ {
+ ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ // create dummy netCDF file with content.
+ createDummyNCFile(NC_FILE_NAME, DataType.CHAR);
+ assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
+
+ ncDefineAttr.execute(args);
+ netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+
+ Variable variable = netcdfFile.findVariable(VARIABLE_NAME_VALUE);
+ assertTrue("The Variable was not defined: " + VARIABLE_NAME_VALUE, (variable != null));
+
+ Attribute attr = variable.findAttribute(ATTR1_NAME);
+ assertTrue("The Attribute was not defined: " + ATTR1_NAME, (attr != null));
+ assertTrue("The Attrbute had the wrong data: " + ATTR1_NAME, attr.getStringValue().contains(
+ ATTR1_DATA));
+
+ }catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ finally
+ {
+ if(netcdfFile != null && ncFile != null)
+ {
+ netcdfFile.close();
+ ncFile.delete();
+ }
+ }
+ }
+
+ /**
+ * Test adding attributes to a non-existing variable
+ *
+ * @throws Exception
+ */
+ public final void testVariableAttributeNoVar() throws Exception
+ {
+ String[] args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME };
+ try
+ {
+ File ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ ncDefineAttr.execute(args);
+ assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
+
+ // Now run a second time on the same file
+ args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME,
+ ATTR1_NAME+"="+ATTR1_DATA,
+ "-"+VARIABLE_NAME,
+ VARIABLE_NAME_VALUE};
+
+ ncDefineAttr.execute(args);
+ fail("adding attribute to non-existing variable should have failed.");
+
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected exception
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ finally
+ {
+ File ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+ }
+ }
+
+ /**
+ * Makes a dummy netCDF file with known contents.
+ */
+ private void createDummyNCFile(String outputFilename, DataType dType) throws IOException
+ {
+ NetcdfFileWriteable ncFile = null;
+
+ ncFile = NetcdfFileWriteable.createNew(outputFilename, true);
+ try
+ {
+ Dimension dimension = new Dimension(DIM_NAME, 10, true /* isShared */, false /* isUnlimited */, false /* isVariableLength */);
+ ncFile.addDimension(null, dimension);
+ ncFile.addVariable(VARIABLE_NAME_VALUE, dType, DIM_NAME);
+ ncFile.create();
+ }
+ finally
+ {
+ ncFile.close();
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jde...@us...> - 2010-06-23 02:23:09
|
Revision: 22
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=22&view=rev
Author: jdempsey
Date: 2010-06-23 02:23:03 +0000 (Wed, 23 Jun 2010)
Log Message:
-----------
ANDSWRON-690 - Add support for attributes with numeric data types
Modified Paths:
--------------
trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
trunk/src/main/java/au/csiro/netcdf/util/NetCDFUtils.java
trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java
Modified: trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-23 00:02:13 UTC (rev 21)
+++ trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-23 02:23:03 UTC (rev 22)
@@ -25,7 +25,9 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
@@ -36,6 +38,7 @@
import org.apache.commons.cli.ParseException;
import org.apache.log4j.Logger;
+import ucar.ma2.DataType;
import ucar.nc2.Attribute;
import ucar.nc2.NetcdfFileWriteable;
import ucar.nc2.Variable;
@@ -56,6 +59,8 @@
*/
public class NcDefineAttributes implements Command
{
+ private static final String NULL_VALUE = "null";
+
/**
* The command name
*/
@@ -96,12 +101,34 @@
* The pattern for accepted file names where multiple files are accepted.
*/
public static final String FILENAME_PATTERN = "pattern";
+
+ /**
+ * The name of the command line option used for specifying the data type of the attribute.
+ */
+ public static final String ATTRIBUTE_DATA_TYPE = "attributeDataType";
/**
* Constant that defines the logger to be used.
*/
private static final Logger LOG = Logger.getLogger(NcDefineAttributes.class.getName());
+
+
+ /**
+ * The only data types that can be used for attributes in netCDF v3 (classic) files.
+ */
+ private static Set<DataType> netCDF3DataTypes = new HashSet<DataType>();
+ static
+ {
+ netCDF3DataTypes.add(DataType.DOUBLE);
+ netCDF3DataTypes.add(DataType.FLOAT);
+ netCDF3DataTypes.add(DataType.INT);
+ netCDF3DataTypes.add(DataType.CHAR);
+ netCDF3DataTypes.add(DataType.SHORT);
+ netCDF3DataTypes.add(DataType.BYTE);
+ netCDF3DataTypes.add(DataType.STRING);
+ }
+
/**
* Command options
*/
@@ -139,6 +166,8 @@
.getOptionValue(FILENAME_PATTERN) : "";
String variableNameArg = (parsedCommandLine.hasOption(VARIABLE_NAME)) ? parsedCommandLine
.getOptionValue(VARIABLE_NAME) : "";
+ String attributeDataTypeArg = (parsedCommandLine.hasOption(ATTRIBUTE_DATA_TYPE)) ? parsedCommandLine
+ .getOptionValue(ATTRIBUTE_DATA_TYPE) : "String";
// check whether large file support is needed
if (Util.fileExists(outputFilenameArg)
@@ -162,9 +191,12 @@
// value is an empty list.
if(!attributesArg.isEmpty())
{
+ // try getting the variable's data type
+ DataType attributeDataType = NcDefineAttributes.mapStringToDataType(attributeDataTypeArg);
+
try
{
- attributes = NetCDFUtils.mapStringToAttributeValueList(attributesArg);
+ attributes = NetCDFUtils.mapStringToAttributeValueList(attributesArg, attributeDataType);
}
catch (IllegalArgumentException iae)
{
@@ -260,7 +292,7 @@
for(Attribute attribute : attributes)
{
// remove Attribute if the value is "null"
- if ("null".equalsIgnoreCase(attribute.getStringValue()))
+ if (NULL_VALUE.equalsIgnoreCase(attribute.getStringValue()))
{
ncfile.deleteGlobalAttribute(attribute.getName());
}
@@ -285,7 +317,7 @@
for(Attribute attribute : attributes)
{
// remove Attribute if the value is "null"
- if ("null".equalsIgnoreCase(attribute.getStringValue()))
+ if (NULL_VALUE.equalsIgnoreCase(attribute.getStringValue()))
{
variable.removeAttributeIgnoreCase(attribute.getName());
}
@@ -444,6 +476,10 @@
+ "set to define variable attribute.")
.isRequired(false).withLongOpt(VARIABLE_NAME).create("v");
+ Option attributeType = OptionBuilder.withArgName("text").hasArg().withDescription(
+ "8: OPTIONAL, the data type of the attribute(s), e.g. " + NcDefineAttributes.netCDF3DataTypes)
+ .isRequired(false).withLongOpt(ATTRIBUTE_DATA_TYPE).create("t");
+
Options options = new Options();
options.addOption(outputFileName);
@@ -453,6 +489,7 @@
options.addOption(largeFileSupport);
options.addOption(pattern);
options.addOption(variableName);
+ options.addOption(attributeType);
return options;
}
@@ -492,6 +529,8 @@
boolean isLargeFileSupport = parsedCommandLine.hasOption(IS_LARGE_FILE);
String pattern = (parsedCommandLine.hasOption(FILENAME_PATTERN)) ? parsedCommandLine
.getOptionValue(FILENAME_PATTERN) : "";
+ String variableDataTypeArg = (parsedCommandLine.hasOption(ATTRIBUTE_DATA_TYPE)) ? parsedCommandLine
+ .getOptionValue(ATTRIBUTE_DATA_TYPE) : "String";
// check whether large file support is needed
if (pattern.length() == 0 && Util.fileExists(outputFilenameArg)
@@ -537,7 +576,12 @@
+ " value is not a comma separated String of attribute-value pairs: "
+ attributesArg);
}
- }
+ }
+
+
+ // try getting the variable's data type
+ NcDefineAttributes.mapStringToDataType(variableDataTypeArg);
+
}
catch (ParseException pe)
{
@@ -550,4 +594,24 @@
return errorMsg;
}
+
+ /**
+ * Maps a <code>String</code> into a {@link DataType}.
+ *
+ * @param variableDataType
+ * a data type description.
+ * @return a {@link DataType}
+ * @throws IllegalArgumentException
+ * thrown if the <code>String</code> can not be mapped to a {@link DataType}.
+ */
+ public static DataType mapStringToDataType(String variableDataType) throws IllegalArgumentException
+ {
+ DataType dataType = DataType.getType(variableDataType);
+ if (dataType != null && netCDF3DataTypes.contains(dataType))
+ {
+ return dataType;
+ }
+ throw new IllegalArgumentException(NcDefineVariable.VARIABLE_DATA_TYPE + " value is not a valid data type: "
+ + variableDataType + ". Allowed data types are: " + netCDF3DataTypes);
+ }
}
Modified: trunk/src/main/java/au/csiro/netcdf/util/NetCDFUtils.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/util/NetCDFUtils.java 2010-06-23 00:02:13 UTC (rev 21)
+++ trunk/src/main/java/au/csiro/netcdf/util/NetCDFUtils.java 2010-06-23 02:23:03 UTC (rev 22)
@@ -27,6 +27,7 @@
import java.util.List;
import ucar.ma2.Array;
+import ucar.ma2.DataType;
import ucar.nc2.Attribute;
import ucar.nc2.Dimension;
import ucar.nc2.NetcdfFile;
@@ -46,6 +47,7 @@
/** Index value to be returned when the value cannot be found in the array */
public static final int NOT_FOUND = -1;
+ public static final String NULL_VALUE = "null";
/**
* Lookup the index of a value in a dimension. The dimension to be searched must
@@ -242,7 +244,7 @@
}
/**
- * Converts a comma separated <code>String</code> into an {@link Attribute} list.
+ * Converts a comma separated <code>String</code> into a String {@link Attribute} list.
*
* @param commaSeparatedAttributeValueString
* a list of comma separated attribute-value pairs, e.g. attribute1=value1,attribute2=value2,...
@@ -253,6 +255,22 @@
public static List<Attribute> mapStringToAttributeValueList(String commaSeparatedAttributeValueString)
throws IllegalArgumentException
{
+ return mapStringToAttributeValueList(commaSeparatedAttributeValueString, DataType.STRING);
+ }
+
+ /**
+ * Converts a comma separated <code>String</code> into an {@link Attribute} list.
+ *
+ * @param commaSeparatedAttributeValueString
+ * a list of comma separated attribute-value pairs, e.g. attribute1=value1,attribute2=value2,...
+ * @param dataType The type of attributes to be created.
+ * @return an {@link Attribute} list.
+ * @throws IllegalArgumentException
+ * thrown if the <code>String</code> can not be converted into an {@link Attribute} list.
+ */
+ public static List<Attribute> mapStringToAttributeValueList(String commaSeparatedAttributeValueString, DataType dataType)
+ throws IllegalArgumentException
+ {
List<Attribute> attributeValues = new ArrayList<Attribute>();
List<String> attributePairs = Util.tokeniseCommaSeparatedString(commaSeparatedAttributeValueString);
@@ -264,8 +282,90 @@
if (keyValuePair.length == 2 && !keyValuePair[0].isEmpty() && !keyValuePair[1].isEmpty())
{
String key = keyValuePair[0].replaceAll("\\\\,", ",").replaceAll("\\\\=", "=");
- attributeValues.add(new Attribute(key.trim(),
- keyValuePair[1].replaceAll("\\\\,", ",").replaceAll("\\\\=", "=")));
+ key = key.trim();
+ String strVal = keyValuePair[1].replaceAll("\\\\,", ",").replaceAll("\\\\=", "=");
+ Attribute attrib;
+
+ if (NULL_VALUE.equals(strVal) || dataType == DataType.STRING || dataType == DataType.CHAR)
+ {
+ attrib = new Attribute(key, strVal);
+ }
+ else if (dataType == DataType.FLOAT)
+ {
+ Float value;
+ try
+ {
+ value = Float.parseFloat(strVal);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("Invalid float value '" + strVal + "' for key "
+ + key + ".");
+ }
+ attrib = new Attribute(key, value);
+ }
+ else if (dataType == DataType.DOUBLE)
+ {
+ Double value;
+ try
+ {
+ value = Double.parseDouble(strVal);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("Invalid double value '" + strVal + "' for key "
+ + key + ".");
+ }
+ attrib = new Attribute(key, value);
+ }
+ else if (dataType == DataType.INT)
+ {
+ Integer value;
+ try
+ {
+ value = Integer.parseInt(strVal);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("Invalid integer value '" + strVal + "' for key "
+ + key + ".");
+ }
+ attrib = new Attribute(key, value);
+ }
+ else if (dataType == DataType.SHORT)
+ {
+ Short value;
+ try
+ {
+ value = Short.parseShort(strVal);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("Invalid short value '" + strVal + "' for key "
+ + key + ".");
+ }
+ attrib = new Attribute(key, value);
+ }
+ else if (dataType == DataType.BYTE)
+ {
+ Byte value;
+ try
+ {
+ value = Byte.parseByte(strVal);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("Invalid byte value '" + strVal + "' for key "
+ + key + ".");
+ }
+ attrib = new Attribute(key, value);
+ }
+ else
+ {
+ throw new IllegalArgumentException(
+ "Unexpected datatype of " + dataType + " supplied to mapStringToAttributeValueList.");
+ }
+ attributeValues.add(attrib);
}
else
{
Modified: trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java
===================================================================
--- trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java 2010-06-23 00:02:13 UTC (rev 21)
+++ trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java 2010-06-23 02:23:03 UTC (rev 22)
@@ -33,10 +33,11 @@
import ucar.nc2.NetcdfFile;
import au.csiro.netcdf.cli.Command;
import au.csiro.netcdf.util.NetCDFUtils;
+
/**
* This class is a unit test suite to verify that the NcDefineAttributes command operates correctly.
* <p>
- * Copyright 2010, CSIRO Australia All rights reserved.
+ * Copyright 2010, CSIRO Australia
*
* @author James Dempsey on 23/03/2010
* @version $Revision: 7130 $ $Date: 2010-06-09 14:23:51 +1000 (Wed, 09 Jun 2010) $
@@ -74,6 +75,12 @@
/** Data for the second Attribute */
private static final String ATTR2_DATA = "Murray Darling Basin Sustainable Yields (MDBSY)";
+
+ /** Name of the third, float, Attribute */
+ private static final String ATTR3_NAME = "Float Val";
+
+ /** Data for the third, float, Attribute */
+ private static final String ATTR3_DATA = "17.5f";
/** Name for history Attribute */
private static final String ATTR_HISTORY = "history";
@@ -299,8 +306,141 @@
}
}
+ /**
+ * Test a valid command creates a netCDF file with a float attribute
+ * @throws Exception If there is an error running the test
+ */
+ public final void testExecuteValidFloatAttr() throws Exception
+ {
+ String[] args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME,
+ "-" + ATTRIBUTES, ATTR3_NAME + "=" + ATTR3_DATA,
+ "-t", "float"};
+ File ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ ncDefineAttr.execute(args);
+ assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
+
+ NetcdfFile netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+ Attribute attr = netcdfFile.findGlobalAttribute(ATTR3_NAME);
+ assertTrue("The Attribute was not defined: " + ATTR3_NAME, (attr != null));
+ assertEquals("The Attrbute " + ATTR3_NAME + " had a string value. ",
+ null, attr.getStringValue());
+ assertEquals("The Attrbute had the wrong data: " + ATTR3_NAME,
+ Float.parseFloat(ATTR3_DATA), (Float)attr.getNumericValue(), 0.01f);
+
+ netcdfFile.close();
+ ncFile.delete();
+ }
+
/**
+ * Test a valid command creates a netCDF file with a short attribute
+ * @throws Exception If there is an error running the test
+ */
+ public final void testExecuteValidShortAttr() throws Exception
+ {
+ final String shortAttrName = "Short";
+ String[] args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME,
+ "-" + ATTRIBUTES, shortAttrName + "=57",
+ "-t", "short"};
+
+ File ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ ncDefineAttr.execute(args);
+ assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
+
+ NetcdfFile netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+ Attribute attr = netcdfFile.findGlobalAttribute(shortAttrName);
+ assertTrue("The Attribute was not defined: " + shortAttrName, (attr != null));
+ assertEquals("The Attrbute " + shortAttrName + " had a string value. ",
+ null, attr.getStringValue());
+ assertEquals("The Attrbute had the wrong data: " + shortAttrName,
+ (short) 57, (Short)attr.getNumericValue(), 0);
+
+ netcdfFile.close();
+ ncFile.delete();
+ }
+
+ /**
+ * Test a valid command creates a netCDF file with an integer attribute
+ * @throws Exception If there is an error running the test
+ */
+ public final void testExecuteValidIntAttr() throws Exception
+ {
+ final String intAttrName = "Integer";
+ final int intAttrValue = 67991082;
+ String[] args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME,
+ "-" + ATTRIBUTES, intAttrName + "=" + String.valueOf(intAttrValue),
+ "-t", "int"};
+
+ File ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ ncDefineAttr.execute(args);
+ assertTrue("The nc file was not created: " + NC_FILE_NAME, ncFile.exists());
+
+ NetcdfFile netcdfFile = NetcdfFile.open(NC_FILE_NAME);
+ Attribute attr = netcdfFile.findGlobalAttribute(intAttrName);
+ assertTrue("The Attribute was not defined: " + intAttrName, (attr != null));
+ assertEquals("The Attrbute " + intAttrName + " had a string value. ",
+ null, attr.getStringValue());
+ assertEquals("The Attrbute had the wrong data: " + intAttrName,
+ intAttrValue, (Integer)attr.getNumericValue(), 0);
+
+ netcdfFile.close();
+ ncFile.delete();
+ }
+
+ /**
+ * Test a valid command creates a netCDF file with an integer attribute
+ * @throws Exception If there is an error running the test
+ */
+ public final void testExecuteInvalidType() throws Exception
+ {
+ final String intAttrName = "Integer";
+ final int intAttrValue = 67991082;
+ String[] args = new String[] { ncDefineAttr.getCommandName(),
+ "-" + OUTPUT_FILE, NC_FILE_NAME,
+ "-" + ATTRIBUTES, intAttrName + "=" + String.valueOf(intAttrValue),
+ "-t", "integer"};
+
+ File ncFile = new File(NC_FILE_NAME);
+ if (ncFile.exists())
+ {
+ ncFile.delete();
+ }
+
+ try
+ {
+ ncDefineAttr.execute(args);
+ ncFile.delete();
+ fail("Type of integer should have been rejected.");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // We can only test the start of the message as the supported types is a set and thus the order is not deterministic
+ assertTrue("Incorrect error message", e.getMessage().startsWith("variableDataType value is not a valid data type: integer. "
+ + "Allowed data types are: ["));
+ }
+
+ }
+
+
+ /**
* Test that required options are reported if missing
*/
public final void testMissingRequiredOption()
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: <rit...@us...> - 2010-06-22 23:14:29
|
Revision: 20
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=20&view=rev
Author: ritacsiro
Date: 2010-06-22 23:14:22 +0000 (Tue, 22 Jun 2010)
Log Message:
-----------
ANDSWRON-678 - Add variable parameter to defineAttributes.
Modified Paths:
--------------
trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java
Modified: trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java
===================================================================
--- trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java 2010-06-22 07:16:36 UTC (rev 19)
+++ trunk/src/test/java/au/csiro/netcdf/TestNcDefineAttributes.java 2010-06-22 23:14:22 UTC (rev 20)
@@ -56,7 +56,7 @@
/**
* The name of the command line option used for specifying the global attributes of a netCDF file.
*/
- private static final String GLOBAL_ATTRIBUTES = "globalAttributes";
+ private static final String ATTRIBUTES = "attributes";
/**
* The name of the netCDF file to write to.
@@ -167,8 +167,8 @@
assertTrue("The following option is not recognised by the command: " + OUTPUT_FILE,
options.hasOption(OUTPUT_FILE));
- assertTrue("The following option is not recognised by the command: " + GLOBAL_ATTRIBUTES,
- options.hasOption(GLOBAL_ATTRIBUTES));
+ assertTrue("The following option is not recognised by the command: " + ATTRIBUTES,
+ options.hasOption(ATTRIBUTES));
}
@@ -212,7 +212,7 @@
{
String[] args = new String[] { ncDefineAttr.getCommandName(),
"-" + OUTPUT_FILE, NC_FILE_NAME,
- "-" + GLOBAL_ATTRIBUTES, ATTR1_NAME+"="+ATTR1_DATA };
+ "-" + ATTRIBUTES, ATTR1_NAME+"="+ATTR1_DATA };
try
{
@@ -265,7 +265,7 @@
{
String[] args = new String[] { ncDefineAttr.getCommandName(),
"-" + OUTPUT_FILE, NC_FILE_NAME,
- "-" + GLOBAL_ATTRIBUTES, ATTR1_NAME + "=" + ATTR1_DATA + "," + ATTR2_NAME + "=" + ATTR2_DATA };
+ "-" + ATTRIBUTES, ATTR1_NAME + "=" + ATTR1_DATA + "," + ATTR2_NAME + "=" + ATTR2_DATA };
try
{
@@ -306,7 +306,7 @@
public final void testMissingRequiredOption()
{
String[] args = new String[] { ncDefineAttr.getCommandName(),
- "-" + GLOBAL_ATTRIBUTES, ATTR1_NAME+"="+ATTR1_DATA };
+ "-" + ATTRIBUTES, ATTR1_NAME+"="+ATTR1_DATA };
String errors = ncDefineAttr.validCommand(args);
assertTrue("Command without output file option should return an error", !errors.isEmpty());
@@ -320,12 +320,12 @@
{
String[] args = new String[] { ncDefineAttr.getCommandName(),
"-" + OUTPUT_FILE, NC_FILE_NAME,
- "-" + GLOBAL_ATTRIBUTES, ATTR1_NAME};
+ "-" + ATTRIBUTES, ATTR1_NAME};
String errors = ncDefineAttr.validCommand(args);
assertTrue("Command with invalid attribute string should return an error", !errors.isEmpty());
assertEquals("Error string was not correct",
- "\nglobalAttributes value is not a comma separated String of attribute-value pairs: Attr1", errors);
+ "\nattributes value is not a comma separated String of attribute-value pairs: Attr1", errors);
}
/**
@@ -337,7 +337,7 @@
"-" + OUTPUT_FILE, NC_FILE_NAME};
String errors = ncDefineAttr.validCommand(args);
- assertEquals("Command with missing " + GLOBAL_ATTRIBUTES + " attribute should not return an error", "", errors);
+ assertEquals("Command with missing " + ATTRIBUTES + " attribute should not return an error", "", errors);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rit...@us...> - 2010-06-22 07:16:42
|
Revision: 19
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=19&view=rev
Author: ritacsiro
Date: 2010-06-22 07:16:36 +0000 (Tue, 22 Jun 2010)
Log Message:
-----------
ANDSWRON-678 - Add variable parameter to defineAttributes.
Modified Paths:
--------------
trunk/USAGE.txt
trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
Modified: trunk/USAGE.txt
===================================================================
--- trunk/USAGE.txt 2010-06-22 06:52:39 UTC (rev 18)
+++ trunk/USAGE.txt 2010-06-22 07:16:36 UTC (rev 19)
@@ -47,10 +47,8 @@
-------------------------------------
-ncdefineAtt
-Define a global attribute in a netCDF file.
-If variable is not specified, then a global attribute is defined.
-If the value of the attribute is null, then the attribute will be deleted.
+usage: ncdefineAtt
+Define an attribute in a netCDF file.
-o,--outputFileName <file> 1: the filename of the netCDF file to be
created.
-i,--inputFileName <file> 2. the filename of a text file containing
@@ -60,11 +58,12 @@
-s,--standardInput 3: OPTIONAL, read attributes from Stdin, ensure
that text containing '=' or ',' characters are
delimited by a backslash.
--a,--globalAttributes <text> 4: a comma separated list of attribute-value
+-a,--attributes <text> 4: a comma separated list of attribute-value
pairs, OPTIONAL, e.g. "netCDF
Java=4.0,Conventions=CF-1.0", ensure that text
containing '=' or ',' characters are delimited
- by a backslash.
+ by a backslash. Set value to null to delete
+ existing attribute.
-l,--largeFileSupport 5: OPTIONAL, set if more than 2 GB of data will
need to be stored in this file.
-p,--pattern <filename pattern> 6: OPTIONAL, a pattern to match multiple
@@ -73,7 +72,7 @@
outptuFilename is expected to be a direcotry
containing the files to be processed.
-v,--variable <text> 7: OPTIONAL, the variable to assign attribute(s)
- to.
+ to, set to define variable attribute.
Example: ncdefineatt -outputFileName ABC.nc -attributes
"netCDF-Java=4.0,Conventions=value with a space,toDelete=null"
Modified: trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-22 06:52:39 UTC (rev 18)
+++ trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-22 07:16:36 UTC (rev 19)
@@ -379,10 +379,8 @@
*/
public String toString()
{
- // generate the help/usage statement //TODO:
- String header = "Define an attribute in a netCDF file. "
- + "\nIf variable is not specified, then a global attribute is defined."
- + "\nIf the value of the attribute is null, then the attribute will be deleted.";
+ // generate the help/usage statement
+ String header = "Define an attribute in a netCDF file.";
String footer = "\nExample: ncdefineatt -outputFileName ABC.nc "
+ "-attributes \"netCDF-Java=4.0,Conventions=value with a space,toDelete=null\"\n"
+ "Will add the two and delete one listed global attributes to the file ABC.nc. "
@@ -424,7 +422,9 @@
.withArgName("text")
.hasArg()
.withDescription(
- "4: a comma separated list of attribute-value pairs, OPTIONAL, e.g. \"netCDF Java=4.0,Conventions=CF-1.0\", ensure that text containing '=' or ',' characters are delimited by a backslash.")
+ "4: a comma separated list of attribute-value pairs, OPTIONAL, e.g. \"netCDF Java=4.0,Conventions=CF-1.0\", "
+ + "ensure that text containing '=' or ',' characters are delimited by a backslash. "
+ + "Set value to null to delete existing attribute.")
.isRequired(false).withLongOpt(ATTRIBUTES).create("a");
Option largeFileSupport = OptionBuilder.withDescription(
@@ -440,7 +440,8 @@
.withArgName("text")
.hasArg()
.withDescription(
- "7: OPTIONAL, the variable to assign attribute(s) to.") //TODO wording....
+ "7: OPTIONAL, the variable to assign attribute(s) to, "
+ + "set to define variable attribute.")
.isRequired(false).withLongOpt(VARIABLE_NAME).create("v");
Options options = new Options();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rit...@us...> - 2010-06-22 06:52:46
|
Revision: 18
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=18&view=rev
Author: ritacsiro
Date: 2010-06-22 06:52:39 +0000 (Tue, 22 Jun 2010)
Log Message:
-----------
ANDSWRON-678 - Add variable parameter to defineAttributes.
Modified Paths:
--------------
trunk/USAGE.txt
trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
Modified: trunk/USAGE.txt
===================================================================
--- trunk/USAGE.txt 2010-06-22 02:24:18 UTC (rev 17)
+++ trunk/USAGE.txt 2010-06-22 06:52:39 UTC (rev 18)
@@ -49,6 +49,8 @@
ncdefineAtt
Define a global attribute in a netCDF file.
+If variable is not specified, then a global attribute is defined.
+If the value of the attribute is null, then the attribute will be deleted.
-o,--outputFileName <file> 1: the filename of the netCDF file to be
created.
-i,--inputFileName <file> 2. the filename of a text file containing
@@ -70,11 +72,13 @@
processed. If this option is present the
outptuFilename is expected to be a direcotry
containing the files to be processed.
+-v,--variable <text> 7: OPTIONAL, the variable to assign attribute(s)
+ to.
-Example: ncdefineatt -outputFileName ABC.nc -globalAttributes
-"netCDF-Java=4.0,Conventions=value with a space"
-Will add the two listed global attributes to the file ABC.nc. The file will be
-created if it doesn't already exist.
+Example: ncdefineatt -outputFileName ABC.nc -attributes
+"netCDF-Java=4.0,Conventions=value with a space,toDelete=null"
+Will add the two and delete one listed global attributes to the file ABC.nc. The
+file will be created if it doesn't already exist.
-------------------------------------
Modified: trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-22 02:24:18 UTC (rev 17)
+++ trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-22 06:52:39 UTC (rev 18)
@@ -38,13 +38,14 @@
import ucar.nc2.Attribute;
import ucar.nc2.NetcdfFileWriteable;
+import ucar.nc2.Variable;
import au.csiro.netcdf.cli.Command;
import au.csiro.netcdf.cli.CommandLineOptionsComparator;
import au.csiro.netcdf.util.NetCDFUtils;
import au.csiro.netcdf.util.Util;
/**
- * The <strong>ncdefineAtt</strong> command defines global {@link Attribute}s in a netCDF file.
+ * The <strong>ncdefineAtt</strong> command defines global or variable {@link Attribute}s in a netCDF file.
* <p>
* Copyright 2010, CSIRO Australia
* All rights reserved.
@@ -76,11 +77,16 @@
private static final String STANDARD_INPUT = "standardInput";
/**
- * The name of the command line option used for specifying the global attributes of a netCDF file.
+ * The name of the command line option used for specifying the attributes of a netCDF file.
*/
- public static final String GLOBAL_ATTRIBUTES = "globalAttributes";
+ public static final String ATTRIBUTES = "attributes";
/**
+ * The name of the command line option used for specifying the name of the variable receiving the attributes.
+ */
+ public static final String VARIABLE_NAME = "variable";
+
+ /**
* Whether the netCDF file should be written with large file support, that is, 64-bit addressing for files greater
* than 2 GB.
*/
@@ -126,11 +132,13 @@
String inputFilenameArg = (parsedCommandLine.hasOption(INPUT_FILE)) ? parsedCommandLine
.getOptionValue(INPUT_FILE) : "";
boolean isStandardInput = parsedCommandLine.hasOption(STANDARD_INPUT);
- String globalAttributesArg = (parsedCommandLine.hasOption(GLOBAL_ATTRIBUTES)) ? parsedCommandLine
- .getOptionValue(GLOBAL_ATTRIBUTES) : "";
+ String attributesArg = (parsedCommandLine.hasOption(ATTRIBUTES)) ? parsedCommandLine
+ .getOptionValue(ATTRIBUTES) : "";
boolean isLargeFileSupport = parsedCommandLine.hasOption(IS_LARGE_FILE);
String pattern = (parsedCommandLine.hasOption(FILENAME_PATTERN)) ? parsedCommandLine
.getOptionValue(FILENAME_PATTERN) : "";
+ String variableNameArg = (parsedCommandLine.hasOption(VARIABLE_NAME)) ? parsedCommandLine
+ .getOptionValue(VARIABLE_NAME) : "";
// check whether large file support is needed
if (Util.fileExists(outputFilenameArg)
@@ -149,35 +157,35 @@
Util.getExistingFile(inputFilenameArg);
}
- // try getting global attributes from the command line
- List<Attribute> globalAttributes = new ArrayList<Attribute>(); // this is non-mandatory option, its default
+ // try getting attributes from the command line
+ List<Attribute> attributes = new ArrayList<Attribute>(); // this is non-mandatory option, its default
// value is an empty list.
- if(!globalAttributesArg.isEmpty())
+ if(!attributesArg.isEmpty())
{
try
{
- globalAttributes = NetCDFUtils.mapStringToAttributeValueList(globalAttributesArg);
+ attributes = NetCDFUtils.mapStringToAttributeValueList(attributesArg);
}
catch (IllegalArgumentException iae)
{
- throw new IllegalArgumentException(NcDefineAttributes.GLOBAL_ATTRIBUTES
- + " value is not a comma separated String of attribute-value pairs: " + globalAttributesArg);
+ throw new IllegalArgumentException(NcDefineAttributes.ATTRIBUTES
+ + " value is not a comma separated String of attribute-value pairs: " + attributesArg);
}
}
// try getting variable's attributes from a file or stdin.
if (!inputFilenameArg.isEmpty())
{
- globalAttributes.addAll(NetCDFUtils.readAttributesFromStream(new FileInputStream(inputFilenameArg)));
+ attributes.addAll(NetCDFUtils.readAttributesFromStream(new FileInputStream(inputFilenameArg)));
}
if(isStandardInput)
{
- globalAttributes.addAll(NetCDFUtils.readAttributesFromStream(System.in));
+ attributes.addAll(NetCDFUtils.readAttributesFromStream(System.in));
}
for (String outputFileName : targetFileNames)
{
- this.execute(outputFileName, globalAttributes, isLargeFileSupport);
+ this.execute(outputFileName, attributes, isLargeFileSupport, variableNameArg);
}
}
@@ -186,7 +194,7 @@
*
* @param outputFilename
* the netCDF file in which to define a dimension.
- * @param globaAttributes
+ * @param attributes
* a attributes of the file.
* @param isLargeFileSupport
* whether the netCDF file should be written with large file support, i.e. 64-bit addressing for files
@@ -196,8 +204,31 @@
* @throws SecurityException
* thrown if a security manager exists and it prevents the netCDF file from being created.
*/
- public void execute(String outputFilename, List<Attribute> globaAttributes, boolean isLargeFileSupport) throws IOException, SecurityException
+ public void execute(String outputFilename, List<Attribute> attributes, boolean isLargeFileSupport) throws IOException, SecurityException
{
+ this.execute(outputFilename, attributes, isLargeFileSupport, "");
+ }
+
+ /**
+ * Allows the command to be run programmatically, instead of from a command line.
+ *
+ * @param outputFilename
+ * the netCDF file in which to define a dimension.
+ * @param attributes
+ * a attributes of the file.
+ * @param isLargeFileSupport
+ * whether the netCDF file should be written with large file support, i.e. 64-bit addressing for files
+ * greater than 2 GB.
+ * @param variableName
+ * the variable name to assign attributes to
+ * @throws IOException
+ * thrown if netCDF can to be written to or read from.
+ * @throws SecurityException
+ * thrown if a security manager exists and it prevents the netCDF file from being created.
+ */
+ public void execute(String outputFilename, List<Attribute> attributes,
+ boolean isLargeFileSupport, String variableName) throws IOException, SecurityException
+ {
// the netcdf file to be written.
NetcdfFileWriteable ncfile = null;
@@ -223,12 +254,49 @@
ncfile.setRedefineMode(true);
ncfile.setLargeFile(isLargeFileSupport);
- // add attributes
- for(Attribute attribute : globaAttributes)
+ // add attributes to file
+ if (variableName.isEmpty())
{
- ncfile.addAttribute(null, attribute);
+ for(Attribute attribute : attributes)
+ {
+ // remove Attribute if the value is "null"
+ if ("null".equalsIgnoreCase(attribute.getStringValue()))
+ {
+ ncfile.deleteGlobalAttribute(attribute.getName());
+ }
+ else
+ {
+ ncfile.addAttribute(null, attribute);
+ }
+ }
}
+ // add attributes to variable
+ else
+ {
+ Variable variable = ncfile.findVariable(variableName);
+ if (variable == null)
+ {
+ throw new IllegalArgumentException("The variable " +
+ variableName + " doesn't exist in file " + outputFilename + ".");
+ }
+ else
+ {
+ for(Attribute attribute : attributes)
+ {
+ // remove Attribute if the value is "null"
+ if ("null".equalsIgnoreCase(attribute.getStringValue()))
+ {
+ variable.removeAttributeIgnoreCase(attribute.getName());
+ }
+ else
+ {
+ variable.addAttribute(attribute);
+ }
+ }
+ }
+ }
+
// close editing header info
ncfile.setRedefineMode(false);
}
@@ -268,7 +336,7 @@
try
{
// add attributes
- for(Attribute attribute : globaAttributes)
+ for(Attribute attribute : attributes)
{
ncfile.addAttribute(null, attribute);
}
@@ -311,11 +379,13 @@
*/
public String toString()
{
- // generate the help/usage statement
- String header = "Define a global attribute in a netCDF file.";
+ // generate the help/usage statement //TODO:
+ String header = "Define an attribute in a netCDF file. "
+ + "\nIf variable is not specified, then a global attribute is defined."
+ + "\nIf the value of the attribute is null, then the attribute will be deleted.";
String footer = "\nExample: ncdefineatt -outputFileName ABC.nc "
- + "-globalAttributes \"netCDF-Java=4.0,Conventions=value with a space\"\n"
- + "Will add the two listed global attributes to the file ABC.nc. "
+ + "-attributes \"netCDF-Java=4.0,Conventions=value with a space,toDelete=null\"\n"
+ + "Will add the two and delete one listed global attributes to the file ABC.nc. "
+ "The file will be created if it doesn't already exist. ";
StringWriter sw = new StringWriter();
HelpFormatter formatter = new HelpFormatter();
@@ -350,12 +420,12 @@
"3: OPTIONAL, read attributes from Stdin, ensure that text containing '=' or ',' characters are delimited by a backslash.").isRequired(false)
.withLongOpt(STANDARD_INPUT).create("s");
- Option globalAttributes = OptionBuilder
+ Option attributes = OptionBuilder
.withArgName("text")
.hasArg()
.withDescription(
"4: a comma separated list of attribute-value pairs, OPTIONAL, e.g. \"netCDF Java=4.0,Conventions=CF-1.0\", ensure that text containing '=' or ',' characters are delimited by a backslash.")
- .isRequired(false).withLongOpt(GLOBAL_ATTRIBUTES).create("a");
+ .isRequired(false).withLongOpt(ATTRIBUTES).create("a");
Option largeFileSupport = OptionBuilder.withDescription(
"5: OPTIONAL, set if more than 2 GB of data will need to be stored in this file.").isRequired(false)
@@ -366,15 +436,22 @@
+ "processed. If this option is present the outptuFilename is expected to be a direcotry "
+ "containing the files to be processed.").isRequired(false).withLongOpt(FILENAME_PATTERN)
.create("p");
+ Option variableName = OptionBuilder
+ .withArgName("text")
+ .hasArg()
+ .withDescription(
+ "7: OPTIONAL, the variable to assign attribute(s) to.") //TODO wording....
+ .isRequired(false).withLongOpt(VARIABLE_NAME).create("v");
Options options = new Options();
options.addOption(outputFileName);
options.addOption(inputFileName);
options.addOption(standardInput);
- options.addOption(globalAttributes);
+ options.addOption(attributes);
options.addOption(largeFileSupport);
options.addOption(pattern);
+ options.addOption(variableName);
return options;
}
@@ -409,8 +486,8 @@
.getOptionValue(OUTPUT_FILE) : "";
String inputFilenameArg = (parsedCommandLine.hasOption(INPUT_FILE)) ? parsedCommandLine
.getOptionValue(INPUT_FILE) : "";
- String globalAttributesArg = (parsedCommandLine.hasOption(GLOBAL_ATTRIBUTES)) ? parsedCommandLine
- .getOptionValue(GLOBAL_ATTRIBUTES) : "";
+ String attributesArg = (parsedCommandLine.hasOption(ATTRIBUTES)) ? parsedCommandLine
+ .getOptionValue(ATTRIBUTES) : "";
boolean isLargeFileSupport = parsedCommandLine.hasOption(IS_LARGE_FILE);
String pattern = (parsedCommandLine.hasOption(FILENAME_PATTERN)) ? parsedCommandLine
.getOptionValue(FILENAME_PATTERN) : "";
@@ -446,18 +523,18 @@
Util.getExistingFile(inputFilenameArg);
}
- // try getting global attributes from the command line.
- if(!globalAttributesArg.isEmpty())
+ // try getting attributes from the command line.
+ if(!attributesArg.isEmpty())
{
try
{
- NetCDFUtils.mapStringToAttributeValueList(globalAttributesArg);
+ NetCDFUtils.mapStringToAttributeValueList(attributesArg);
}
catch (IllegalArgumentException iae)
{
- throw new IllegalArgumentException(NcDefineAttributes.GLOBAL_ATTRIBUTES
+ throw new IllegalArgumentException(NcDefineAttributes.ATTRIBUTES
+ " value is not a comma separated String of attribute-value pairs: "
- + globalAttributesArg);
+ + attributesArg);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jde...@us...> - 2010-06-22 03:09:00
|
Revision: 17
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=17&view=rev
Author: jdempsey
Date: 2010-06-22 02:24:18 +0000 (Tue, 22 Jun 2010)
Log Message:
-----------
ANDSWRON-657 - Allow defineAttributes to manipulate multiple files
Modified Paths:
--------------
trunk/USAGE.txt
trunk/pom.xml
trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
trunk/src/main/java/au/csiro/netcdf/util/Util.java
Modified: trunk/USAGE.txt
===================================================================
--- trunk/USAGE.txt 2010-06-21 06:41:03 UTC (rev 16)
+++ trunk/USAGE.txt 2010-06-22 02:24:18 UTC (rev 17)
@@ -49,21 +49,27 @@
ncdefineAtt
Define a global attribute in a netCDF file.
--o,--outputFileName <file> 1: the filename of the netCDF file to be created.
--i,--inputFileName <file> 2. the filename of a text file containing
- attributes to be loaded. OPTIONAL, ensure that text
- containing '=' or ',' characters are delimited by a
- backslash.
--s,--standardInput 3: OPTIONAL, read attributes from Stdin, ensure
- that text containing '=' or ',' characters are
- delimited by a backslash.
--a,--globalAttributes <text> 4: a comma separated list of attribute-value pairs,
- OPTIONAL, e.g. "netCDF
- Java=4.0,Conventions=CF-1.0", ensure that text
- containing '=' or ',' characters are delimited by a
- backslash.
--l,--largeFileSupport 5: OPTIONAL, set if more than 2 GB of data will
- need to be stored in this file.
+-o,--outputFileName <file> 1: the filename of the netCDF file to be
+ created.
+-i,--inputFileName <file> 2. the filename of a text file containing
+ attributes to be loaded. OPTIONAL, ensure that
+ text containing '=' or ',' characters are
+ delimited by a backslash.
+-s,--standardInput 3: OPTIONAL, read attributes from Stdin, ensure
+ that text containing '=' or ',' characters are
+ delimited by a backslash.
+-a,--globalAttributes <text> 4: a comma separated list of attribute-value
+ pairs, OPTIONAL, e.g. "netCDF
+ Java=4.0,Conventions=CF-1.0", ensure that text
+ containing '=' or ',' characters are delimited
+ by a backslash.
+-l,--largeFileSupport 5: OPTIONAL, set if more than 2 GB of data will
+ need to be stored in this file.
+-p,--pattern <filename pattern> 6: OPTIONAL, a pattern to match multiple
+ existing files, where multiple files should be
+ processed. If this option is present the
+ outptuFilename is expected to be a direcotry
+ containing the files to be processed.
Example: ncdefineatt -outputFileName ABC.nc -globalAttributes
"netCDF-Java=4.0,Conventions=value with a space"
@@ -85,7 +91,7 @@
delimited by a backslash.
-v,--variableName <text> 4: the name to be given to the variable.
-t,--variableDataType <text> 5: the data type of the variable, e.g. [int,
- byte, char, short, double, float]
+ double, char, float, short, byte]
-a,--variableAttributes <text> 6: a comma separated list of attribute-value
pairs, OPTIONAL, e.g. "units=mm", ensure that
text containing '=' or ',' characters are
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-21 06:41:03 UTC (rev 16)
+++ trunk/pom.xml 2010-06-22 02:24:18 UTC (rev 17)
@@ -349,6 +349,11 @@
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
</dependencies>
<reporting>
<plugins>
Modified: trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-21 06:41:03 UTC (rev 16)
+++ trunk/src/main/java/au/csiro/netcdf/NcDefineAttributes.java 2010-06-22 02:24:18 UTC (rev 17)
@@ -87,6 +87,11 @@
public static final String IS_LARGE_FILE = "largeFileSupport";
/**
+ * The pattern for accepted file names where multiple files are accepted.
+ */
+ public static final String FILENAME_PATTERN = "pattern";
+
+ /**
* Constant that defines the logger to be used.
*/
private static final Logger LOG = Logger.getLogger(NcDefineAttributes.class.getName());
@@ -124,6 +129,8 @@
String globalAttributesArg = (parsedCommandLine.hasOption(GLOBAL_ATTRIBUTES)) ? parsedCommandLine
.getOptionValue(GLOBAL_ATTRIBUTES) : "";
boolean isLargeFileSupport = parsedCommandLine.hasOption(IS_LARGE_FILE);
+ String pattern = (parsedCommandLine.hasOption(FILENAME_PATTERN)) ? parsedCommandLine
+ .getOptionValue(FILENAME_PATTERN) : "";
// check whether large file support is needed
if (Util.fileExists(outputFilenameArg)
@@ -134,6 +141,8 @@
+ " flag.");
}
+ List<String> targetFileNames = Util.getListOfTargetFiles(outputFilenameArg, pattern);
+
// check that if an input file is specified then it actually exists.
if (!inputFilenameArg.isEmpty())
{
@@ -165,7 +174,11 @@
{
globalAttributes.addAll(NetCDFUtils.readAttributesFromStream(System.in));
}
- this.execute(outputFilenameArg, globalAttributes, isLargeFileSupport);
+
+ for (String outputFileName : targetFileNames)
+ {
+ this.execute(outputFileName, globalAttributes, isLargeFileSupport);
+ }
}
/**
@@ -348,6 +361,12 @@
"5: OPTIONAL, set if more than 2 GB of data will need to be stored in this file.").isRequired(false)
.withLongOpt(IS_LARGE_FILE).create("l");
+ Option pattern = OptionBuilder.withArgName("filename pattern").hasArg().withDescription(
+ "6: OPTIONAL, a pattern to match multiple existing files, where multiple files should be "
+ + "processed. If this option is present the outptuFilename is expected to be a direcotry "
+ + "containing the files to be processed.").isRequired(false).withLongOpt(FILENAME_PATTERN)
+ .create("p");
+
Options options = new Options();
options.addOption(outputFileName);
@@ -355,6 +374,7 @@
options.addOption(standardInput);
options.addOption(globalAttributes);
options.addOption(largeFileSupport);
+ options.addOption(pattern);
return options;
}
@@ -392,9 +412,11 @@
String globalAttributesArg = (parsedCommandLine.hasOption(GLOBAL_ATTRIBUTES)) ? parsedCommandLine
.getOptionValue(GLOBAL_ATTRIBUTES) : "";
boolean isLargeFileSupport = parsedCommandLine.hasOption(IS_LARGE_FILE);
+ String pattern = (parsedCommandLine.hasOption(FILENAME_PATTERN)) ? parsedCommandLine
+ .getOptionValue(FILENAME_PATTERN) : "";
// check whether large file support is needed
- if (Util.fileExists(outputFilenameArg)
+ if (pattern.length() == 0 && Util.fileExists(outputFilenameArg)
&& Util.getExistingFile(outputFilenameArg).length() >= MAX_32BIT_OFFSET_FILE_SIZE
&& !isLargeFileSupport)
{
@@ -402,6 +424,22 @@
+ " flag.");
}
+ // Check that if a pattern is present that the output file is a directory
+ if (pattern.length() > 0)
+ {
+ if (!Util.fileExists(outputFilenameArg))
+ {
+ throw new IllegalArgumentException("When a pattern is specified " +
+ "the output file must be an existing directory.");
+ }
+ File file = new File(outputFilenameArg);
+ if (!file.isDirectory())
+ {
+ throw new IllegalArgumentException("When a pattern is specified "
+ + "the output file must be an existing directory.");
+ }
+ }
+
// check that if an input file is specified then it actually exists.
if (!inputFilenameArg.isEmpty())
{
Modified: trunk/src/main/java/au/csiro/netcdf/util/Util.java
===================================================================
--- trunk/src/main/java/au/csiro/netcdf/util/Util.java 2010-06-21 06:41:03 UTC (rev 16)
+++ trunk/src/main/java/au/csiro/netcdf/util/Util.java 2010-06-22 02:24:18 UTC (rev 17)
@@ -17,15 +17,19 @@
package au.csiro.netcdf.util;
import java.io.File;
+import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
+
/**
* Util - utility class with various helpful tools...
*
@@ -202,4 +206,40 @@
splitted.add(text.substring(last_match));
return splitted.toArray(new String[splitted.size()]);
}
+
+ /**
+ * Retrieve a list of the absolute path names of the files in a folder that match a pattern. The pattern uses the
+ * characters '?' and '*' to represent a single or multiple wildcard characters. This is the same as often found on
+ * Dos/Unix command lines.
+ *
+ * @param foldername
+ * The name of the folder to be searched or the single file if no pattern
+ * @param pattern
+ * The pattern to be matched against. The wildcard characters '?' and '*' are supported.
+ * @return A list of the absolute names of the matching files
+ */
+ public static List<String> getListOfTargetFiles(String foldername, String pattern)
+ {
+ List<String> fileNameList = new ArrayList<String>();
+ if (pattern == null || pattern.length() == 0)
+ {
+ fileNameList.add(foldername);
+ return fileNameList;
+ }
+
+ File dir = new File(foldername);
+ if (!dir.exists() || !dir.isDirectory() || !dir.canRead())
+ {
+ return Collections.emptyList();
+ }
+
+ FileFilter patternFilter = new WildcardFileFilter(pattern);
+ File[] files = dir.listFiles(patternFilter);
+ for (int i = 0; i < files.length; i++)
+ {
+ fileNameList.add(files[i].getAbsolutePath());
+ }
+
+ return fileNameList;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-21 06:41:09
|
Revision: 16
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=16&view=rev
Author: robertbridle
Date: 2010-06-21 06:41:03 +0000 (Mon, 21 Jun 2010)
Log Message:
-----------
ANDSWRON-618 - Include <site>scp://...</site>, so that a user can manually perform mvn site-deploy.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-21 06:13:25 UTC (rev 15)
+++ trunk/pom.xml 2010-06-21 06:41:03 UTC (rev 16)
@@ -17,12 +17,10 @@
<url>http://netcdftools.svn.sourceforge.net/viewvc/netcdftools/trunk</url>
</scm>
<distributionManagement>
- <!--
<site>
<id>sourceforge.net</id>
<url>scp://shell.sourceforge.net/home/groups/n/ne/netcdftools/htdocs</url>
</site>
- -->
<repository>
<id>releases</id>
<url>http://junk-yf:8085/nexus/content/repositories/releases</url>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-21 06:13:31
|
Revision: 15
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=15&view=rev
Author: robertbridle
Date: 2010-06-21 06:13:25 +0000 (Mon, 21 Jun 2010)
Log Message:
-----------
ANDSWRON-618 - Remove configuration from pom.xml that performs site deploy, this will now be done manually.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-21 05:36:40 UTC (rev 14)
+++ trunk/pom.xml 2010-06-21 06:13:25 UTC (rev 15)
@@ -17,10 +17,12 @@
<url>http://netcdftools.svn.sourceforge.net/viewvc/netcdftools/trunk</url>
</scm>
<distributionManagement>
+ <!--
<site>
<id>sourceforge.net</id>
<url>scp://shell.sourceforge.net/home/groups/n/ne/netcdftools/htdocs</url>
</site>
+ -->
<repository>
<id>releases</id>
<url>http://junk-yf:8085/nexus/content/repositories/releases</url>
@@ -252,8 +254,9 @@
</executions>
</plugin>
- <!-- Run script to create SourceForge shell so that site can be uploaded via SCP -->
- <plugin>
+ <!-- WE NOW MANUALLY PERFORM A SITE DEPLOY -->
+ <!-- Run script to create SourceForge shell so that site can be uploaded via SCP -->
+ <!-- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
@@ -277,7 +280,7 @@
<argument>create</argument>
</arguments>
</configuration>
- </plugin>
+ </plugin> -->
</plugins>
</build>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-21 05:36:46
|
Revision: 14
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=14&view=rev
Author: robertbridle
Date: 2010-06-21 05:36:40 +0000 (Mon, 21 Jun 2010)
Log Message:
-----------
ANDSWRON-681 - Added task to create a SourceForge shell whenever we try and perform a site-deploy.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-21 04:56:47 UTC (rev 13)
+++ trunk/pom.xml 2010-06-21 05:36:40 UTC (rev 14)
@@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>au.csiro</groupId>
+ <groupId>net.sourceforge.netcdftools</groupId>
<artifactId>netcdf-tools</artifactId>
<packaging>jar</packaging>
<version>0.1.4-SNAPSHOT</version>
@@ -252,6 +252,32 @@
</executions>
</plugin>
+ <!-- Run script to create SourceForge shell so that site can be uploaded via SCP -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <executable>plink</executable>
+ <arguments>
+ <argument>-ssh</argument>
+ <argument>-pw</argument>
+ <argument>${scm.password}</argument>
+ <argument>-P</argument>
+ <argument>22</argument>
+ <argument>${scm.username},net...@sh...</argument>
+ <argument>create</argument>
+ </arguments>
+ </configuration>
+ </plugin>
</plugins>
</build>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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: <rob...@us...> - 2010-06-18 05:23:09
|
Revision: 12
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=12&view=rev
Author: robertbridle
Date: 2010-06-18 05:23:03 +0000 (Fri, 18 Jun 2010)
Log Message:
-----------
ANDSWRON-618 - Add echo debug statements in pom.xml to show the username/password SCM values from settings.xml file being used.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-18 04:52:32 UTC (rev 11)
+++ trunk/pom.xml 2010-06-18 05:23:03 UTC (rev 12)
@@ -224,12 +224,34 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
<configuration>
<username>${scm.username}</username>
<password>${scm.password}</password>
</configuration>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>deploy</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <echo>Using SCM credentials</echo>
+ <echo>[scm.username] ${scm.username}</echo>
+ <echo>[scm.password] ${scm.password}</echo>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2010-06-18 04:52:38
|
Revision: 11
http://netcdftools.svn.sourceforge.net/netcdftools/?rev=11&view=rev
Author: robertbridle
Date: 2010-06-18 04:52:32 +0000 (Fri, 18 Jun 2010)
Log Message:
-----------
ANDSWRON-618 - Add plugin to reference username/password SCM values from settings.xml file.
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-18 04:37:48 UTC (rev 10)
+++ trunk/pom.xml 2010-06-18 04:52:32 UTC (rev 11)
@@ -220,6 +220,17 @@
</plugin>
-->
+ <!-- Used to reference username/password settings from a settings.xml file stored locally -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-scm-plugin</artifactId>
+ <version>1.0</version>
+ <configuration>
+ <username>${scm.username}</username>
+ <password>${scm.password}</password>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|