;PRO read_themis_mag_cdf ext='thg_l2_mag_*.cdf' list = findfile(ext) n0 = 0 if (n_elements(list) gt 0) then for ll=0,n_elements(list)-1 do begin file = list[ll] stat_id = 'xxx' str_pos = strpos(file,'thg') stat_name = strmid(file,str_pos+11,3) stat_id = mkupper(stat_name) if (stregex(file,'amd',/fold_case) ge 0) then stat_id='AMK' if (stregex(file,'and',/fold_case) ge 0) then stat_id='ADS' if (stregex(file,'amer',/fold_case) ge 0) then stat_id='AME' if (stregex(file,'arct',/fold_case) ge 0) then stat_id='ARC' if (stregex(file,'atha',/fold_case) ge 0) then stat_id='ATH' if (stregex(file,'benn',/fold_case) ge 0) then stat_id='BEN' if (stregex(file,'bett',/fold_case) ge 0) then stat_id='BTL' if (stregex(file,'bmls',/fold_case) ge 0) then stat_id='BML' if (stregex(file,'ccnv',/fold_case) ge 0) then stat_id='CCN' if (stregex(file,'cdrt',/fold_case) ge 0) then stat_id='CDC' if (stregex(file,'cigo',/fold_case) ge 0) then stat_id='CCN' if (stregex(file,'chbg',/fold_case) ge 0) then stat_id='CHB' if (stregex(file,'cigo',/fold_case) ge 0) then stat_id='CIG' if (stregex(file,'crvr',/fold_case) ge 0) then stat_id='CYC' if (stregex(file,'ded',/fold_case) ge 0) then stat_id='DDH' if (stregex(file,'drby',/fold_case) ge 0) then stat_id='DRB' if (stregex(file,'eagl',/fold_case) ge 0) then stat_id='EAG' if (stregex(file,'ekal',/fold_case) ge 0) then stat_id='EKA' if (stregex(file,'fsim',/fold_case) ge 0) then stat_id='FSP' if (stregex(file,'fsmi',/fold_case) ge 0) then stat_id='FSM' if (stregex(file,'fykn',/fold_case) ge 0) then stat_id='FYU' if (stregex(file,'fyts',/fold_case) ge 0) then stat_id='FYT' if (stregex(file,'gako',/fold_case) ge 0) then stat_id='GAK' if (stregex(file,'gdh',/fold_case) ge 0) then stat_id='GDH' if (stregex(file,'ghb',/fold_case) ge 0) then stat_id='GHB' if (stregex(file,'gill',/fold_case) ge 0) then stat_id='GIL' if (stregex(file,'gbay',/fold_case) ge 0) then stat_id='GSB' if (stregex(file,'gjoa',/fold_case) ge 0) then stat_id='GHC' if (stregex(file,'glyn',/fold_case) ge 0) then stat_id='GLY' if (stregex(file,'hlms',/fold_case) ge 0) then stat_id='AMU' if (stregex(file,'homl',/fold_case) ge 0) then stat_id='AMU' if (stregex(file,'homr',/fold_case) ge 0) then stat_id='HOM' if (stregex(file,'hop',/fold_case) ge 0) then stat_id='HOP' if (stregex(file,'hon',/fold_case) ge 0) then stat_id='HON' if (stregex(file,'hots',/fold_case) ge 0) then stat_id='HOT' if (stregex(file,'iglo',/fold_case) ge 0) then stat_id='IGC' if (stregex(file,'inuk',/fold_case) ge 0) then stat_id='T44' if (stregex(file,'inuv',/fold_case) ge 0) then stat_id='INK' if (stregex(file,'jck',/fold_case) ge 0) then stat_id='JCK' if (stregex(file,'iqa',/fold_case) ge 0) then stat_id='IQA' if (stregex(file,'kako',/fold_case) ge 0) then stat_id='KAV' if (stregex(file,'kapu',/fold_case) ge 0) then stat_id='KAP' if (stregex(file,'kena',/fold_case) ge 0) then stat_id='T55' if (stregex(file,'kar',/fold_case) ge 0) then stat_id='KAR' if (stregex(file,'kian',/fold_case) ge 0) then stat_id='KIA' if (stregex(file,'kuuj',/fold_case) ge 0) then stat_id='KUU' if (stregex(file,'kuv',/fold_case) ge 0) then stat_id='KUV' if (stregex(file,'larg',/fold_case) ge 0) then stat_id='LAR' if (stregex(file,'leth',/fold_case) ge 0) then stat_id='LET' if (stregex(file,'loys',/fold_case) ge 0) then stat_id='LOY' if (stregex(file,'lres',/fold_case) ge 0) then stat_id='LRE' if (stregex(file,'lrel',/fold_case) ge 0) then stat_id='T54' if (stregex(file,'lrv',/fold_case) ge 0) then stat_id='LRV' if (stregex(file,'lyr',/fold_case) ge 0) then stat_id='LYR' if (stregex(file,'lyfd',/fold_case) ge 0) then stat_id='LYF' if (stregex(file,'mcgr',/fold_case) ge 0) then stat_id='MGR' if (stregex(file,'nain',/fold_case) ge 0) then stat_id='NAN' if (stregex(file,'nor',/fold_case) ge 0) then stat_id='NDP' if (stregex(file,'nrsq',/fold_case) ge 0) then stat_id='NAQ' if (stregex(file,'pang',/fold_case) ge 0) then stat_id='PGC' if (stregex(file,'pcel',/fold_case) ge 0) then stat_id='PCE' if (stregex(file,'pgeo',/fold_case) ge 0) then stat_id='PGE' if (stregex(file,'pina',/fold_case) ge 0) then stat_id='PIN' if (stregex(file,'pine',/fold_case) ge 0) then stat_id='PNE' if (stregex(file,'pokr',/fold_case) ge 0) then stat_id='PKR' if (stregex(file,'ptrs',/fold_case) ge 0) then stat_id='PTR' if (stregex(file,'rank',/fold_case) ge 0) then stat_id='RAN' if (stregex(file,'rbay',/fold_case) ge 0) then stat_id='RPB' if (stregex(file,'redr',/fold_case) ge 0) then stat_id='RED' if (stregex(file,'rmus',/fold_case) ge 0) then stat_id='RMU' if (stregex(file,'roe',/fold_case) ge 0) then stat_id='ROE' if (stregex(file,'roth',/fold_case) ge 0) then stat_id='ROT' if (stregex(file,'rich',/fold_case) ge 0) then stat_id='RIC' if (stregex(file,'satx',/fold_case) ge 0) then stat_id='SAX' if (stregex(file,'snap',/fold_case) ge 0) then stat_id='SNP' if (stregex(file,'snkq',/fold_case) ge 0) then stat_id='SNK' if (stregex(file,'swno',/fold_case) ge 0) then stat_id='SWN' if (stregex(file,'talo',/fold_case) ge 0) then stat_id='TAL' if (stregex(file,'tpas',/fold_case) ge 0) then stat_id='TPS' if (stregex(file,'trap',/fold_case) ge 0) then stat_id='TRC' if (stregex(file,'ucla',/fold_case) ge 0) then stat_id='UCL' if (stregex(file,'ukia',/fold_case) ge 0) then stat_id='UKI' if (stregex(file,'vldr',/fold_case) ge 0) then stat_id='VDR' if (stregex(file,'whit',/fold_case) ge 0) then stat_id='WHS' if (stregex(file,'wrth',/fold_case) ge 0) then stat_id='WRT' if (stregex(file,'yknf',/fold_case) ge 0) then stat_id='YKC' print,'Working on file: ',file id=cdf_open(file) res=cdf_inquire(id) vars = strarr(res.nzvars) for i=0,res.nzvars-1 do begin r = cdf_varinq(id,i,/zvariable) vars(i) = r.name ;print,'help,r,/str' ;help,r,/str ;print,'i = ',i, ' name = ',r.name,' record= ',r.dim cdf_control, id, variable=vars(i), /zvariable,get_var_info=v ;print,'help,v,/str' ;help,v,/str ;numrec = v.maxrec+1 ;vinq = cdf_varinq(id,vars(i)) ;print,'numrec = ',numrec,' i,vinq=',i,vinq if (i eq 0) then cdf_varget,id,vars(i),data,rec_count=v.maxrec if (i eq 5) then cdf_varget,id,vars(i),epoch if (stregex(vars(i),'epoch0',/fold_case) ge 0) then $ cdf_varget,id,vars(i),epoch0 if (stregex(vars(i),'units',/fold_case) ge 0) then begin cdf_varget,id,vars(i),units,/string print,'units = ',units endif if (stregex(vars(i),'labl',/fold_case) ge 0) then begin cdf_varget,id,vars(i),label,/string print,'label = ',label endif if (stregex(vars(i),'comp',/fold_case) ge 0) then begin cdf_varget,id,vars(i),comp print,'comp = ',comp endif if (stregex(vars(i),'time',/fold_case) ge 0) then begin cdf_varget,id,vars(i),time,rec_count=v.maxrec ;print,'min, max time = ',min(time), max(time) endif endfor npt = n_elements(time) print,stat_id,': Total data record = ',npt ; STOP ; save ascii output output = 1 if (output gt 0) then begin cdf_epoch,epoch0+time(0)*1000.,yr,mo,da,hr,mn,sc,milli,/break str_yr = strtrim(string(yr),2) str_mo = strtrim(string(mo),2) if (mo lt 10) then str_mo='0'+str_mo str_da = strtrim(string(da),2) if (da lt 10) then str_da='0'+str_da fileout = stat_id+str_yr+str_mo+str_da+'.ascii' close,50 openw,50,fileout printf,50,'year mo da hr mn sec H(mag.N) D(mag.E) Z(down)' fmt = '(i4,4i3.2,f6.2,3f10.2)' for i=0L,npt-1L,2 do begin ;cdf_epoch,epoch(i),year(i),month(i),day(i),hour(i),minute(i),second(i),milli,/break cdf_epoch,epoch0+time(i)*1000.,yr,mo,da,hr,mn,sc,milli,/break second = sc + milli/1000. printf,50,format=fmt,yr,mo,da,hr,mn,second,data(0,i),data(1,i),data(2,i) endfor endif plot_id=0 if (plot_id gt 0) then begin if (ll eq 0) then begin !p.font = 1 set_plot,'PS' device, filename= 'read_themis_mag_cdf.ps', /landscape,/color !x.thick=3 !y.thick=3 mkcolors pos=[.08,.20,.99,.90] plot_io,daily_goes_time,daily_goes_eflux,/nodata, $ xrange = [0,24], $ yrange = [3.e5,9.e9], $ xtitle = 'Year', $ ycharsize=2.5, xcharsize= 2.5,charthick=1,$ max_value=1900.,linestyle=0,$ position=pos ;xyouts,pos(0)-0.105,.5*(pos(3)+pos(1)),'GOES e-flux',size=2.5,align=0.5,orientation=90.,/norm xyouts,pos(0)-0.07,.5*(pos(3)+pos(1)),'GOES e-flux (cm!U2!N-day-sr)!U-1!N',size=2.5,align=0.5,orientation=90.,/norm endif ;oplot,daily_goes_time,daily_goes_eflux,thick=1,color=8 oplot,daily_goes_time,smooth(daily_goes_eflux,30),thick=8,linestyle=2,color=ll+1 oplot,month_goes_time,month_goes_eflux,thick=3,linestyle=0,color=0,psym=10 xyouts,pos(0)+ll*0.15+0.02,pos(3)+0.01,goes_id,size=2.5,color=ll+1,align=0,/norm endif endfor if (!d.name eq 'PS') then device,/close stop end