OpenDX Intro 3: Import and Export of Data

Author: R.S. Weigel
Date: 05/01/2006
Note: Prepared after the 2005 NCAR Summer school. Not field tested.

Keywords and Acronyms:

Field: The primary OpenDX data structure. A valid field has at least three components including "data", "connections", and "positions". Other OpenDX data structures include lists, vectors, matrices, and strings.

Online References:
See Import and Export chapter from OpenDX manual


In this section we show how to import and export data in OpenDX. First a single column ASCII data file is read. Next, a multi-row and multi-column data file is read. Finally, data is output in various forms.

Start CISM_DX with OpenDX extensions using /usr/local/CISM_DX/cismdx_opendx. From the top menu bar, select File, Open Program, type /usr/local/CISM_DX/Labs/2005_AFWA_ShortCourse/IntroToOpenDX/*.net in the Filter section, and double click the file OpenDXIO.net. (If you do not want to type this path, enter /*.net in the Filter section and use the mouse to find the directory)

Part I

To read an ASCII files the Import module needs two pieces of information. The first is the name of the data file and the second is the name of a .general file that tells Import how the values in the ASCII file should be mapped to a OpenDX data strucutre. If you review the Export chapter from the OpenDX manual you will see that very complex data files can be read. In this exercise we assume that you have control over the data file format. In the file OpenDXIO.general you should see

file = OpenDXIO.dat
grid = 3 x 3
structure = 2-vector

end
The "grid" line tells Import how many grid points there are. In this case we have specified that there are 2 measurements per grid point. The "strucutre" line indicates how many measurements are located at each grid point. If we changed "structure" to 1-vector, only the numbers 1-9 are read in. The "majority" line indicates that the file is to be read column-by-column. To verify this, change "structure" to 1-vector and "majority" to "column" and execute the network.

Explore:

Test your understanding:

Part II

After completing Part I, select the Route module and set the "selector" input to 0. (This will prevent anything being executed beyond the Route module.) Switch to the Part II page and set the "selector" input on the Route module to 1. Note that in this section we have encoded the information in the ".general" file used in Part I in the Import module as a string in the third entry. This method is useful if your .general file contains only a few lines. Next, we have created the text file data.dat with the IDL commands. We have also created the text file positions.dat using a text editor.

;IDL code for creating plain text data files for import into OpenDX
data=rebin(indgen(10)+1,10,2)
data=transpose([data,data])
OPENW,lu_data,'data.dat',/get_lun
for i=0,19 do begin
 print,lu_data,data(0,i),data(0,i)
endfor
free_lun,lu_data

Explore:


Part III

Follow the examples on OpenDX native (.dx) files shown in section B2 of the OpenDX manual Appendix B. Importing Data: File Formats. Sample .dx (text) files are available: [dir].

Explore: