IDL and Arrays to Converting .fits Files into Arrays

  • Thread starter Thread starter Radiohannah
  • Start date Start date
AI Thread Summary
To read .fits files into IDL and convert them into arrays, use the command `A = readfits('A.fits')` and `B = readfits('B.fits')`. IDL arrays are indexed starting at 0, so the first element is accessed with A(0,0). To define the ith column and jth row, utilize a FOR loop. For example, `FOR i = 0, 99 DO A(i,*) = i` labels the ith column, while `FOR j = 0, 99 DO A(*,j) = j` labels the jth row. The SIZE function can be used to determine the dimensions of the arrays, and the HELP function provides documentation for further assistance with IDL commands.
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!
 
Computer science 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!


 
In my discussions elsewhere, I've noticed a lot of disagreement regarding AI. A question that comes up is, "Is AI hype?" Unfortunately, when this question is asked, the one asking, as far as I can tell, may mean one of three things which can lead to lots of confusion. I'll list them out now for clarity. 1. Can AI do everything a human can do and how close are we to that? 2. Are corporations and governments using the promise of AI to gain more power for themselves? 3. Are AI and transhumans...
Sorry if 'Profile Badge' is not the correct term. I have an MS 365 subscription and I've noticed on my Word documents the small circle with my initials in it is sometimes different in colour document to document (it's the circle at the top right of the doc, that, when you hover over it it tells you you're signed in; if you click on it you get a bit more info). Last night I had four docs with a red circle, one with blue. When I closed the blue and opened it again it was red. Today I have 3...

Similar threads

Replies
2
Views
2K
Replies
21
Views
3K
Replies
14
Views
5K
Replies
11
Views
3K
Replies
1
Views
3K
Replies
13
Views
3K
Back
Top