comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: how to preserve trailing Shallow dimensions!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: how to preserve trailing Shallow dimensions! [message #61933] Thu, 14 August 2008 06:39 Go to next message
vino is currently offline  vino
Messages: 36
Registered: March 2008
Member
Hi!
Thank you very much for the reply. As you said, my problem is with the
size function. I am doing stellar photometry. I store star position
in an array and most of the time, i am tracking more than 1 star but
the problem arose when i had only star in my image. But i think the
problem might be solved if i follow your example...
Thanks again,
Vino





On Aug 14, 2:28 pm, Vince Hradil <hrad...@yahoo.com> wrote:
> On Aug 14, 6:33 am, vino <astrocr...@gmail.com> wrote:
>
>> Hello Everyone,
>> I was wondering whether there is any way i can preserve a trailing
>> shallow dimension in array?
>
>> eg:
>> IDL> ab=make_array(2,1,1)
>> IDL> print,size(ab,/dimensions)
>> 2
>> How can i make it preserve it as 2 1 1?
>
>> Thanks and regards,
>> Vino
>
> Perhaps you should tell us why... The answer may be different than
> you expect...
>
> So, anyways, the trailing dims are "still there" as 1's:
>
> IDL> f = findgen(3,1,1)
> IDL> help, f
> F FLOAT = Array[3]
> IDL> help, f[*,0]
> <Expression> FLOAT = Array[3]
> IDL> help, f[*,0,0]
> <Expression> FLOAT = Array[3]
> IDL> print, f
> 0.000000 1.00000 2.00000
> IDL> print, f[*,*]
> 0.000000 1.00000 2.00000
> IDL> print, f[*,0]
> 0.000000 1.00000 2.00000
> IDL> print, f[*,0,0]
> 0.000000 1.00000 2.00000
> IDL> print, f[*,*,*]
> 0.000000 1.00000 2.00000
>
> If you are worried about the SIZE function:
> IDL> fsize = size(f,/dimensions)
> IDL> nx = fsize[0]
> IDL> if n_elements(fsize) gt 1 then ny = fsize[1] else ny = 1L
> IDL> if n_elements(fsize) gt 2 then nz = fsize[2] else nz = 1L
> etc...
Re: how to preserve trailing Shallow dimensions! [message #61934 is a reply to message #61933] Thu, 14 August 2008 06:28 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Aug 14, 6:33 am, vino <astrocr...@gmail.com> wrote:
> Hello Everyone,
> I was wondering whether there is any way i can preserve a trailing
> shallow dimension in array?
>
> eg:
> IDL> ab=make_array(2,1,1)
> IDL> print,size(ab,/dimensions)
>            2
> How can i make it preserve it as 2 1 1?
>
> Thanks and regards,
> Vino

Perhaps you should tell us why... The answer may be different than
you expect...

So, anyways, the trailing dims are "still there" as 1's:

IDL> f = findgen(3,1,1)
IDL> help, f
F FLOAT = Array[3]
IDL> help, f[*,0]
<Expression> FLOAT = Array[3]
IDL> help, f[*,0,0]
<Expression> FLOAT = Array[3]
IDL> print, f
0.000000 1.00000 2.00000
IDL> print, f[*,*]
0.000000 1.00000 2.00000
IDL> print, f[*,0]
0.000000 1.00000 2.00000
IDL> print, f[*,0,0]
0.000000 1.00000 2.00000
IDL> print, f[*,*,*]
0.000000 1.00000 2.00000

If you are worried about the SIZE function:
IDL> fsize = size(f,/dimensions)
IDL> nx = fsize[0]
IDL> if n_elements(fsize) gt 1 then ny = fsize[1] else ny = 1L
IDL> if n_elements(fsize) gt 2 then nz = fsize[2] else nz = 1L
etc...
Re: how to preserve trailing Shallow dimensions! [message #61994 is a reply to message #61933] Sun, 17 August 2008 15:43 Go to previous message
Mark[1] is currently offline  Mark[1]
Messages: 66
Registered: February 2008
Member
Functions like make_array and indgen silently strip off trailing
shallow dimensions, but it is possible to override this using reform,
eg:

IDL> help, make_array(2,1,1)
<Expression> FLOAT = Array[2]
IDL> help, reform(make_array(2,1,1),2,1,1)
<Expression> FLOAT = Array[2, 1, 1]

The size function does accurately report the number of dimensions, I
think

IDL> print, size(make_array(2,1,1), /DIMENSIONS)
2
IDL> print, size(reform(make_array(2,1,1),2,1,1), /DIMENSIONS)
2 1 1

However, IDL is generally prone to chopping them off when you least
expect it, so is best to write code that will handle this.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: LaTex?
Next Topic: A question about map projection

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:11:54 PDT 2025

Total time taken to generate the page: 0.00457 seconds