IDL and Arrays to Converting .fits Files into Arrays

  • Thread starter Thread starter Radiohannah
  • Start date Start date
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
1 reply · 4K views
Radiohannah
Messages
47
Reaction score
0
IDL and arrays...help!

Hello!

I have 2 .fits files which I wish to read into IDL.
Then I want to convert these into arrays with i columns and j rows.

I am going a bit mad trying to 'define' i and j and would really appreciate any help.

Say I had 2 files, A.fits and B.fits....

If I wanted to open these into IDL as arrays I would type

A = readfits('A.fits')
B = readfits('B.fits')

After which the terminal says READFITS: Now reading 100 by 100 array, etc

How do I then label the ith column of numbers 'i' and jth rows 'j' for A and B?

I have tried

A(100,100) = A(i,j)
B(100,100) = B(i,j)

amongst many, many others combinations and cannot 'define' i nor j at all!

Any pointers would be massively appreciated!

Cheers!
 
Physics news on Phys.org




Thank you for reaching out for help with your IDL and array issue. I understand the frustration of trying to define variables and manipulate data in a new programming language. Here are some tips that may help you with your task:

1. First, it is important to understand how arrays work in IDL. Arrays in IDL are indexed starting at 0, meaning the first element of an array is A(0,0). The second element is A(1,0), and so on. This may be different from other programming languages you are familiar with, so keep this in mind when defining your i and j variables.

2. To define i and j, you can use the FOR loop in IDL. This loop allows you to iterate through a range of values and perform operations on them. For example, if you wanted to label the ith column of numbers as 'i' and the jth row as 'j' for array A, you could use the following code:

FOR i = 0, 99 DO A(i,*) = i ;This will label the ith column as 'i'
FOR j = 0, 99 DO A(*,j) = j ;This will label the jth row as 'j'

3. You can also use the SIZE function in IDL to determine the dimensions of your arrays. This function will return the number of rows and columns in your array, which you can then use to define your i and j variables.

4. Another helpful tool is the HELP function in IDL. This function allows you to access the documentation and examples for specific IDL commands and functions. You can use this to learn more about how to use the READFITS and SIZE functions in your code.

I hope these tips help you with your task. If you continue to have trouble, don't hesitate to reach out for more specific assistance. Good luck with your project!