Документ взят из кэша поисковой машины. Адрес оригинального документа : http://jet.sao.ru/hq/sun/WorkScan/ws_fits.pro
Дата изменения: Wed Feb 24 16:27:43 2010
Дата индексирования: Tue Oct 2 00:32:50 2012
Кодировка:

Поисковые слова: с р р с с п п р п п п п п п п п п п р п р п п п п р п р п п
pro loadfits
common ws_comm,namobj,solar_r,bunit,angle,xscale,centr_x, $
nfield,dtype,tdim,xmas,ddata,status,wscan,base,draw, $
list,fl_load,fl_iv,nfile,twoscn,exbeg,exend,wlsfrq

;pro loadfits
wscan=-1 & fl_load=0
nfile=pickfile(TITLE='Select Binary FITS file',filter='*.fit')
if nfile eq '' then goto,x_end
fxbopen, fid, nfile,1
fhdr=fxbheader(fid)
ndate=fxpar(fhdr,'DATE_OBS')
nobj=fxpar(fhdr,'OBJECT')
solar_r=fxpar(fhdr,'SOLAR_R')
bunit=fxpar(fhdr,'BUNIT')
angle=fxpar(fhdr,'ANGLE')
xscale=fxpar(fhdr,'XSCALE')
centr_x=fxpar(fhdr,'CENTRE_X')
nfield=fxpar(fhdr,'TFIELDS')
;tscal=fxpar(fhdr,'TSCAL*')
;tzero=fxpar(fhdr,'TZERO*')
dtype=strmid(fxpar(fhdr,'TTYPE*'),12,50)
tdim=fix(fxpar(fhdr,'TFORM1'))
xmas=(findgen(tdim)-centr_x)/solar_r;*xscale
ddata=make_array(nfield,tdim,/double)
for i=0,nfield-1 do begin
fxbread,fid,xdata,i+1;,/noscale
ddata(i,*)=xdata;*tscal(i)+tzero(i)
end
namobj=nobj+' '+ndate
widget_control, status, set_value='Load file:'+nfile
widget_control, list, set_value=dtype
widget_control, exbeg, set_value=strtrim(string(min(xmas)),2)
widget_control, exend, set_value=strtrim(string(max(xmas)),2)
wscan=0 & fl_load=1
x_end:
end

pro save_fits
common ws_comm,namobj,solar_r,bunit,angle,xscale,centr_x, $
nfield,dtype,tdim,xmas,ddata,status,wscan,base,draw, $
list,fl_load,fl_iv,nfile,twoscn,exbeg,exend,wlsfrq

sname=pickfile(/write, filt='*.save',file=nfile+'.save')
if sname(0) eq '' then return
rsun=solar_r*xscale
data_type=dtype
xarray=xmas*rsun
object=namobj
save,file=sname,rsun,data_type,ddata,xarray,object,bunit
end

pro ws_fits_event,ev

common ws_comm,namobj,solar_r,bunit,angle,xscale,centr_x, $
nfield,dtype,tdim,xmas,ddata,status,wscan,base,draw, $
list,fl_load,fl_iv,nfile,twoscn,exbeg,exend,wlsfrq
ivflux=-1
widget_control,get_uvalue=uval,ev.id
case uval of
'Menu': begin
case ev.value of
' 7': begin& wscan=-1& widget_control, /destroy, base& end ;Exit
' 6': save_fits ;save data to IDL save file
' 5': ivflux=1 ;V Flux
' 4': ivflux=0 ;I Flux
' 0': loadfits
' 1': if(fl_load eq 1 and wscan le nfield-1*twoscn) then wscan=wscan+1*twoscn
' 3': if(fl_load eq 1 and wscan ge 1*twoscn) then wscan=wscan-1*twoscn
' 2': if(fl_load eq 1) then begin
widget_control, exbeg, set_value=strtrim(string(min(xmas)),2)
widget_control, exend, set_value=strtrim(string(max(xmas)),2) & endif
endcase
end
'IandV': begin& if(twoscn eq 1) then twoscn=2 else twoscn=1
;wscan=twoscn*int(wscan/twoscn)& end
wscan=twoscn*round(wscan/twoscn)& end
'RandL': if(fl_iv eq 1) then fl_iv=0 else fl_iv=1
'WlsFrq': if(wlsfrq eq 1) then wlsfrq=0 else wlsfrq=1
'List': if(fl_load eq 1) then wscan=twoscn*round(ev.index/twoscn)
;'List': if(fl_load eq 1) then wscan=twoscn*int(ev.index/twoscn)
endcase
if (wscan ne -1) then begin
widget_control, get_value=xb, exbeg
widget_control, get_value=xe, exend
xb=float(xb)& xe=float(xe)
if (ivflux ne -1) then begin
if (ivflux eq 0) then titl='Intensity [R+L]' else titl='Polarization [L-R]'
yflux=dblarr(nfield/2) & frqmas=dindgen(nfield/2)
for i=0,nfield/2-1,1 do begin
j0=0 & while xmas(j0) lt xb(0) do j0= j0+1 & ss=ddata((i*2+ivflux),j0)
j1=0 & while xmas(j1) lt xe(0) do j1= j1+1
if j1 gt tdim-1 then j1=tdim-1 & ss=(ss+ddata((i*2+ivflux),j1))/2.0
yflux(i)=total(ddata((i*2+ivflux),j0:j1)) & yflux(i)=(yflux(i)-ss*(j1-j0))*1.0e-4*xscale
frqmas(i)=float(strmid(dtype(i*2+ivflux),0,6))
end
yflux1=smooth(yflux,5)
xtit='Frequency [GHz]'
save,frqmas,yflux,namobj,titl,xtit,ivflux,file='rat-flux.save'
if(wlsfrq eq 1) then begin & frqmas=30.0/frqmas & xtit='Wavelength [cm]' & end
; widget_control, get_value=index, draw
; wset,index
plot,frqmas,yflux,title=namobj+' : '+titl, xtitle=xtit, ytitle='Flux [s.f.u]' ,psym=2
oplot,frqmas,yflux1
endif else begin
titl=namobj+' '+dtype(wscan)
iscan=reform(ddata(wscan,*),tdim)
if(twoscn eq 2)then if (fl_iv eq 0) then begin
vscan=reform(ddata(wscan+1,*),tdim)& yshift=median(iscan)/2
endif else begin
iscan=reform(ddata(wscan,*)+ddata(wscan+1,*),tdim)
vscan=reform(ddata(wscan,*)-ddata(wscan+1,*),tdim)
yshift=0 ; &print,size(xmas),size(iscan),size(vscan)
endelse
; widget_control, get_value=index, draw
; wset,index
plot,xmas,iscan,xstyle=1,xrange=[xb,xe],title=titl,xtitle='Solar Radii', ytitle='Flux '+bunit
if(twoscn eq 2) then oplot,xmas,vscan+yshift,linestyle=1
endelse
end
end


pro ws_fits

common ws_comm,namobj,solar_r,bunit,angle,xscale,centr_x, $
nfield,dtype,tdim,xmas,ddata,status,wscan,base,draw, $
list,fl_load,fl_iv,nfile,twoscn,exbeg,exend,wlsfrq

wscan=-1 & fl_load=0 & namobj='None'& twoscn=1 & fl_iv=0 &wlsfrq=1
mtitl='Scan View for IDL v.1.0'
base=widget_base(title=mtitl,/column)
menu=cw_bgroup(base,/row,['Open','Next','Full','Prev','I Flux','V Flux','Save to IDL','Exit'],uvalue='Menu')
axa=widget_base(base,/row)
draw=widget_draw(axa,xsize=600,ysize=400,uvalue='Pics',ret=2)
list=widget_list(axa,value=['None'],/frame,uvalue='List',xsize=18)
axa=widget_base(base,/row)
aza=widget_base(axa,/row,/nonexclusive,/frame)
btnc=widget_button(aza,uvalue='IandV',value='Two polarization',/frame)
btnc=widget_button(aza,uvalue='RandL',value='R and L',/frame)
btnc=widget_button(aza,uvalue='WlsFrq',value='Frequency',/frame)
aaa=widget_label(axa,value='X begin:')
exbeg=widget_text(axa,value='-2',/editable,/frame,xsize=14)
aaa=widget_label(axa,value='X end:')
exend=widget_text(axa,value='2',/editable,/frame,xsize=14)
status=widget_label(base,value='No file open',xsize=600)
widget_control, /realize, base
widget_control, get_value=index, draw
wset,index
xmanager,'ws_fits',base
end