Skip to content

Category: IDL hints

idl save set query contents

Here’s how to figure out the contents of a save set.

1. This is the classic way:
restore,’filename.sav’,/verbose  will list the variable names in the saveset.

help, variable_name will then give details on any such variable.

2. This  is the modern (object-oriented) way. Note that it does not require a restore:

[After http://northstar-www.dartmouth.edu/doc/idl/html_6.2/IDL_Savefile.html#wp1034474 ] :

Use the IDL_Savefile object to query the contents of a SAVE file containing data and selectively restore variables.

So first, create a savefile object out of of the .sav file:   sObj = obj_new(‘IDL_Savefile’, ‘p2206.B1913+16.wapp4.53958.0004_shifted.sav’)

Typically, IDL_Savefile::Contents is the first method called on a savefile object; the information retrieved indicates the number of different types of items contained in the file (variables, routines, etc.).

sContents = sObj->Contents()

one type of query of sContents is:  print, sContents.N_var
20

Next, a call to IDL_Savefile::Names is used to obtain the names of items of a specific type.

sNames = sObj ->Names()
print,snames
ACTUAL_NRECS BINSHIFT BW DELFREQ IDLFILE LSRK NBIN NCHAN OBSJULDATE OBSTIME PROFILE_VERSION ROUNDBINSHIFT SCANNO SHIFTONOFFA SHIFTONOFFB
SHIFTTOTA SHIFTTOTB SRC VEL WAPPHOST

Then,  IDL_Savefile::Size can be used to determine the size of a given (named) variable in the file:

size_of_shiftonoffa = sObj->Size(‘shiftonoffA’)
print, size_of_shiftonoffA
1    512   4    512,  which means:

If no keywords are set, SIZE returns a vector of integer type. The first element is equal to the number of dimensions of Expression. This value is zero if Expression is scalar or undefined. The next elements contain the size of each dimension, one element per dimension (none if Expression is scalar or undefined). After the dimension sizes, the last two elements contain the type code (zero if undefined) and the number of elements in Expression, respectively. The type codes are listed at https://www.harrisgeospatial.com/docs/size.html.  (the four here means floating point).

 

–Joel

IDL license info

To determine IDL license number on a particular host, I think logging in to idl gives the license number.  But the geeky way is to  look near the top of the following file on a machine hosting an IDL license:

/usr/local/exelis/license/license.dat

(Mirzam is 217420)

–Joel

examples: histogram, creating date+time filename, writing out plot object

all this and more is in /data/psrdata/usr4/lutzkelker/APJsourcecode/createProbForD.pro      :

creating histogram with coyote cghistoplot and with a simple plot object

decoding systime() into a string of yyyyMOdd-HHmi for filename writeout with date&time embedded

but note that the function call may need to be all lowercase!!!!!Also note that above program now calls the function which resides in the path at /usr/share/astro/idlshare/locallib/getyyyymoddhhmi.pro , and that it is called in main as: mydatimestring=getyyyymoddhhmi(). And furthermore that one can test for existence of a routine in path by typing from command line:  print, file_which(‘getyyyymoddhhmi.pro’)

writing out a postscript from an old style plot procedure and from an already-generated plot object (extremely easy!)

When the IDL license manager halts for no good reason on canopus…

Updated by Bruce and Joel July 2019

So apparently the license manager for idl on canopus loses connection to the server from time to time and Bruce found out that the best way to deal with it was just to power cycle it. Yuping encountered the problem again today and tried the following and it worked.

sudo su – (puts one into root and bash shell – must have sudo privileges)

$ cd /usr/local/exelis/idl83

This is where the IDL installation is

$./bin/lmutil lmdown

This will kill all of the license managers.

$ps aux|grep lm

Make sure that all lm’s are killed

$ ./bin/lmgrd > lmgrd-201Y-MM-DD.log

imgrd starts the license managers.

This appears to fix the problem.

-Yuping

On 2016-05-26, joel found that the above did not quitre work without some help.  I had to first create the log file with a sudo touch filename command, and then CONCAT to the log file in the above sh command by adding a second > to the first one.

How to configure Oklular to show a document’s file name in its titlebar instead of the document’s “title property”

By default, the version of Okular available to CentOS 6 does not show the viewed document’s filename in the Okular window titlebar, but rather the value of the “Document Title” property embedded in the document being viewed. This is bad news because the Document Title property is usually set to the name of the app that created the document, making it difficult to tell multiple documents generated by the same app apart.

You can force Okular to set it’s window titlebar value to the name of the file being viewed by editing the file ~/.kde/share/config/okularpartrc and appending this line to the ‘[General]’ section:

DisplayDocumentTitle=false

When you finish, the file will end up looking like this:


[General]
UseKTTSD=false
DisplayDocumentTitle=false

 

Thanks Bruce!

IDL COLOR PLOTTING WITH FANNING ROUTINES – YUPINGS 2014 UPDATE

On June 11, 2014, Yuping Huang said:

 

I just realized that fsc_color is no longer available because the shared Coyote library was updated a couple weeks ago. So yes the library was updated from its previous early 2000s version. The development for fsc_color stopped at 2011 so now it is not in the library any more, with CGPlot as its successor.

Hence, if you are calling Coyote stuff in idl and found idl telling you that it does not exist, you might want to check the latest Coyote source code online to see if it has been expelled from the library.

Make Evince Display IDL PS Filename on Banner: JUST USE EVINCE!

AS OF 2020 Sep (and I believe much earlier), using the graphics displayer EVINCE automatically puts filename on banner, and furthermore the following did not work with other viewers. Therefore consider the following to be “deprecated” (withdrawn) –jmw

To  actually use evince from the command line, type evince <filename> &

To actually use evince in a nautilus file manager, select (click on) the desired file, and go to
file>>open with>>evince

Commonly when one prints plots to a postscript from IDL and open it with evince(as we always do), the banner of the evince window perennially shows “Graphics Produced By IDL”, which is not helpful at all especially when you’re plotting a thousand plots and trying to compare them.

Hence a pair of IDL routines (OPENPS and CLOSEPS )can be called now to make the output PS file display the file name at the banner and to make the plotting to file process slightly less complicated. The way to call them is as follows:

OPENPS, blablabla.ps      //Before you plot anything. This will set the output device to blablabla.ps and by default color plot

[ DEVICE, FONT_SIZE=9]  //This is the optional part if you want anything about the graph beyond color, see IDL documentation on DEVICE for more

//information. Note that you may overwrite the color attribute here by saying DEVICE,/COLOR=PS

plot,bla

overplot.bla //Plot and add labels and do whatever as you like

CLOSEPS //When you’re done with one graph, simply call CLOSEPS, it will save the file for you and set the plotting device back to xwindows

WARNING: DO CLOSEPS BEFORE YOU OPENPS A NEW FILE. IN OTHER WORDS, EACH PLOT FILE MUST BE ENCLOSED BY A PAIR OF

OPENPS-CLOSEPS statement.

For more information, the code locates at /usr/share/astro/idlshare/locallib, or email huangy@carleton.edu.

 

-yuping