IDL and Arrays to Converting .fits Files into Arrays

  • Thread starter Thread starter Radiohannah
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on converting .fits files into arrays using IDL (Interactive Data Language). Users can read .fits files with the command A = readfits('A.fits') and B = readfits('B.fits'). To define the indices for the arrays, the FOR loop is utilized, allowing users to label the ith column and jth row effectively. The SIZE and HELP functions in IDL are also recommended for determining array dimensions and accessing documentation, respectively.

PREREQUISITES
  • Understanding of IDL (Interactive Data Language)
  • Familiarity with .fits file format
  • Basic knowledge of array indexing in programming
  • Experience with control structures like FOR loops
NEXT STEPS
  • Learn how to use the IDL SIZE function to determine array dimensions
  • Explore the IDL HELP function for accessing documentation on commands
  • Practice using FOR loops in IDL for array manipulation
  • Investigate advanced IDL functions for data visualization of arrays
USEFUL FOR

Researchers, data analysts, and programmers working with astronomical data who need to manipulate .fits files in IDL.

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!


 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 14 ·
Replies
14
Views
6K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
6K
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K