Well, there are several things to mention here.
First, when you index an array in IDL you should use []
instead of ()
to avoid confusion and compiling errors.
Second, in your statement
if (data(1,*) ge 0) then printf,2, data
you are trying to print the entire data file for every time your test in your IF statement is satisfied.
Third, you did not specify a FORMAT
statement for your READF
statement, which should be done.
Fourth, are you trying to index the second dimension of the array data
? If so, you need to use i
in the FOR
loop.
Fifth, would it be easier to just read in the data and use it? A [4,96]-element array is incredibly small and would take a fraction of a second to read in each time you need it. Then you could use the WHERE
routine to determine which elements are greater than zero. For instance, you could try (in the FOR
loop):
good = WHERE(data[*,i] GE 0,gd)
where the variable good
would contain all the indices satisfying the test statement.
Sixth, I should say that you can and should use WHERE
without using a FOR
loop here. You can just do the following:
good = WHERE(data GE 0,gd)
and the variable good
will contain only elements of data
≥ 0. To index data
, you need only do something similar to the following:
data_pos = data[good]
If you want to keep the new variable data_pos
the same dimensions as data
, then you could use the ARRAY_INDICES
routine in IDL and leave the rest of the indices of data_pos
as some dummy value you define and know not to be used later.