A Short But Edifying Digression About the Internet 1.3 Example Sessions 1.4 Updating the Dataset List Index
NVODS Home

1.3.2 Creating a Time Series

It is often the case that the data you wish to see cannot be easily displayed in the OPeNDAP Matlab GUI window. OPeNDAP allows much richer access to the data than the browser can accommodate. This means that you can often use the OPeNDAP Matlab GUI to help construct a URL, even though you may not use it to submit the data request.

Can't exec program: /usr/local/bin/giftext.pl The following example shows how you might go about constructing and displaying a time series from the OPeNDAP Matlab GUI datasets, even though there is limited browser capacity for displaying this kind of data. The OPeNDAP Matlab GUI actually is flexible enough to plot this example, but there are others for which this technique is useful. It's also useful to become familiar with loaddods in case you want to include access to OPeNDAP datasets in your own scripts.

  1. Start up the browser and select the "Surface - COADS Monthly Datasets - PMEL" dataset.
  2. Select "Air Temperature" from the Variables menu. (See the figure.) If it's not there, you haven't selected a dataset containing that variable.

     

    The Variables Menu

  3. Using the Zoom and Select Data Range buttons, select a very small geographic range. This dataset is arranged in two-degree squares, so pick a two-degree square somewhere. Pick a wide time range.
  4. Click on Get Details. Select a time at the beginning of the range. Click on Get Data.
  5. Repeat the process for a time at the end of the time range. Click on Get Data.
  6. Look at the Matlab session. You will see two messages like this:

    Reading: http://ferret.wrc.noaa.gov/cgi-bin/nph-nc/data/coads_air.nc
      Constraint: AIR[1316:1316][57:1:57][140:1:140]
    Server version: dods/2.15
    Creating matrix AIR (2 by 2) with 4 elements.
    Creating scalar TIME.
    Creating vector LAT with 2 elements.
    Creating vector LON with 2 elements.
                                      
              ..... data transfer complete
       
    This request generated 1 separate URLs,
    which are stored in the sets:  R3_   
       
    Each individual argument is stored like so:
       
    R3_Time R3_Longitude R3_Latitude R3_Air_Temp 
    

    The above URL indicates that your request asked for time index 1316 in the dataset, latitude index 57, and longitude index 140. (This corresponds to September, 1963, at about 24°N and 78°W.)

  7. Type the following at the Matlab prompt (all on one line):

    >> loaddods('http://ferret.wrc.noaa.gov/cgi-bin/nph-nc/data/
    coads_air.nc?AIR[1316:1500][57:57][140:140]')
    

    You will see a message like this:

    Reading: http://ferret.wrc.noaa.gov/cgi-bin/nph-nc/data/coads_air.nc
      Constraint: AIR[1316:1500][57:57][140:140]
    Server version: dods/2.15
    Creating vector AIR with 185 elements.
    Creating vector TIME with 185 elements.
    Creating scalar LAT.
    Creating scalar LON.
    
  8. You now have, in the Matlab workspace, a vector of temperatures, AIR, whose entries correspond to a vector of times, TIME. The scalars LAT and LON give the location of the data. You can display the data with Matlab functions. Type the following at the Matlab prompt:

    >> figure
    >> plot(TIME,AIR)
    

Caution: There are some pitfalls to using loaddods directly. The OPeNDAP Matlab GUI does quite a bit of housekeeping for you, including some unit conversions. When you use the browser, you get your data back in consistent units, whatever dataset you are looking at. When you use loaddods, you get the data are returned in the units they are stored in. The COADS time data, used in the above example, comes in units of days since 1700. 

Similarly, different data providers use different values within their datasets to indicate "bad" or "missing" data points. Through the browser, these data flags are transformed into Matlab NaNs. (See Matlab `help nan' if you are not familiar with the NaN symbol.) Again, downloading the data directly with loaddods skips this transformation.

If you like, you can save your data with the Matlab save command and restore it with the load command. See the Matlab documentation for more information about these commands.  


Tom Sgouros, December 21, 2004