1

I am a bit new to this, and have been assigned something quite simple. However, I can't seem to get the job done.

I'm working on light curves for a research product and the data has up to 10,000 elements (sometimes more). My professor asked me to simply turn all these elements into an array with n-elements of dimension so that when we print the data, all 10,000 elements are not loading and we can just call the element we want from the array.

How do I go about approaching this? Feel free to ask for more clarification!

The data file that I call given my prof's routine called ldsk; it tells me how big the file is.

s.amir
  • 9
  • 2
  • 1
    Are we talking about Interface Description Language, or Interactive Data Language? The former is the association with the tag [tag:idl], while the latter uses tag [tag:idl-programming-language] – asynchronos Jul 20 '16 at 17:12

1 Answers1

0

My professor asked me to simply turn all these elements into an array with n-elements...

Let me use the variables ej for the j-th element of an array. Assume each of your ~10,000 values corresponds to a different element, ej, then you can create the array doing the following:

array = [e1, e2, e3, e4, ..., eN]

where N = ~10,000 and the ... was used to avoid having to type out 10,000 terms. Does that make more sense?

Make sure you use []'s in IDL, not ()'s to create arrays. Newer versions under different compiling options can mistake the ()'s for the calling of a function.

we can just call the element we want from the array.

Once created, you can index the array and print to the screen using the following (assume you want the j-th element):

PRINT, array[j]

where j can be any number between 1 and N - 1 (since IDL starts indexing from zero).

honeste_vivere
  • 308
  • 5
  • 11
  • Is there a less tedious way of typing out 10,000 elements to name a new array? I can't imagine a data file having hundreds of thousands of elements and having to create an array by single-handedly typing in every single element from the data file. – s.amir Jul 20 '16 at 21:57
  • @s.amir - In what format is the data currently? How is the data being created? If it is the output of a function, then you can assign the indices of a dummy array to each call of the function. I would need more info before answering your question. – honeste_vivere Jul 20 '16 at 22:10
  • so the data has already been collected and is in a file that i call up given the routines the professor has already created: I just put a screenshot of it up in my original question. The data is in a file called Kepler-0.dsk. – s.amir Jul 21 '16 at 07:18
  • What does the routine `ldsk` do? When you run that routine, does it create pointers or something? How are you getting data into IDL? – honeste_vivere Jul 21 '16 at 12:38