pro barrel_sp_pick_datatime,ss,startdatetime,duration,payload,bkgmethod,$
lcband=lcband,uselog=uselog,level=level,version=version,$
starttimes=starttimes,endtimes=endtimes,startbkgs=startbkgs,$
endbkgs=endbkgs,mticks=mticks,sticks=sticks
if not keyword_set(level) then level='l2'
if not keyword_set(lcband) then lcband=1
if not keyword_set(uselog) then uselog=0
payload = strupcase(payload)
ss.payload = payload
ss.askdate = startdatetime
ss.askduration = duration
ss.bkgmethod = bkgmethod
timespan,startdatetime,duration,/hour
if keyword_set(starttimes) then begin
typ = size(starttimes[0],/type)
if typ EQ 7 then begin
for i=0,ss.numsrc-1 do ss.trange[0,i] = str2time(starttimes[i],informat='YMDhms')
for i=0,ss.numsrc-1 do ss.trange[1,i] = str2time(endtimes[i],informat='YMDhms')
endif else begin
for i=0,ss.numsrc-1 do ss.trange[0,i] = starttimes[i]
for i=0,ss.numsrc-1 do ss.trange[1,i] = endtimes[i]
endelse
if ss.bkgmethod eq 1 then begin
typ = size(startbkgs[0],/type)
if typ EQ 7 then begin
for i=0,ss.numbkg-1 do ss.bkgtrange[0,i] = str2time(startbkgs[i],informat='YMDhms')
for i=0,ss.numbkg-1 do ss.bkgtrange[1,i] = str2time(endbkgs[i],informat='YMDhms')
endif else begin
for i=0,ss.numsrc-1 do ss.bkgtrange[0,i] = startbkgs[i]
for i=0,ss.numsrc-1 do ss.bkgtrange[1,i] = endbkgs[i]
endelse
endif
return
endif
barrel_load_data, probe=payload, datatype=['FSPC'], level=level,/no_clobber,$
version=version,/no_update
varname='brl'+payload+'_FSPC'+strtrim(lcband,2)
tplot_names,varname, NAMES=matches,/ASORT
if (n_elements(matches) EQ 1) then get_data, matches[0], data=lc $
else message, 'Bad number of variable name matches: '+ $
strtrim(n_elements(matches))
if keyword_set(mticks) then begin
barrel_load_data, probe=payload, datatype=['MSPC'], level=level,$
version=version,/no_update
varname='brl'+payload+'_MSPC'
tplot_names,varname, NAMES=matches,/ASORT
if (n_elements(matches) EQ 1) then get_data, matches[0], data=med $
else message, 'Bad number of variable name matches for MSPC: '+ $
strtrim(n_elements(matches))
medsum = total(med.y,2)
endif
yr=strmid(startdatetime,0,4)
reads,yr,year
mo=strmid(startdatetime,5,2)
reads,mo,month
dy=strmid(startdatetime,8,2)
reads,dy,day
hr=strmid(startdatetime,11,2)
reads,hr,hour
mn=strmid(startdatetime,14,2)
reads,mn,minute
sc=strmid(startdatetime,17,2)
reads,mn,second
daystart = str2time(strmid(startdatetime,0,10),informat='YMD')
hourtimes = (lc.x - daystart)/3600.d
timestart = str2time(startdatetime,informat='YMDhms')
hourstart = (timestart-daystart)/3600.d
w=where(hourtimes GE hourstart and hourtimes LE hourstart+duration,nw)
if nw EQ 0 then begin
print,'No data available in range!'
return
end
if keyword_set(mticks) then begin
hourtimes_med = (med.x - daystart)/3600.d
wm=where(hourtimes_med GE hourstart and hourtimes_med LE hourstart+duration,nwm)
if nwm EQ 0 then begin
print,'No medium data available in range!'
mticks=0
endif
end
window,2,xsize=1200,ysize=600
!p.multi=[0,1,2]
barrel_load_data, probe=payload, datatype=['GPS'], level=level,/no_clobber,$
version=version
varname='brl'+payload+'_GPS_Alt'
tplot_names,varname, NAMES=matches2,/ASORT
if (n_elements(matches2) EQ 1) then get_data, matches2[0], data=gpsalt
hourtimes2=(gpsalt.x-daystart)/3600.d
plot,hourtimes2,gpsalt.y,xrange=[hourstart,hourstart+duration],ytitle='Altitude, km'
if uselog then yrange=[0.5,max(lc.y[w])*2.] else yrange=[0,max(lc.y[w])*1.1]
plot,hourtimes[w],lc.y[w],xrange=[hourstart,hourstart+duration],yrange=yrange,$
ylog=uselog,xtitle='hours from start time',ytitle='counts/50ms'
if keyword_set(mticks) then begin
medsumscale = medsum*max(lc.y[w])/max(medsum)
oplot,hourtimes_med[wm],medsumscale[wm],psym=10,color=1
endif
for ns=0,ss.numsrc-1 do begin
print,'Click at the left and right of a time range for spectral interval ',ns+1
barrel_selecttimes,hourtimes,lc.y, datause, ndatause, color=3
ss.trange[*,ns] = [lc.x[datause[0]], lc.x[datause[ndatause-1]]]
end
if ss.bkgmethod eq 1 then begin
for nb=0,ss.numbkg-1 do begin
print,'Click at the left and right of a time range for background interval ',nb+1
barrel_selecttimes,hourtimes,lc.y, datause, ndatause, color=6
ss.bkgtrange[*,nb] = [lc.x[datause[0]], lc.x[datause[ndatause-1]]]
end
endif
end