; NAME : fit2dat.pro (procedure) ; PURPOSE : ; Translate data of HSOS from Fits format to dat format ; CATEGORY : ; IDL/HSOS ; CALLING SEQUENCE: ; IDL> fit2dat ; or (eg.) ; IDL> fit2dat, infile='L50213612020817.fit', outfile='l512136a.dat' ; ; KEYWORD PARAMETERS: ; infile: Fits data name ; outfile: dat file name ; data: 512 X 512 ; info: information of the observation ; SUBROUTINE: READFITS.PRO ; RESTRICTIONS: ; ONLY FOR MAGNETOGRAM FITS DATA OF HSOS ; ; NOTE: the output information is less than which in FITS header ; MODIFICATION HISTORY ; 2002-7-8 Liu Yu, write ;--------------------------------------------------------------- pro fit2dat,infile=fitsfile,outfile=datfile,data=data,info=info on_error,2 if n_elements(infile) eq 0 then begin infile='' outfile='' read,prompt='Enter the input Fits file: ',infile endif fitsname=strupcase(infile) length=strlen(fitsname) if length ne 19 then begin print,'Haven''t selected a file of Huairou!' data=0 info=0 goto,end_lable end first_char=strmid(fitsname,length-19,1) case first_char of "S":data=bytarr(640,480) "R":data=bytarr(640,480) "T":data=bytarr(640,480) "D":data=bytarr(640,480) "L":data=intarr(640,480) "Q":data=intarr(640,480) "U":data=intarr(640,480) "V":data=intarr(640,480) else: message,'Not a HSOS Fits format file!' endcase f1=strlowcase(strmid(infile,0,2)) f2=strmid(infile,7,2) f3=strmid(infile,4,3) f4='' read,prompt='Enter the alphabet for DAT file (a,b,c...x,y,z): ',f4 outfile=f1+f2+f3+f4+'.dat' tail=bytarr(65) xy=intarr(7) head=bytarr(80,36) ;<----------------------begin-------- openr,unit,infile,/get_lun readu,unit,head,data free_lun,unit head=string(head) calibration=sxpar(head,'CALIBRAT') tvscl,data data=congrid(data,512,512) pos=strpos(head(13),"' ") MHpos=strpos(head(13),":") tail(2:MHpos-11)=byte(strmid(head(13),11,MHpos-2-11+1)) tail(15:22)=byte(strmid(head(13),pos-8,8)) tail(62:62)=byte(strmid(head(16),11,1)) cal=strcompress(string(long(calibration)),/remo) help,cal tail(30:30)=strmid(cal,0,1) tail(31:31)=strmid(cal,1,1) tail(32:32)=strmid(cal,2,1) tail(33:33)=strmid(cal,3,1) tail(34:34)=strmid(cal,4,1) tail(35:35)=strmid(cal,5,1) pos=strpos(head(8),"' ") xy(0)=fix(float(strmid(head(8),11,pos-11))*10) pos=strpos(head(9),"' ") xy(1)=fix(float(strmid(head(9),11,pos-11))*10) pos=strpos(head(12),",L") xy(2)=fix(float(strmid(head(12),13,pos-12))*10) pos1=strpos(head(12),"' ") xy(3)=fix(float(strmid(head(12),pos+3,pos1-pos-4))*10) pos=strpos(head(11),",L") xy(5)=fix(float(strmid(head(11),13,pos-12))*10) pos1=strpos(head(11),"' ") xy(4)=fix(float(strmid(head(11),pos+3,pos1-pos-4))*10) xy(6)=fix(float(strmid(head(21),25,5))*10) openw,unit,outfile,/get_lun writeu,unit,data,tail,xy free_lun,unit ;-------------------------------end----> end_lable: end