pro read_k2_cdf ;+ ; wkp 3/9/10 read a k2 cdf file in and make ; some summary spectrograms using ; FAST/THEMIS tplot software available from UC Berkeley ; or the THEMIS web site. ; ; look_directions variable seems to be empty!!! 3/9/10 ;- set_plot,'x' device, decomposed=0 ; to get color x plots loadct,39 !path = '/home/pete/working/idl/:'+!path print,time_to_str(0) ; pointer to the FAST tplot software on willow at lasp ; ; intereactively select a file cdf_file=dialog_pickfile( default_extension='cdf') cdfid=cdf_open(cdf_file) print,'CDFID ',cdfid info=cdf_inquire(cdfid) info=cdf_inquire(cdfid) help,/structure, info print, 'Dimensions: ',info.dim print, '' ;print,'Z Variable names and Types' ;for i=0, info.nzvars-1 do begin ; vinfo= cdf_varinq(cdfid,i,/zvariable) ; print, vinfo.name, ' Type:', vinfo.datatype, ' DIMS:', vinfo.DIM ;endfor ; cdf_control,cdfid,variable=0,/zvariable,get_var_info=einfo max_records=einfo.maxrec print, 'NOTE: The NO_PADVALUE_SPECIFIED: error is a feature of idl. no problem/wkp.' ;% CDF_CONTROL: Function completed but: NO_PADVALUE_SPECIFIED: A pad value has ; not been specified. print,'MAXRECORDS= ',max_records if max_records eq 0 then begin print, 'No valid Summary Data for this UT day' print_null,cdfid,einfo ; call to print_null.pro ???? print,cdfname stop endif if max_records lt 0 then begin print, 'ERRORR NO FILL RECORD IN THIS CDF' print, 'KEY PARAMETER CDF NOT CLOSED when generated' print, ' ..... or .......' print, 'you forgot to specify bin when you used ftp ' print, 'to transfer the file here! ' print, cdfname stop endif i=0 ; make the record star===0 (insruance statement status='' ;Center_Epoch Type:CDF_EPOCH DIMS: 0 cdf_varget,cdfid,'Center_Epoch',Center_EPOCH, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Center_epoch call/',Result,'/', status ;Start_Epoch Type:CDF_EPOCH DIMS: 0 cdf_varget,cdfid,'Start_Epoch',Start_EPOCH, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Start_epoch call/',Result,'/', status ;Stop_Epoch Type:CDF_EPOCH DIMS: 0 cdf_varget,cdfid,'Stop_Epoch',Stop_EPOCH, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Stop_epoch call/',Result,'/', status ;Mass_Spectra Type:CDF_REAL4 DIMS: 6 8 64 cdf_varget,cdfid,'Mass_Spectra',Mass_Spectra, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Mass_Spectra call/',Result,'/', status ; 6 angles, 8 energies, and 64 mass steps ;Energy_LUT Type:CDF_UINT1 DIMS: 0 cdf_varget,cdfid,'Energy_LUT',Energy_LUT, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Energy_LUT call/',Result,'/', status ;Energy Type:CDF_REAL4 DIMS: 8 cdf_varget,cdfid,'Energy',Energy, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Energy call/',Result,'/', status ;Energy_Status Type:CDF_UINT1 DIMS: 8 cdf_varget,cdfid,'Energy_Status',Energy_Status, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Energy_Status call/',Result,'/', status ;Upper_Energy Type:CDF_REAL4 DIMS: 8 cdf_varget,cdfid,'Upper_Energy',Upper_Energy, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Upper_Energy call/',Result,'/', status ;Lower_Energy Type:CDF_REAL4 DIMS: 8 cdf_varget,cdfid,'Lower_Energy',Lower_Energy, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Lower_Energy call/',Result,'/', status ;PA_Status Type:CDF_UINT1 DIMS: 0 cdf_varget,cdfid,'PA_Status',PA_Status, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for PA_Status call/',Result,'/', status ;Pitch_Angles Type:CDF_REAL4 DIMS: 6 cdf_varget,cdfid,'Pitch_Angles',Pitch_Angles, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Pitch_Angles call/',Result,'/', status ;Look_Directions Type:CDF_REAL4 DIMS: 6 3 cdf_varget,cdfid,'Look_Directions',Look_Directions, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Look_Directions call/',Result,'/', status ; variable seems to be empty wkp 3/9/10 ;PA_Drift Type:CDF_REAL4 DIMS: 6 cdf_varget,cdfid,'Look_Directions',Look_Directions, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Look_Directions call/',Result,'/', status ;Mass Type:CDF_REAL4 DIMS: 64 cdf_varget,cdfid,'Mass',Mass, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Mass call/',Result,'/', status ;ICP Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'ICP',ICP, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for ICP call/',Result,'/', status ;Energy_Range_ID Type:CDF_UINT1 DIMS: 0 cdf_varget,cdfid,'Energy_Range_ID',Energy_Range_ID, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Energy_Range_ID call/',Result,'/', status ;FEC Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'FEC',FEC, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for FEC call/',Result,'/', status ;BCR Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'BCR',BCR, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for BCR call/',Result,'/', status ;Spins Type:CDF_REAL4 DIMS: 8 cdf_varget,cdfid,'Spins',Spins, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Spins call/',Result,'/', status ;Quality Type:CDF_UINT1 DIMS: 0 cdf_varget,cdfid,'Quality',Quality, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Quality call/',Result,'/', status ;Orbit_Status Type:CDF_UINT1 DIMS: 0 cdf_varget,cdfid,'Orbit_Status',Orbit_Status, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Orbit_Status call/',Result,'/', status ;L Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'L',L, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for L call/',Result,'/', status ;MLT Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'MLT',MLT, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for MLT call/',Result,'/', status ;Ltime Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'Ltime',Ltime, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Ltime call/',Result,'/', status ;RE Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'RE',RE, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for RE call/',Result,'/', status ;Mlat Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'Mlat',Mlat, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for Mlat call/',Result,'/', status ;INVL Type:CDF_REAL4 DIMS: 0 cdf_varget,cdfid,'INVL',INVL, rec_count=max_records,/zvariable Result=CDF_ERROR(status) if result ne 'CDF_OK: Function completed successfully.' then $ print, 'Status after cdf_varget for INVL call/',Result,'/', status CDF_CLOSE,cdfid print,'CDF FILE CLOSED' start_year=0 start_month=0 start_day=0 stop_year=0 stop_month=0 stop_day=0 cdf_epoch, start_epoch(0,0), start_year, start_month, start_day,/breakdown cdf_epoch, stop_epoch(N_elements(Re)-1),stop_year,stop_month, stop_day,hour,min,sec,/breakdown cdf_epoch, begin_of_day,start_year,start_month,start_day,/compute print, 'FILE: ' ,cdf_file print, 'START: ',start_year, start_month, start_day print, 'STOP: ',stop_year, stop_month, stop_day, hour, min, sec ; put some plots here to set_plot,'ps' device,/landscape,file='k2_test_lines.ps' !p.multi=[0,2,2] plot,(start_epoch(0,*)-begin_of_day)/3600000.,FEC(0,*),/ylog, $ title='FEC Counts', xrange=[0,24], xstyle=1, yrange=[1, 1e8],ystyle=1, $ Xtitle='Year/Month/Day ='+string(start_year)+string(start_month)+string(Start_day) plot,(start_epoch(0,*)-begin_of_day)/3600000.,BCR(0,*), $ title='Background Counts', xrange=[0,24], xstyle=1, $ yrange=[1, 1e6],/ylog, $ ; live with bad plots such as 3/27/96 Xtitle='LAST H/M/S ='+string(hour)+string(min)+string(sec) plot,(start_epoch(0,*)-begin_of_day)/3600000.,Re,title='Earth Radii', $ xrange=[0,24], xstyle=1 plot,(start_epoch(0,*)-begin_of_day)/3600000.,INVL,Title='INVL', $ xrange=[0,24], xstyle=1 !p.multi=[0,1,1] device,/close set_plot,'x' ; now convert center_epoch to Unix time for compatibility with tplot software fast_time=dblarr(n_elements(center_epoch)) for it=0,n_elements(fast_time)-1 do begin cdf_epoch,center_epoch(it), yr,mo,day,hr,min,sec,mil,/breakdown time_string=string(yr,format='(i4)')+'-'+string(mo,format='(i02)')+'-' time_string=time_string+string(day,format='(i02)')+'/'+string(hr,format='(i02)')+':' time_string=time_string+string(min,format='(i02)')+':'+string(sec,format='(i02)') fast_time(it)=str_to_time(time_string) ; what a kludge endfor ;MASS_SPECTRA FLOAT = Array[6, 8, 64, 440] ;PITCH_ANGLES FLOAT = Array[6, 440] ;ENERGY FLOAT = Array[8, 440] ; Mass spectra ; 6 fixed look directions in despun spacecraft coords see instrument paper ; 8 energy steps .... see energy look up table for values ; 64 mass steps ; 440 or whatever arrays per day ;Here make a ms specta and pitch angle plots for ; ia=0, ie=0 ; ia=2, ie=0 ; ia=4, ie=0 ; ia=5, ie=0 ; thats enough for one page mass_steps=indgen(64) mass_0_0=fltarr(max_records,64) for iseq=0,max_records-1 do for ims=0,63 do mass_0_0(iseq,ims)=Mass_Spectra(0,0,ims,iseq) data= create_struct ('x', fast_time, $ 'Y', mass_0_0, $ 'V', mass_steps ) store_data,'MS-0_0', data=data ; Remove acne. options,'MS-0_0','spec',1 zlim,'MS-0_0',1e-1,1e3,1 ; 1=log 0=linear ff_ylim,'MS-0_0',[0,63] options,'MS-0_0','ytitle', $ 'MS-0_0 !C!CES 0' options,'MS-0_0','ztitle','Counts!C!Cspin' options,'MS-0_0','x_no_interp',1 options,'MS-0_0','y_no_interp',1 options,'MS-0_0','panel_size',2 options,'MS-0_0','yticks',3 temp=fltarr(n_elements(fast_time)) for it=0,n_elements(fast_time)-1 do temp(it)=pitch_angles(0,it) data=create_struct('x', fast_time, $ 'y', temp ) store_data,'MS_0_0_pa', data=data ylim,'MS_0_0_pa',0,180,0 ; options,'MS_0_0_pa','ytitle', $ 'PA !C!CDegrees ' options,'MS_0_0_pa','x_no_interp',1 options,'MS_0_0_pa','y_no_interp',1 options,'MS_0_0_pa','panel_size',1 options,'MS_0_0_pa','yticks',4 ; ia=2, ie=0 mass_2_0=fltarr(max_records,64) for iseq=0,max_records-1 do for ims=0,63 do mass_2_0(iseq,ims)=Mass_Spectra(2,0,ims,iseq) data= create_struct ('x', fast_time, $ 'Y', mass_2_0, $ 'V', mass_steps ) store_data,'MS-2_0', data=data ; Remove acne. options,'MS-2_0','spec',1 zlim,'MS-2_0',1e-1,1e3,1 ; 1=log 0=linear ff_ylim,'MS-2_0',[0,63] options,'MS-2_0','ytitle', $ 'MS-2_0 !C!CES 0' options,'MS-2_0','ztitle','Counts!C!Cspin' options,'MS-2_0','x_no_interp',1 options,'MS-2_0','y_no_interp',1 options,'MS-2_0','panel_size',2 options,'MS-2_0','yticks',3 temp=fltarr(n_elements(fast_time)) for it=0,n_elements(fast_time)-1 do temp(it)=pitch_angles(2,it) data=create_struct('x', fast_time, $ 'y', temp ) store_data,'MS_2_0_pa', data=data ylim,'MS_2_0_pa',0,180,0 ; options,'MS_2_0_pa','ytitle', $ 'PA !C!CDegrees ' options,'MS_2_0_pa','x_no_interp',1 options,'MS_2_0_pa','y_no_interp',1 options,'MS_2_0_pa','panel_size',1 options,'MS_2_0_pa','yticks',4 ; ia=4, ie=0 mass_4_0=fltarr(max_records,64) for iseq=0,max_records-1 do for ims=0,63 do mass_4_0(iseq,ims)=Mass_Spectra(4,0,ims,iseq) data= create_struct ('x', fast_time, $ 'Y', mass_4_0, $ 'V', mass_steps ) store_data,'MS-4_0', data=data ; Remove acne. options,'MS-4_0','spec',1 zlim,'MS-4_0',1e-1,1e3,1 ; 1=log 0=linear ff_ylim,'MS-4_0',[0,63] options,'MS-4_0','ytitle', $ 'MS-4_0 !C!CES 0' options,'MS-4_0','ztitle','Counts!C!Cspin' options,'MS-4_0','x_no_interp',1 options,'MS-4_0','y_no_interp',1 options,'MS-4_0','panel_size',2 options,'MS-4_0','yticks',3 temp=fltarr(n_elements(fast_time)) for it=0,n_elements(fast_time)-1 do temp(it)=pitch_angles(4,it) data=create_struct('x', fast_time, $ 'y', temp ) store_data,'MS_4_0_pa', data=data ylim,'MS_4_0_pa',0,180,0 ; options,'MS_4_0_pa','ytitle', $ 'PA !C!CDegrees ' options,'MS_4_0_pa','x_no_interp',1 options,'MS_4_0_pa','y_no_interp',1 options,'MS_4_0_pa','panel_size',1 options,'MS_4_0_pa','yticks',4 ; ia=5, ie=0 ; thats enough for one page mass_5_0=fltarr(max_records,64) for iseq=0,max_records-1 do for ims=0,63 do mass_5_0(iseq,ims)=Mass_Spectra(5,0,ims,iseq) data= create_struct ('x', fast_time, $ 'Y', mass_5_0, $ 'V', mass_steps ) store_data,'MS-5_0', data=data ; Remove acne. options,'MS-5_0','spec',1 zlim,'MS-5_0',1e-1,1e3,1 ; 1=log 0=linear ff_ylim,'MS-5_0',[0,63] options,'MS-5_0','ytitle', $ 'MS-5_0 !C!CES 0' options,'MS-5_0','ztitle','Counts!C!Cspin' options,'MS-5_0','x_no_interp',1 options,'MS-5_0','y_no_interp',1 options,'MS-5_0','panel_size',2 options,'MS-5_0','yticks',3 temp=fltarr(n_elements(fast_time)) for it=0,n_elements(fast_time)-1 do temp(it)=pitch_angles(5,it) data=create_struct('x', fast_time, $ 'y', temp ) store_data,'MS_5_0_pa', data=data ylim,'MS_5_0_pa',0,180,0 ; options,'MS_5_0_pa','ytitle', $ 'PA !C!CDegrees ' options,'MS_5_0_pa','x_no_interp',1 options,'MS_5_0_pa','y_no_interp',1 options,'MS_5_0_pa','panel_size',1 options,'MS_5_0_pa','yticks',4 tplot,['MS-0_0','MS_0_0_pa','MS-2_0','MS_2_0_pa','MS-4_0','MS_4_0_pa','MS-5_0','MS_5_0_pa'] pname='K2_test_spectra' dir = './' popen, pname,/port, dir=dir, xsize = 7.5, ysize = 10.0 loadct2,39 tplot_options,'charsize',1.1 tplot pclose print,a(-1) stop end