very very strange thing is happening with modfits...... [message #93458] |
Thu, 21 July 2016 22:15  |
Sapna Mishra
Messages: 66 Registered: December 2015
|
Member |
|
|
Hello all, Here I am pasting a protion of my code:
readcol,'comb_file.dat',wav,new_flux,new_eflux,F='(f,f,f)'
new_loglam=alog10(wav)
id_ok = where(new_eflux gt 0, cnt_ok)
eivar_new=(1./new_eflux(id_ok))^2
new_loglam=alog10(wav(id_ok))
new_flux=new_flux(id_ok)
aa=mrdfits(fname(n_elements(fname)-1),1,h1)
aa.flux=cspline(new_loglam,new_flux,aa.loglam)
aa.ivar=abs(cspline(new_loglam,ivar_new,aa.loglam))
modfits,fname(n_elements(fname)-1),aa,h1,EXTEN_NO=1
I checked the value of aa.flux and aa.ivar before modifying with modfits:
They are just normal values eg. 14.7555,15.9066......etc.
But after modifying it to a fits file stored in variable:fname(n_elements(fname)-1)
I got very different values: 2.26270e+28,-5.91691e-11.......with message:
%Program caused arithmetic error: Floating illegal operand.
I wasted my whole day in this checking what is going wrong after modfits. I am using the latest version of modfits.pro.
What is going wrong can anyone please tell me???????????????????////
I checked there is no problem in cspline or anything they are just normal finite values.(eg. not inf and NaN anywhere)
|
|
|
|
Re: very very strange thing is happening with modfits...... [message #93464 is a reply to message #93463] |
Fri, 22 July 2016 08:30   |
Sapna Mishra
Messages: 66 Registered: December 2015
|
Member |
|
|
On Friday, July 22, 2016 at 8:30:03 PM UTC+5:30, wlandsman wrote:
> On Friday, July 22, 2016 at 1:15:26 AM UTC-4, Sapna Mishra wrote:
>> ..etc.
>> But after modifying it to a fits file stored in variable:fname(n_elements(fname)-1)
>> I got very different values: 2.26270e+28,-5.91691e-11.......with message:
>
> I don't know what is happening -- it works for me.
>
> But why don't you just write a new FITS file (using mwrfits.pro) instead of using modfits.pro? It is likely faster (and certainly less complicated) to write a complete new FITS file, rather than modify bits and pieces of an existing file.
Actually what I want is that my fits file contains data and header in three extentions e.g. 0,1,2(h0,h1,h2) using mwrfits create a complete new files with a
certain extention. What If i want to recover values of all other two extensions?
Creating a new fits file with same name will do so???
|
|
|
Re: very very strange thing is happening with modfits...... [message #93465 is a reply to message #93463] |
Fri, 22 July 2016 08:31   |
Sapna Mishra
Messages: 66 Registered: December 2015
|
Member |
|
|
On Friday, July 22, 2016 at 8:30:03 PM UTC+5:30, wlandsman wrote:
> On Friday, July 22, 2016 at 1:15:26 AM UTC-4, Sapna Mishra wrote:
>> ..etc.
>> But after modifying it to a fits file stored in variable:fname(n_elements(fname)-1)
>> I got very different values: 2.26270e+28,-5.91691e-11.......with message:
>
> I don't know what is happening -- it works for me.
>
> But why don't you just write a new FITS file (using mwrfits.pro) instead of using modfits.pro? It is likely faster (and certainly less complicated) to write a complete new FITS file, rather than modify bits and pieces of an existing file.
And One more thing, have you ever modified a value of a single variable of a structure stored in a fits file in particular ext.???? I think after my this error we can not use modfits.pro to modify value of a single variable in a structure ...
|
|
|
Re: very very strange thing is happening with modfits...... [message #93466 is a reply to message #93464] |
Fri, 22 July 2016 11:01  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Friday, July 22, 2016 at 11:30:12 AM UTC-4, Sapna Mishra wrote:
> On Friday, July 22, 2016 at 8:30:03 PM UTC+5:30, wlandsman wrote:
>> On Friday, July 22, 2016 at 1:15:26 AM UTC-4, Sapna Mishra wrote:
>>> ..etc.
>>> But after modifying it to a fits file stored in variable:fname(n_elements(fname)-1)
>>> I got very different values: 2.26270e+28,-5.91691e-11.......with message:
>>
>> I don't know what is happening -- it works for me.
>>
>> But why don't you just write a new FITS file (using mwrfits.pro) instead of using modfits.pro? It is likely faster (and certainly less complicated) to write a complete new FITS file, rather than modify bits and pieces of an existing file.
>
> Actually what I want is that my fits file contains data and header in three extentions e.g. 0,1,2(h0,h1,h2) using mwrfits create a complete new files with a
> certain extention. What If i want to recover values of all other two extensions?
> Creating a new fits file with same name will do so???
If I am modifying an existing FITS file I typically use the FXBOPEN, FXBWRITE, FXBCLOSE family of functions. They are documented on the IDL Astronomy Library site.
extnum = 1
fxbopen, unit, 'myfile.fits', extnum, hh, access='RW'
fxbwrite, unit, aa.flux, 'FLUX', 1
fxbfinish, unit
Done.
|
|
|