## B.3 Reading measured data files

Contained here are further details on loading your measured data files into IMD.

As described in section 3.1, the easiest easiet way to load your data into IMD is to use the `File->Open Measured Data File...` option from the main IMD widget menu bar. Alternatively, you can use the procedure IMD_M_RD (described in the previous section) directly from the IDL command line (at the IMD prompt.) But in either case, you must

(a) indicate what type of data your file contains (either by setting the droplist values on the `Open Measured Data File...` widget, or by explicitly setting values for X_M_PTR and Y_M_PTR when using IMD_M_RD from the IDL command line)

and

(b) provide a command string to tell IMD (or IMD_M_RD) how to open your measured data file.

The Read-Measured-Data Command String

If your measured data file is an ASCII file containing columns of data, you can use the EROM procedure to read the file (see the documentation for EROM in the `windt` directory.) If the file is not an ASCII file, or you cannot use EROM for some reason, then you will need to write your own IDL procedure (or function) to read your file.

But however you read your measured data file (EROM or your own procedure) you must either

(a) explicitly define the IMD variables X_M, Y_M, and optionally SIGY_M in the Read-Measured-Data Command String, as in:

"`EROM, X_M, Y_M, SIGY_M`"

or

"`MY_PROCEDURE, X_M, Y_M, SIGY_M`"

or

(b) use the IMD_M common block (see Appendix B.4) and define X_M, Y_M, and SIGY_M inside the IDL procedure you write to read your data. For example:

    PRO MY_PRO_TO_READ_MY_DATA

    COMMON IMD_M

    ;; IDL code to read your data goes here

    X_M=my_x_data
    Y_M=my_y_data

    ;; and optionally
    SIGY_M=my_sigy_data

    return
    end

So that the Read-Measured-Data Command String would read simply

"`MY_PRO_TO_READ_MY_DATA`".

As indicated in section 3.1, it's important to set - before loading the data - the independent variable `Units` to correspond with what's actually in your file. For instance, if you're reading in data as a function of Normal incidence angle, make sure that the `Angle units` are set for `Normal Incidence`, and not `Grazing Incidence`. Likewise for wavelength/energy or length units.

You can change units to whatever you prefer after you load in the data, but IMD needs to know what units are actually in your data file ahead of time, as IMD will convert (i.e., redefine) X_M after it reads the file.

But...if you want to get fancy, you can take advantage of the values of the IMD COMMON block variables IMD.ANGLEUNITS_PTR, IMD.PHOTONUNITS_PTR, or IMD.LAYERUNITS_PTR, (see Appendix B.4) to make sure that your data get converted correctly, regardless of how these pointers might be set. That is, if you know your data file contains, for example, reflectance vs. grazing incidence data, then you might write a procedure like this:

    PRO MY_PRO_TO_READ_MY_GRAZING_DATA

    COMMON IMD
    COMMON IMD_M

    ;; Read an ASCII file of grazing incidence vs reflectance data

    EROM, X_M, Y_M

    ;; Now make sure that the grazing incidence data always gets
    ;; converted to normal incidence properly, regardless of how
    ;; IMD.ANGLEUNITS_PTR is set.  That is, if IMD thinks the file
    ;; contains normal incidence data (IMD.ANGLEUNITS_PTR=0), then make
    ;; it so, even though the file actually contains grazing incidence
    ;; data:

    if IMD.ANGLEUNITS_PTR eq 0 then X_M=90-X_M

    return
    end

Remember that X_M will get converted (redefined) to "internal" units (i.e., normal incidence, or angstroms) after the file is read; this conversion procedes according to the current value of IMD.X_M.

Note: Included in the `extras.dir` directory of the imd distribution are some additional IDL procedures that I have used to read in my measured data files; you might wish to use these procedures as starting points for your own procedures.

Back | Contents | Next