


Nearly all of IDL's mathematical functions can accept arrays and not just single values, and the result will be a corresponding array. Vectorizing, or operating on an entire array at once, is probably the first piece of advice found from the Google search above. That said, what is the best way to avoid this problem? Vectorize In loops with many, many iterations or when there are several statements inside the loop, the loop will be very slow to complete. This means that when IDL executes a for loop, each statement inside the loop is interpreted at the IDL level and then sent down to the machine to process, and this is done every time the loop iterates. The interpreter executes the program directly, translating each statement into a sequence of one or more subroutines already compiled into machine code. IDL is an interpreted language, which is defined by Wikipedia asĪn interpreted language is a programming language for which most of its implementations execute instructions directly, without previously compiling a program into machine-language instructions. If you don't believe me, look at what people commonly ask Google: Why do loops in IDL seem slow?įirst of all, this is not unique to IDL. As it turns out, there are quite a few ways to move calculations outside of a loop and reduce how much work is done inside the loop.
IDL IF HOW TO
That was when I decided to pick up some IDL books and learn more on how to write better code.
IDL IF CODE
Not only that, but it took over a day to run code that calculated a day's worth of atmospheric radiation, and the algorithms don't do much good if data comes in faster than it can be processed. In fact, it was so bad that a guy from IT came into my office to tell me I had to stop using so much of their processors. To say the least, this code was slow and painful to run. Before I knew much about IDL, I wrote some code that performed the desired calculations and placed it inside a giant for loop. Once upon a time, I worked as an undergraduate programmer, where I wrote code that calculated atmospheric radiation algorithms.
