      MAST STScI Tools Mission Search Search Website  Follow Us Register Forum   FAQ Data Search & Retrieval MAST Services About IUE Data High-Level Science   Products Data Reduction &   Analysis Atlases and Catalogs Documentation Publications Historical Documents Related Sites Gallery Data Use Policy Acknowledgments # Using IDL Structures

Below are notes on using IDL structures. A structure can be thought of as a user-defined data type, and can be particularly useful when reading data from a binary table FITS file. To learn more about IDL structures (and recent changes), see the IDL documentation provided by RSI. For IDL version 5.2, documentation on structures can be found in Chapter 4 of "Building IDL Applications".

Generally the IUEDAC IDL software uses anonymous rather than named structures. The format of a named structure is defined once and can not be changed (although see "relaxed structure assignments" in IDL version 5.1 or higher). Anonymous structures can be redefined, but creating arrays of anonymous structures can be more difficult. In most cases, the two types of structures can be used in the same way. See the examples below.

## Basic Structures:

• To define an anonymous structure containing hdr,wav,flux,nu, & sigma vectors:
A = {H: hdr, W: wav, F: flux, NU: nu, SIG: sigma}

• To define a named structure called IUE containing hdr,wav,flux,nu, & sigma vectors
A = {IUE, H: hdr, W: wav, F: flux, NU: nu, SIG: sigma}

• To extract a vector W of wavelengths from structure A:
W = A.W (or W = A.(1))

• To plot W & F:
plot,a.w,a.f or
plot a.(1),a.(2)) or
W=a.w
F=a.f
plot,W,F

• To display format of structure:
help,a,/struc

• To determine number of fields in structure:
print,n_tags(a)

• To determine the length in bytes of a structure:
print,n_tags(a,/length)

• To determine names of fields in structure:
print,tag_names(a)

• To determine whether a variable is a structure:
s=size(a)
if (s(s(0)+1) eq 8) then a is a structure

• To sum images N, O, & P stored in a structure:
B = {i1:N, i2:O, i3:P}
sum = N
for i=1,2 do sum = sum + B.(i)

• To replace elements in B.(0) > 250 DN with same elements from B.(1):
ind = where(B.(0) gt 250)
B.(0)(ind) = B.(1)(ind)

## Arrays of Structures:

• To create an array of 4 A structures:
cat = replicate(a,4)

• To combine 3 identical NAMED structures A, B, C:
cat = replicate(a,3)
cat(1) = b
cat(2) = c

• To combine 3 identical ANONYMOUS structures A,B,C:
(Note the commands above will generate a "conflicting data structure" error with anonymous structures. One possible solution is shown below.)
cat = replicate(a,3)
b = a
b.h = hd2
c = a
c.w = w3
cat(1) = b
cat(2) = c

• To get help on the 2nd structure in array:
help,cat(1),/struc

• To plot W & F from 3rd structure in array:
plot,cat(2).w,cat(2).f    