pro mk_drawing_hdr,date,_extra=extra,defhhmm=defhhmm,defseeing=defseeing, $ index=index,data=data,map=map ;+ ; ; Name : mk_drawing_hdr ; ; Purpose : Create header file (*.hdr) for sunspot sketch data observed ; in Mt. Wilson. ; ; Syntax : IDL> mk_drawing_hdr,date,[linethick=linethick], $ ; [index=index],[data=data],[map=map] ; ; The sketch image is displayed for reading the time and seeing ; of the observation. ; ; Observation time? (hhmm or xxxx(No description)) : 1530 ; Observation seeing? (ex: 2.5 or xxx(No description)) : 1.5 ; OK? (y/n/q) : y ; ; y -> header file will be created. ; n -> click 3 points on the solar limb to derive correct sun ; center. ; q -> program aborted. ; ; Input : date = observation date (YYYYMMDD) ; linethick = line thick of the limb plotting (in pixels) ; default value is 10 pixels. ; ; Output : drYYYYMMDD_HHMMSS.hdr is created in drawings/YYYY directory. ; drYYMMDD.jpg or drYYMMDD.gif is also downloaded from ; ftp://howard.astro.ucla.edu/pub/obs/drawings to the directory. ; index = fits header structure output ; data = sketch image data ; map = map structure created from index and data ; ; History : Written 1-Oct-2013 - by K. Otsuji ; ;- url='ftp://howard.astro.ucla.edu/pub/obs/drawings' obs='Mt. Wilson' tel='150ft. solar tower' savedir='drawings' if not isvalid(defhhmm) then defhhmm='1530' if not isvalid(defseeing) then defseeing='3' if not file_test(savedir) then file_mkdir,savedir date0=strjoin(strmid(date,[0,4,6],[4,2,2]),'-') utc=anytim2utc(date0) year=strmid(date,0,4) filename='dr'+strmid(date,2,6) imgfile=file_search(savedir+'/'+year+'/'+filename+['.jpg','.gif'],count=ni) if ni eq 0 then begin urllist=url+'/'+([year+'/',''])[indgen(4)/2]+ $ filename+(['.jpg','.gif'])[indgen(4) mod 2] openw,1,'url.list' printf,1,transpose(urllist) close,1 spawn,'wget -P '+savedir+'/'+year+' -i url.list',result,err file_delete,'url.list',/allow flg=strmatch(err,'*100%*') if max(flg,line) then imgfile=(strsplit(err[line+2],"`'",/ex))[1] else $ begin print,'No drawing data for the specified date.' return endelse endif data=read_image(imgfile) ss=size(data,/dim) if n_elements(ss) eq 3 then begin data=min(data,dim=1) ss=size(data,/dim) endif ss1=ss while max(ss1 gt 2000) do ss1/=2 wdef,0,ss1[0],ss1[1]+200 tvscl,data[ss[0]/2-ss1[0]/2:ss[0]/2+ss1[0]/2-1,0:199] tvscl,congrid(data,ss1[0],ss1[1]),0,200 hhmm='' flg=0 while flg eq 0 do begin read,hhmm,prompt='Observation time? (hhmm or xxxx(No description)) : ' if hhmm eq '' then hhmm=defhhmm notime=hhmm eq 'xxxx' if notime then hhmm=defhhmm tmp=strmid(hhmm,[0,2],[2,2]) flg=((max(tmp[0] eq string(indgen(48),form='(i2.2)')) and $ max(tmp[1] eq string(indgen(60),form='(i2.2)'))) or notime) $ and strlen(hhmm) eq 4 endwhile utc.MJD+=tmp[0]/24 time=strjoin(strmid(anytim2cal(utc,/date,form=8),[0,4,6],[4,2,2]),'-')+'T'+ $ string(tmp[0] mod 24,form='(i2.2)')+':'+tmp[1]+':00' filename0='dr'+anytim2cal(time,/date,form=8)+'_'+anytim2cal(time,/time,form=8) seeing='' flg=0 while flg eq 0 do begin read,seeing,prom='Observation seeing? (ex: 2.5 or xxx(No description)) : ' if seeing eq '' then seeing=defseeing noseeing=seeing eq 'xxx' if not noseeing then seeing=string(seeing,form='(f3.1)') flg=noseeing?1b:(float(seeing) ge 1.0 and float(seeing) le 5) endwhile xyr=detect_sketch_limb(data,_extra=extra) JUMP2: rb0p=get_rb0p(time,/deg,_extra=extra) mag=rb0p[0]/xyr[2] ;[arcsec/pixel] xc=-(xyr[0]-ss[0]/2.)*mag ;[arcsec] yc=-(xyr[1]-ss[1]/2.)*mag ;[arcesc] map=make_map(data,time=time,xc=xc,yc=yc,dx=mag,dy=mag) map=add_tag(map,rb0p[1],'B0') map=add_tag(map,rb0p[0],'RSUN') plot_map,map,grid=10,/limb,gsty=1,gcolor=0,lcolor=0,/noerase, $ position=[0,200./(ss1[1]+200),1,1] ans='ans' while ans ne '' and ans ne 'y' and ans ne 'n' and ans ne 'q' do $ read,ans,prompt='OK? (y/n/q) : ' if ans eq 'n' then begin plot_image,data,position=[0,200./(ss1[1]+200),1,1],/noerase print,'Click 3 points on solar limb. (1/3)' cursor,x1,y1,/down tmp=min(data[x1-5:x1+5,y1-5:y1+5],xy1) x1=x1-5+(xy1 mod 11) & y1=y1-5+(xy1/11) plots,x1,y1,psy=2,color=0 print,'Click 3 points on solar limb. (2/3)' cursor,x2,y2,/down tmp=min(data[x2-5:x2+5,y2-5:y2+5],xy2) x2=x2-5+(xy2 mod 11) & y2=y2-5+(xy2/11) plots,x2,y2,psy=2,color=0 print,'Click 3 points on solar limb. (3/3)' cursor,x3,y3,/down tmp=min(data[x3-5:x3+5,y3-5:y3+5],xy3) x3=x3-5+(xy3 mod 11) & y3=y3-5+(xy3/11) plots,x3,y3,psy=2,color=0 xyr=fit_circle([x1,x2,x3],[y1,y2,y3]) erase goto,JUMP2 endif if ans eq 'q' then return map=add_tag(map,map.time,'DATE_OBS') ssw_fake_index,time,index,cdelt1=mag,indata=data,xcen=xc,ycen=yc map2index,map,index index.filename=filename0 index.origin=obs index.telescop=tel index.object='sun' index=add_tag(index,file_basename(imgfile),'IMGFILE') index=add_tag(index,notime,'NOTIME') index=add_tag(index,noseeing,'NOSEEING') index=add_tag(index,seeing,'SEEING') head=struct2fitshead(index,data) openw,1,savedir+'/'+year+'/'+filename0+'.hdr' printf,1,transpose(head) close,1 end