PDA

View Full Version : does anybody know IDL?


hobbsmann
12-02-2005, 03:06 AM
I'm working on writing a routine in IDL right now and can't get it to work so given the collective brain power of OOT I thought one you might be able to help out. If any of guys know this language at all I'll post my problem...

requisite hot chick:
http://fullbuzzz-qc.tripod.com/sitebuildercontent/sitebuilderpictures/carolineneron20.jpg

tonypaladino
12-02-2005, 03:26 AM
you need to rehost your hot chick

Ed Miller
12-02-2005, 06:18 AM
[ QUOTE ]
I'm working on writing a routine in IDL right now and can't get it to work so given the collective brain power of OOT I thought one you might be able to help out. If any of guys know this language at all I'll post my problem...

requisite hot chick:
http://fullbuzzz-qc.tripod.com/sitebuildercontent/sitebuilderpictures/carolineneron20.jpg

[/ QUOTE ]

You at MIT? I coded IDL like eight years ago at the Center for Space Research for Dr. Lazarus.

hobbsmann
12-02-2005, 06:33 AM
Well Ed if you see this again soon help would be much appriciated. The problem should be simple, but I'm new to IDL and am lost on why this doesn't work.

I'm using this program written for extracting data from output files for our model (files are .bpch files)

; NAME:
; CTM_GET_DATA
;
; PURPOSE:
; Retrieve specific data records from CTM output files.
; Opening files, parsing header information, and loading
; of data are handled transparently and can be
; controlled by various keywords. The routine returns a
; subset of the global DATAINFO structure that matches the
; requested category and (optional) tracer and time step(s).
;
; This routine should be called *whenever* you want to
; access data and you are not sure that it has been
; loaded previously. It provides the general user-interface
; for GAMAP (the Global Atmospheric Model output Analysis
; Package).
;
; For the future, a widget interface to this routine is
; planned.
;
; CATEGORY:
; CTM Tools
;
; CALLING SEQUENCE:
; CTM_GET_DATA,DATAINFO [,DIAGN] [,keywords]
;
; INPUTS:
; DIAGN -> A diagnostic number or category name (see
; (CTM_DIAGINFO). A value of 0 (or an empty string)
; prompts processing of all available diagnostics.
; DIAGN can also be an array of diagnostic numbers or
; category names.
;
; KEYWORD PARAMETERS:
; FILENAME -> (optional) If FILENAME is a fully qualified file path
; the specified file is opened without user interaction.
; If filename is empty or contains wildchards (*,?), a
; pickfile dialog will be displayed.
; If FILENAME is a named variable it will contain the full
; file path upon return so that a subsequent call to
; CTM_GET_DATA with the same FILENAME argument will not prompt
; another file selection dialog.
; If the FILENAME keyword is present, CTM_GET_DATA
; will restrict it's scope to records from the selected
; is file (even if FILENAME contains an empty string, it will
; restrict the scope of the search!).
; If the file is found in the global FILEINFO structure or
; the USE_FILEINFO structure (i.e. it has been opened
; previously), then it will not be parsed again; instead the
; data records are returned from memory.
; The data itself is loaded transparently via
; CTM_RETRIEVE_DATA.
;
; ILUN -> An optional value or array of logical unit numbers. If
; given, the search is restricted to data from the specified
; files. Default is to use all files (unless the FILENAME
; keyword is present). If an undefined variable
; is passed into ILUN, information about all accessible files
; in the global FILEINFO structure (or USE_FILEINFO) is returned.
;
; TRACER -> A tracer ID number or a list of those. If given, the
; search is restricted to those tracers. Default is to use all
; tracers. If an undefined variable is passed into TRACER,
; and one specific diagnostics is requested with DIAGN,
; information about all accessible tracers in the global
; DATAINFO structure or USE_DATAINFO structure or the
; DATAINFO structure associated with a specific file is returned.
;
; TAU0 -> A time value or list of values to restrict the search.
; Default handling as with ILUN or TRACER. TAU0 superseeds
; /FIRST, /LAST or TAURANGE.
;
; TAURANGE -> A 2-element vector containing the first and last tau0
; value to look for.
;
; /FIRST, /LAST -> extract first or last time step that is stored for
; the selected diagnostics, ilun, and tracer. Only one can be
; be active at a time. /LAST superseeds /FIRST.
;
; INDEX -> A named variable that will contain the indices of the
; records in USE_DATAINFO that match the selection criteria.
; You can test INDEX[0] ge 0 in order to see if CTM_GET_DATA has
; been successful although it is now recommended to test for
; n_elements(DATAINFO) eq 0.
; The INDEX keyword is useful if you want to change the
; information contained in the selected DATAINFO structures
; globally.
;
; USE_FILEINFO -> (optional) If provided, CTM_GET_DATA will
; restrict its search to only the files that are
; contained in USE_FILEINFO which must be a FILEINFO
; structure array. Default is to use the global information
; (see gamap_cmn.pro).
; If an undefined named variable is provided in USE_FILEINFO,
; it will either contain the global FILEINFO structure array
; or the FILEINFO record of the specified file.
; USE_FILEINFO must contain entries for all logical unit numbers
; that are used in USE_DATAINFO.
;
; USE_DATAINFO -> (optional) Restrict search to records contained
; in USE_DATAINFO which must be a DATAINFO structure array.
; If an undefined named variable is provided in USE_DATAINFO,
; it will either contain the global DATAINFO structure array
; or all DATAINFO records of the specified file.
; See also USE_FILEINFO.
;
; /INTERNAL_USE -> Set this keyword if you want to prevent a call
; to CTM_OPEN_FILE, but instead abort in case of undefined
; (global) FILEINFO or DATAINFO structures.
;
; OUTPUTS:
; DATAINFO -> An array of DATAINFO records that match the selected
; criteria. You can then simply loop over
; 0..n_elements(DATAINFO)-1 to access all data records and
; extract the data as *(DATAINFO[i].data).
; DATAINFO will be undefined if no records are found!!
; Always test for IF (n_elements(DATAINFO) eq 0) ... !
; NOTE: Alternatively you can return the INDEX to the selected
; data records in the global (or USE_) datainfo structure array
; with the INDEX keyword. This may in some cases eliminate the
; need to make a local copy of the selected DATAINFO records.



The thing is when I write a simple routine like the following the output array doesn't doesn't have any data, but when I physically type in the the three so lines of code in my routine into the IDL prompt it works. Thoughts?


pro test


ctm_get_data,datainfo,diagn,file = 'mamnh4aqavg.bpch',tracer=13

DATANH4 = *datainfo[0].data


;calc for a specific height level

NHLEVEL = reform(DATANH4(*,*,6))



end

Ed Miller
12-02-2005, 06:49 AM
Hrmm.. not sure. I'm beyond rusty, so I don't have a whole lot of insight. But if it works if you type in the prompt, but not as a program, it might be a variable scope thing. Like datainfo might not be being created/populated/accessed correctly from within the program. You might have to initialize it before you call ctm_get_data, for instance. Not sure, though. This is one of those things I figure out by playing with it for a while.

hobbsmann
12-02-2005, 07:19 AM
thanks ed, I'll keep plugging away.

If you're still around, how do I output a tvimage as .ps file?