new to IDL - question about modularity [message #54585] |
Fri, 22 June 2007 15:48  |
Josh
Messages: 21 Registered: June 2007
|
Junior Member |
|
|
despite having five manuals on IDL in front of me, I'm having some
trouble with writing modular code. I think it lies in my lack of
understanding of the structure, but hopefully it's a simple issue...
I'm using IDL 6.3, and have written a single .pro file that looks
like,
pro xxx
...
end
pro yyy
...
end
pro zzz
...
end
in an effort to break up the tasks to be done. However, within the
zzz procedure I would like to access an array that was built in the
xxx procedure. I realize that's not possible, and was hoping for some
guidance as to a better way to do this.
Thanks!
|
|
|
Re: new to IDL - question about modularity [message #54674 is a reply to message #54585] |
Wed, 27 June 2007 13:56   |
swingnut
Messages: 30 Registered: September 2005
|
Member |
|
|
The best approach depends on what ELSE the xxx procedure is doing. On
the one hand, xxx could be building xxx as one of multiple tasks, in
which case xxx could well be left alone except for adding an argument
that will have have the array, or a structure containing the array in
one of its fields. On the other hand, if xxx doesn't do anything but
build the array, it really would be handier to make it a function. On
the other other hand, if, for example, xxx initializes a whole bunch
of variables, I'd recommend going changing xxx to be a function that
returns a structure, one of whose fields contains this array you want
for zzz. I have to say, putting it in a structure ain't a bad way to
go -- I have a template for plotting code that uses a couple of
structures (one of which is generated using FSC_Color, one of which
contains estimated bin sizes for some satellite data generated using
the header data for the satellite records I use); these structures
really make it easier to do some things and to pass a collection of
different types of data back and forth as a unit.
Making a structure is easy, you just put strings and variables
together in a certain format: {tag, variable}, or, {first tag, first
variable, second tag, second variable, ...}, where each tag will be
the name used to access the value stored in that field. To get at
values in the fields, you just store the structure in a variable and
use the variable's name with a certain operator and a tag name:
myStruct={"tagOne", firstVariable, "tagTwo", secondVariable, ...}
print, myStruct.tagOne
It can get a lot more complicated than this, but that's really not an
issue at this point based on the info you've provided.
Here's a couple of handy links about structures in IDL.
http://www.dfanning.com/tips/recursive_struct_tags.html
http://groups.google.com/group/comp.lang.idl-pvwave/browse_t hread/thread/1bca12b02ac21459/9ec919cd5115345d
----------
On Jun 22, 5:48 pm, Josh <joshuamonta...@gmail.com> wrote:
> despite having five manuals on IDL in front of me, I'm having some
> trouble with writing modular code. I think it lies in my lack of
> understanding of the structure, but hopefully it's a simple issue...
>
> I'm using IDL 6.3, and have written a single .pro file that looks
> like,
>
> pro xxx
> ...
> end
>
> pro yyy
> ...
> end
>
> pro zzz
> ...
> end
>
> in an effort to break up the tasks to be done. However, within the
> zzz procedure I would like to access an array that was built in the
> xxx procedure. I realize that's not possible, and was hoping for some
> guidance as to a better way to do this.
>
> Thanks!
|
|
|
Re: New to IDL [message #84549 is a reply to message #54585] |
Thu, 06 June 2013 07:47  |
Carsten Lechte
Messages: 124 Registered: August 2006
|
Senior Member |
|
|
On 05/06/13 23:22, saroj thapa wrote:
> I have a hdf file that has 6 different layers ...
Is it a version 5 file? Then I would use the H5_PARSE function with the
/READ_DATA parameter on the hdf file, and then explore the nested structures
that it delivers.
chl
|
|
|
Re: New to IDL [message #84560 is a reply to message #54585] |
Wed, 05 June 2013 15:15  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
saroj thapa writes:
> I have a hdf file that has 6 different layers such as LAI, FPAR, LAI and FPAR and so on. Can any body suggest me how to i extract these layers seperatly using idl code, after seperating those layers how do i mosaic the similar layers such as LAI with LAi and FPAR with FPAR, and Finally sub-setting those mosiac image to my study site. I have huge number of images so i want to use scripting. If any body can help pls help me with basics and code. Thanks
I suppose it is time for our periodic reminder on how to ask a question
on a technical forum that is likely to get answered:
http://www.catb.org/esr/faqs/smart-questions.html
If we start with basics, then I suggest we start with a link to where we
might find a file like this one, so we can figure out what in the world
you are talking about. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|