IDL and Arrays to Converting .fits Files into Arrays

  • Thread starter Radiohannah
  • Start date
In summary: Your Name]In summary, the conversation is about a user seeking help with defining variables and manipulating data in IDL. They are struggling with defining i and j for two .fits files they want to read into IDL and convert into arrays. They have tried various combinations without success and are looking for pointers. The expert suggests using a FOR loop, understanding how arrays work in IDL, using the SIZE function, and accessing the HELP function for assistance. They also offer to provide more specific help if needed.
  • #1
Radiohannah
49
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
  • #2




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!


 

Related to IDL and Arrays to Converting .fits Files into Arrays

1. What is IDL and how is it used in scientific research?

IDL (Interactive Data Language) is a programming language commonly used in scientific research for data analysis, visualization, and manipulation. It has a user-friendly interface and powerful tools for working with large datasets.

2. How do I declare and initialize arrays in IDL?

To declare an array in IDL, you can use the syntax: variable = [value1, value2, value3]. To initialize an array with a set of values, you can use the syntax: variable =
MAKE_ARRAY([value1, value2, value3]). You can also use the REPLICATE function to create arrays with repeated values.

3. How can I access and modify elements in an IDL array?

You can access elements in an IDL array using square brackets and the index of the element you want to access. For example, to access the first element in an array, you can use: array[0]. To modify an element, you can assign a new value to it using the same syntax.

4. Can I perform mathematical operations on IDL arrays?

Yes, IDL has built-in functions for performing mathematical operations on arrays, such as addition, subtraction, multiplication, and division. These functions can be used to manipulate data and perform calculations on large datasets.

5. How can I resize or reshape an IDL array?

You can resize an IDL array using the REFORM function, which allows you to specify the new dimensions of the array. To reshape an array, you can use the RESHAPE function, which allows you to change the number of dimensions and the size of each dimension. Both functions can be useful for manipulating data and preparing it for analysis.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Linear and Abstract Algebra
Replies
2
Views
940
  • Engineering and Comp Sci Homework Help
Replies
17
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
21
Views
2K
  • Programming and Computer Science
Replies
6
Views
991
  • Computing and Technology
Replies
14
Views
3K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
Replies
15
Views
5K
  • Programming and Computer Science
Replies
17
Views
972
Back
Top