MGHNCREADFILE__DEFINE Name
Class MGHncReadFile Purpose
This class encapsulates a netCDF file for READ-ONLY access. It
exposes methods for manipulating dimensions, variables and
attributes. Category
Scientific Data Formats. Background
The original reason for having a separate netCDF class for
read-only access (c.f. MGHncFile, which allows read-write access)
was to work around the limit of 32 on the number of open netCDF
files in versions before IDL 6.0. An MGHncReadFile
object does not keep its file open for the lifetime of the
object--instead it calls NCDF_OPEN each time data is required and
NCDF_CLOSE afterwards. This is reasonably efficient for read-only
access, because opening and closing the file is not too
expensive. It would not make sense if the file were to be changed,
because then changes would be flushed to disk on every close.
With the above modification it becomes practical to maintain
sequences of MGHncReadFile objects, as is done by the
MGHncSequence class. After some experience with the latter, I
found it desirable to also add to the MGHncReadFile class the
facility to specify that a subset of records (positions along the
unlimited dimension) were to be read. (For a while I kept track of
this inside MGHncSequence, but the arithmetic was horrendous.)
Some time in the future I may move the "open only when necessary"
functionality into MGHncFile (or into a yet-to-be invented class)
in order to separate it from the "select records" functionality.
Properties
TMP (Init, Get)
Set this property to 1 to make a temporary copy of the netCDF
file. This can be highly advantageous when the original is on a
fast network drive, where opening and closing the file
repeatedly (as MGHncReadFile methods tend to do) is slow and
copying the whole file is reasonably fast.
###########################################################################
This software is provided subject to the following conditions:
1. NIWA makes no representations or warranties regarding the
accuracy of the software, the use to which the software may
be put or the results to be obtained from the use of the
software. Accordingly NIWA accepts no liability for any loss
or damage (whether direct of indirect) incurred by any person
through the use of or reliance on the software.
2. NIWA is to be acknowledged as the original author of the
software where the software is used or presented in any form.
###########################################################################
Modification History
Mark Hadfield, 2000-02:
Written, based on MGHncFile.
Mark Hadfield, 2000-05:
Cleaned up code and added the ability to specify a subset of the
records: all operations involving the unlimited dimension can
see only this subset.
Mark Hadfield, 2001-11:
Major overhaul of interface along with MGHncFile and
MGHncSequence. Eliminated the separate class, MGHncReadFileVar,
for variable objects.
Mark Hadfield, 2002-04:
Added a facility I've been considering for a while to the VarGet
method: a zero value in the COUNT vector means get all data and
a negative value in the OFFSET vector specifies an offset
relative to the end of the dataset.
Mark Hadfield, 2004-10:
Found and fixed a long-standing bug in HasAtt method: argument
order should resemble that of NCDF_ATTGET, ie either of
result = onc->HasAtt(var, att)
result = onc->HasAtt(att, /GLOBAL).
Mark Hadfield, 2008-10:
Cleaned up the valid-range code in the _VarGet method. This
was failing to detect missing FLOAT and DOUBLE data. It's still
not right for BYTE data.