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

Home » Public Forums » archive » mrd_struct failure for string values inside the VM
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
mrd_struct failure for string values inside the VM [message #90768] Mon, 13 April 2015 10:42 Go to next message
vino is currently offline  vino
Messages: 36
Registered: March 2008
Member
Hi,

I am trying to run a project in IDL VM. I am trying to convert fits headers into structures using the fitshead2struct.pro. My program fails at the MRD_STRUCT.pro, when the given tag values are strings, such as DATE_OBS.

Can someone please help? Even an alternative to fitshead2struct is also welcome..

This is all the error I receive from VM:

'ERROR - Invalid field value: ''

Thanks in advance,

Regards,
Vino
Re: mrd_struct failure for string values inside the VM [message #90774 is a reply to message #90768] Tue, 14 April 2015 05:49 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I can tell you why the problem is likely occuring but not how to fix it :-(

mrd_struct.pro creates a structure given a list of tag names and associated variables inside a program ( http://idlastro.gsfc.nasa.gov/ftp/pro/structure/mrd_struct.p ro ). By default, it uses EXECUTE() but it also has a less capable mode which does not use EXECUTE() and so can be used with the viriual machine. In this less capable mode, one supplies mrd_struct with the data type and dimensions of the variables rather than the variables themselves. I suspect FITSHEAD2STRUCT needs to be modified -- in a manner similar to mrdfits.pro -- so it can call mrd_struct in this less capable mode.


On Monday, April 13, 2015 at 1:42:28 PM UTC-4, vino wrote:
> Hi,
>
> I am trying to run a project in IDL VM. I am trying to convert fits headers into structures using the fitshead2struct.pro. My program fails at the MRD_STRUCT.pro, when the given tag values are strings, such as DATE_OBS.
>
> Can someone please help? Even an alternative to fitshead2struct is also welcome..
>
> This is all the error I receive from VM:
>
> 'ERROR - Invalid field value: ''
>
> Thanks in advance,
>
> Regards,
> Vino
Re: mrd_struct failure for string values inside the VM [message #90804 is a reply to message #90774] Thu, 16 April 2015 12:52 Go to previous messageGo to next message
vino is currently offline  vino
Messages: 36
Registered: March 2008
Member
Hi Wlandsman,

Thank you for reply. Can you please suggest any work around to this.. I just need to read in a fits header as a structure, so that I can access and modify them. I am taking some MEF files and making them single FITS files with appropriate headers added to them. Any help, will be much appreciated.

Thanks and regards,
Vino
Re: mrd_struct failure for string values inside the VM [message #90805 is a reply to message #90804] Fri, 17 April 2015 07:12 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
If you only have access to the IDL VM, I don't believe that you are going to be able to modify FITS files. Or is it that you have a license and are trying to write a VM application?

Anyway, if you have a FITS header (e.g. read in with headfits() ) then the following little program will convert it to a structure (by using a hash as a intermediary). --Wayne

function fits2struct,hdr
; struct = fits2struct(hdr)

keywords = strmid(hdr,0,8)
hashfits = hash()
foreach key,keywords do hashfits[key] = sxpar(hdr,key,/silent)
return,hashfits.tostruct()
end


On Thursday, April 16, 2015 at 3:52:04 PM UTC-4, vino wrote:
> Hi Wlandsman,
>
> Thank you for reply. Can you please suggest any work around to this.. I just need to read in a fits header as a structure, so that I can access and modify them. I am taking some MEF files and making them single FITS files with appropriate headers added to them. Any help, will be much appreciated.
>
> Thanks and regards,
> Vino
Re: mrd_struct failure for string values inside the VM [message #90806 is a reply to message #90805] Fri, 17 April 2015 10:10 Go to previous messageGo to next message
vino is currently offline  vino
Messages: 36
Registered: March 2008
Member
On Friday, 17 April 2015 10:12:50 UTC-4, wlandsman wrote:
> If you only have access to the IDL VM, I don't believe that you are going to be able to modify FITS files. Or is it that you have a license and are trying to write a VM application?
>
> Anyway, if you have a FITS header (e.g. read in with headfits() ) then the following little program will convert it to a structure (by using a hash as a intermediary). --Wayne
>
> function fits2struct,hdr
> ; struct = fits2struct(hdr)
>
> keywords = strmid(hdr,0,8)
> hashfits = hash()
> foreach key,keywords do hashfits[key] = sxpar(hdr,key,/silent)
> return,hashfits.tostruct()
> end
>
>
> On Thursday, April 16, 2015 at 3:52:04 PM UTC-4, vino wrote:
>> Hi Wlandsman,
>>
>> Thank you for reply. Can you please suggest any work around to this.. I just need to read in a fits header as a structure, so that I can access and modify them. I am taking some MEF files and making them single FITS files with appropriate headers added to them. Any help, will be much appreciated.
>>
>> Thanks and regards,
>> Vino

Hi Wayne,

wow.. Thank you so much.. I do have a runtime license..but have to write an application to run in a cluster without a license.. I will try this and let you know how it goes...

With warm regards,
Vino
Re: mrd_struct failure for string values inside the VM [message #90811 is a reply to message #90768] Sat, 18 April 2015 20:26 Go to previous messageGo to next message
alepliee is currently offline  alepliee
Messages: 4
Registered: April 2015
Junior Member
home='C:\Users\Cliente02\.idl\itt\projetos\'
;hubble=rd_tfile('teste.rtf',/auto,/convert)
openr,1,home+'distancia1.txt'

dados=fltarr(2,24)
readf,1,dados
close,1

openr,1,home+'velocidade1.txt'

luz=fltarr(1,24)
readf,1,luz
close,1

openr,1,home+'erro1.txt'

erros=fltarr(1,24)
readf,1,erros
close,1

redshift=dados(0,*)
velocidade=luz(0,*)
erroy=erros(0,*)

plot,redshift,velocidade,psym=2,xrange=[0.0,2.5],yrange=[-50 0.0,1500.0],$
xtit='Distancia(10E6)',ytit='Velocidade (km/s)',charsize=1.0,xminor=11,yminor=11
oploterror,redshift,velocidade,erroy,psym=3,errcolor=fsc_col or('red')
plots,2.2,1350,psym=2,symsize=1.
redshift2=[0.0,2.5]
xyouts,2.22,1350,'Amostras',charsize=1.
xyouts,2.22,1250,'Aj.Linear',charsize=1.,color=fsc_color('re d')
xyouts,2.22,1150,'Aj.Robusto',charsize=1.,color=fsc_color('g reen')

result=LINFIT(distancia,velocidade)
print,result
yfit=result(0)+result(1)*redshift2
oplot,redshift2,yfit,linestyle=3,color=fsc_color('red')
robusto=robust_linefit(redshift,velocidade,/bisect,NumIT = 1000)
yrob=robusto(0)+robusto(1)*redshift2
oplot,redshift2,yrob,linestyle=2,color=fsc_color('green')

end

Can someone tell me Why NOT appears as lines ?
Re: mrd_struct failure for string values inside the VM [message #90814 is a reply to message #90811] Mon, 20 April 2015 07:47 Go to previous messageGo to next message
vino is currently offline  vino
Messages: 36
Registered: March 2008
Member
On Saturday, 18 April 2015 23:26:16 UTC-4, alep...@gmail.com wrote:
> home='C:\Users\Cliente02\.idl\itt\projetos\'
> ;hubble=rd_tfile('teste.rtf',/auto,/convert)
> openr,1,home+'distancia1.txt'
>
> dados=fltarr(2,24)
> readf,1,dados
> close,1
>
> openr,1,home+'velocidade1.txt'
>
> luz=fltarr(1,24)
> readf,1,luz
> close,1
>
> openr,1,home+'erro1.txt'
>
> erros=fltarr(1,24)
> readf,1,erros
> close,1
>
> redshift=dados(0,*)
> velocidade=luz(0,*)
> erroy=erros(0,*)
>
> plot,redshift,velocidade,psym=2,xrange=[0.0,2.5],yrange=[-50 0.0,1500.0],$
> xtit='Distancia(10E6)',ytit='Velocidade (km/s)',charsize=1.0,xminor=11,yminor=11
> oploterror,redshift,velocidade,erroy,psym=3,errcolor=fsc_col or('red')
> plots,2.2,1350,psym=2,symsize=1.
> redshift2=[0.0,2.5]
> xyouts,2.22,1350,'Amostras',charsize=1.
> xyouts,2.22,1250,'Aj.Linear',charsize=1.,color=fsc_color('re d')
> xyouts,2.22,1150,'Aj.Robusto',charsize=1.,color=fsc_color('g reen')
>
> result=LINFIT(distancia,velocidade)
> print,result
> yfit=result(0)+result(1)*redshift2
> oplot,redshift2,yfit,linestyle=3,color=fsc_color('red')
> robusto=robust_linefit(redshift,velocidade,/bisect,NumIT = 1000)
> yrob=robusto(0)+robusto(1)*redshift2
> oplot,redshift2,yrob,linestyle=2,color=fsc_color('green')
>
> end
>
> Can someone tell me Why NOT appears as lines ?

Hi,

I think you have to post this as a separate question. Also, maybe you can be a little more clear as what does not appear as lines?
Re: mrd_struct failure for string values inside the VM [message #90815 is a reply to message #90805] Mon, 20 April 2015 07:48 Go to previous message
vino is currently offline  vino
Messages: 36
Registered: March 2008
Member
On Friday, 17 April 2015 10:12:50 UTC-4, wlandsman wrote:
> If you only have access to the IDL VM, I don't believe that you are going to be able to modify FITS files. Or is it that you have a license and are trying to write a VM application?
>
> Anyway, if you have a FITS header (e.g. read in with headfits() ) then the following little program will convert it to a structure (by using a hash as a intermediary). --Wayne
>
> function fits2struct,hdr
> ; struct = fits2struct(hdr)
>
> keywords = strmid(hdr,0,8)
> hashfits = hash()
> foreach key,keywords do hashfits[key] = sxpar(hdr,key,/silent)
> return,hashfits.tostruct()
> end
>
>
> On Thursday, April 16, 2015 at 3:52:04 PM UTC-4, vino wrote:
>> Hi Wlandsman,
>>
>> Thank you for reply. Can you please suggest any work around to this.. I just need to read in a fits header as a structure, so that I can access and modify them. I am taking some MEF files and making them single FITS files with appropriate headers added to them. Any help, will be much appreciated.
>>
>> Thanks and regards,
>> Vino

Hi Wayne,

I owe you a lot...Your solution works like a charm.. Thanks a ton....

With regards,
Vino
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Help!!!!
Next Topic: Function graphics in a widget window

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

Current Time: Wed Oct 08 11:34:51 PDT 2025

Total time taken to generate the page: 0.00494 seconds