![]() |
getxxx Function ToolsOPeNDAP provides several tools with which to construct your getxxx
function. The tools fall into two broad classes:
loaddods, the function used to dereference an OPeNDAP URL, and
getxxx function.
loaddods FunctionThe loaddods3 function is the OPeNDAP client for the Matlab browser.
Can't exec program: /usr/local/bin/giftext.pl
The function accepts a URL from the user, sends it out over the
internet, and creates Matlab scalars, vectors, and matrices to hold
the data that is returned from that request. The loaddods.m
help file contains several examples of its use. (Type help loaddods
at the Matlab command prompt.)
The function is called like this:
function values = loaddods([switches,]
URL [per-url switches] [, URL [per-url switches]])
-v which is on by default.
-v:+v to disable it).
-g:-k:loaddods to concatenate two
or more variables with same name. When reading from multi-file
datasets, use this option to concatenate the values read from
several accesses into a single Matlab variable. This is intended for
getxxx functions which build up lists of URLs and pass them to
loaddods for evaluation.
You must supply the URLs whose variables are to be
concatenated in a single invocation of loaddods. The -k
switch will not work across two or more calls to loaddods. That is,
loaddods('-k', '<URL1> <URL2')
will work, while calling loaddods twice with -k (once for
URL1 and once for URL2) won't work.
-n:-n, variables are
named using the name of the leaf variable. This means, for example,
that two separate Structures who each happen to have a
member with the same name will create a name conflict.
-s:-s option can only be used when
assigning the values accessed by loaddods to a vector. If
-s is used in this situation, then the first variable in the
vector will be set to a vector of strings which name the successive
variables.
-V:-t[abclmpstu]:-F:-F option is needed when reading from datasets that return
as string values that should be interned as numbers.
CAUTION: This is a change from previous versions of
loaddods and introduces potential incompatibilities with
version 1.5 and prior. In other words you'll need to change your
software if it used version 1.5 or earlier.
-p:-F).
-A:-A option provides a way to access the DAS
object of a dataset. Given with a URL, -A will cause all
attributes to be interned in the Matlab workspace. Given with
-c only the contents of named attribute
container4 in a dataset
will be interned. The latter is much safer since many DAS objects
contain long names and names that repeat in several containers.
Choosing an attribute container known to have `Matlab safe'
identifiers is a good idea. (See OPeNDAP User Guide for more information
about the DAS structure, and attributes in general.) Note that the
attributes are interned into the Matlab workspace under their own
names, not the name of the container5.
NOTE: While DAS objects are separate from the DDS (data) objects in
OPeNDAP, once loaddods reads the information from the writeval client
program they are treated no differently than data objects. Each
attribute container is interned as if it was a Structure variable
in the
DDS object.
-r var:new name.:-r option provides a way to rename variables so that
variables read will not overwrite ones already present in a Matlab
session.
-c expr:? notation.
loaddods function should be called with a
OPeNDAP URL which references data, in which case the command will
access the dataset and create Matlab data structures to hold those
data. If the URL argument is a * or ?,
loaddods will cause Netscape to start up and open the default
OPeNDAP URL-builder. If the * or ? is followed by a URL,
then that URL will be used instead of the URL builder. Finally, when
called without an argument, the command will wait for a URL to be
passed to it by Netscape or another program6.
The loaddods function is at the core of the OPeNDAP Matlab GUI. However, for
backwards compatibility, it was originally written not to take
advantage of the advanced data structures now available in Matlab.
The loaddap function is a newer version, that makes use of
Matlab data structures in an attempt to preserve the structure of
datasets.
For example, if the target dataset contains three arrays in a
structure, the loaddods function will bring them in as three
arrays. The loaddap function will import the data as three
arrays in a structure, corresponding to the original arrangement.
The use of loaddap is identical in all other respects to
loaddods.
If you find that the OPeNDAP Matlab GUI is more work than is necessary for your
application, and you use the command-line client, you might consider
using loaddap.
Several functions used in the OPeNDAP Matlab GUI are general enough to be of use to
people who have to write new getxxx functions7. This
section contains a short list of some of the functions likely to be
useful. The list is not complete, since the whole collection is
Can't exec program: /usr/local/bin/giftext.pl
fairly fluid, as new datasets are constantly being added to the
archive. We encourage function writers to browse the OPeNDAP Matlab GUI
directories before starting in on what may seem like a common problem.
Many of the utility functions are listed below. Use the Matlab
help command for details of their invocation.
day2yeardods_dbk%20) into underscores,
so that Surface%20Temperature gets translated into
Surface_Temperature.
dods_ddtCast.Temperature is changed
to Temperature. Actually, it removes all of a string up to
and including the right-most period.
findnewisleapmminmaxstrntokyear2day1985.0 will return day 0. To convert to the more
common calendrical representation, where days are numbered from one,
you must add one to the returned day integer.)