; LION-Level-2 plot ;-----------------note! evtl uebergabe von rin durch L2plot ;=========================================================================== ;========================================================= ;=============== *** !!! programmer ! update Version no in module: MAIN ; ; VERSION_NR='1.0' ; VERSION_NR='1.03' allow file names LIO... and LIP... RMM ; ;=============== *** !!! update Version no in module: MAIN ;========================================================== ;=========================================================================== ; The Program is coded to plot LION Level-2 Data, generated by ; University of Kiel, Extraterrestrial Physics Group, resp. Ingo Elendt ; Coded by Holger Boll, boll@astrophysik.uni-kiel.de ; ;=========================================================================== ; This is a "library file" of the IDL program >LIONPLOT<. ALL procedures, ; needed to run it should be inside of the file. ; To run >LIONPLOT< compile first the whole file by typing ; ; IDL> .compile LIONPLOT ; ; Now, aLL routines wiLL be translated in one step. ; Then type in: ; IDL> main ; ; and the program wiLL start up. ;--------------------------------------------------------------------------- ; ;--------------------------------------------------------------------------- pro LioL2labcom ;--------------- common L2lab, L2label common LioL2lab, LL2label LL2label=[ $ ;--line 1 'GND1','GND2','CurT1D2','CurT2D1' $ ;-- 0: 3 ,'Ref1','Ref2' ,'Cur+5V','Cur+6V','CurT1B','CurT2B' $ ;-- 4: 9 ,'Cur-6V','Temp','CurT1D1','CurT2D1' $ ;-- 10:13 ,'+6V','+5V' $ ;-- 14:15 ,'stat1','stat2','stat3','stat4','stat5','stat6','stat7','stat8' $ ;--16:23 ;--line 2 ,'T2D1 P 300-750keV','T2D1 P .75-2MeV','T2D1 P 2-6 MeV' $ ;-- :26 ,'T2D1 He 7-26MeV' $ ;-- :27 ,'T2D2 P 300-750keV','T2D2 P .75-2MeV','T2D2 P 2-6 MeV' $ ;-- :30 ,'T2D2 He 7-26MeV' $ ;-- :31 ,'T2D1 P 40-80keV','T2D1 P 80-125 keV','T2D1 P 125-200keV' $ ;-- :34 ,'T2D1 P 200-300 keV' $ ;-- :35 ,'T2D2 P 40-80keV','T2D2 P 80-125 keV','T2D2 P 125-200keV' $ ;-- :38 ,'T2D2 P 200-300keV' $ ;-- :39 ,'T1D1 P+e 40-80keV','T1D1 P+e 80-125keV','T1D1 P+e 125-200keV' $ ;-- :42 ,'T1D1 P+e 200-300keV' $ ;:43 ,'T1D2 P+e 40-80keV','T1D2 P+e 80-125keV','T1D2 P+e 125-200keV' $ ;:46 ,'T1D2 P+e 200-300keV' $ ;:47 ,'T1D1 P 300-750 keV','T1D1 P .75-2MeV','T1D1 P 2-6MeV' $ ;:50 ,'T1D1 He 7-26MeV' $ ;:51 ,'T1D2 P 300-750 keV','T1D2 P .75-2MeV','T1D2 P 2-6MeV' $ ;:54 ,'T1D2 He 7-26 MeV' $ ;:55 ,'T1D1 Event Counts',' T2D1 Event Counts','T1D2 Event Counts' $ ;:58 ,'T2D2 Event Counts','T1B Event Counts','T2B Event Counts' ] ;:61 return end ;=========================================================================== ;=========================================================================== pro Lioplotcom ;---------------------------------------------------------------------------- ; plot parameter initialisation ;---------------------------------------------------------------------------- common Liofilepath $ ;-- init in Log_set , linpath $ ;-- input science file directory , loutpath ;-- output PostScript file directory ;-----y-axe parameter: y range setting ;----------------------------------------------------------------------------- common ylpar, ylran,yrlplt,lrin ;--ylrangedefault, in plot used ylran, ;.. index to ylran yrlplt=fltarr(2) yrlplt(*)=0 lrin=0 ;-- pntr to ylran(*,*,0) (default) or ylran(*,*,1) (selfmade) ;-- use idl automatic scaling ylran=fltarr(62,2,3) ylran(*)=0. x=findfile('YLRANL2.SVE',count=cnt) if(cnt gt 0)then begin restore,'YLRANL2.SVE' ;-- if a selfmade ylrange file exists: load it ylran(*,*,1)=ylrange endif ylran(*,*,2)=0 ;- IDL automatic ylrange common plotpar, pflag $ ; pflag 0=no period set 1=period set , yrmmdm $ ; string start date: year, month , noday $ ; number of days to plot , avgm ; averageing interval in minutes common plotdev, pdev ;-- plot device type common ncolor,ncol ;-- plot color setting x=size(pdev) if(x(1) eq 0)then begin pdev=!d.name loadct,0,/silent ncol=0 yrmmdm='19951207' noday=1l avgm=15 !x.style=1 !x.ticks=8 endif return end ;=========================================================================== ;=========================================================================== pro readL2com ;---------------------------------------------------------------------- common lreadpar $ ;-- aLL file info ,lin_file $ ;-- L2 input-file-array ,lfptr $ ;-- index pointer to in_file ,leof $ ;-- end of file flag ,lostat $ ;-- open status flag ,lfpos ;-- position in input-file in bytes lin_file='' ;-- aLL file info lfptr=0 ;-- index pointer to in_file leof=-1 ;-- end of file flag lostat=-1 ;-- open status flag lfpos=0 ;-- position in input-file in bytes return end ;=========================================================================== ;=========================================================================== pro syscom ;---------------------------------------------------------------------------- ; ;-- save sysvars for later resettings --; ; ;---------------------------------------------------------------------------- common syspar , resetp $ , resetd $ , resetx $ , resety resetp=!P resetd=!D resetx=!X resety=!Y return end ;=========================================================================== ;=========================================================================== pro xpscom ; Var definitions of general interest ;---------------------------------------------------------------------------- common psfile $ ,psfina $ ;-- postscript filename ,psopen $ ;-- flags open / not open status of PS file ,psopenlab $ ;-- label for psopenflag ,xps $ ;-- flags if output to ps file is desired ,xpslab $ ;-- label for xps ,Xmulti $ ;-- save !p.multi for X-window ,PSmulti ;-- save !p.multi for PS file xmulti=!p.multi PSmulti=!p.multi psfina='none' ; postscript file name xps=0 ; plot output to ps file =1/x-window=0 xpslab=['X-Window','Post-Script-File'] psopen=0 ; ps file open/ not open flag psopenlab=['not open','open'] common cntplot, cntX,cntPS ; plot counter for x-win & ps-file cntPS=0 ; count # plot in ps file cntX=0 ; count no plots in X window common panptr, ptrx,ptrps ; Panel pointer (saves !p.multi) ptrx=intarr(8) & ptrx(*) =0 ; .. in case of oplots ptrps=intarr(8) & ptrps(*)=0 common pmulti, px, py ;-- save !p.multi settings from px=0 ;.. set_plotwin.pro py=0 common pform $ ;-- plot paper config ,DinA $ ;-- Papersize 1=DinA-4, 2=DinA-3, 3=Us ,Pfmt ;-- protrait / landscape DinA=1 Pfmt=1 common printdev,devices,pdevice ; print device selection, selected device devices=['PS86 ','PSHP ','PS '] pdevice='PS86 ' return end ;=========================================================================== ;=========================================================================== function epoch_print,epoch ;---------------------------------------------------------------------- ; character function gives back a formatted string of time ; yyyy-mon-mod hh:mm:ss ;---------------------------------------------------------------------- cdf_epoch,epoch,yy,mo,dd,hh,mi,ss,/breakdown_epoch ctime=strtrim(string(yy,format='(I4)'),2)+'-' $ ; year +strtrim(string(mo,format='(I2.2)'),2)+'-' $ ; month +strtrim(string(dd,format='(I2.2)'),2)+' ' $ ; day of month +strtrim(string(hh,format='(I2.2)'),2)+':' $ ; hour +strtrim(string(mi,format='(I2.2)'),2)+':' $ ; minute +strtrim(string(ss,format='(I2.2)'),2) ; second RETURN,CTIME END ;=========================================================================== function ep_to_int,epoch ;------------------------------------------------------ ; compress EPOCH real*8 to int4, ms wiLL be lost ;------------------------------------------------------ ep_ref=62900000000000.d iepoch=long( (epoch - 62900000000000.d)/1000.) return,iepoch end ;=========================================================================== ;=========================================================================== function int_to_ep,iepoch ;---------------------------------------------------------------------- ; decompress int*4 iepoch to real*8 ;---------------------------------------------------------------------- ep_ref=62900000000000.d epoch=(iepoch*1000.d)+ep_ref return,epoch end ;=========================================================================== ;=========================================================================== function date_to_doy,year,month,dom ;---------------------------------------------------------------------- ; conversion from year, month, day of month to day of year (doy) ;---------------------------------------------------------------------- monthday=[31,28,31,30,31,30,31,31,30,31,30,31] if ( (year mod 4) eq 0)then monthday(1)=29 if(month eq 1)then begin doy=dom endif else begin doy=total(monthday(0:month-2))+dom endelse return,fix(doy) end ;=========================================================================== ;=========================================================================== function doy_to_date,year,doy ;---------------------------------------------------------------------- ; conversion day of year to month and day of month ; input: year for digits [yyyy] ; doy day of year [doy] ; output int array(2): month,day of month ;---------------------------------------------------------------------- ;------------! eval # month and day of month !------------------------ monthday=[31,28,31,30,31,30,31,31,30,31,30,31,10] if ( (year mod 4) eq 0)then monthday(1)=29 ;! SCHALTJAHR leap isum=0 i=-1 if(doy le 31)then begin ; January dom=doy month=1 endif else begin while(isum lt doy )do begin i=i+1 isum=isum+monthday(i) ;! SUM UP DAYS if ( isum ge doy)then begin dom=doy-total(monthday(0:i-1)) month=i+1 endif endwhile endelse ;------------! eval # month and day of month !------------------------ if(month ge 13 )then begin month=-1 dom=-1 endif return,[fix(month),fix(dom)] end ;=========================================================================== ;=========================================================================== pro ldatedefault common plotpar, pflag $ ; pflag 0=no period set 1=period set , yrmmdm $ ; string start date: year, month , noday $ ; number of days to plot , avgm ; averageing interval in minutes common Liofilepath $ ;-- init in Log_set , linpath $ ;-- input science file directory , loutpath ;-- output PostScript file directory ;x=findfile(linpath+'Lio*.SL*',count=cnt) x=findfile(linpath+'Li*.SL*',count=cnt) if(cnt gt 0)then begin xn=where(strpos(x,'GZ') eq -1) if(xn(0) eq -1)then begin wx=widget_message([' There is something wrong ' $ ,' with the Input-File Path ' $ ,' I could not find one file ' $ ,' ' $ ,' I advise to set a new path ' $ ,' ','or check extensions of input files !']) endif else begin x=x(xn) npos=rstrpos(x(0),'.SL')-5 yr='19'+strmid(x(0),npos,2) doy=strmid(x(0),npos+2,3) dat=doy_to_date(yr,doy) yrmmdm=string(yr,format='(I4.4)')+string(dat,format='(2i2.2)') endelse endif else begin wx=widget_message([' There is something wrong ' $ ,' with the Input-File Path ' $ ,' I could not find one file ' $ ,' ' $ ,' I advise to set a new path ' $ ,' ','or check extensions of input files !']) endelse return end ;=========================================================================== ;=========================================================================== pro save_dat,pl_tim,pl_dat ;-------------------------------------------------------------------- ; write selected data into a file ;-------------------------------------------------------------------- common dataformat, dset x=size(dset) if(x(1) eq 0)then dset=[1,1,0,0] ;-- init start config mset=dset ;-- save start config wb=widget_base(/column,title='S A V E D A T A ') wlb=widget_label(wb,xsize=150,ysize=30,/frame $ ,value='Select Time Tag(s)') cw=cw_bgroup(wb $ ,['1997-05-21:12:48' $ ,'EPOCH (ms since year 0)' $ ,'PB5 (yyyy doy ms)' $ ,'Std (since plot start)'] $ ,/nonexclusive,/column $ ,/return_index $ ,set_value=dset ) wbt1=widget_button(wb,value='ok') wbt2=widget_button(wb,value='cancel') widget_control,wb,/realize form='(x' loop=0 while( loop eq 0)do begin ev=widget_event(wb) widget_control,cw,get_value=dset if(ev.id eq cw) then form='(x' if(dset(0) eq 1)then form=form+',A19,x' else form=form+',a,x' if(dset(1) eq 1)then form=form+',D15.0,x' else form=form+',a,x' if(dset(2) eq 1)then form=form+',I4,x,I3,x,I8,x' else form=form+',a,x' if(dset(3) eq 1)then form=form+',f15.2,x' else form=form+',a,x' if(ev.id eq wbt1)then begin ;-- ok loop=2 widget_control,get_value=dset widget_control,wb,/destroy endif if(ev.id eq wbt2)then begin ;-- cancel loop=2 dset=mset widget_control,wb,/destroy endif endwhile ;pl_dat=indgen(6)*200 ;pl_tim=[104089664,104099664,104109664,104119664,104129664,104139664] vs=size(pl_dat) form=form+','+ strtrim(vs(2),2) +'(E15.5,x))' openw,13,'L2plot.dat' ep=int_to_ep(pl_tim(0)) cdf_epoch,ep,ryr,rmo,md,rhh,rmm,rss,/breakdown_epoch jd=julday(rmo,md,ryr) for i=0,vs(1)-1 do begin ep=int_to_ep(pl_tim(i)) eps=int_to_ep(pl_tim(i)) if(dset(0) eq 1)then begin ;--datum dt=epoch_print(eps) endif else dt=' ' if(dset(2) eq 1)then begin ;--pb5 pb5=ep_to_pb5(eps) endif else pb5=' ' if(dset(3) eq 1)then begin ;--std seit plot start cdf_epoch,eps,yr,mo,md,hh,mm,ss,/breakdown_epoch jda=julday(mo,md,yr) std=float(jda-jd)*24.+ float(hh) +float(mm)/60.+float(ss)/3600. endif else std=' ' if(dset(1) eq 1)then begin ;--epoch endif else ep=' ' if(pl_dat(i,0) gt -1)then begin printf,13,strtrim( $ strcompress( $ string(dt,ep,pb5,std,pl_dat(i,*),format=form) $ ) $ ,2) endif endfor close,13 dms=widget_message('Your data are saved in file: L1PLOT.DAT') return end ;=========================================================================== ;=========================================================================== pro set_ylrange,pidx,prange ;---------------------------------------------------------------------- ; set y selfmade range for LION single channels ; pidx: plot index: pointer into whole-channel-array (0:61) ; prange: plot y range , extract from whole-channel-array, contains only ; the channels which were selected for plotting ;---------------------------------------------------------------------- common LioL2lab, LL2label common ylpar, ylran,yrlplt,lrin ;--ylrangedefault, in plot used ylran, ;.. index to ylran wb=widget_base(/row,title='Set your personal Y-axe ranges') wb1=widget_base(wb,/column) wb2=widget_base(wb,/column) wla01=widget_label(wb1,value='select channel',xsize=300,ysize=30) wli=widget_list(wb1,value=LL2label,scr_xsize=70,scr_ysize=10*28) wla11=widget_label(wb2,value='channel default values ' $ ,xsize=300,ysize=30,/frame) wla12=widget_label(wb2,value='default values ' $ ,xsize=300,ysize=30,/frame) wt11=cw_field(wb2,ysize=1,xsize=26,/float,title='Lower value' $ ,/column ) wt12=cw_field(wb2,ysize=1,xsize=26,/float,title='Upper value' $ ,/column ) wbt=widget_button(wb2,value=' ----Done----') wbc=widget_button(wb2,value=' ----cancel----') widget_control,wb,/realize loop=0 while(loop eq 0) do begin x=size(cindx) ev=widget_event(wb) ;-- select channel in list widget if(ev.id eq wli)then begin if(x(1) ne 0)then begin widget_control,wt11,get_value=ylranl widget_control,wt12,get_value=ylranu if(ylranl ne ylran(cindx,0,1)) then ylran(cindx,0,1)=ylranl ;-- ylran low if(ylranu ne ylran(cindx,1,1)) then ylran(cindx,1,1)=ylranu ;-- ylran up endif widget_control,wla11,set_value=LL2label(ev.index)+': default values' widget_control,wla12,set_value=string(ylran(ev.index,0,0))+' - ' $ +string(ylran(ev.index,1,0)) cindx=ev.index ;-- save channel index widget_control,wt11,set_value=ylran(cindx,0,1) widget_control,wt12,set_value=ylran(cindx,1,1) endif ;--- if(ev.id eq wbt)then begin ;---done--- button if(x(1) ne 0)then begin widget_control,wt11,get_value=ylranl widget_control,wt12,get_value=ylranu if(ylranl ne ylran(cindx,0,1)) then ylran(cindx,0,1)=ylranl ;-- ylran low if(ylranu ne ylran(cindx,1,1)) then ylran(cindx,1,1)=ylranu ;-- ylran up for i=0,n_elements(pidx)-1 do begin ;--update prange prange(i,*,1)=ylran(pidx(i),*,1) endfor endif widget_control,wb,/destroy loop=2 ;-- end loop ylrange=ylran(*,*,1) ;-- get selfmade y-range values save,filename='YLRANL2.SVE',ylrange ;-- save them into file endif ;--- if(ev.id eq wbc)then begin ;---cancel--- button widget_control,wb,/destroy loop=2 ;-- end loop endif ;--- endwhile return end ;=========================================================================== ;=========================================================================== ;=========================================================================== pro set_newlxran ;------------------------------------------------------------------------ ; simple input widget for plot time parameter ; startdate in [yymmdmhhmm] : year, month , day of month ; enddate in [yymmdmhhmm] : year, month , day of month ; ; cancel: 0= no cancel 1=cancel ;------------------------------------------------------------------------ ; --- plotparameter (to be initialized by rtn >plotcom.pro< common plotdev, pdev ;-- plot device type common plotpar, pflag $ ; pflag 0=no period set 1=period set , yrmmdm $ ; string start date: year, month , noday $ ; number of days to plot , avgm ; averageing interval in minutes common lnewplotpar $ , lstart $ ; start time of new plot , lende ; endtime of newplot x=size(lstart) if(x(1) eq 0)then begin ;-- compute start end date values lstart=yrmmdm+'0000' juld=julday(strmid(yrmmdm,4,2),strmid(yrmmdm,6,2),strmid(yrmmdm,0,4)) juld=juld+noday caldat,juld,month,day,year cend= string(year,format='(i4)') $ + string(month,format='(i2.2)') $ + string(day,format='(i2.2)') lende=strcompress(strtrim(cend)+'0000') endif cancel=0 wcnt=0 savet=yrmmdm saven=noday savea=avgm pflag=1 ;------------------------------------------------widget construct start----- wb=widget_base(/column,title=' Plot Period Settings ') wlb0=widget_label(wb,xsize=600,ysize=20 $ ,value='Default values: ',/frame) lab1=widget_label(wb,xsize=600,ysize=20,value='Start: '+yrmmdm) lab2=widget_label(wb,xsize=600,ysize=20,value='Nod: '+string(noday)) wlb1=widget_label(wb,xsize=600,ysize=20 $ ,value=' Enter Start Time, Format [yyyymmdmhhmm]') wlb11=widget_label(wb,xsize=600,ysize=20 $ ,value=' yyyy=year, mm=month, dm=day of month, hh=hour,mm=minute ') wt1=widget_text(wb,/editable,/frame,ysize=1,xsize=8,value=lstart) wlb2=widget_label(wb,xsize=600,ysize=20 $ ,value=' Enter End Time, Format [yyyymmdmhhmm]') wlb22=widget_label(wb,xsize=600,ysize=20 $ ,value=' yyyy=year, mm=month, dm=day of month, hh=hour,mm=minute ') wt2=widget_text(wb,/editable,/frame,ysize=1,xsize=8,value=lende) ;-- cancel=widget_button(wb,value='---cancel---') reset =widget_button(wb,value='---reset---') okexit=widget_button(wb,value='--ok!-back--') widget_control,wb,/realize ;-----------------------------------------------------widget construct end--- ;---------------------------------------------widget loop start-------------- loop=0 while(loop eq 0)do begin wdf=0 ;-- wrong data format flag 0: ok: -1 not ok ev=widget_event(wb) if(ev.id eq okexit)then begin ;-- exit loop=2 ;-- widget_control,wt1,get_value=lstart ;--- get start date if( lstart(0) ne '' and strlen(lstart(0)) eq 12 )then lstart=lstart(0) if( strlen(lstart(0)) ne 12 or lstart(0) lt '199512070000')then begin x=widget_message('wrong start date format') loop=0 wdf=-1 endif ;-- widget_control,wt2,get_value=lende ;--- get number of days to plot if( lende(0) ne '' and strlen(lende(0)) eq 12 )then lende=lende(0) if( strlen(lende(0)) ne 12 or lende(0) lt '199512070000')then begin x=widget_message('wrong end date format') loop=0 wdf=-1 endif ;-- ; okexit=0 endif ;--- if(ev.id eq cancel)then begin ;-- cancel loop=2 cancel=0 endif ;--- if(ev.id eq reset)then begin ;-- reset loop=2 reset=0 endif ;--- endwhile widget_control,wb,/destroy ;--- if(wdf eq 0)then begin mth='' & dm='' & yr='' & hh='' & mm='' reads,lstart,yr,mth,dm,hh,mm,format='(i4,i2,i2,i2,i2)' cdf_epoch,epoch,yr,mth,dm,hh,mm,/compute_epoch ; eval epoch for plot start sepoch=ep_to_int(epoch) reads,lende,yr,mth,dm,hh,mm,format='(i4,i2,i2,i2,i2)' cdf_epoch,epoch,yr,mth,dm,hh,mm,/compute_epoch ; eval epoch for plot start eepoch=ep_to_int(epoch) !x.range=[sepoch,eepoch] !x.style=1 plttim=[sepoch,eepoch] endif ;--- if( reset eq 0)then begin ;-- set plot period to original values mth='' & dm='' & yr='' reads,yrmmdm,yr,mth,dm,format='(i4,i2,i2)' jul=julday(mth,dm,yr) ; get julday for plot start cdf_epoch,epoch,yr,mth,dm,/compute_epoch ; eval int-epoch for plot start sepoch=ep_to_int(epoch) jul=jul+long(noday) ; make julday for plot end caldat,jul,emth,edm,eyr ; eval date for plot end cdf_epoch,epoch,eyr,emth,edm,/compute_epoch ; eval int-epoch for plot end cdf_epoch,epoch,eyr,emth,edm,/breakdown_epoch ; eval int-epoch for plot end eepoch=ep_to_int(epoch) !x.range=[sepoch,eepoch] !x.style=1 plttim=[sepoch,eepoch] endif ;--- if( cancel eq 0 )then goto, bye ;--- plt=[10,10] ;-nuLL plot-- !x.tickv(*)=0 set_plot,/copy,'nuLL' plot,plttim,plt,xtick_get=v ;-- dummy plot !x.tickv=v ;... to get values of the ticks nel=n_elements(v) ticks=strarr(nel) for i=0,nel-1 do begin ;--then convert epoch values of ticks epo=int_to_ep(v(i)) ;--into date cdf_epoch,epo,yy,mm,dd,hh,mi,/breakdown_epoch date=string(date_to_doy(yy,mm,dd)) $ +'-'+string(hh,format='(i2.2)') $ +':'+string(mi,format='(i2.2)') ticks(i)=strcompress(date,/remove_aLL) endfor !x.tickname(*)='' !x.tickname=ticks set_plot,/copy,pdev bye: return end ;=========================================================================== ;=========================================================================== pro findpathlio,new ;---------------------------------------------------------------------- ; looks for a path to restore path information and set default path ; new: there are 2 situtations: 1. new=0: initial call ; 2. new=1: extra call for new path setting ;---------------------------------------------------------------------- common liofilepath,linpath,loutpath in_stat=0 ipath=' ' opath=' ' x=findfile('LIO2PATH.SVE',count=cnt) if(cnt ge 1)then begin restore,'LIO2PATH.SVE' ;--restore dpath variable linpath=ipath(0) loutpath=opath(0) endif if(cnt eq 0 and new eq 0)then begin xm=widget_message(['Before the program starts,' $ ,'enter the correct paths' $ ,'for input and output files']) endif if(cnt eq 0 or new eq 1)then begin ;====================================================widget construct======= WB=widget_base(title='SOHO LION File Path Selection',/column) WB1=widget_base(WB,/row) WB01=widget_base(WB1,/column) WB02=widget_base(WB1,/column) ;----input file path wlabi=widget_label(wb01,xsize=200,ysize=20,value='Input File Selection') wlisi=widget_list(wb01,xsize=25,ysize=3,value=ipath) wlabi=widget_label(wb01,xsize=200,ysize=20,value='(Set) Actual Input Path') wtexi=widget_text(wb01,/edit,value=ipath(0)) wclri=widget_button(wb01,value='-----Clear-----') wdeli=widget_button(wb01,value='-Delete from List-') waddi=widget_button(wb01,value='---Add to List---') wseeli=widget_button(wb01,value='-See File List-') ;----output file path wlabo=widget_label(wb02,xsize=200,ysize=20,value='Output File Selection') wliso=widget_list(wb02,xsize=25,ysize=3,value=ipath) wlabo=widget_label(wb02,xsize=200,ysize=20,value='(Set) Actual Output Path') wtexo=widget_text(wb02,/edit,value=opath(0)) wclro=widget_button(wb02,value='-----Clear-----') wdelo=widget_button(wb02,value='-Delete from List-') waddo=widget_button(wb02,value='---Add to List---') wseelo=widget_button(wb02,value='-See File List-') wdon=widget_button(wb,value='--Done--') widget_control,wb,/realize ;====================================================widget construct======= loop0=0 while(loop0 eq 0) do begin ;--loop as long input file are not found widget_control,wlisi,set_value=ipath widget_control,wliso,set_value=opath loop=0 while( loop eq 0) do begin ev=widget_event(wb) ;-- input list click ;--input---------------------------------------------------------------------- if(ev.id eq wlisi)then begin widget_control,wtexi,set_value=ipath(ev.index) ;--update actual input endif if(ev.id eq wclri)then begin ;--clear input widget widget_control,wtexi,set_value=' ',/input_focus endif if(ev.id eq wdeli)then begin ;--delete from list (input) widget_control,wtexi,get_value=idel x=where(ipath ne idel(0),cnt) if(cnt ge 1) then ipath=ipath(x) else ipath=' ' widget_control,wlisi,set_value=ipath ;--update list widget_control,wtexi,set_value=' ',/input_focus ;--clear input widget endif if(ev.id eq waddi)then begin ;--update list widget_control,wtexi,get_value=iadd if(iadd(0) ne ' ')then begin x=where(ipath eq iadd(0),cnt) if(cnt eq 0 ) then ipath=[iadd,ipath] widget_control,wlisi,set_value=ipath ;--update list endif endif if(ev.id eq wseeli)then begin ;--File List- (input) widget_control,wtexi,get_value=iadd x=findfile(iadd(0)+'*.SL2',count=cnt) if(cnt ge 1)then begin wl=widget_base(/column,title=' Input file list ') wld=widget_list(wl,value=x,scr_xsize=250,scr_ysize=200) done=widget_button(wl,value='---done---') widget_control,wl,/realize loopl=0 while(loopl eq 0)do begin ev=widget_event(wl) if(ev.id eq done)then loopl=1 endwhile widget_control,wl,/destroy endif else begin x=widget_message('No input files found, try another path') endelse wl=0 wld=0 done=0 endif ;--output------------------------------------------------------------------ if(ev.id eq wliso)then begin ;-- output list click widget_control,wtexo,set_value=opath(ev.index) ;--update actual output endif if(ev.id eq wclro)then begin ;--clear input widget (output) widget_control,wtexo,set_value=' ',/input_focus endif if(ev.id eq wdelo)then begin ;--delete from list (output) widget_control,wtexo,get_value=odel x=where(opath ne odel(0),cnt) if(cnt ge 1) then opath=opath(x) else opath=' ' widget_control,wliso,set_value=opath ;--update actual output widget_control,wtexo,set_value=' ',/input_focus ;--clear input window endif if(ev.id eq waddo )then begin ;--update list (output) widget_control,wtexo,get_value=oadd if(oadd(0) ne ' ')then begin x=where(opath eq oadd(0),cnt) if(cnt eq 0 ) then opath=[oadd,opath] widget_control,wliso,set_value=opath ;--update list (output) endif endif if(ev.id eq wseelo)then begin ;--File List- (input) widget_control,wtexo,get_value=oadd x=findfile(oadd(0)+'*.PS',count=cnt) if(cnt ge 1)then begin wl=widget_base(/column,title=' Output File List ') wld=widget_list(wl,value=x,scr_xsize=250,scr_ysize=200) done=widget_button(wl,value='---done---') widget_control,wl,/realize loopl=0 while(loopl eq 0)do begin ev=widget_event(wl) if(ev.id eq done)then loopl=1 endwhile endif else begin x=widget_message('No output files found, try another path') endelse widget_control,wl,/destroy wl=0 wld=0 done=0 endif if(ev.id eq wdon)then begin ;--done button loop=1 ;-----------------------------------------re-organize input path array widget_control,wtexi,get_value=iact linpath=iact(0) if(iact(0) ne ' ')then begin ipath=[iact,ipath] x=where(ipath eq iact(0),cnt) y=where(ipath ne iact(0)) if(cnt gt 1)then ipath=[ipath(0),ipath(y)] endif ;-----------------------------------------re-organize output path array widget_control,wtexo,get_value=oact loutpath=oact(0) if(oact(0) ne ' ')then begin opath=[oact,opath] x=where(opath eq oact(0),cnt) y=where(opath ne oact(0)) if(cnt gt 1)then opath=[opath(0),opath(y)] endif ;---------------------------------------------------------------------- endif ;--wdon endwhile loop0=1 ;------------------------------------check actual directory-------- fina=findfile(linpath+'*.SL2*',count=cnt) if(fina(0) eq '')then begin txt=['No files found in input directory ' $ ,' Are all logicals defined? ' $ ,' exit IDL? '] ok=widget_message(txt,/question) if(ok eq 'Yes')then exit else loop0=0 endif endwhile widget_control,wb,/destroy save,filename='LIO2PATH.SVE',ipath,opath endif return end ;=========================================================================== ;=========================================================================== pro open_psfile,psok ;---------------------------------------------------------------------- ; asks for detailed postscript file output desires ;---------------------------------------------------------------------- common plotdev, pdev ;-- plot device type common Liofilepath, linpath, loutpath ;--init in log_set common psfile $ ;-- def in PLOTCOM.PRO ,psfina $ ;-- postscript filename ,psopen $ ;-- flags open / not open status of PS file ,psopenlab $ ;-- label for psopenflag ,xps $ ;-- flags if output to ps file is desired ,xpslab $ ;-- label for xps ,Xmulti $ ;-- save !p.multi for X-window ,PSmulti ;-- save !p.multi for PS file common pform $ ;-- def in XPSCOM.PRO ,DinA $ ;-- Papersize 1=DinA-4, 2=DinA-3, 3=Us ,plfmt ;-- protrait / landscape common size_w $ ;-- def in OPEN_PSFILE.PRO , psize $ ;-- papersize widget switch status , plori ;-- plot orientation widget switch status ;======================================================================= xsize=fltarr(3,2) ; [a4/p, a3/p, us/p, a4/l, a3/l, us/l] xsize(*)=[17.5, 27.5, 18.5, 27.5, 35., 26.] ysize=fltarr(3,2) ; [a4/p, a3/p, us/p, a4/l, a3/l, us/l] ysize(*)=[26.5, 35. ,26. , 17.5, 27.5, 18.5] yoffset=fltarr(3,2) ; [a4/p, a3/p, us/p, a4/l, a3/l, us/l] yoffset(*)=[ 0.5, 1., 1. , 28.5 ,35. ,26.] papsize=['Din-A4: ','Din-A3: ','US-Format: '] plorient=['Portrait','Landscape'] ;============================================================================= psok=0 ;-- 0: opening of file was ok / 1: not ok if(psfina(0) eq 'none')then psfina='idl.ps' x=size(psize) if(x(1) eq 0)then psize=0 ;-- init paper size x=size(plori) if(x(1) eq 0)then plori=0 ;-- init plot orientation ;============================================================================= ;-start---------------- widget construct------------------------------------- if(psopen ne 1)then begin ;--if no other psfile was opened wb = WIDGET_BASE(title='Open Your Personal Postscript File' $ ,/column $ ,SPACE = 20 $ ,YPAD = 10) wlb1=widget_label(wb,xsize=350,ysize=30,/frame $ ,value='Open Your Personal Postscript File') wb1 = WIDGET_BASE(wb,/row) ;---Paper Size widget--- bg1=cw_bgroup(wb1,['A4','A3','USF'] $ ,/exclusive,/frame,set_value=psize $ ,/return_index,/column,LABEL_TOP=' Paper Size Selection') ;---plot orientation widget--- bg2=cw_bgroup(wb1,['Portrait','Landscape'] $ ,/exclusive,/frame,set_value=plori $ ,/return_index,/column,LABEL_TOP=' Plot Orientation') ;---filename widget--- wlb1=widget_label(wb,xsize=300,ysize=30,value='Change File Name here') wt=widget_text(wb, value=psfina,XSIZE = 45 ,YSIZE = 1,/edit ) wbc = WIDGET_BUTTON(wb, VALUE = "not open") wbt = WIDGET_BUTTON(wb, VALUE = "Open PS File and Exit") widget_control,wb,/realize ;-end---------------- widget construct------------------------------------- ;======================================================================= loop=0 while(loop eq 0) do begin we=widget_event(wb) if(we.id eq bg1)then psize=we.value ;--get papersize if(we.id eq bg2)then plori=we.value ;--get plot orientation widget_control,wt,get_value=psfina ;--get filename DinA=psize(0) plfmt=plori(0) ;======================================================================= if(we.id eq wbt)then begin ;--exit and open-- button loop=1 psopen=1 ;-- open-ps-file flag: 0=close, 1=open set_plot,/copy,'PS' device,filename=loutpath+psfina(0) $ ,landscape=plfmt $ ,xoffset=1. $ ,yoffset=yoffset(DinA,plfmt) $ ,xsize=xsize(DinA,plfmt) $ ,ysize=ysize(DinA,plfmt) mx=widget_message( ['Open PostScript File: '+psfina(0) $ ,'Format: '+papsize(dinA) $ +': '+string(xsize(DinA,plfmt)) $ +' x '+string(ysize(DinA,plfmt)) $ ,'Orient: '+plorient(plfmt) $ ,'!! Do not forget to toggle the output' $ ,'to PS output'] ) set_plot,/copy,pdev endif ;======================================================================= if(we.id eq wbc)then begin ;--cancel and not open--- loop=1 psopen=0 endif ;======================================================================= endwhile widget_control,wb,/destroy ;--if no other psfile was openedend endif else begin mx=widget_message('Sorry, but there is aLLready a PS file open') psok=1 endelse ;======================================================================= return end ;=========================================================================== ;=========================================================================== pro panfig ;------------------------------------- ; Panel configurations ;------------------------------------- common plotdev, pdev ;-- plot device type common syspar , resetp $ , resetd $ , resetx $ , resety common plotpar, pflag $ ;-- 0=no period set 1=period set , yrmmdm $ ;-- string start date: year, month , noday $ ;-- number of days to plot , avgm ;-- averageing interval in minutes ;--------------------------------initial tick settings------------------------ wcnt=0 ;--init x-window pmulti=!p.multi !p.multi=[0,0,0] mth='' & dm='' & yr='' reads,yrmmdm,yr,mth,dm,format='(i4,i2,i2)' jul=julday(mth,dm,yr) ; get julday for plot start cdf_epoch,epoch,yr,mth,dm,/compute_epoch ; eval int-epoch for plot start sepoch=ep_to_int(epoch) jul=jul+long(noday) ; make julday for plot end caldat,jul,emth,edm,eyr ; eval date for plot end cdf_epoch,epoch,eyr,emth,edm,/compute_epoch ; eval int-epoch for plot end cdf_epoch,epoch,eyr,emth,edm,/breakdown_epoch ; eval int-epoch for plot end eepoch=ep_to_int(epoch) !x.range=[sepoch,eepoch] !x.style=1 plt=[10,100,1000] plttim=[sepoch,sepoch+(eepoch-sepoch)/2,eepoch] ;-nuLL plot-- !x.tickv(*)=0 set_plot,/copy,'nuLL' plot,plttim,plt,xtick_get=v ; dummy plot to get values of the ticks !x.tickv=v nel=n_elements(v) ticks=strarr(nel) for i=0,nel-1 do begin epo=int_to_ep(v(i)) cdf_epoch,epo,yy,mm,dd,hh,mi,/breakdown_epoch date=string(date_to_doy(yy,mm,dd)) $ +'-'+string(hh,format='(i2.2)') $ +':'+string(mi,format='(i2.2)') ticks(i)=strcompress(date,/remove_aLL) endfor !x.tickname(*)='' !x.tickname=ticks set_plot,/copy,pdev ;--------------------------------initial tick settings------------------------ axetype=[' linear ',' logarithmic '] xi=size(init) if(xi(1) eq 0)then init=0 if(init eq 0)then begin init=1 endif plts=['point to point' $ ,'Plus sign (+)' $ ,'Asterix (*)' $ ,'Period (.)' $ ,'Diamond' $ ,'Triangle' $ ,'Square' $ ,'X' $ ,'undefined' $ ,'undefined' $ ,'Histogr. mode'] ;======================================================================= wb=widget_base(/column,title='Set Panel Configuration') wtx=widget_text(wb,value=' Set Panel Configuration & Plot symbol' $ ,xsize=40,ysize=1) wb1=widget_base(wb,/row) wsl11=widget_slider(wb1,minimum=0,maximum=20,value=!y.ticks $ ,title='set major tick number y-axe',/vertical) wsl12=widget_slider(wb1,minimum=0,maximum=20,value=!x.ticks $ ,title='set major tick number x-axe' ) wb2=widget_base(wb,/row) wsL21=widget_slider(wb2,minimum=0,maximum=20,value=!y.minor $ ,title='set minor tick number y-axe',/vertical) wsL22=widget_slider(wb2,minimum=0,maximum=20,value=!x.minor $ ,title='set minor tick number x-axe' ) wb3=widget_base(wb,/row) wl31=widget_list(wb3,value=plts,scr_xsize=200,scr_ysize=200) wtx31=widget_text(wb3,value= $ [' present config: ' $ ,' y-major: '+string(!y.ticks) $ ,' x-major: '+string(!x.ticks) $ ,' y-minor: '+string(!y.minor) $ ,' x-minor: '+string(!x.minor) $ ,' Plott symbol: '+plts(!p.psym) $ ,' P symbol size: '+string(!p.symsize) $ ,' y-axe type: '+axetype(!y.type)] $ ,xsize=25,ysize=6) wsl01=cw_fslider(wb,minimum=0.,maximum=6.,value=!P.symsize $ ,title='Plot symbol size',/drag) wb4=widget_base(wb,/row) wbt40=widget_button(wb,value='show tick settings') wbt41=widget_button(wb4,value='reset aLL ') wbt42=widget_button(wb4,value='done with Panel config') widget_control,wb,/realize ;======================================================================= loop=0 while(loop eq 0) do begin ;======================================================================= ev=widget_event(wb) ;======================================================================= widget_control,wsl01,get_value=psize widget_control,wsl01,set_value=psize !P.symsize=psize(0) widget_control,wtx31,set_value= $ [' present config: ' $ ,' y-major: '+string(!y.ticks) $ ,' x-major: '+string(!x.ticks) $ ,' y-minor: '+string(!y.minor) $ ,' x-minor: '+string(!x.minor) $ ,' Plot symbol: '+plts(!p.psym) $ ,' P symbol size: '+string(!p.symsize) $ ,' y-axe type: '+axetype(!y.type)] if(ev.id eq wsl11)then !y.ticks=ev.value ; y-axe major ticks if(ev.id eq wsl12)then !x.ticks=ev.value ; x-axe major ticks if(ev.id eq wsL21)then !y.minor=ev.value ; y-axe minor ticks if(ev.id eq wsL22)then !x.minor=ev.value ; x-axe minor ticks if(ev.id eq wl31)then !p.psym=ev.index ; plot symbol if(ev.id eq wbt41)then begin ; reset !p=resetp ; !x=resetx ; !y=resety widget_control,wsl11,set_value=!y.ticks widget_control,wsl12,set_value=!x.ticks widget_control,wsL21,set_value=!y.minor widget_control,wsL22,set_value=!x.minor widget_control,wsl01,set_value=!P.symsize endif ;======================================================================= ;---set x-range, show tick setting-------------- if(ev.id eq wsl12)then begin mth='' & dm='' & yr='' reads,yrmmdm,yr,mth,dm,format='(i4,i2,i2)' jul=julday(mth,dm,yr) ; get julday for plot start cdf_epoch,epoch,yr,mth,dm,/compute_epoch ; eval int-epoch for plot start sepoch=ep_to_int(epoch) jul=jul+long(noday) ; make julday for plot end caldat,jul,emth,edm,eyr ; eval date for plot end cdf_epoch,epoch,eyr,emth,edm,/compute_epoch ; eval int-epoch for plot end cdf_epoch,epoch,eyr,emth,edm,/breakdown_epoch ; eval int-epoch for plot end eepoch=ep_to_int(epoch) !x.range=[sepoch,eepoch] !x.style=1 plttim=[sepoch,sepoch+(eepoch-sepoch)/2,eepoch] ;-nuLL plot-- !x.tickv(*)=0 set_plot,/copy,'nuLL' plot,plttim,plt,xtick_get=v ; dummy plot to get values of the ticks !x.tickv=v nel=n_elements(v) ticks=strarr(nel) for i=0,nel-1 do begin epo=int_to_ep(v(i)) cdf_epoch,epo,yy,mm,dd,hh,mi,/breakdown_epoch date=string(date_to_doy(yy,mm,dd)) $ +'-'+string(hh,format='(i2.2)') $ +':'+string(mi,format='(i2.2)') ticks(i)=strcompress(date,/remove_aLL) endfor !x.tickname(*)='' !x.tickname=ticks set_plot,/copy,pdev endif if(ev.id eq wbt40)then begin ;--show tickmark settings set_plot,/copy,pdev if(wcnt ne 5)then window,5 plot,plttim,plt,ytype=!y.type ; dummy plot to show ticksettings wcnt=5 endif ;======================================================================= ;--- if(ev.id eq wbt42)then loop=1 endwhile !p.multi=pmulti if !D.window eq 5 then wdelete,5 widget_control,wb,/destroy return end ;=========================================================================== ;=========================================================================== pro readr_LioL2,posflag,L2dat ;---------------------------------------------------------------------- ;posflag: ;-- file position flag ; ;.. 0=read from actual position ; ;.. 1=read from preceding position ;--L2 rate structure---------------------------- LL2={Lio2 $ ;-line-1 , pb51:lonarr(3) $ ; year [yyyy], doy [ddd], ms of day [ss sss sss] , epoch:0.d $ ;-- ms sinc ad , lihk1:fltarr(16) $ ;-- LION housekeeping , lihk2:lonarr(8) $ ;-- LION housekeeping, misc ;-line-2 , pb52:lonarr(3) $ ; hh/min/sec , ldat1:fltarr(38) $ ;--LION intens 1.part , spar2:0 $ ;-line-3 , pb53:lonarr(3) $ ; hh/min/sec , ldat2:fltarr(38) $ ;--LION intens 2.part , spar3:0 $ ;-line-4 , pb54:lonarr(3) $ ; hh/min/sec , ldat3:fltarr(38) $ ;--LION intens 3.part , spar4:0 $ ;-line-5 , pb55:lonarr(3) $ ; hh/min/sec , ldat4:fltarr(38) $ ;--LION intens 4.part , spar5:0 } L2dat={L2s ,epoch:0.d, LLdat:fltarr(62) } ;-- handover struct to sum up proc common lreadpar, lin_file,lfptr,leof,lostat,lfpos ;-- aLL file info common liunits, li_un,li_msg li_un=30 li_msg=31 common plotpar, pflag $ ;-- 0=no period set 1=period set , yrmmdm $ ;-- string start date: year, month , noday $ ;-- number of days to plot , avgm ;-- averageing interval in minutes xs=size(lfpos) if(xs(1) eq 0)then lfpos=0 loop=0 while (loop eq 0) do begin loop=1 !err=0 if(leof eq -1)then begin ;--open new file ix=size(li_un) if(ix(1) ne 0 )then begin if(li_un ne 0)then free_lun,li_un ;--init filepointer endif on_ioerror,ioerr if(lfptr ge noday)then begin print,'End of read-in period reached' lostat=-2 ;--end of last file , end of read-in period goto, enderr endif openr,li_un,lin_file(lfptr) ;,/get_lun print,'READR_LioL2:: open: ',lin_file(lfptr) lfptr=lfptr+1 ;--increment filepointer lfpos=0 lostat=0 ;-- open status = ok goto,noerr ioerr: print,strcompress(!err_string) lostat=-1 ;-- open status = not ok goto,enderr noerr: endif ;print,' read:: ',strcompress(!err_string),' lostat',lostat,' pos ',posflag if(lostat eq 0)then begin on_ioerror,rerr ;-- on read error goto r-error: mark if(posflag eq 1)then point_lun,li_un,lfpos point_lun,-li_un,lfpos readf,li_un,LL2 ;-- read data set L2dat.epoch=LL2.epoch L2dat.LLDAT( 0:15)=LL2.lihk1 L2dat.LLDAT(16:23)=float(LL2.lihk2) for i=0,37 do begin L2dat.LLDAT(i+24)= $ total([LL2.ldat1(i),LL2.ldat2(i),LL2.ldat3(i),LL2.ldat4(i)]) endfor leof=0 goto,norerr rerr: print,strcompress(!err_string) if(strpos(!err_string,'End of file') gt -1) then begin leof=-1 lfpos=0 loop=0 ;-- second loop with new file to open endif norerr: endif ;---- hier evtl error interrupt endwhile enderr: return end ;=========================================================================== ;=========================================================================== pro sum_LioL2,lindx,pl_tim,pl_dat ;print,'sum:: lindx: ',lindx ;---------------------------------------------------------------------- ; LioL2dat: see readr_LioL2 for data format ; ; lindx : pointer to L2 data, cnts and intensities ; pl_dat : averaged plot data ;---------------------------------------------------------------------- common initsum, sinit ;-- start-of-summing-up flag common plotpar, pflag $ ;-- 0=no period set 1=period set , yrmmdm $ ;-- string start date: year, month , noday $ ;-- number of days to plot , avgm ;-- averageing interval in minutes common lreadpar , lin_file $ ;-- input file names , lfptr $ ;-- pointer to in_file , leof $ ;-- End-of-File flag , lostat ;-- file open status nex=n_elements(lindx) ;-- number of channel to plot ix=size(sinit) ;-- initialize start of summing up if(ix(1) eq 0)then sinit=0 ;--init summings if(sinit eq 0)then begin ;--find first intervaltime posflag=0 ;-- file position flag ;.. 0=read from actual position ;.. 1=read from preceding position lfptr=0 leof=-1 nint=(noday*1440)/avgm ;--number of intervals if(((noday*1440)/avgm) ne 0)then nint=nint+1 pl_tim=fltarr(nint) ;--init plot time array pl_dat=fltarr(nint,nex) ;--init plot data array hlp_dt=fltarr(nex) ;--interims data buffer hlp_dt(*)=0. reads,yrmmdm,syr,smm,sdm,format='(i4,i2,i2)' ;--split up start date cdf_epoch,sepoch,syr,smm,sdm,0,0,/compute_epoch ;--intvl start in epoch eepoch=sepoch+avgm*60000 ;--intvl end in epoch mepoch=sepoch+(avgm*30000) ;--mid of interval jul=julday(smm,sdm,syr)+noday ;-- get julday for final plot time caldat,jul,fmm,fdm,fyr ;-- eval date for final plot time cdf_epoch,fepoch,fyr,fmm,fdm,0,0,/compute_epoch ;-- final epoch ;--print,'first int: ',epoch_print(sepoch),' - ',epoch_print(eepoch) endif ;--init summings --end-- for i=0,nint-1 do begin ;-- aLL-interval loop------------------------- loop=0 ;-- interval time loop switch intcnt=0 ;-- count number of elements in intcl hcnt=intarr(nex) hcnt(*)=0 ;--interval fiLL loop pl_dat(i,*)=0. ;-- init pl_dat while(loop eq 0) do begin ;-- read input until interval is fuLL loopl=0 ;-------------------------------------------------------- ;--find first record with fitting time tag in input file ;-------------------------------------------------------- while(loopl eq 0) do begin ;-- read input file until time fits loopl=1 readr_LioL2,posflag,L2dat ;-- read 1 set of L2 data if(lostat eq -1) then begin msx=widget_message(['Error opening input file', lin_file(lfptr) $ ,'----File path wrong???----']) goto,enderr endif posflag=0 ;-- next read from actual file position pl_tim(i)=ep_to_int(L2dat.epoch) ;-- get epoch, convert it to flt*4 if(L2dat.epoch le sepoch)then loopl=0 ;print,' int: ',epoch_print(sepoch),' - ',epoch_print(eepoch),' - ' $ ; ,epoch_print(fepoch) ;print,' L2 ep ',epoch_print(L2dat.epoch) if(lostat eq -2)then loopl=1 ;-- ostat-2: end of last file endwhile if((L2dat.epoch gt sepoch) and (L2dat.epoch le eepoch) $ and (L2dat.epoch le fepoch)) then begin ;------------- ;-- summing up ;------------- intcnt=intcnt+1 ;-- count number of elements per intvl for j=0,nex-1 do begin ;-- get L2 data, shift them to helpbuff pl_dat(i,j)=pl_dat(i,j)+L2dat.LLdat(lindx(j)) hcnt(j)=hcnt(j)+ (L2dat.LLdat(lindx(j)) ne 0) endfor ;-- help-buf shift loop (loop counter=j) endif else begin ;-- L2 time fits into intvl or not ;---------------- ;-- build average ;---------------- if(intcnt gt 0)then begin hcnt=hcnt > 1 pl_dat(i,*)=pl_dat(i,*)/hcnt endif else pl_dat(i,*)=-707. ;-- flag data gap loop=1 ;-- start next interval posflag=1 ;-- next read from preceding record mepoch=sepoch+avgm*30000. pl_tim(i)=ep_to_int(mepoch) ;-- get epoch, convert it to flt*4 sepoch=eepoch ;-- set new intvl times eepoch=sepoch+avgm*60000. endelse ;-- sum up / build average if(lostat eq -2)then loop=1 ;-- ostat-2: end of last file endwhile ;-- fiLL-intervaLL loop )loop switch = >loop< endfor ;-- aLL-interval loop (loop counter =i) enderr: return end ;=========================================================================== ;=========================================================================== pro plot_LL2d,LLidx,plabel,prange,pl_tim,pl_dat,lbdat ;-- plot L-2 data ;---------------------------------------------------------------------- ; input : LLidx: indeces to intensity and counter arrays ; : plabel plot label (extracted out of LL2label) ; : prange plot y-range (extracted out of YLRAN) ; : pl_tim plot time array, contains (averaged) mid of intervals ; : pl_dat plot data array, depending on number of channels to ; plot, a 1-dim or a 2-dim array ; values of -707 flag data gaps ;---------------------------------------------------------------------- common ncolor,ncol ;-- plot color setting common ylpar, ylran,yrlplt,lrin ;-- ylrange default, in plot used ylran ;.. index to ylran common plotdev, pdev ;-- plot device type common plotpar, pflag $ ; pflag 0=no period set 1=period set , yrmmdm $ ; string start date: year, month , noday $ ; number of days to plot , avgm ; averageing interval in minutes common psfile $ ,psfina $ ;-- postscript filename ,psopen $ ;-- flags open / not open status of PS file ,psopenlab $ ;-- label for psopenflag ,xps $ ;-- flags if output to ps file is desired ,xpslab $ ;-- label for xps ,Xmulti $ ;-- save !p.multi for X-window ,PSmulti ;-- save !p.multi for PS file common LioL2lab, LL2label common cntplot, cntX,cntPS ; plot counter for x-win & ps-file common panptr, ptrx,ptrps ; Panel pointer (saves !p.multi) datatype=strarr(41) datatype(0:12)='Intensity' datatype(13:*)='Counts' ytit=strarr(62) xs=size(LLidx) if(xs(0) eq 0)then ploop=0 ;-- 0-dim data array if(xs(0) ge 1)then ploop=xs(1)-1 ;-- n-dim data array nex=n_elements(pl_dat(*,0)) ;-- number of data records for j=0,xps do begin ;--x/ps loop if(j eq 1)then set_plot,/copy,'PS' for i=0,ploop do begin ;-- channel loop pl_hlp=pl_dat(*,LLidx(i)) pl_hlp=reform(pl_hlp) ;--generate 0-dim plot array xn=where(pl_hlp ne -707,cntn) pltim=pl_tim(xn) ;--kick -707 out pl_hlp=pl_hlp(xn) ;------------data gap detector------------ px=where([pltim,0] - [0,pltim] gt avgm*65, cnt) ;-------------y-range setting------------- yrlplt=[prange(LLidx(i),0,lrin), prange(LLidx(i),1,lrin)] ;--ylrange ;------------plot device pannel pointer if(!D.name eq pdev)then !p.multi=Xmulti if(!D.name eq 'PS')then !p.multi=PSmulti ;-- no-data plot to get frame, o-plot foLLows plot,pltim,pl_hlp $ ,title='SOHO LION '+ plabel(LLidx(i)) $ ,ytitle=ytit(LLidx(i)) $ ,ytype=!y.type $ ,yrange=yrlplt $ ,xtitle='Start Date:'+yrmmdm $ ,background=255 $ ,color=0 $ ,/nodata if(!D.name eq 'PS')then begin PSmulti=!p.multi cntPS=cntPS+1 ;--plot-counter PS-file endif if(!D.name eq pdev)then begin Xmulti=!p.multi cntX=cntX+1 ;--plot-counter x-window endif s=0 if(px(0) eq 0 and cnt eq 1)then cnt=0 if(cnt eq 0)then begin ;-- if no data gaps, prepare px and cnt cnt=1 ;.. to loop once for a complete plot px(0)=n_elements(pltim)-1 endif for p=0,cnt-1 do begin ;--plot in intervals from gap to gap e=px(p)-1 if(s lt e)then begin oplot,pltim(s:e),pl_hlp(s:e),color=ncol endif s=px(p) endfor if(((n_elements(pltim)-1) -e) gt 1)then begin e=e+1 oplot,pltim(e:*),pl_hlp(e:*),color=ncol endif endfor ;--channel loop endfor ;--x/ps loop if(!D.name eq 'PS')then set_plot,/copy,pdev lbdat=[min(pl_hlp),max(pl_hlp)] return end ;=========================================================================== ;=========================================================================== pro oplot_LL2d,lindx,pindx,pl_tim,pl_dat,pin,sran,lbdat ;---------------------------------------------------------------------- ; input : lindx: indeces to intensity and counter arrays ; : pl_tim plot time array, contains (averaged) mid of intervals ; : pl_dat plot data array, depending on number of channels to ; plot, a 1-dim or a 2-dim array ; values of -707 flag data gaps ; : pin channel index, to save y-range from the basic plot ; : sran y range, used in plot which now shaLL be overplotted ; : lbdat min and max value,used in last plot ;---------------------------------------------------------------------- common loplotfac,lofac common ncolor,ncol ;-- color settings common ylpar, ylran,yrlplt,lrin ;--ylrangedefault, in plot used ylran ;.. index to ylran common plotdev, pdev ;-- plot device type common plotpar, pflag $ ; pflag 0=no period set 1=period set , yrmmdm $ ; string start date: year, month , noday $ ; number of days to plot , avgm ; averageing interval in minutes common psfile $ ,psfina $ ;-- postscript filename ,psopen $ ;-- flags open / not open status of PS file ,psopenlab $ ;-- label for psopenflag ,xps $ ;-- flags if output to ps file is desired ,xpslab $ ;-- label for xps ,Xmulti $ ;-- save !p.multi for X-window ,PSmulti ;-- save !p.multi for PS file common LioL2lab, LL2label common cntplot, cntX,cntPS ;-- plot counter for x-win & ps-file common panptr, ptrx,ptrps ;-- Panel pointer (saves !p.multi) xsmulti=xmulti pssmulti=psmulti ;---- ;----set !P.multi back for plot/noerase-(o-plot)----x-window ;--set back pmulti(0), but look that it does not become bigger then max plot# smul= indgen(max([xsmulti(1),1]) * max([xsmulti(2),1]) ) smul=shift(smul,-1) xsmulti(0)=smul(xsmulti(0)) ;----set !P.multi back for plot/noerase----- ;---- ;----set !P.multi back for plot/noerase-(o-plot)----ps-file ;--set back pmulti(0), but look that it does not become bigger then maps plot# psmul= indgen( max([pssmulti(1),1]) *max([pssmulti(2),1]) ) psmul=shift(psmul,-1) pssmulti(0)=psmul(pssmulti(0)) ;----set !P.multi back for plot/noerase----- ; datatype=strarr(41) datatype(0:12)='Intensity' datatype(13:*)='Counts' ytit=strarr(41) ytit(0:7)='/cm**2 s sr MeV' ytit(8:11)='/cm**2 s sr MeV/n' ytit(12)='/cm**2 s sr ' ytit(13:*)='Counts/minute' xs=size(lindx) if(lindx(0) eq -1)then lindx=lindx(1:*) ;-- shrink array if(xs(0) eq 0)then ploop=0 ;-- 0-dim data array if(xs(0) ge 1)then ploop=xs(1)-1 ;-- n-dim data array nex=n_elements(pl_dat(*,0)) ;-- number of data records for j=0,xps do begin ;--x/ps loop if(j eq 1)then set_plot,'PS' for i=0,ploop do begin ;-- channel loop pl_hlp=pl_dat(*,pindx(i)) pl_hlp=reform(pl_hlp) ;--generate 0-dim plot array xn=where(pl_hlp ne -707,cntn) pltim=pl_tim(xn) ;--kick -707 out pl_hlp=pl_hlp(xn) ;------------data gap detector------------ px=where([pltim,0] - [0,pltim] gt avgm*65, cnt) if(!D.name eq pdev)then !p.multi=Xsmulti if(!D.name eq 'PS')then !p.multi=PSsmulti ; yrlplt=[ylran(0,pin,lrin), ylran(1,pin,lrin)] ;--ylrange yrlplt=sran ;--plot frame first---- plot,[min(pltim),max(pltim)],lbdat $ ;-- no-data plot for the Panel ,yrange=yrlplt $ ;..with data from last plot ,ytype=!y.type $ ;--lin/log ,background=255 $ ,color=0 $ ,xstyle=5 $ ;--exact range, suppress x-axe ,/noerase $ ,/nodata if(!D.name eq 'PS')then begin psmul=shift(psmul,2) !p.multi(0)=psmul(pssmulti(0)) PSmulti=!p.multi ; cntPS=cntPS+1 ;--plot-counter PS-file endif if(!D.name eq pdev)then begin smul=shift(smul,2) !p.multi(0)=smul(xsmulti(0)) Xmulti=!p.multi ; cntX=cntX+1 ;--plot-counter x-window endif s=0 if(px(0) eq 0 and cnt eq 1)then cnt=0 if(cnt eq 0)then begin ;-- if no data gaps, prepare px and cnt cnt=1 ;.. to loop once for a complete plot px(0)=n_elements(pltim)-1 endif ;--check if y-axe logarithm (1) or linear(0) scaled if(!y.type eq 0) then pl_hlp=pl_hlp +lofac(0) else pl_hlp=pl_hlp*lofac(0) for p=0,cnt-1 do begin ;--plot in intervals from gap to gap e=px(p)-1 if(s lt e)then begin oplot,pltim(s:e),pl_hlp(s:e),color=ncol endif s=px(p) endfor if(((n_elements(pltim)-1) -e) gt 1)then begin e=e+1 oplot,pltim(e:*),pl_hlp(e:*),color=ncol endif endfor ;--channel loop endfor ;--x/ps loop if(!D.name eq 'PS')then set_plot,pdev return end ;=========================================================================== pro Lplot_menL2,lindx,plabel,prange,pl_tim,pl_dat ;---------------------------------------------------------------------- ; input lindx: index in LL2label-array (contains intensity and counter labels) ; pl_tim: plot time array ; pl_dat: plot data array ;---------------------------------------------------------------------- common ylpar, ylran,yrlplt,lrin ;--ylrangedefault, in plot used ylran, ;.. index to ylran common plotdev, pdev ;-- plot device type common psfile $ ,psfina $ ;-- postscript filename ,psopen $ ;-- flags open / not open status of PS file ,psopenlab $ ;-- label for psopenflag ,xps $ ;-- flags if output to ps file is desired ,xpslab $ ;-- label for xps ,Xmulti $ ;-- save !p.multi for X-window ,PSmulti ;-- save !p.multi for PS file common LioL2lab, LL2label common cntplot, cntX,cntPS ; plot counter for x-win & ps-file common panptr, ptrx,ptrps ; Panel pointer (saves !p.multi) common pmulti, px,py ; window config (Panel dispersion) common loplotfac,lofac ; -- overplot factor lofac=1 ;--overplot factor ylab=['default','selfmade','IDL-autom'] axetype=['---linear---','-logaritmic-'] plotmode=['Plot Mode: Plot','Plot Mode: O-plot'] pmode=0 pin=-1 ;--plot basic index for o-plots if(lindx(0) eq -1)then lindx=lindx(1:*) ;-- shrink array to delete -1 flag ;====================================================================== ;-----------------! widget construct !--------------------------------- wb = WIDGET_BASE(title='LION L2 Plot-Menu ', $ ;create the base /row) wb1=widget_base(wb,/column) mchoice=LL2label(lindx) ;--preset list widget with selected channels lnel=n_elements(lindx) wt=widget_text(wb1,value=['To plot single channels' $ ,'double-click on list, else use' $ ,'>--Plot ALL--< Button'] $ ,ysize=3,xsize=26 ) wl=widget_list(wb1,value=mchoice,scr_xsize=70,scr_ysize=lnel*28) wbt=widget_button(wb1,value='---Plot ALL---') wbt1=widget_button(wb1,value='---y-linear--') wbt2=widget_button(wb1,value='y-range: '+ylab(lrin)) wbt3=widget_button(wb1,value='---Save Data---') wla=widget_label(wb1,value='! Watch Info Boxes !',xsize=200,ysize=26) wt12=widget_text(wb1,ysize=2,xsize=30 $ ,value=['Output goes to :'+xpslab(xps) $ ,'PS File is: '+psopenlab(psopen)]) wt13=widget_text(wb1,value=['PostScript Filename:',psfina] $ ,ysize=2,xsize=30) wt21=widget_text(wb1,value=['Plot Window Config:' $ ,'X-Directn.: '+string(!p.multi(1)) $ ,'Y-Directn.: '+string(!p.multi(2))] $ ,ysize=3,xsize=20) wt23=widget_text(wb1,value=['X-win counter: '+string(cntX) $ ,'PS-File count: ',+string(cntPS)] $ ,ysize=2,xsize=20) wb2=widget_base(wb,/column) bg20=widget_button(wb2,value='--set color--') bg200=widget_button(wb2,value=plotmode(pmode)) bg202=widget_button(wb2,value='O-plot fac help') ;--over plot help wt20=widget_text(wb2,value='1',XSIZE = 11 ,YSIZE = 1,/edit) bg201=widget_button(wb2,value='Annotations') bg203=widget_button(wb2,value='Write_GIF') bg21=cw_bgroup(wb2, ['open PS ', 'close PS','toggle x/ps ' ,'-' $ ,'clear plotwindow','destroy plotwindow','-' $ ,'config plotwindow ','config pltpanel' $ ,'set Y-range','set x-range' $ ,'back to main menu'] $ ,/column,/return_index) widget_conTRol,wb,/realize ;-----------------! widget construct !--------------------------------- ;====================================================================== ;====================================================================== ;-----------------! widget loop !-------------------------------------- loop=0 while(loop eq 0 ) do begin widget_conTRol,wb,/show pe=widget_event(wb) ; check widget base event ;==================================================================== if(pe.id eq wbt)then begin ;--- plot aLL channel pmultx=Xmulti pmultPs=Psmulti xmulti=[0,0,lnel] psmulti=[0,0,lnel] pindx=indgen(lnel) ;--index list of left list ;... widget in main menu plot_LL2d,pindx,plabel,prange,pl_tim,pl_dat,lbdat pin=-1 pmode=0 widget_control,bg200,set_value=plotmode(pmode) xmulti=pmultx & xmulti(0)=0 psmulti=pmultps & psmulti(0)=0 endif ;==================================================================== if(pe.id eq wbt1)then begin ;--- linear/ logarithmic scaling if(!y.type eq 0) then !y.type=1 else !y.type=0 widget_control,wbt1,set_value='y-scaling: '+axetype(!y.type) endif ;==================================================================== if(pe.id eq wbt2)then begin ;--- select y-range if(pmode eq 0)then begin lrin=lrin+1 ;-- lrin: range index default: 0 ;.. selfmade: 1 ;.. idl automat: 2 if(lrin eq 3)then lrin=0 widget_control,wbt2,set_value='y-Range: '+ylab(lrin) endif else begin pmsg=widget_message(' you cannot change Y-ranging in O-plot mode') endelse endif ;==================================================================== if(pe.id eq wbt3)then begin ;--- save data save_dat,pl_tim,pl_dat endif ;==================================================================== ;--widget_list, coincidence and SDC choice------ plot single channel if(pe.id eq wl)then begin ;--- widget list choice xmulti(1:2)=[px,py] psmulti(1:2)=[px,py] if(pe.clicks eq 2 )then begin if(pmode eq 0)then begin plot_LL2d,pe.index,plabel,prange,pl_tim,pl_dat,lbdat pin=pe.index ;-- save channel index for o-plots sran=yrlplt if(lrin eq 2)then sran=!y.crange endif else begin if(pin gt -1) then begin ;-- start O-plot widget_control,wt20,get_value=cofac lofac=float(cofac) oplot_LL2d,lindx(pe.index),pe.index,pl_tim,pl_dat,pin,sran,lbdat endif else begin wms=widget_message( ['Dont o-plot an empty or PLOT-ALL sheets' $ ,' ' $ ,'set plot mode to >PLOT< and repeat'] ) endelse endelse endif endif ;==================================================================== ;---set plot mode plot/oplot if(pe.id eq bg200)then begin ;--plot-mode: 0 / o-plot mode:1 if(pmode eq 0)then pmode=1 else pmode=0 widget_control,bg200,set_value=plotmode(pmode) endif ;==================================================================== ;---annotations if(pe.id eq bg201)then begin anots,xps endif ;==================================================================== ;---overplot factor help if(pe.id eq bg202)then begin omsg=widget_message($ ['The ''factor'' below this button is multiplicated '$ ,'with the data in case of logarithmic scaling,' $ ,'it is added to the data in case of linear scaling']) endif ;==================================================================== if(pe.id eq bg203)then begin ;---write_gif write_gif,'LION.gif',tvrd() mgif=widget_message('New GIF file: LION.GIF') endif ;==================================================================== ;---set color if(pe.id eq bg20)then set_col ;====cw_button_group==================================================== if(pe.id eq bg21)then begin ;----left button group ;=-0-=================================================================== if(pe.value eq 0)then begin ;---open PostScript file open_psfile,psok if(psok eq 0)then begin cntPS=0 ;-- reset plot Panel counter for PS file endif widget_control,wt12 $ ,set_value=['Output goes to: '+xpslab(xps) $ ,'PS File is : '+psopenlab(psopen)] endif ;=-1-=================================================================== if(pe.value eq 1)then begin ;---close PostScript file if(psopen eq 0)then begin txt='no PS file open ' mes=widget_message(txt,/information) endif else begin set_plot,/copy,'PS' xps=0 device,/close set_plot,/copy,pdev psopen=0 txt='close PS file: '+psfina mes=widget_message(txt,/information) widget_control,wt12 $ ,set_value=['Output goes to:'+xpslab(xps) $ ,'PS File is : '+psopenlab(psopen)] endelse endif ;=-2-================================================================= if(pe.value eq 2)then begin ;---set output to PS file if(xps eq 1) then xps=0 else xps=1 ;-- toggle switch X/PS if(xps eq 1) then begin if(psopen eq 0)then begin txt='You must first open a PS File' mes=widget_message(txt,/information) xps=0 endif else begin xps=1 ;-- set plot output to X and PS endelse endif else begin xps=0 ;-- set plot output to X endelse widget_control,wt12 $ ,set_value=['output:'+xpslab(xps),'PS File is : '+psopenlab(psopen)] endif ;=-3-================================================================= ;=-4-================================================================= if(pe.value eq 4 )then begin ;-- clear plotwindow erase,color=255 ; reset aLL plot counter cntX=0 !p.multi(0)=0 endif ;=-5-================================================================= if(pe.value eq 5)then begin ;---destr. plotwin wdelete cntX=0 !p.multi(0)=0 endif ;=-6-================================================================= ;=-7-================================================================= if(pe.value eq 7)then begin ;---config plotwin set_plotwin cntX=0 pin=-1 endif ;=-8-================================================================= if(pe.value eq 8)then begin ;---config plot Panel--- panfig endif ;=-9-================================================================= if(pe.value eq 9)then begin ;---ylrange setting set_ylrange,lindx,prange endif ;=-10-================================================================= if(pe.value eq 10)then begin ;---x sub range setting set_newlxran endif ;=-11-================================================================= if(pe.value eq 11)then begin ;---back to outputmanager loop=2 endif ;====================================================================== ;--show plotwindow config-- widget_control,wt21,set_value=['Plot Window Config:' $ ,'X-Directn.: '+string(!p.multi(1)) $ ,'Y-Directn.: '+string(!p.multi(2))] endif ;====cw_button_group=end================================================ widget_control,wt13,set_value=['PostScript Filename:',psfina] widget_control,wt23,set_value=['X-win counter: ' $ +strcompress(string(cntX)) $ ,'PS-File count: ' $ +strcompress(string(cntPS))] endwhile ende: widget_control,wb,/destroy return end ;=========================================================================== ;=========================================================================== pro anots,xps ;-------------------------------------------------------------------------- ;simple tool to annotate the plots ;input xps flags whether output goes to postscript file or not ;-------------------------------------------------------------------------- common ncolor,ncol peh=!p !p.background=255 atext=' ' chsiz=1. orient=0 xfon=3 cfont=['','','' $ ,' 3 Simplex Roman' $ ,' 4 Simplex Greek' $ ,' 5 Duplex Roman' $ ,' 6 Complex Roman' $ ,' 7 Complex Greek' $ ,' 8 Complex Italic' $ ,' 9 Math & Special' $ ,'10 Special Char' $ ,'11 Gothic English' $ ,'12 Simplex Script' $ ,'13 Complex Script' $ ,'14 Gothic Italian' $ ,'15 Gothic German' $ ,'16 CyriLLic' $ ,'17 Triplex Roman' $ ,'18 Triplex Italic'] wb=widget_base(/column) wt1=widget_text(wb,value= ['Put in your annotation: ' $ ,'- text, size, orientation - first,' $ ,'then click on >Start Mouse<' $ ,'then move mouse over X-Window' $ ,'then click, and your text appears'] $ ,ysize=6,xsize=40) wt2=widget_text(wb,/editable,/frame,ysize=1,xsize=30) wsl1=cw_fslider(wb,minimum=1.0,maximum=4.0 $ ,title='set text character size' ,value=1.,/drag) wsL2=widget_slider(wb,minimum=0,maximum=360,title='set text orientation' $ ,value=0) wsl3=widget_slider(wb,minimum=3,maximum=18,title='set vector font' $ ,value=3) wbt1=widget_button(wb,value='font help') wbt2=widget_button(wb,value='start mouse') wbt3=widget_button(wb,value='done with annots') widget_control,wb,/realize xx=indgen(100) yy=indgen(100) loop=0 while(loop eq 0) do begin ev=widget_event(wb) widget_control,wt2,get_value=atext ; get annotation text widget_control,wsl1,get_value=chsiz ; get charactersize widget_control,wsL2,get_value=orient ; get orientation widget_control,wsl3,get_value=xfon ; get font widget_control,wsl1,set_value=chsiz ; get charactersize wdelete,2 if(ev.id eq wbt1)then begin ; --- help vector font window,2 mult=!p.multi ; save x window config !p.multi(*)=0 ; reset x window config plot,xx,yy,/nodata,title='Font help' ; dummy plot frame cnt=2 for i=0.95,0.05,-0.057 do begin cnt=cnt+1 xyouts,0.05,i,'!'+strcompress(string(cnt),/remove_aLL ) $ +cfont(cnt),charsize=2. $ ,color=0,/norm endfor !p.multi=mult endif if(ev.id eq wbt2)then begin cursor,x,y,/wait,/data,/up atext='!'+strcompress(string(xfon),/remove_aLL)+atext+'!X' xyouts,x,y,atext,charsize=chsiz,orientation=orient,color=0 if(xps eq 1)then begin set_plot,/copy,'ps' xyouts,x,y,atext,charsize=chsiz,orientation=orient,color=0 set_plot,/copy,'x' endif endif if(ev.id eq wbt3)then loop=1 endwhile widget_control,wb,/destroy wdelete,2 !p=peh return end ;=========================================================================== ;=========================================================================== pro set_col ;-------------------------------------------------------------------------- ; set plot colors. background is set to white, line color can be selected ; by draging a slider button ;------------------------------------------------------------------------- red= [0,255, 0, 0,255,255, 0,125,225,125,125] green=[0, 0,255, 0, 0,255,255, 0,125,125,125] blue= [0, 0, 0,255,255, 0,255,125, 0, 0,125] pmul=!p.multi ;--save window config !p.multi(*)=0 sp=!p sx=!x sy=!y common ncolor, ncol x=size(ncol) if(x(1) eq 0)then ncol=0 uwin=!D.window ;-- save window nr wb=widget_base(/column,title='Plot Color Setting Menu') wd=widget_draw(wb,xsize=255,ysize=150) ws=widget_slider(wb,minimum=0,maximum=10,/drag,xsize=255,value=ncol $ ,title='drag slider to change plot color') wbt0=widget_button(wb,value='color') wbt1=widget_button(wb,value='black & white') wbt2=widget_button(wb,value='done') widget_control,wb,/realize widget_control,wd,get_value=wnr wset=wnr x=indgen(100) !x.range=[0,100] !x.tickv(*)=0 plot,background=255,color=0,x,x/cos(x),yrange=[3000,-3000],xrange=[0,100] $ ,ystyle=0,xstyle=0 oplot,x,x/cos(x),color=ncol,thick=3. loop=0 while(loop eq 0)do begin widget_control,ws,get_value=ncol ev=widget_event(wb) if(ev.id eq wbt0)then begin ;-- load color table tvlct,red,green,blue oplot,x,x/cos(x),color=ncol,thick=3. ; loadct,12,/silent endif if(ev.id eq wbt1)then begin ;-- load black and white loadct,0,/silent oplot,x,x/cos(x),color=ncol,thick=3. endif if(ev.id eq wbt2)then begin ;-- done loop=2 widget_control,ws,get_value=ncol widget_control,wb,/destroy if(uwin gt -1)then wset, uwin endif if(ev.id eq ws)then begin ;-- slider widget_control,ws,get_value=ncol oplot,x,x/cos(x),color=ncol,thick=3. endif endwhile !p=sp !x=sx !y=sy return end ;=========================================================================== ;=========================================================================== pro set_Lplotrange,cancel ;------------------------------------------------------------------------ ; simple input widget for plot time parameter ; startdate in [yymmdm] : year, month , day of month ; noday : number of days to plot ; avgm : average period in minutes ; ; cancel: 0= no cancel 1=cancel ;------------------------------------------------------------------------ ; --- plotparameter (to be initialized by rtn >plotcom.pro< common plotdev, pdev ;-- plot device type common plotpar, pflag $ ; pflag 0=no period set 1=period set , yrmmdm $ ; string start date: year, month , noday $ ; number of days to plot , avgm ; averageing interval in minutes cancel=0 wcnt=0 savet=yrmmdm saven=noday savea=avgm pflag=1 ;----widget construct ----- wb=widget_base(/column,title=' Plot Period Settings ') wlb0=widget_label(wb,xsize=400,ysize=20 $ ,value='Set Plottime Period and Averaging Time! ') wlb1=widget_label(wb,xsize=400,ysize=20 $ ,value=' Enter Start Time, Format [yyyymmdm]') wlb11=widget_label(wb,xsize=400,ysize=20 $ ,value=' yyyy=year, mm=month, dm=day of month ') wt1=widget_text(wb,/editable,/frame,ysize=1,xsize=8,value=yrmmdm) wlb2=widget_label(wb,xsize=400,ysize=20 $ ,value=' Enter Number of Days You want to plot') wt2=widget_text(wb,/editable,/frame,ysize=1,xsize=4,value=strtrim(noday,2)) wlb3=widget_label(wb,xsize=400,ysize=20 $ ,value='Averaging Time in Minutes (0=highest Resolution ') wt3=widget_text(wb,/editable,/frame,ysize=1,xsize=5,value=strtrim(avgm,2)) ;-- list=widget_button(wb,value='----see filelist----') wbt3=widget_button(wb,value='-----! cancel !-----') wbt2=widget_button(wb,value='-ok-start-read-in-') widget_control,wb,/realize loop=0 while(loop eq 0)do begin ev=widget_event(wb) ;----event tracking ;-- if(ev.id eq wbt2)then begin ;-- EXIT button clicked-------- pflag=1 loop=2 ;-- widget_control,wt1,get_value=yrdat ;--- get start date if( yrdat(0) ne '' and strlen(yrdat(0)) eq 8 )then yrmmdm=yrdat(0) if( strlen(yrdat(0)) ne 8 or long(yrmmdm) lt 19951207)then begin x=widget_message('wrong start date format') loop=0 endif ;-- widget_control,wt2,get_value=nod ;--- get number of days to plot if( nod(0) ne '')then noday=long(nod(0)) ;-- widget_control,wt3,get_value=avg ;--- get desired average interval if( avg(0) ne '0')then avgm=long(avg(0)) ;-- endif ;--- if(ev.id eq wbt3)then begin ;-- cancel yrmmdm=savet noday=saven avgm=savea widget_control,wt1,set_value=yrmmdm ;--- reset start year ;--- reset number of days widget_control,wt2,set_value=strtrim(noday,2) ;--- reset average time period widget_control,wt3,set_value=strtrim(avgm,2) loop=2 cancel=1 endif ;--- if(ev.id eq list)then Linfilelist ;--display LION infilelist endwhile widget_control,wb,/destroy ;--- mth='' & dm='' & yr='' reads,yrmmdm,yr,mth,dm,format='(i4,i2,i2)' jul=julday(mth,dm,yr) ; get julday for plot start cdf_epoch,epoch,yr,mth,dm,/compute_epoch ; eval int-epoch for plot start sepoch=ep_to_int(epoch) jul=jul+long(noday) ; make julday for plot end caldat,jul,emth,edm,eyr ; eval date for plot end cdf_epoch,epoch,eyr,emth,edm,/compute_epoch ; eval int-epoch for plot end cdf_epoch,epoch,eyr,emth,edm,/breakdown_epoch ; eval int-epoch for plot end eepoch=ep_to_int(epoch) !x.range=[sepoch,eepoch] !x.style=1 plt=[10,10] plttim=[sepoch,eepoch] ;-nuLL plot-- !x.tickv(*)=0 set_plot,/copy,'nuLL' plot,plttim,plt,xtick_get=v ;-- dummy plot !x.tickv=v ;... to get values of the ticks nel=n_elements(v) ticks=strarr(nel) for i=0,nel-1 do begin ;--then convert epoch values of ticks epo=int_to_ep(v(i)) ;--into date cdf_epoch,epo,yy,mm,dd,hh,mi,/breakdown_epoch date=string(date_to_doy(yy,mm,dd)) $ +'-'+string(hh,format='(i2.2)') $ +':'+string(mi,format='(i2.2)') ticks(i)=strcompress(date,/remove_aLL) endfor !x.tickname(*)='' !x.tickname=ticks set_plot,/copy,pdev return end ;=========================================================================== ;=========================================================================== pro Linfilelist ;--------------------------------------------- ; just for orientation, to see aLL input files ;--------------------------------------------- common Liofilepath $ ;-- init in Log_set , linpath $ ;-- input science file directory , loutpath ;-- output PostScript file directory ;x=findfile(linpath+'Lio*.sl*') x=findfile(linpath+'Li*.sl*') xn=where(strpos(x,'GZ') eq -1,cnt) x=x(xn) wb=widget_base(/column,title=' Input file list ') wld=widget_list(wb,value=x,scr_xsize=250,scr_ysize=200) datum=widget_text(wb,/frame,ysize=1,xsize=50) done=widget_button(wb,value='---done---') widget_control,wb,/realize loop=0 while(loop eq 0)do begin ev=widget_event(wb) if(ev.id eq wld)then begin nam=x(ev.index) pos=rstrpos(nam,'SL') year=strmid(nam,pos-6,2) doy=strmid(nam,pos-4,3) date=doy_to_date(year,doy) widget_control,datum,set_value='date: ' $ +strcompress(string(year)+string(date(0))+string(date(1))) endif if(ev.id eq done)then loop=1 endwhile widget_control,wb,/destroy return end ;=========================================================================== ;=========================================================================== pro set_plotwin ;---------------------------------------------------------------------- ; configueres the plot window: with the help of slider widgets ; the number of plots in x and or y direction is determined ;---------------------------------------------------------------------- ;---------------- widget construct------------------------------------- common pmulti,px,py x=size(px) if(x(1) eq 0)then px=1 ;-- initialize no plots in x-direction x=size(py) if(x(1) eq 0)then py=1 ;-- initialize no plots in y-direction wb = WIDGET_BASE(title='Set Plot-Window Configuration' $ ;create the base ,/column $ ,SPACE = 20 $ ,YPAD = 10) wt=widget_text(wb, $ value=['To config. plot window ' $ ,'move slider with mouse','into desired position'] $ ,XSIZE = 45 $ ,YSIZE = 3 ) wsl1=widget_slider(wb,minimum=0,maximum=10,title='no plots in X dir' $ ,value=px) wsL2=widget_slider(wb,minimum=0,maximum=10,title='no plots in y dir' $ ,value=py) wbt = WIDGET_BUTTON(wb, $ ;create a Done Button VALUE = "done", $ UVALUE = "EXIT") ;--------------- widget construct------------------------------------- ;--------------------------------------------------------------------- widget_control,wb,/realize loop=0 while(loop eq 0) do begin we=widget_event(wb) if(we.id eq wbt) then loop=1 ; when done button was clicked widget_control,wsl1,get_value=px widget_control,wsL2,get_value=py ; if(we.id eq wsl1)then px=we.value ; if(we.id eq wsL2)then py=we.value endwhile !p.multi=[0,px,py] ; set plotscreen division widget_control,wb,/destroy return end ;=========================================================================== ;=========================================================================== pro sum_L2,lindx,pl_tim,pl_dat ;---------------------------------------------------------------------- ; L2dat={L2 $ ; , pb5:lonarr(3) $ ; year [yyyy], doy [ddd], ms of day [ss sss sss] ; , epoch:0.d $ ; ms sinc ad ; , stat:lonarr(2) $ ; LION status information ; ,intst:fltarr(13) $ ; intensity of coincidence channel ; ,cnts:lonarr(28) $ ; counts of coincidence channels ; ,tbd:lonarr(4) } ; spare ; ; lindx : pointer to L2 data, cnts and intensities ; pl_dat : averaged plot data ;---------------------------------------------------------------------- common initsum, sinit ;-- start-of-summing-up flag common plotpar, pflag $ ;-- 0=no period set 1=period set , yrmmdm $ ;-- string start date: year, month , noday $ ;-- number of days to plot , avgm ;-- averageing interval in minutes common lreadpar , lin_file $ ;-- input file names , lfptr $ ;-- pointer to lin_file , leof $ ;-- End-of-File flag , lostat ;-- file open status nex=n_elements(lindx) ;-- number of channel to plot if(avgm eq 0)then begin ;-- no summing up, fuLL resolution ; caLL readf_L2,L2dat endif else begin ix=size(sinit) ;-- initialize start of summing up if(ix(1) eq 0)then sinit=0 ;--init summings if(sinit eq 0)then begin ;--find first intervaltime posflag=0 ;-- file position flag ;.. 0=read from actual position ;.. 1=read from preceding position lfptr=0 leof=-1 nint=(noday*1440)/avgm ;--number of intervals if(((noday*1440)/avgm) ne 0)then nint=nint+1 pl_tim=fltarr(nint) ;--init plot time array pl_dat=fltarr(nint,nex) ;--init plot data array hlp_dt=fltarr(nex) ;--interims data buffer hlp_dt(*)=0. reads,yrmmdm,syr,smm,sdm,format='(i4,i2,i2)' ;--split up start date cdf_epoch,sepoch,syr,smm,sdm,0,0,/compute_epoch ;--intvl start in epoch eepoch=sepoch+avgm*60000 ;--intvl end in epoch mepoch=sepoch+(avgm*30000) ;--mid of interval jul=julday(smm,sdm,syr)+noday ;-- get julday for final plot time caldat,jul,fmm,fdm,fyr ;-- eval date for final plot time cdf_epoch,fepoch,fyr,fmm,fdm,0,0,/compute_epoch ;-- final epoch ;---print,'first int: ',epoch_print(sepoch),' - ',epoch_print(eepoch) endif ;--init summings --end-- for i=0,nint-1 do begin ;-- aLL-interval loop------------------------- loop=0 ;-- interval time loop switch intcnt=0 ;-- count number of elements in intcl ;--interval fiLL loop pl_dat(i,*)=0. ;-- init pl_dat while(loop eq 0) do begin ;-- read input until interval is fuLL loopl=0 while(loopl eq 0) do begin ;-- read input file until time fits loopl=1 readr_LioL2,posflag,L2dat ;-- read 1 set of L2 data if(lostat eq -1) then begin msx=widget_message(['Error opening input file', lin_file(lfptr) $ ,'----File path wrong???----']) goto,enderr endif posflag=0 ;-- next read from actual file position ; pl_tim(i)=ep_to_int(L2dat.epoch) ;-- get epoch, convert it to flt*4 if(L2dat.epoch le sepoch)then loopl=0 ;----print,' int: ',epoch_print(sepoch),' - ',epoch_print(eepoch),' - ' $ ; ,epoch_print(fepoch) ;----print,' L2 ep ',epoch_print(L2dat.epoch) if(lostat eq -2)then loopl=1 ;-- ostat-2: end of last file endwhile if((L2dat.epoch gt sepoch) and (L2dat.epoch le eepoch) $ and (L2dat.epoch le fepoch)) then begin ;-- summing up intcnt=intcnt+1 ;-- count number of elements per intvl for j=0,nex-1 do begin ;-- get L2 data, shift them to helpbuff if(lindx(j) gt 12)then begin ;-- no intensities but counts ix=lindx(j)-13 ;-- index correction for the counts pl_dat(i,j)=pl_dat(i,j)+float( L2dat.cnts(ix)) endif else begin ;-- index f. intensities directly taken pl_dat(i,j)=pl_dat(i,j)+L2dat.intst(lindx(j)) endelse endfor ;-- help-buf shift loop (loop counter=j) endif else begin ;-- L2 time fits into intvl or not if(intcnt gt 0)then begin pl_dat(i,*)=pl_dat(i,*)/intcnt endif else pl_dat(i,*)=-707. ;-- flag data gap loop=1 ;--start next interval posflag=1 ;--next read from preceding record mepoch=sepoch+avgm*30000. pl_tim(i)=ep_to_int(mepoch) ;-- get epoch, convert it to flt*4 sepoch=eepoch ;--set new intvl times eepoch=sepoch+avgm*60000. ;----print,epoch_print(mepoch),' mitte' endelse ;-- new input data fit/ fit not into interval if(lostat eq -2)then loop=1 ;-- ostat-2: end of last file endwhile ;-- fiLL-intervaLL loop )loop switch = >loop< endfor ;-- aLL-interval loop (loop counter =i) endelse enderr: return end ;=========================================================================== ;=========================================================================== ;-main------------------------------------------------------------------------; ; pro main ;--caLL in single run mode ; ;-main------------------------------------------------------------------------; ; pro Lio2plot,lindx,plabel,prange,pl_tim,pl_dat ;--caLL in syn mode ;-main------------------------------------------------------------------------; ; ;========================= ; ; VERSION_NR='1.01, Nov-97' ; VERSION_NR='1.02, Jan-98' Version_NR='1.03, Apr-00' ; ;======================== common L2lab, L2label ;-- check if lio2plot runs in syn xw=size(l2label) ;.. or in single mode (l2label is L2plot ;.. variable) Lioplotcom ;LLOG_SET,0 findpathlio,0 ;--set file paths for in- and output common Liofilepath, linpath, loutpath ;-- in and output-file paths if(xw(1) eq 0)then ldatedefault LioL2labcom if(xw(1) eq 0)then xpscom if(xw(1) eq 0)then syscom common LioL2lab, LL2label ;-- Label array (41) readL2com common lreadpar, lin_file,lfptr,leof,lostat,lfpos ;-- aLL file info common ylpar, ylran,yrlplt,lrin ;--ylrangedefault, in plot used ylran, ;.. index to ylran common plotpar, pflag $ ;-- 0=no period set 1=period set , yrmmdm $ ;-- string start date: year, month , noday $ ;-- number of days to plot , avgm ;-- averageing interval in minutes lindx=-1 ;--init index array (pointer) for LL2label LLidx=intarr(1) ;--init pointer LL2label plabel=strarr(1) ;--in plot_Lio used labels, selected from LL2label ; --- plotparameter---(init in plotcom.pro)------------------------------------ ;--------------------------------------------------------- ;---input file selection & input number of days to convert ;--------------------------------------------------------- wb=widget_base(/column, title='LION Level-2 Main Menu, Version: '+VERSION_NR) wt01=widget_text(wb,value=' Welcome to SOHO-LION L-2-plotter ' $ ,ysize=1,xsize=50) wt02=widget_text(wb,value=' select channel (click) ' $ +' unselect channel' $ ,ysize=1,xsize=50 ) varnam=['click on', 'left list', 'to', 'select' $ ,'plotchannel', '(maximal', '8', 'channel permitted)'] wb1=widget_base(wb,/row) wld=widget_list(wb1,value=LL2label,scr_xsize=300,scr_ysize=200) wlv=widget_list(wb1,value=varnam,scr_xsize=300,scr_ysize=200) plr=widget_button(wb,value='-Select Plot Period - Start Plot Menu-') plo=widget_button(wb,value='---Restart Plot Menu----- ',/frame) ler=widget_button(wb,value ='------------------------- ') pathf=widget_button(wb,value='---set LION path--- ') wlab1=widget_label(wb,value='Actual Input Path: '+linpath(0), $ xsize=400,ysize=20,/frame) wlab2=widget_label(wb,value='Actual Output Path: '+loutpath(0), $ xsize=400,ysize=20,/frame) don=widget_button(wb,value='--EXIT SOHO LION L2-PLOTTER--',/frame) widget_control,wb,/realize ;;========================================================widget loop========= loop=0 while (loop eq 0) do begin ;lindx=-1 ;-- reset labelpointer for labelarray LL2label ;------------------ ev=widget_event(wb) ;=== event poLLing of widget construct ;------------------ ;============================================================================== if(ev.id eq wld)then begin ;-- select channel-widget_list sX=size(plabel) ;-- if plabel not defined yet if(sX(1) eq 1 and plabel(0) eq '')then begin LLidx=ev.index plabel=LL2label(ev.index) ;--define plabel prange=fltarr(1,2,3) ;--channelid/min-max/mode hrange=fltarr(1,2,3) prange(0,*,1)=yLran(ev.index,*,1) ;-- get y plotrange selfmade endif else begin LLidx=[LLidx,ev.index] plabel=[plabel,LL2label(ev.index)] hrange(0,*,*)=yLran(ev.index,*,*) ;-- interims buffer prange=[prange,hrange] ;-- concat if(n_elements(plabel) gt 8)then begin ;--reduce size to 8 elements plabel=shift(plabel,-1) plabel=plabel(0:7) endif endelse widget_control,wlv,set_value=plabel endif ;============================================================================== if(ev.id eq wlv)then begin ;-- unselect channel choice ix=indgen(n_elements(LLidx)) ix=where(ix ne ev.index,cnt) if(cnt gt 0)then begin LLidx=LLidx(ix) plabel=plabel(ix) prange=prange(ix,*,*) endif else plabel='' widget_control,wlv,set_value=plabel endif ;============================================================================== if(ev.id eq plr)then begin ;---read in data, set plotrange --- ; x=size(pflag) ; if(x(0) eq 0)then pflag=0 ;; if(pflag eq 0)then begin ; yrmmdm='19951207' ; noday=1 ; avgm=10 set_lplotrange,cancel ;--return yrmmdm, noday, avgm ; endif ;..in common plotpar if(cancel eq 0) then begin ;---input file selection & input number of days to convert ; L2_nam=findfile(linpath+'Lio*.SL*') ;-- L2 input file names L2_nam=findfile(linpath+'Li*.SL*') ;-- L2 input file names xn=where(strpos(L2_nam,'GZ') eq -1,neln) L2_nam=L2_nam(xn) ; neln=n_elements(L2_nam) fidat='0' yr=0l & mm=0 & dm=0 reads,yrmmdm,yr,mm,dm,format='(i4,2i2)' ;-- eval doy from first day to plot doy=date_to_doy(yr,mm,dm) doy=string(doy,format='(i3.3)') fidoy=strmid(strtrim(yr,2),2,2)+doy findx=where(strpos(L2_nam,fidoy) gt 0 ) if(findx(0) eq -1)then begin ixm=widget_message(['Lio Main:: No file found with this id: ',fidoy ]) lin_file=' ' endif else begin if(findx(0)+noday gt neln)then begin noday=neln-findx(0) L2_nam=L2_nam(findx(0):findx(0)+(noday-1)) ;-- truncate L2_filename array xw=widget_message('Number of days reduced to: '+string(noday)) endif else L2_nam=L2_nam(findx(0):findx(0)+(noday-1)) lin_file=L2_nam for i=0,n_elements(plabel)-1 do begin ;--get index of selected channels indx=where(plabel(i) eq LL2label,cntX) ;-- identify index by its label if(cntX gt 0)then begin ;--if label found save total index if(lindx(0) eq -1)then begin ;-- init pointer (see rtn start) lindx=indx(0) endif else begin lindx=[lindx,indx(0)] ;-- concat channel pointer endelse endif endfor if(lindx(0) eq -1)then begin ;-- no channels selected ==> warning msgx=widget_message('You must select a channel first') endif else begin ;-- start plotting wbn=widget_base(title='*** Wait Window *** Wait Window ***') wbnt=widget_text(wbn,xsize=60,ysize=5 $ ,value=['>>>',' >>>' $ ,' >>>>>> Please wait, data read-in started<<<<<' $ ,' ',' ! ! ! This window disappears when read-in is finished ! ! ']) widget_control,wbn,/realize sum_LioL2,lindx,pl_tim,pl_dat ;-- read and sum up data widget_control,wbn,/destroy ;============================================================================== ;if(ev.id eq plo)then begin ;-----PLOT-menu-WIDGET----- ' if(pflag eq 1)then begin widget_control,wb,iconify=1 Lplot_menL2,lindx,plabel,prange,pl_tim,pl_dat widget_control,wb,iconify=0 lindx=[-1,lindx] endif else begin mx=widget_message(['You must first select channels (click left list)' $ ,'and read in the data']) endelse ;endif endelse ;-- no channel selected endelse ;-- no file with desired id endif ;--cancel endif ;============================================================================== if(ev.id eq plo)then begin ;-----PLOT-menu-WIDGET----- ' if(pflag eq 1)then begin widget_control,wb,iconify=1 Lplot_menL2,lindx,plabel,prange,pl_tim,pl_dat widget_control,wb,iconify=0 lindx=[-1,lindx] endif else begin mx=widget_message(['You must first select channels (click left list)' $ ,'and read in the data']) endelse endif ;============================================================================== if(ev.id eq don) then begin ;--widget_button-EXIT CDFPLOTTER----- ' loop=1 widget_control,wb,/destroy endif ;============================================================================== if(ev.id eq pathf) then begin ;--widget_button- input file path ; LLOG_SET,1 findpathlio,1 if(xw(1) eq 0)then ldatedefault ;-- check syn or single run mode endif ;============================================================================== endwhile ;======================================================================== nixda: if(xw(1) eq 0)then begin ;--in case this module is used in singel run mode wdelete ;.. do not destoy xwindow msg=widget_message(['LION Level-2 Plotter may have generated files ' $ ,'on your directory:' $ ,'LIO2PATH.SVE: contains the path to input and output' $ ,' directory ' $ ,'YLRANL2.SVE: contains your selfmade Y-ranges.' $ ,'If you delete these files or start the program ' $ ,'from another directory, these informations wiLL not' $ ,'be used ! '] ) endif end ;=========================================================================== ;===========================================================================