Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/test-native-compression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ jobs:
ubuntu-24.04,
ubuntu-24.04-arm,
windows-2022,
macos-13,
macos-14,
macos-15
macos-15,
macos-15-intel
]
name: netCDF-Java Native Compression Tests
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup JDK 8, 17
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-13' }}
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-15-intel' }}
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: |
8
17
- name: Setup JDK 21
if: ${{ matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-13' }}
if: ${{ matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-15-intel' }}
uses: actions/setup-java@v5
with:
distribution: 'temurin'
Expand All @@ -47,12 +47,12 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Run libaec JNA tests
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-13' }}
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-15-intel' }}
run: ./gradlew -Dorg.gradle.java.installations.auto-detect=true clean :libaec-jna:test
env:
JDK8: /usr/thredds-test-environment/temurin8
- name: Run libaec JNA tests (JDK 21 tests)
if: ${{ matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-13' }}
if: ${{ matrix.os != 'ubuntu-24.04' && matrix.os != 'macos-15-intel' }}
run: ./gradlew clean :libaec-jna:test21
- uses: actions/upload-artifact@v4
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions build-logic/src/main/kotlin/base-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ val publicArtifacts =
":legacy",
":libaec-jna",
":libaec-native",
":libblosc2-jna",
":libblosc2-native",
":netcdf4",
":opendap",
":udunits",
Expand Down
57 changes: 0 additions & 57 deletions cdm/core/src/main/java/ucar/nc2/filter/Blosc.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ucar.nc2.filter.Blosc$Provider
ucar.nc2.filter.Deflate$Provider
ucar.nc2.filter.Checksum32$Fletcher32Provider
ucar.nc2.filter.Checksum32$Adler32Provider
Expand Down
4 changes: 4 additions & 0 deletions cdm/zarr/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ dependencies {
implementation(libs.jackson.databind)
implementation(libs.slf4j.api)

runtimeOnly(project(":libblosc2-jna"))

testImplementation(platform(project(":netcdf-java-testing-platform")))

testImplementation(project(":cdm-s3"))
Expand All @@ -38,6 +40,8 @@ dependencies {

testCompileOnly(libs.junit4)

testRuntimeOnly(project(":libblosc2-native"))

testRuntimeOnly(libs.junit5.platformLauncher)
testRuntimeOnly(libs.junit5.vintageEngine)
}
22 changes: 22 additions & 0 deletions cdm/zarr/src/test/java/ucar/nc2/iosp/zarr/TestZarrIosp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import ucar.ma2.ArrayLong;
import ucar.ma2.DataType;
import ucar.ma2.InvalidRangeException;
import ucar.ma2.MAMath;
import ucar.ma2.MAMath.MinMax;
import ucar.ma2.Section;
import ucar.nc2.*;

Expand Down Expand Up @@ -399,4 +401,24 @@ public void testGeozarrSharedDimension() throws IOException {
}
}
}

@Test
public void testBloscCompressedData() throws IOException {
NetcdfFile ncfile = NetcdfFiles.open(SCALAR_GEOZARR_DATA);
Variable bloscVariable = ncfile.findVariable("temperature");
assertThat(bloscVariable != null).isTrue();
Attribute compressor = bloscVariable.findAttribute("_Compressor");
assertThat(compressor).isNotNull();
assertThat(compressor.getStringValue()).isEqualTo("blosc");
Array data = bloscVariable.read();
assertThat(data).isNotNull();
MinMax mm = MAMath.getMinMax(data);
assertThat(mm).isNotNull();
// values from python zarr implementation
double expectedMin = 1.9752643660053693e-05;
double expectedMax = 0.9999808929333684;
assertThat(mm.min).isWithin(1e-9).of(expectedMin);
assertThat(mm.max).isWithin(1e-7).of(expectedMax);
}

}
8 changes: 7 additions & 1 deletion docs/src/site/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ sidebars:
- netcdfJavaTutorial_sidebar

# project logo (32x32), name, main landing page (currently used in the footer)
project_logo: https://www.unidata.ucar.edu/images/logos/thredds_netcdf-32x32.png
project_logo: https://assets.unidata.ucar.edu/images/logos/thredds_netcdf-32x32.png
project_name: netCDF-Java
project_landing_page: https://unidata.ucar.edu/software/netcdf-java/

Expand All @@ -74,3 +74,9 @@ description: "This is a documentation site for the netCDF-Java, which is part of
# needed for sitemap.xml file only
# must include trailing slash, leave off the version :-)
base_docs_url: https://docs.unidata.ucar.edu/netcdf-java/

# these will appear in various doc pages
java_version_build: 17
java_version_runtime: 8
libaec_version: 1.1.3.0
cblosc2_version: 2.22.0.0
19 changes: 16 additions & 3 deletions docs/src/site/pages/netcdfJava/Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ permalink: upgrade.html

## Requirements

* Java 8 or later is required to use the library.
* Starting with version 5.10.0, Java 17 is required to build the library.
* Java {{ site.java_version_runtime }} or later is required to use the library.
* Java {{ site.java_version_build }} is required to build the library.

## Quick Navigation
* [Summary of changes for v5.10.x](#netcdf-java-api-changes-510x)
Expand All @@ -29,10 +29,23 @@ permalink: upgrade.html
Point release notes:
* [5.10.0](https://github.com/Unidata/netcdf-java/releases/tag/v5.10.0){:target="_blank"} (_yyyy-mm-dd, unreleased_)

Starting with 5.10.x, the netCDF-Java library requires Java 17 to build (although the build will produce Java 8 bytecode, so the minimum supported version is still Java 8).
Starting with 5.10.0, the netCDF-Java library requires Java 17 to build (although the build will produce Java 8 bytecode, so the minimum supported version is still Java 8).
Note: we are looking to update the minimum version of the JVM we support for the project.
Please consider taking a moment to participate in the [poll on GitHub](https://github.com/Unidata/netcdf-java/discussions/1468){:target="_blank"}.

The 5.10.0 release adds support for reading blosc compressed data using the C-Blosc2 native library.
The new artifact for JNA support is `edu.ucar.unidata:libblosc2-jna` (the current version is `2.22.0.0`).

### Native jar group name changes

Going forard, all native jars will be published under the `edu.ucar.unidata` group.
Their version will match the version of the native library that they contain, plus a build number.
This is to help make clear which version of the native library is being used by the jar.
Starting with this release, `libaec-native` will be published under the `edu.ucar.unidata` group as well.
Consider using the netcdf-java-bom artifact to manage your netCDF-Java dependencies, as it will always contain the latest versions of the native jars.
The new `edu.ucar.unidata:libaec-native:1.1.3.0` is equivalent to the previous `edu.ucar:libaec-native:5.9.1`.
Please use the new group name for any `*-native` artifacts going forward.

## netCDF-Java API Changes (5.9.x)

Point release notes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ toc: false

{% include image.html file="netcdf-java/tutorial/coordsystems/CoordSys.png" alt="Coordinate Systems UML" caption="Coordinate Systems UML" %}

For an overview, see: [CDM Object Model]( /common_data_model_overview.html). The Coordinate Axes for a Variable must use a subset of the Variables's dimensions.
For an overview, see: [CDM Object Model](common_data_model_overview.html). The Coordinate Axes for a Variable must use a subset of the Variables's dimensions.

## Goals of _Coordinate Attribute Convention

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.ft.point.writer.CFPointW

## GribCdmIndex

Write GRIB Collection Indexes from an XML file containing a [GRIB `<featureCollection>`](/grib_feature_collections_ref.html) XML element.
Write GRIB Collection Indexes from an XML file containing a [GRIB `<featureCollection>`](grib_feature_collections_ref.html) XML element.

~~~bash
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.grib.collection.GribCdmIndex [options]
Expand All @@ -173,7 +173,7 @@ Example:
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.grib.collection.GribCdmIndex -fc /data/fc/gfs_example.xml
~~~

Note that the output file is placed in the root directory of the collection, as specified by the [Collection Specification](/collection_spec_string_ref.html) of the GRIB [`<featureCollection>`](feature_collections_ref.html).
Note that the output file is placed in the root directory of the collection, as specified by the [Collection Specification string](https://docs.unidata.ucar.edu/tds/current/userguide/collection_spec_string_ref.html){:target="_blank"} of the GRIB [`<featureCollection>`](grib_feature_collections_ref.html).

## FeatureScan

Expand Down
4 changes: 2 additions & 2 deletions docs/src/site/pages/netcdfJava/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ In the following example, the <b>_type_</b> may be byte, short, int or long:
### Reading
#### Q: What files can the library read?

See [File Types])/common_data_model_overview.html).
See [File Types](common_data_model_overview.html).

#### Q: How do I read a file of type X?

In general, you [open any CDM file](common_data_model_overview.html) in the same way, and access it through the [extended netCDF data model(/common_data_model_overview.html#data-access-layer-object-model). The whole point of the CDM is to hide the details of the file format. However, some file type may require special handling:
In general, you [open any CDM file](common_data_model_overview.html) in the same way, and access it through the [extended netCDF data model](common_data_model_overview.html#data-access-layer-object-model). The whole point of the CDM is to hide the details of the file format. However, some file type may require special handling:

GRIB and BUFR files may require special tables that the CDM doesn't have. Open the file as above and see 1) if you get any error messages, 2) if any of the variables have "Unknown" in their name, and 3) if the data looks wrong. If any of those happen, prepare to enter [GRIB table hell realm](grib_tables.html). (BUFR is arguably worse, but there's nothing yet that you can do about it).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ toc: false

The netCDF-Java source code is hosted on GitHub, and — as of v4.6.1 — we use Gradle to build it.
Ant and Maven builds are no longer supported.
To build, you need Git and, as of v5.9.2, Java 17 or higher (required for Gradle 9.0.0 or higher).
To build, you need Git and, as of v5.10.0, Java 17 or higher (required for Gradle 9.0.0 or higher).
Note that the bytecode produced by the Gradle build will be compatible with Java 8, and the test task will run using JDK 8 (thanks to the Gradle Toolchain feature).
If the build cannot find a suitable JDK for testing, you will need to specify one in your `gradle.properties` file (see the [Gradle toolchain documentation](https://docs.gradle.org/current/userguide/toolchains.html#sec:custom_loc){:target="_blank"} for more details).
The tests can be run using other JDK versions using `testX`, where `X` is the version number of one of the LTS releases of Java (currently `11`, `17`, `21`, or `25`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ For maximum compatibility, please include the Unidata repository after any other

Next, select modules based on the functionality you need.
In the minimal case, you’ll just want `cdm-core` and a logger.
`cdm` implements the CDM data model and allows you to read NetCD-3 files (and a number of other file types).
`cdm-core` implements the [Common Data Model (CDM)](common_data_model_overview.html) and allows you to read NetCD-3 files (and a number of other file types).
An example using JDK14 logging:

~~~xml
Expand Down Expand Up @@ -128,8 +128,10 @@ dependencies {

## Native compression code

### libaec

netCDF-Java `>=v5.8.0` supports libaec compression for GRIB2 messages using JNA to call the libaec C library.
To ease the use of this feature, we now distribute a jar file containing the native libraries for the following platforms/architectures:
To ease the use of this feature, we distribute a jar file containing the native libraries for the following platforms/architectures:

|---
| platform | x86-64 | aarch64
Expand All @@ -138,14 +140,29 @@ To ease the use of this feature, we now distribute a jar file containing the nat
| MacOS | <span class="glyphicon glyphicon-ok" style="color: green;"> | <span class="glyphicon glyphicon-ok" style="color: green;">
| Windows | <span class="glyphicon glyphicon-ok" style="color: green;"> | <span class="glyphicon glyphicon-ok" style="color: green;">

If you are using on the of the supported platform/architecture combinations above, you may include the `edu.ucar:libaec-native:${netcdfJavaVersion}` artifact in your project to bypass the need to install libaec on your system.
If you are using on the of the supported platform/architecture combinations above, you may include the `edu.ucar.unidata:libaec-native:{{ site.libaec_version }}` artifact in your project to bypass the need to install libaec on your system.
Otherwise, libaec will need to be installed and reachable in your system library path in order to read data compressed using libaec.

### C-Blosc2

netCDF-Java `>=v5.10.0` supports blosc compression using JNA to call the C-Blosc2 library.
To ease the use of this feature, we distribute a jar file containing the native libraries for the following platforms/architectures:

|---
| platform | x86-64 | aarch64
|:-|:-:|:-:
| Linux | <span class="glyphicon glyphicon-ok" style="color: green;"></span> | <span class="glyphicon glyphicon-ok" style="color: green;">
| MacOS | <span class="glyphicon glyphicon-ok" style="color: green;"> | <span class="glyphicon glyphicon-ok" style="color: green;">
| Windows | <span class="glyphicon glyphicon-ok" style="color: green;"> | <span class="glyphicon glyphicon-ok" style="color: green;">

If you are using on the of the supported platform/architecture combinations above, you may include the `edu.ucar.unidata:libblosc2-native:{{ site.cblosc2_version }}` artifact in your project to bypass the need to install C-Blosc2 on your system.
Otherwise, C-Blosc2 will need to be installed and reachable in your system library path in order to read data compressed using blosc.

## Building with netcdfAll

This is the appropriate option if you’re not using a dependency management tool like Maven or Gradle and you don’t care about jar size or compatibility with other libraries. Simply include netcdfAll-${netcdfJavaVersion}.jar on the classpath when you run your program.
You’ll also need a logger.
Currently, the netcdfAll jar does not include `cdm-s3` due to the size of the AWS S3 SDK dependency, and does not include the `libaec-native` (native library binaries for libaec).
Currently, the netcdfAll jar does not include `cdm-s3` due to the size of the AWS S3 SDK dependency, and does not include any `edu.ucar.unidata:*-native` jars (native library binaries for compression).
The netcdfAll jar can be found at https://downloads.unidata.ucar.edu, or (starting with `5.9.0`) on the [GitHub release page](https://github.com/Unidata/netcdf-java/releases).

## Logging
Expand Down
10 changes: 10 additions & 0 deletions native-compression/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Publishing Native Jars

The native jars are versioned based on the native library version (plus a build number).
These jars are also published separate to the rest of the project jars.
To publish a native jar, you must set the `` system property when running the gradle publish command.
For example, to publish the libblosc2-native jar, run:

```
./gradlew -D"unidata.native.publish=true" :libblosc2-native:publish
```
32 changes: 30 additions & 2 deletions native-compression/libaec-native/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ import java.net.URL
import java.security.DigestInputStream
import java.security.MessageDigest

plugins { id("java-library-conventions") }
plugins {
id("java-base-conventions")
id("artifact-publishing-conventions")
}

group = "edu.ucar.unidata"

var aecVersion = "1.1.3"
var build = "0"

version = "${aecVersion}.${build}"

description = "Jar distribution of native libraries for libaec compression."

project.extra["project.title"] = "Native libraries for libaec."

// zip file produced by GitHub workflow
val libaecNative = "libaec-native-1.1.3-fec016ecd4b8ff1918877e582898d4257c405168.zip"
val libaecNative = "libaec-native-${aecVersion}-fec016ecd4b8ff1918877e582898d4257c405168.zip"

// sha256 checksum from GitHub workflow output
val expectedChecksum = "3db1ba7bc95b48eff74501382b90b0c7d0770a98f369d8c376c8ca4b6003487e"
Expand Down Expand Up @@ -58,3 +68,21 @@ val processNativeResources =
}

tasks.processResources { dependsOn(processNativeResources) }

var publishTaskName = "nativeLibs"

publishing {
publications {
create<MavenPublication>(publishTaskName) {
from(components["java"])
versionMapping {
usage("java-api") { fromResolutionOf("runtimeClasspath") }
usage("java-runtime") { fromResolutionResult() }
}
}
}
}

tasks
.matching { it.group == "publishing" }
.forEach { it.enabled = System.getProperty("unidata.native.publish")?.toBoolean() ?: false }
Loading
Loading