Skip to content

Commit 1ab5629

Browse files
authored
Merge pull request #1575 from lesserwhirls/docs
Update documentation
2 parents f3130b9 + 0e0f29c commit 1ab5629

5 files changed

Lines changed: 97 additions & 10 deletions

File tree

docs/src/site/_data/sidebars/netcdfJavaTutorial_sidebar.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ entries:
159159
url: /arraystructures_ref.html
160160
output: web, pdf
161161

162+
- title: CDM Section Specification
163+
url: /section_specification_ref.html
164+
output: web, pdf
165+
162166
- title: CDM Calendar Date Handling
163167
url: /cdm_calendar_date_time_ref.html
164168
output: web, pdf
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: Section Specification
3+
last_updated: 2026-06-23
4+
sidebar: netcdfJavaTutorial_sidebar
5+
toc: false
6+
permalink: section_specification_ref.html
7+
---
8+
## CDM Section Specification
9+
10+
### Syntax
11+
12+
Array sections can be specified with Fortran 90 array section syntax, using zero-based indexing. For example:
13+
14+
`/group1/group2/varName(12:22,0:100:2,:,17)`
15+
16+
specifies an array section for a four-dimensional variable:
17+
18+
1. `12:22` includes all the elements from 12 to 22 inclusive
19+
1. `0:100:2` includes the elements from 0 to 100 inclusive, with a stride of 2
20+
1. `:` includes all the elements
21+
1. `17` includes just the 18th element.
22+
23+
For structures, you can specify nested selectors, e.g. `record(12).wind(1:20,:,3)` does a selection on the `wind` member variable of the `record` structure at index 12.
24+
If you don’t specify a section, it means read the entire variable, e.g. `record.wind` means all the data in all the wind variables in all the record structures.
25+
26+
Formally:
27+
28+
```
29+
sectionSpec := selector | selector '.' selector
30+
selector := varName ['(' sectionSpec ')']
31+
varName := STRING
32+
sectionSpec := dim | dim ',' sectionSpec
33+
dim := ':' | slice | start ':' end | start ':' end ':' stride
34+
35+
36+
slice := INTEGER
37+
start := INTEGER
38+
stride := INTEGER
39+
end := INTEGER
40+
STRING := String with escaped chars = '.', '/', '(', and ')'
41+
```
42+
43+
where:
44+
45+
* Nonterminals are in lower case, terminals are in upper case, and literals are in single quotes.
46+
* Optional components are enclosed between square braces `[` and `]`.
47+
48+
TBD:
49+
50+
* escape mechanism is currently %xx , mostly following opendap
51+
* not sure if any other chars need to be escaped.
52+
53+
### Restrictions
54+
55+
A Sequence is a one-dimensional Structure with a variable length, it cannot be subsetted.
56+
57+
A variable long name must be used, that is with its group names: `/group1/group2/varName`
58+
59+
### Use
60+
61+
`public Array NetcdfFile.readSection(String variableSection);`

docs/src/site/pages/netcdfJava/developer/CdmUtilityPrograms.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ permalink: cdm_utility_programs.html
77
---
88

99
Below are useful command-line utilities that can be called from the CDM library.
10-
The easiest way to use these is to grab the latest netcdfAll.jar file.
10+
One way to use these tools is to grab the latest netcdfAll.jar or toolsUI.jar file from the [Unidata downloads page](https://downloads.unidata.ucar.edu/netcdf-java/){:target="_blank"} or the [netCDF-Java GitHub releases page](https://github.com/Unidata/netcdf-java/releases){:target="_blank"}.
11+
However, a super handy [community-led effort](https://github.com/conda-forge/netcdf-java-feedstock){:target="_blank"} makes JAR management and a set of convenient wrapper scripts (`.sh` and `.bat`) available through `conda-forge`:
12+
13+
```bash
14+
conda install -c conda-forge netcdf-java
15+
```
16+
17+
## Utilities
1118

1219
* [ncdump](#ncdump): prints the textual representation of a dataset to standard output
1320
* [nccopy](#nccopy): copies a CDM dataset to a netCDF-3 (default) or netCDF-4 file
@@ -17,7 +24,6 @@ The easiest way to use these is to grab the latest netcdfAll.jar file.
1724
* [CFPointWriter](#cfpointwriter): copies a CDM point feature dataset to CF/NetCDF format
1825
* [GribCdmIndex](#gribcdmindex): write GRIB Collection Indexes
1926
* [FeatureScan](#featurescan): scans a directory to find CDM datasets and determines their FeatureTypes
20-
* [NetcdfDataset](#netcdfdataset): copies a NetcdfFile object, or parts of one, to a netcdf-3 or netcdf-4 disk file
2127
* [ToolsUI](#toolsui): Netcdf Tools user interface
2228

2329
## ncdump
@@ -42,6 +48,7 @@ where:
4248
* `-v varName1;varName2;..`: show data for these variables, use variable’s full names (including groups if present)
4349
* `-v varName(0:1,:,12)`: show data for a section of this variable only, using FORTRAN 90 section specification
4450

51+
The conda wrapper script is named `ncj-ncdump`.
4552

4653
## nccopy
4754

@@ -88,6 +95,8 @@ java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.write.Nccopy [options]
8895
Default: false
8996
~~~
9097

98+
The conda wrapper script is named `ncj-nccopy`.
99+
91100
## nccompare
92101

93102
Compares two [CDM files](file_types.html) for semantic equivalence.
@@ -103,6 +112,8 @@ where
103112
* `file1`: first file to compare
104113
* `file2`: second file to compare
105114

115+
The conda wrapper script is named `ncj-nccompare`.
116+
106117
## BufrSplitter
107118

108119
Copies a BUFR file\'s messages into separate output files, depending on message type.
@@ -116,6 +127,8 @@ where
116127
* `--fileSpec`: file to split
117128
* `--dirOut`: output directory of split operation
118129

130+
The conda wrapper script is named `ncj-bufrsplitter`.
131+
119132
## CFPointWriter
120133

121134
Copies a CDM point feature dataset to CF/NetCDF format.
@@ -150,6 +163,8 @@ java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.ft.point.writer.CFPointW
150163
Default: false
151164
~~~
152165

166+
The conda wrapper script is named `ncj-cfpointwriter`.
167+
153168
## GribCdmIndex
154169

155170
Write GRIB Collection Indexes from an XML file containing a [GRIB `<featureCollection>`](grib_feature_collections_ref.html) XML element.
@@ -175,11 +190,13 @@ java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.grib.collection.GribCdmI
175190

176191
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).
177192

193+
The conda wrapper script is named `ncj-gribcdmindex`.
194+
178195
## FeatureScan
179196

180197
Scans all the files in a directory to see if they are [CDM files](file_types.html) and can be identified as a particular feature type.
181198

182-
~~~basj
199+
~~~bash
183200
java -Xmx1g -classpath netcdfAll-<version>.jar ucar.nc2.ft.scan.FeatureScan directory [-subdirs]
184201
~~~
185202

@@ -188,6 +205,8 @@ where
188205
* `directory`: scan this directory
189206
* `-subdirs`: recurse into subdirectories
190207

208+
The conda wrapper script is named `ncj-featurescan`.
209+
191210
## CatalogCrawler
192211

193212
Crawl a catalog, optionally open datasets to look for problems.
@@ -260,13 +279,12 @@ count fail = 3
260279
count failException = 0
261280
~~~
262281

263-
## NetcdfDataset
264-
265-
Use [nccopy](#nccopy) instead.
282+
The conda wrapper script is named `ncj-catalogcrawler`.
266283

267284
## ToolsUI
268285

269286
~~~bash
270-
java -Xmx8g -jar netcdfAll-<version>.jar
287+
java -Xmx8g -jar toolsUI-<version>.jar
271288
~~~
272289

290+
The conda wrapper script is named `ncj-toolsui`.

docs/src/site/pages/netcdfJava_tutorial/cdmdatasets/readingcdm.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Note that you can edit the `Variable`'s ranges (`T(0:30:10, 1, 0:3)` in this exa
5454
These are expressed with Fortran 90 array section syntax, using zero-based indexing.
5555
For example, `varName( 12:22 , 0:100:2, :, 17)` specifies an array section for a four dimensional variable.
5656
The first dimension includes all the elements from 12 to 22 inclusive, the second dimension includes the elements from 0 to 100 inclusive with a stride of 2, the third includes all the elements in that dimension, and the fourth includes just the 18th element.
57+
The [CDM section specification](section_specification_ref.html) describes the section string syntax in more detail.
5758

5859
The following code to dump data from your program is equivalent to the above ToolsUI actions:
5960

@@ -98,20 +99,22 @@ Or suppose you want to loop over all time steps, and make it general to handle a
9899
In this case, we call reduce(0), to reduce dimension 0, which we know has length one, but leave the other two dimensions alone.
99100

100101
Note that `varShape` holds the total number of elements that can be read from the variable; `origin` is the starting index, and `size` is the number of elements to read.
101-
This is different from the Fortran 90 array syntax, which uses the starting and ending array indices (inclusive):
102+
This is different from the section (Fortran 90) array syntax, which uses the starting and ending array indices (inclusive):
102103

103104
{% capture rmd %}
104105
{% includecodeblock netcdf-java&docs/src/test/java/examples/cdmdatasets/ReadingCdmTutorial.java&readSubset %}
105106
{% endcapture %}
106107
{{ rmd | markdownify }}
107108

108-
If you want strided access, you can use the Fortran 90 string routine:
109+
If you want strided access, you can use the section string method:
109110

110111
{% capture rmd %}
111112
{% includecodeblock netcdf-java&docs/src/test/java/examples/cdmdatasets/ReadingCdmTutorial.java&readByStride %}
112113
{% endcapture %}
113114
{{ rmd | markdownify }}
114115

116+
The [CDM section specification](section_specification_ref.html) describes the section string syntax in more detail.
117+
115118
#### Reading with Range Objects
116119

117120
For general programing, use the read method that takes a `List` of `ucar.ma2.Range` objects.

grib/src/test/java/ucar/nc2/grib/grib2/TestPds41.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import org.junit.runners.JUnit4;
1616

1717
/**
18-
* Test data from Meteo Swiss CH2 https://data.geo.admin.ch/browser/#/collections/ch.meteoschweiz.ogd-forecasting-icon-ch2?.language=en
18+
* Test data from Meteo Swiss CH2
19+
* https://data.geo.admin.ch/browser/#/collections/ch.meteoschweiz.ogd-forecasting-icon-ch2?.language=en
1920
* Pollen Grasses Data (POACsnc parameter) was used to create a .gbx9 file for testing.
2021
* <p>
2122
* PDS (Secton 4) output from ecCodes grib_dump at the end of the file, uses as a basis for

0 commit comments

Comments
 (0)