-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6068310
Showing
20 changed files
with
2,122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Workflow executed on "push" events. | ||
name: push | ||
|
||
on: push | ||
|
||
jobs: | ||
|
||
# Run tests in Maven. | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
container: | ||
image: maven:3-jdk-8-slim | ||
|
||
steps: | ||
|
||
# Retrieve the code from Github. | ||
# Use branch "v2" of the "checkout" plugin | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: | | ||
apt-get update | ||
apt-get install -y libnetcdf-c++4 | ||
- name: Execute tests with Maven. | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: mvn -B --settings settings.xml clean test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Workflow executed on "release" events. | ||
name: release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
|
||
# Deploy to Github Packages. | ||
deploy: | ||
name: Deploy to Github Packages | ||
|
||
runs-on: ubuntu-latest | ||
|
||
container: | ||
image: maven:3-jdk-8-slim | ||
|
||
steps: | ||
|
||
# Retrieve the code from Github. | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: | | ||
apt-get update | ||
apt-get install -y libnetcdf-c++4 | ||
- name: Publish to GitHub Packages. | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: mvn -B -e --settings settings.xml deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# IntelliJ files | ||
.idea/ | ||
*.iml | ||
# OpenJDK bug: https://bugs.openjdk.java.net/browse/JDK-8214300 | ||
.attach_pid* | ||
|
||
# Maven files | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Australian Institute of Marine Science | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
This project can be used to generate very small NetCDF files, which can be included in projects to run unit tests. | ||
|
||
## Tools | ||
|
||
NetCDF files can be viewed using different tools. The most convenient ones are: | ||
- [Panoply](https://www.giss.nasa.gov/tools/panoply/) | ||
- [Dive](http://software.cmar.csiro.au/www/en/software/dive.html) | ||
|
||
**NOTE**: As of writing this documentation, CMAR have ceased to support the download link for **Dive**. | ||
If you really want to use this tool, you can still find it on the | ||
[Web Archive](https://web.archive.org/web/20170314023923/http://software.cmar.csiro.au/www/en/software/dive.html). | ||
|
||
## NetCDF variable naming conventions | ||
|
||
If you want to create your own NetCDF file, you may be interested in the following resources. | ||
|
||
- [NetCDF naming convention for `long-name` and `standard-name`](https://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch02s03.html) | ||
- [Table of common NetCDF `standard-name`](https://cfconventions.org/Data/cf-standard-names/77/build/cf-standard-name-table.html) | ||
|
||
Some metadata information is hidden in unrelated attributes. Just have a look at the EDAL library source code | ||
to see how `standard_name` and `long_name` can be used to infer metadata on the component variables of a vector variable. | ||
|
||
Package: uk.ac.rdg.resc.edal.dataset.cdm | ||
Class: CdmDatasetFactory | ||
Source code: | ||
``` | ||
private IdComponentEastNorth determineVectorIdAndComponent(String stdName) { | ||
if (stdName.contains("eastward_")) { | ||
return new IdComponentEastNorth(stdName.replaceFirst("eastward_", ""), true, true); | ||
} else if (stdName.contains("northward_")) { | ||
return new IdComponentEastNorth(stdName.replaceFirst("northward_", ""), false, true); | ||
} else if (stdName.matches("u-.*component")) { | ||
return new IdComponentEastNorth(stdName.replaceFirst("u-(.*)component", "$1"), true, | ||
false); | ||
} else if (stdName.matches("v-.*component")) { | ||
return new IdComponentEastNorth(stdName.replaceFirst("v-(.*)component", "$1"), false, | ||
false); | ||
} else if (stdName.matches(".*x_.*velocity")) { | ||
return new IdComponentEastNorth(stdName.replaceFirst("(.*)x_(.*velocity)", "$1$2"), | ||
true, false); | ||
} else if (stdName.matches(".*y_.*velocity")) { | ||
return new IdComponentEastNorth(stdName.replaceFirst("(.*)y_(.*velocity)", "$1$2"), | ||
false, false); | ||
} | ||
return null; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
|
||
<servers> | ||
<!-- Used by Maven (GitHub server) to resolve AIMS-KS dependencies when running tests or building the package --> | ||
<server> | ||
<id>github_aimsks</id> | ||
<username>USERNAME</username> | ||
<password>${env.GITHUB_TOKEN}</password> | ||
</server> | ||
<!-- Used by Maven (GitHub server) to resolve Open-AIMS dependencies when running tests or building the package --> | ||
<server> | ||
<id>github_openaims</id> | ||
<username>USERNAME</username> | ||
<password>${env.GITHUB_TOKEN}</password> | ||
</server> | ||
</servers> | ||
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>au.gov.aims</groupId> | ||
<artifactId>netcdf-generator</artifactId> | ||
<version>0.2</version> | ||
<packaging>jar</packaging> | ||
<description>This project was created to produce very small NetCDF files, | ||
to be used in unit tests of projects like NcAnimate, | ||
without increasing the project size considerably.</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
|
||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
|
||
<netcdfVersion>5.0.0-alpha3</netcdfVersion> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>github_openaims</id> | ||
<name>GitHub Open-AIMS repo</name> | ||
<url>https://maven.pkg.github.com/open-AIMS/*</url> | ||
</repository> | ||
|
||
<!-- AIMS ks maven mirror repository on GitHub --> | ||
<repository> | ||
<id>aims-ks.mvn-repo</id> | ||
<name>AIMS Knowledge System MVN Repo</name> | ||
<url>https://raw.githubusercontent.com/aims-ks/mvn-repo/master/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>edu.ucar</groupId> | ||
<artifactId>cdm</artifactId> | ||
<version>${netcdfVersion}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>edu.ucar</groupId> | ||
<artifactId>netcdf4</artifactId> | ||
<version>${netcdfVersion}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.17</version> | ||
</dependency> | ||
|
||
<!-- Used for JUnit tests - Not included in the war --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>github</id> | ||
<name>GitHub AIMS-KS Apache Maven Packages</name> | ||
<url>https://maven.pkg.github.com/open-aims/netcdf-generator</url> | ||
</repository> | ||
</distributionManagement> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
|
||
<servers> | ||
<!-- Used to deploy the package to GitHub --> | ||
<server> | ||
<id>github</id> | ||
<username>${env.GITHUB_USERNAME}</username> | ||
<password>${env.GITHUB_TOKEN}</password> | ||
</server> | ||
<!-- Used by GitHub server to resolve AIMS-KS dependencies when running tests or building the package --> | ||
<server> | ||
<id>github_aimsks</id> | ||
<username>${env.GITHUB_USERNAME}</username> | ||
<password>${env.GITHUB_TOKEN}</password> | ||
</server> | ||
</servers> | ||
</settings> |
53 changes: 53 additions & 0 deletions
53
src/main/java/au/gov/aims/netcdf/DownloadManagerGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) Australian Institute of Marine Science, 2021. | ||
* @author Gael Lafond <g.lafond@aims.gov.au> | ||
*/ | ||
package au.gov.aims.netcdf; | ||
|
||
import org.joda.time.DateTime; | ||
import org.joda.time.DateTimeZone; | ||
|
||
import java.io.File; | ||
|
||
/* | ||
* Class used to generate small NetCDF files used with DownloadManager tests | ||
*/ | ||
|
||
public class DownloadManagerGenerator { | ||
private static final DateTimeZone TIMEZONE_BRISBANE = DateTimeZone.forID("Australia/Brisbane"); | ||
|
||
public static void main(String ... args) throws Exception { | ||
Generator netCDFGenerator = new Generator(); | ||
|
||
// For the DownloadManager | ||
NcAnimateGenerator.generateGbr4v2(netCDFGenerator, | ||
new DateTime(2018, 10, 1, 0, 0, TIMEZONE_BRISBANE), | ||
new DateTime(2018, 10, 2, 0, 0, TIMEZONE_BRISBANE), | ||
new File("/tmp/gbr4_simple_2018-10.nc"), false); | ||
|
||
NcAnimateGenerator.generateGbr4v2(netCDFGenerator, | ||
new DateTime(2018, 11, 1, 0, 0, TIMEZONE_BRISBANE), | ||
new DateTime(2018, 11, 2, 0, 0, TIMEZONE_BRISBANE), | ||
new File("/tmp/gbr4_simple_2018-11.nc"), false); | ||
|
||
NcAnimateGenerator.generateGbr4v2(netCDFGenerator, | ||
new DateTime(2018, 12, 1, 0, 0, TIMEZONE_BRISBANE), | ||
new DateTime(2018, 12, 2, 0, 0, TIMEZONE_BRISBANE), | ||
new File("/tmp/gbr4_simple_2018-12.nc"), false); | ||
|
||
NcAnimateGenerator.generateGbr4v2(netCDFGenerator, | ||
new DateTime(2018, 12, 1, 0, 0, TIMEZONE_BRISBANE), | ||
new DateTime(2018, 12, 2, 0, 0, TIMEZONE_BRISBANE), | ||
new File("/tmp/gbr4_simple_2018-12_modified.nc"), false, 1000); | ||
|
||
NcAnimateGenerator.generateGbr4v2(netCDFGenerator, | ||
new DateTime(2019, 1, 1, 0, 0, TIMEZONE_BRISBANE), | ||
new DateTime(2019, 1, 2, 0, 0, TIMEZONE_BRISBANE), | ||
new File("/tmp/gbr4_simple_2019-01.nc"), false); | ||
|
||
NcAnimateGenerator.generateGbr4v2(netCDFGenerator, | ||
new DateTime(2019, 2, 1, 0, 0, TIMEZONE_BRISBANE), | ||
new DateTime(2019, 2, 2, 0, 0, TIMEZONE_BRISBANE), | ||
new File("/tmp/gbr4_simple_2019-02.nc"), false); | ||
} | ||
} |
Oops, something went wrong.