gaqstickers.blogg.se

Idl strmid
Idl strmid







idl strmid

IDL was designed as an array processing language and it excells at handling data arrays all at once rather than in loops. Your code might look like this:Īlthough this code will certainly work in IDL, it will not be very fast. You could read values into temporary variables, and store them in your loop if you like. With the number of rows known, it might occur to you (especially if you are a FORTRAN programmer) that you can initialize the three vectors you are after and read them directly, like this:įOR j=0,rows-1 DO READF, lun, pressure(j), temperature(j), humidity(j)Īlthough this is exactly what you would do with a FORTRAN program, it will absolutely not work in IDL! The reason it won't work is that there is a rule in IDL that you cannot read into a subscripted variable.

idl strmid

Now you are ready to read the data itself. This will be useful if you don't know if the number of rows will be 100 or 10000. The "I0" format in the READS command above allows you to read an integer value with a variable number of digits. Starts on 18th column in the file (see the FORMAT keyword, below). That the integer specifying how many rows of data there are in the file The method shown here requires that you know

idl strmid

Here is one way to do that using the READS (READ from String) command. The next step is to read the number of rows in the data file from the second line of the header. If you like, you can print the header out now, like this: To read the header, you use the READF command, like this: When reading a string variable, IDL reads until the end of the current line in the file. Since in this case you know that the header is the first three lines of the file, you can read the header into a three-element string array. The logical unit number will be assigned to the variable lun in the command below. You will use the GET_LUN keyword to get an available logical unit number out of a pool of numbers IDL manages. This is done with the OPENR (OPEN for Read) command. First, you must attach the file to a logical unit number, since all file input and output occurs over logical unit numbers in IDL. There are any number of ways to read this type of data file in IDL, but here is one way. Library and learn to use the ReadCol procedure The first few lines of the data file look like this:ĪNSWER: The short answer to this question is to go download the How can I read this kind of data file in IDL? The number of rows in the data file is variable, but the number is written in the second line of the header. I want each column to be a separate IDL vector. QUESTION: I have an ASCII data file named exp2b9c.dat with a three line header and three columns of data.









Idl strmid