[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #HLX-917795]: a question about variables with one or more unlimited dimensions

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.


  • Subject: [netCDF #HLX-917795]: a question about variables with one or more unlimited dimensions
  • Date: Tue, 07 Feb 2012 12:17:01 -0700

ok, Given your example, at any point in time,
the three unlimited dimensions will have some
defined size.
The total number of elements in the DATA array
will be the crossproduct of the sizes of the
three dimensions: i.e. |obs| * |parts| * |events|
The critical point is that the size of, for example,
events is independent of obs and parts.
That is the sizeof the subslice DATA(x,y)
is independent of x and y.
So to your questions:

(1) how many observations exist in the particular instance of the variable: DATA
A: |obs| * |parts| * |events|

(2) for each observation in DATA, how many parts were written for that 
observation
A: |parts| * |events| although some of these probably are fill values.

(3) for each part of a specific observation in DATA, how many events were 
written
A: |events| again some will be fill values.

Lets take a simpler case of an integer array A(X,Y),
where X and Y are unlimited.
Suppose A is initially as follows

1  10
11 12

This means that |X| = 2 and |Y| = 2
Suppose we insert the value 17 (using nc_put_vara)
at A(2,0)
We will then have

1 10
11 12
17 _

where _ indicates the use of a fill value,
which is a default value for the type, integer in this case.

Note the |Y| =2 still holds.

Now let us insert the value 23 at A(1,2),
We will get
1 10  _
11 12 23
17 _  _

|X| = 3 and |Y|=3 still holds even though
you only added a single value at A(1,2).

I should note that at least for netcdf-4, those
extra fill values do not necessarily take up space
on disk.

personally, I do not like multiple unlimited dimensions
because of this rather non-intuitive semantics.

An alternative uses variable length types (vlen).
So you might define the following types:
types:
int(*) events_t;
events_t(*) parts_t;

and either this:
dimensions: U=UNLIMITED;
variables: parts_t A(U);

or
types: parts_t(*) obs_t;
variables: obs_t A;

Personally, I prefer the use of a the
unlimited dimension here because it
is easier to access.




=Dennis Heimbigner
  Unidata


Ticket Details
===================
Ticket ID: HLX-917795
Department: Support netCDF
Priority: Normal
Status: Closed