PRO get_dens_corr,trange,index=index,name=name ;+ ;NAME: get_dens_corr ;PURPOSE: get the ratio of 3DP proton density to WAVES electron density ; ;CALLING SEQUENCE: get_dens_corr ;INPUTS: trange: dblarr(2), start and stop time in seconds from ; 1970-01-01 ;KEYWORD PARAMETERS: index: lonarr(2), indices of first and last time sample ; an index of 0 refers to the first file record ; name: specifies a tplot name, default is 'ratio' ;OUTPUTS: stores 'ratio', 3DP H+ Dens/WAVES e- Dens ;LAST MODIFICATION: @(#)get_dens_corr.pro 1.2 96/08/21 ;CREATED BY: Frank V. Marcoline, from Davin's get_*_lt procedures. ;FUTURE MODS NEEDED: Check input index for proper range. Optimize search ; through file. ; (Something like point_lun,lun,index(0)*rec_len) ;- on_ioerror,error dir = '/disks/aeolus/home/wind/scratch/long_term/' openr,fp,dir+'dens_corr_accums',/get_lun dat = {time:0.d, data:0.0} filedata = assoc(fp,dat) if not keyword_set(index) then begin file_status = fstat(fp) rec_len = 12 ;8*1 + 4*1 (double, float) ;help,dat,file_status,/st ;stop num_records = file_status.size / rec_len index = [0l,num_records -1] print,' Records:',index endif np =index(1)-index(0)+1 time = dblarr(np) data = fltarr(np) n = 0l for i=0l,np-1 do begin ;foo = filedata(i+index(0)) readu,fp,dat if dat.time > 7.5738240e+08 then begin time(n) = dat.time data(n) = dat.data n=n+1 endif endfor error: time = time(0:n-1) data = data(0:n-1) if data_type(name) ne 7 then name = 'ratio' if data_type(trange) EQ 5 THEN BEGIN IF n_elements(trange) EQ 2 THEN BEGIN a = where((time GE trange(0)) AND (time LE trange(1)),ac) IF ac GT 0 THEN BEGIN time = time(a) data = data(a) ENDIF ELSE BEGIN print,'No data in specified time range: ',time_to_str(trange(0)),$ ' to ',time_to_str(trange(1)) return ENDELSE ENDIF ELSE $ print,'trange must be a two element double array of seconds from 1970-01-01' ENDIF dat = {ytitle:'3DP H!u+!n/WAVES e!u-!n Density',x:time, y:data, yrange:[0,2.0]} store_data,name,data=dat free_lun,fp end