Showing posts with label IDL. Show all posts
Showing posts with label IDL. Show all posts

Wednesday, October 3, 2012

IDL read csv file

My first search for this turned up more information about the function that is being used, read_csv.pro. However, all links are essentially printouts of the code, and hint that the first row must be a header row. I'm not sure if the version of this function that we have is exactly the same.

http://home.strw.leidenuniv.nl/~hoekstra/downloads/read_csv.pro

My problem is that my csv file has hexadecimal numbers, and read_csv just happens to be interpreting values with an E in the 2nd from the last digit incorrectly. I'd like it to just read in the entire file as strings and let me do the string to number conversion. There's a "STRINGS" keyword in the listing, but it's not clear how to use it. It looks like you just have to say strings=something, some examples seem to show strings=strings (it doesn't look like the /STRINGS nomenclature that goes with IDL operations).

Then, this forum thread says use readcol if you want to do everything by hand, or just use Readf or read_data_file which I guess will treat the csv file like an array:

http://www.rhinocerus.net/forum/lang-idl-pvwave/118138-reading-csv-file.html

Sunday, September 30, 2012

IDL show line numbers

How to get the fancy viewer to show the line numbers is a bit tricky. Here's the link that gave me the answer:

https://www.exelisvis.com/language/en-US/UserCommunity/UserForums/forumid/27/postid/11936/scope/posts.aspx

IDL pause for debugging

IDL can be a royal pain sometimes, but the fact that it's a scripted language comes in handy when you have to debug. Aside from being able to just start typing in IDL commands right in the current focus if a proc hangs up, you can also set breakpoints and do stepping.

I never used the following info about doing it from the command line, but this has lots of useful features.

http://idlastro.gsfc.nasa.gov/idl_html_help/BREAKPOINT.html

Formatting strings in IDL

Just a quick dump of links that I searched to get a handle on IDL's syntax for formatting strings.

These two may have been the best pages, with examples that show the nearly but not quite C-like formatting methods and a nice table of the format codes:

http://idlastro.gsfc.nasa.gov/idl_html_help/C_printf-Style_Quoted_String_Format_Code.html

http://star.pst.qub.ac.uk/idl/Format_Codes.html

This one showed one example of how to print an array to a file with formatting:

http://www.cis.rit.edu/class/simg211/datao.html

For a beginner's guide, this page was surprisingly useless:

http://www.stsci.edu/hst/training/events/IDLTopics/SSD98IDL/IDL_dataio.html#Writing%20Formatted%20Data

Here's the whole damn manual:

http://www.astro.virginia.edu/class/oconnell/astr511/IDLresources/getting-started-IDL-v7.0.pdf

Thursday, March 22, 2012

IDL, MATLAB scp command imbedding

For my IDL and MATLAB scripts, calling scp is as easy as using each language's system call, with command strings built up through normal concatination.

IDL:
In IDL it's the "spawn" command. Here are some nice tutorials with examples:

http://archive.stsci.edu/iue/manual/dacguide/node8.html
http://www.astro.virginia.edu/class/oconnell/astr511/idl_5.1_html/idl1a9.htm
http://idlastro.gsfc.nasa.gov/idl_html_help/SPAWN.html


MATLAB:
This shows a very fancy script, but it's just a wrapper for the system call that allows specification of an array of scenarios for the scp command. The take-away for me was to be sure to use the full path for the scp executable.

http://www.mathworks.com/matlabcentral/fileexchange/25256-scpsftp-from-matlab/content/ssh/scpfrommatlab.m

Monday, November 7, 2011

IDL Create Directory:

Use the super easy FILE_MKDIR command, part of a family of os operation functions:

http://idlastro.gsfc.nasa.gov/idl_html_help/FILE_MKDIR.html

Here was the clue:

http://www.rhinocerus.net/forum/lang-idl-pvwave/139535-how-create-new-folder-idl.html

IDL test if directory exists

To test if a directory exists (prior to creating it) using IDL, the FILE_TEST command has a special parameter just for that:

result = FILE_TEST (,/DIRECTORY)

See here:

http://idlastro.gsfc.nasa.gov/idl_html_help/FILE_TEST.html

Look at this nightmarish way this person did it:

http://www.astro.washington.edu/docs/idl/cgi-bin/getpro/library27.html?DIR_EXIST

Another very difficult way to do this would have been to use FILE_INFO:

http://idlastro.gsfc.nasa.gov/idl_html_help/FILE_INFO.html