pro hr_css ;+ ; Purpose: Transfer Huairou full-disk H-alpha Mag data automatically to CSS everyday. ; modified from idl_winftp(by wxf,lgh,wgp), edited by yangx, HSOS, 2010-04-07 ; add latitude/longitude grid and limb-darkening correction (ref.: v1 by wxf), yangx, HSOS, 2011-05-14 ; ; Specify the directory where data are stored manually. ---YANG Xiao, HSOS, 2010-10-25 ;- ;on_error,2 device,retain=2,decomposed=0 !p.position=[0,0,1,1] ;spawn,'C:\Program Files (x86)\杩滅▼浠g悊宸ュ叿\SepcDRT.exe' ;-------------------------------------------------------------- ; Initialize variables, and define useful directory. spawn,'mkdir '+' E:\Data-css\Mag\Data\',/hide spawn,'mkdir '+' E:\Data-css\Mag\Jpg\',/hide spawn,'mkdir '+' E:\Data-css\Halpha\Jpg\',/hide month_str=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] month=['01','02','03','04','05','06','07','08','09','10','11','12'] while (1) do begin mm=month(where(month_str eq strmid(systime(),4,3))) dd=strmid(systime(),8,2) hh=strmid(systime(),11,2)+0 yr=strmid(systime(),20,4) if (hh gt 15) then begin get_juldate,jd jd=jd+0.666667 daycnv,jd,yr,mm,dd,hours mm=strtrim(string(mm),2) if (strlen(mm) eq 1) then mm='0'+mm dd=strtrim(string(dd),2) if (strlen(dd) eq 1) then dd='0'+dd yr=strmid(systime(),20,4) endif mmdd=mm+dd ;yr='2020' ;mmdd='0627' ;mm='06' ;dd='27' dhjpg='E:\H_alpha\JPG\'+yr+mmdd ;dhjpg='Z:\JPG\'+yr+mmdd if ~file_test(dhjpg) then spawn,'mkdir '+dhjpg,/hide ;dh='E:\H_alpha\2017\'+mm+'\'+dd+'\' ;---directory where halpha data are located ;dh='Z:\'+mmdd+'\' ;dh='E:\H_alpha\2019\08\03\' ; if ~file_test(dhjpg+'_.txt') then begin openw,11,dhjpg+'_.txt' printf,11, format='(A80)','aaaaaaaa' close,11 free_lun,11 endif openu,11,dhjpg+'_.txt' njpg=file_lines(dhjpg+'_.txt') fjpg=strarr(njpg) readf,11,fjpg ;if ~eof(11) then readf,11,oneline start_pos=(strlen(fjpg))(0) ffjpg=strmid(fjpg,start_pos-16,12);;Note that here the pos-16 is related to A80 dh='E:\H_alpha\'+yr+'\'+mm+'\'+dd+'\' ;---ldirectory where halpha data are located ;dh='Z:\'+mmdd+'\' dhjpg=dhjpg tf=file_search(dh+'\HrHa*full.fit',count=nn) ;fjpg=file_search(dhjpg+'\D_252000100401*.jpg',count=nnjpg) wait,1 for tfi=0,nn-1 do begin if(strlowcase(strmid(tf(tfi),strlen(tf(tfi))-8,4)) eq 'full') then ff1=strmid(tf(tfi),strlen(tf(tfi))-20,12) if(strlowcase(strmid(tf(tfi),strlen(tf(tfi))-9,5) eq 'local')) then ff1=strmid(tf(tfi),strlen(tf(tfi))-21,12) ind1=where(ffjpg eq ff1) if((size(ind1))(2) gt 1) then continue if(ind1 eq -1) then print,ind1,tf(tfi) if(ind1 eq -1) then begin img=readfits(tf(tfi),hdr) ;img=swap_endian(img) time=sxpar(hdr,'TIME_OBS') p_angle=get_rb0p(time,/pangle,/deg) ;+ ========================== add latitude/longitude grid and limb-darkening correction (ref.: v1 by wxf) B0 = get_rb0p(time, /b0angle);====The default is radians img=rotate(rot(img,-p_angle,1.,1234.5,1234.5,/interp,/pivot),5) loadct,3 ;nx=(size(img))(1)&ny=(size(img))(2) ;window,xs=nx,ys=ny,/pixmap window,0,xs=512,ys=512,/pixmap img=congrid(img,512,512,/interp) tvscl,img if(strlowcase(strmid(tf(tfi),strlen(tf(tfi))-8,4)) eq 'full') then begin date='20'+strmid(tf(tfi),strlen(tf(tfi))-20,2)+'-'+strmid(tf(tfi),strlen(tf(tfi))-18,2)+'-'+strmid(tf(tfi),strlen(tf(tfi))-16,2) time0=strmid(tf(tfi),strlen(tf(tfi))-14,2)+':'+strmid(tf(tfi),strlen(tf(tfi))-12,2)+':'+strmid(tf(tfi),strlen(tf(tfi))-10,2) ; xyouts,0.03,0.96,'Huairou Solar Observing Station',/normal,charsize=0.8,charthick=1.2 ; xyouts,0.03,0.93,'Ha '+date+' '+time0+' UT',/normal,charsize=0.8,charthick=1.2 xyouts,0.02,0.96,'Huairou Solar Observing Station',/normal,font=0 xyouts,0.02,0.92,date+' '+time0+' UT',/normal,font=0 xyouts,0.02,0.88,'Ha Image',/normal,font=0 endif ; if(strmid(tf(tfi),strlen(tf(tfi))-9,5) eq 'LOCAL') then begin ; date='20'+strmid(tf(tfi),strlen(tf(tfi))-21,2)+'-'+strmid(tf(tfi),strlen(tf(tfi))-19,2)+'-'+strmid(tf(tfi),strlen(tf(tfi))-17,2) ; time0=strmid(tf(tfi),strlen(tf(tfi))-15,2)+':'+strmid(tf(tfi),strlen(tf(tfi))-13,2)+':'+strmid(tf(tfi),strlen(tf(tfi))-11,2) ; xyouts,0.05,0.9,'Huairou Solar Observing Station',/normal,charsize=1 ; xyouts,0.05,0.1,'Ha '+date+' '+time0+' UT',charsize=1,/normal ; endif ; if(strmid(tf(tfi),strlen(tf(tfi))-8,4) eq 'FULL') then namefff=dhjpg+'\'+'D_252000100401_SA004001_01M_'+'20'+strmid(tf(tfi),strlen(tf(tfi))-20,12)+'.jpg' ; if(strmid(tf(tfi),strlen(tf(tfi))-9,5) eq 'LOCAL') then namefff=dhjpg+'\'+'D_252000100401_SA004001_01M_'+'20'+strmid(tf(tfi),strlen(tf(tfi))-21,12)+'.jpg' ; write_jpeg,namefff,tvrd(true=1),true=1,quality=100 ; ; spawn,'copy '+namefff+' E:\Data-css\Halpha\Jpg\',/hide if(strlowcase(strmid(tf(tfi),strlen(tf(tfi))-8,4) eq 'full')) then namefff='D_252000100401_SA004001_01M_'+'20'+strmid(tf(tfi),strlen(tf(tfi))-20,12)+'.jpg' if(strlowcase(strmid(tf(tfi),strlen(tf(tfi))-9,5) eq 'local')) then namefff='D_252000100401_SA004001_01M_'+'20'+strmid(tf(tfi),strlen(tf(tfi))-21,12)+'.jpg' write_jpeg,'E:\Data-css\Halpha\Jpg\'+namefff,tvrd(true=1),true=1,quality=100 ;缁熻浼犺緭缁檆ss鐨凥alpha鏁版嵁閲� ;openw,lun,'E:\zhaocui_nodelete\staticsone.txt',/get_lun,/append ;file=findfile('E:\Data-css\Halpha\Jpg\'+namefff,count=nn) ;if (nn eq 1) then begin ;OPENR,/GET_LUN,unit,file[0] ;status=FSTAT(unit) ;aa=bin_date(systime()) ;shjian=strtrim(aa[0],2)+'-'+strtrim(aa[1],2)+'-'+strtrim(aa[2],2)+' '+strtrim(aa[3],2)+':'+strtrim(aa[4],2)+':'+strtrim(aa[5],2) ;printf,lun,string('HrHa HrHa jpg ')+string(namefff)+' '+shjian+' '+strtrim(string(status.size),2)+string(' css') ;FREE_LUN,unit ;endif ;free_lun,lun ;缁撴潫缁熻 printf,11,format='(A80)',namefff endif endfor close,11 ; free_lun,11 iffi=0;;Two directory iffi=0 'E:\' for iff=iffi,4 do begin if (iff eq 0)then dh='E:\' if (iff eq 1)then dh='E:\'+strmid(yr,2,2)+mm+dd+'\' ; if (iff eq 2)then dh='E:\'+mm+dd+'\' ; if (iff eq 3)then dh='E:\Mag\'+strmid(yr,2,2)+mm+dd+'\' if (iff eq 4)then dh='E:\Mag\'+yr+'\'+mm+'\'+dd+'\' print,dh dhjpg='E:\Mag\JPG\'+yr+mmdd if ~file_test(dhjpg) then spawn,'mkdir '+dhjpg,/hide if ~file_test(dhjpg+'_.txt') then begin openw,21,dhjpg+'_.txt' printf,21, format='(A80)','aaaaaaaa' close,21 free_lun,21 endif openu,21,dhjpg+'_.txt' njpg=file_lines(dhjpg+'_.txt') fjpg=strarr(njpg) readf,21,fjpg start_pos=(strlen(fjpg))(0) ffjpg=strmid(fjpg,start_pos-21,12) tf=file_search(dh+'\*.fit',count=nn) ;fjpg=file_search(dhjpg+'\D_*.jpg',count=nnjpg) wait,1 ;if (nnjpg eq 0) then ffjpg='qqqqqqq' ; ;if (nnjpg ne 0) then begin ; ;ffjpg=strarr(nnjpg) ;for iii=0,nnjpg-1 do begin ;ffjpg(iii)=(strmid(fjpg(iii),strlen(fjpg(iii))-21,12)) ;endfor ;endif for i=0,nn-1 do begin ff1=strmid(tf(i),strlen(tf(i))-22,12) ind1=where(ffjpg eq ff1) ;print,ind1 if(ind1 eq -1) then begin l1=fltarr(992,992) & l2=fltarr(992,992) ;l=swap_endian(readfits(tf(i),hl)) l=readfits(tf(i),hl) m=strlen(tf(i)) time=strmid(tf(i),m-24,24) date='20'+strmid(time,2,2)+'-'+strmid(time,4,2)+'-'+strmid(time,6,2) time0=strmid(time,8,2)+':'+strmid(time,10,2)+':'+strmid(time,12,2) l1=l(*,*,0); & ls=congrid(l1,992/2.,1004/2.) l2=l(*,*,1) ;------------ vmax=max(l1+l2) ;print, vmax sv=10000.0*(l1-l2)/(l1+l2) ss=where(l1 lt 0.05*vmax, count) if count gt 0 then sv(ss)=-300 ; The above three lines used to cause error when WHERE returns -1. ; The original version is the following. (Xiaobo LI, Jan 22, 2012) ; ss=where(l1 lt 0.05*vmax) ; sv=10000.0*(l1-l2)/(l1+l2) ; sv(ss)=-300 ; ;sv=rot(sv,-16,/interp) ; sv=rotate(sv,5) ;wav=[-0.3] nx=(size(sv))(1)&ny=(size(sv))(2) window,0, xs=nx,ys=ny,/pixmap loadct,0 tvscl,sv>(-100)<100 xyouts,10,955,'Stokes '+sxpar(hl,'STOKES') ,size=3,CHARTHICK=3,/device xyouts,10,920,date,size=3,CHARTHICK=3,/device xyouts,10,885,time0,size=3,CHARTHICK=3,/device stokes=sxpar(hl,'STOKES') startobs=sxpar(hl,'startobs') datefff='20'+strmid(time,2,2)+strmid(time,4,2)+strmid(time,6,2) time0fff=strmid(time,8,2)+strmid(time,10,2)+strmid(time,12,2) ;namefff=dhjpg+'D_252000100301_SA003001_'+strmid(stokes,0,1)+'_'+string(datefff)+string(time0fff)+'_P00A.jpg' namefff='D_252000100301_SA003001_'+strmid(stokes,0,1)+'_'+string(datefff)+string(time0fff)+'_P00A.jpg' printf,21,format='(A80)',namefff write_jpeg,'E:\Data-css\Mag\Jpg\'+namefff,tvrd(true=1),true=1,quality=100 spawn,'copy '+tf(i)+' E:\Data-css\Mag\Data\',/hide ;spawn,'copy '+namefff+' E:\Data-css\Mag\Jpg\',/hide ;缁熻浼犺緭缁檆ss鐨勫叏鏃ラ潰纾佸満鏁版嵁閲� openw,lun1,'E:\zhaocui_nodelete\staticsone.txt',/get_lun,/append file=findfile('E:\Data-css\Mag\Jpg\'+namefff,count=nn) if (nn eq 1) then begin OPENR,/GET_LUN,unit,file[0] status=FSTAT(unit) aa=bin_date(systime()) shjian=strtrim(aa[0],2)+'-'+strtrim(aa[1],2)+'-'+strtrim(aa[2],2)+' '+strtrim(aa[3],2)+':'+strtrim(aa[4],2)+':'+strtrim(aa[5],2) if(strpos(namefff,'L') NE -1) then begin printf,lun1,string('FullMag L5 jpg ')+string(namefff)+' '+shjian+' '+strtrim(string(status.size),2)+string(' css') endif else begin if (strpos(namefff,'Q') NE -1) then begin printf,lun1,string('FullMag Q5 jpg ')+string(namefff)+' '+shjian+' '+strtrim(string(status.size),2)+string(' css') endif else begin printf,lun1,string('FullMag U5 jpg ')+string(namefff)+' '+shjian+' '+strtrim(string(status.size),2)+string(' css') endelse endelse FREE_LUN,unit endif file=findfile(tf(i),count=nn) if (nn eq 1) then begin OPENR,/GET_LUN,unit,file[0] status=FSTAT(unit) strspl=strsplit(tf(i),'\') number=N_ELEMENTS(strspl) filename=strmid(tf(i),strspl(number-1)) print,tf(i) print,file aa=bin_date(systime()) shjian=strtrim(aa[0],2)+'-'+strtrim(aa[1],2)+'-'+strtrim(aa[2],2)+' '+strtrim(aa[3],2)+':'+strtrim(aa[4],2)+':'+strtrim(aa[5],2) if(strpos(filename,'L') NE -1) then begin printf,lun1,string('FullMag L5 fit ')+string(filename)+' '+shjian+' '+strtrim(string(status.size),2)+string(' css') endif else begin if (strpos(filename,'Q') NE -1) then begin printf,lun1,string('FullMag Q5 fit ')+string(filename)+' '+shjian+' '+strtrim(string(status.size),2)+string(' css') endif else begin printf,lun1,string('FullMag U5 fit ')+string(filename)+' '+shjian+' '+strtrim(string(status.size),2)+string(' css') endelse endelse FREE_LUN,unit endif free_lun,lun1 ;缁撴潫缁熻 endif endfor close,21 free_lun,21 endfor;;iff wait,5 endwhile END