Re: Change structure tags from float to double [message #67204] |
Wed, 08 July 2009 08:30 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Anthony schrieb:
> Hi again,
>
> David - I'm reading data using MRDFITS - not sure I can convert the
> data when reading it in??
>
> Reimar - does it work on arrays of structures? I tried this:
not directly but you can call reform_struct beforehand
http://www.fz-juelich.de/icg/icg-1/idl_icglib/idl_source/idl _html/dbase/reform_struct_dbase.pro.html
and afterwards
wget
http://www.fz-juelich.de/icg/icg-1/idl_icglib/idl_source/idl _html/dbase/download/reform_struct.sav
IDL> x2 = reform_struct(x,5,/tag)
IDL> help,x2
X2 STRUCT = -> <Anonymous> Array[1]
y = replace_tagvalue(x2, 'A', double(x.a))
x = reform_struct(y,5,/str)
IDL> help ,x
X STRUCT = -> <Anonymous> Array[5]
IDL> help ,x,/str
** Structure <1dc3b78>, 2 tags, length=16, data length=10, refs=1:
A DOUBLE 0.0000000
B INT 0
cheers
Reimar
>
> IDL> x = replicate({a:0., b:0}, 5)
> IDL> help, x
> X STRUCT = -> <Anonymous> Array[5]
> IDL> help, x, /struct
> ** Structure <15ee908>, 2 tags, length=8, data length=8, refs=1:
> A FLOAT 0.00000
> B LONG 0
> IDL> y = replace_tagvalue(x, 'A', double(x.a))
> IDL> help, y
> Y STRUCT = -> <Anonymous> Array[1]
> IDL> help, y, /struct
> ** Structure <15f5518>, 2 tags, length=64, data length=60, refs=1:
> A DOUBLE Array[5]
> B LONG Array[5]
>
> ... but it completely changed the structure.
>
> Maybe I'll just edit the FITS file manually...
>
> Anthony
|
|
|
Re: Change structure tags from float to double [message #67206 is a reply to message #67204] |
Wed, 08 July 2009 08:04  |
Anthony[1]
Messages: 20 Registered: December 2006
|
Junior Member |
|
|
> I guess I don't understand. If you read it from a file,
> and the data comes back as floats, what do you gain
> by changing the structure field to doubles?
Later on I want to change the values in those fields, using double
precision, then write the modified data to a new file.
Cheers,
Anthony
|
|
|
Re: Change structure tags from float to double [message #67207 is a reply to message #67206] |
Wed, 08 July 2009 07:43  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Anthony writes:
> David - I'm reading data using MRDFITS - not sure I can convert the
> data when reading it in??
I guess I don't understand. If you read it from a file,
and the data comes back as floats, what do you gain
by changing the structure field to doubles?
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
Re: Change structure tags from float to double [message #67211 is a reply to message #67208] |
Wed, 08 July 2009 07:23  |
Anthony[1]
Messages: 20 Registered: December 2006
|
Junior Member |
|
|
Hi again,
David - I'm reading data using MRDFITS - not sure I can convert the
data when reading it in??
Reimar - does it work on arrays of structures? I tried this:
IDL> x = replicate({a:0., b:0}, 5)
IDL> help, x
X STRUCT = -> <Anonymous> Array[5]
IDL> help, x, /struct
** Structure <15ee908>, 2 tags, length=8, data length=8, refs=1:
A FLOAT 0.00000
B LONG 0
IDL> y = replace_tagvalue(x, 'A', double(x.a))
IDL> help, y
Y STRUCT = -> <Anonymous> Array[1]
IDL> help, y, /struct
** Structure <15f5518>, 2 tags, length=64, data length=60, refs=1:
A DOUBLE Array[5]
B LONG Array[5]
... but it completely changed the structure.
Maybe I'll just edit the FITS file manually...
Anthony
|
|
|
Re: Change structure tags from float to double [message #67213 is a reply to message #67211] |
Wed, 08 July 2009 06:40  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
David Fanning schrieb:
> Anthony writes:
>
>> I have an array of structures, with many tags, including "table.ra"
>> and "table.dec", which are floats
>>
>> I want to change "table.ra" and "table.dec" to double precision.
>>
>> Is there an easy way of doing this? (Optimistic question, I know...)
it is
>
> You mean NOW!? No, it's *way* too late for that.
> You should have thought of that when you were defining
> the structure. :-)
>
> Cheers,
>
> David
>
>
>
it isn't you just need a program for that as usual.
http://www.fz-juelich.de/icg/icg-1/idl_icglib/idl_source/idl _html/dbase/replace_tagvalue_dbase.pro.html
e.g. wget
http://www.fz-juelich.de/icg/icg-1/idl_icglib/idl_source/idl _html/dbase/download/replace_tagvalue.sav
e.g.
d = {A: 1, B: {B1: 0, B2: 1}, C: {B1: 0, B2: 1}}
help, replace_tagvalue(d, 'A', 2, NEW_TAGNAME = 'CC'),/str
** Structure <1056ea8>, 3 tags, length=10, refs=1:
CC INT 2
B STRUCT -> Array[1]
C STRUCT -> Array[1]
result = replace_tagvalue(d, 'A', {A:2})
HELP, result.a, /STR
** Structure <133aa58>, 1 tags, length=2, refs=2:
A INT 2
result = replace_tagvalue(d, 'B1', {A:2}, NEW_TAGNAME = 'I', /ALL)
HELP,result.b,/str
** Structure <1055248>, 2 tags, length=4, refs=2:
I STRUCT -> Array[1]
B2 INT 1
result = replace_tagvalue(d, 'B1', {A:2}, sub='B')
HELP, result.b, /STR
** Structure <13243f8>, 2 tags, length=4, refs=2:
B1 STRUCT -> Array[1]
B2 INT 1
HELP, result.b.b1, /STR
** Structure <1369998>, 1 tags, length=2, refs=2:
A INT 2
further tools could be found at
http://www.fz-juelich.de/icg/icg-1/idl_icglib/idl_lib_intro. html
cheers
Reimar
|
|
|
Re: Change structure tags from float to double [message #67215 is a reply to message #67213] |
Wed, 08 July 2009 05:44  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Anthony writes:
> I have an array of structures, with many tags, including "table.ra"
> and "table.dec", which are floats
>
> I want to change "table.ra" and "table.dec" to double precision.
>
> Is there an easy way of doing this? (Optimistic question, I know...)
You mean NOW!? No, it's *way* too late for that.
You should have thought of that when you were defining
the structure. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|