예제 #1
0
def empirical_deadtime(band,trange,verbose=0,retries=20,feeclkratio=0.966):
    """Calculate empirical deadtime (per global count rate) using revised
    formulas.
    """
    model = {'FUV':[-0.000386611005025,76.5419507472],
             'NUV':[-0.000417794996843,77.1516557638]}
    rawexpt = trange[1]-trange[0]
    gcr = gQuery.getValue(gQuery.globalcounts(band,trange[0],trange[1]))/rawexpt
    refrate = model[band][1]/feeclkratio
    scr = model[band][0]*gcr+model[band][1]
    return (1-scr/feeclkratio/refrate)
예제 #2
0
def globalcount_shuttered(band,trange,verbose=0,timestamplist=False):
    try:
        t = (timestamplist if np.array(timestamplist).any() else
                np.array(gQuery.getArray(
                    gQuery.uniquetimes(band,trange[0],trange[1],flag=True),
                        verbose=verbose),dtype='float64')[:,0]/gQuery.tscale)
    except IndexError: # Shutter this whole time range.
        if verbose:
            print 'No data in {t0},{t1}'.format(t0=trange[0],t1=trange[1])
        return 0
    times = np.sort(np.unique(np.append(t,trange)))
    tranges = distinct_tranges(times,maxgap=0.05)
    nonnullevents,nullevents = 0,0
    for trange in tranges:
        nullevents += gQuery.getValue(
                    gQuery.deadtime2(band,trange[0],trange[1]),verbose=verbose)
        nonnullevents += gQuery.getValue(gQuery.deadtime1(band,trange[0],
                                        trange[1]),verbose=verbose)

    return nullevents+nonnullevents
예제 #3
0
def stimcount_shuttered(band,trange,verbose=0,retries=20.,timestamplist=False):
    try:
        t = (timestamplist if np.array(timestamplist).any() else
                np.array(gQuery.getArray(
                    gQuery.uniquetimes(band,trange[0],trange[1]),
                        verbose=verbose),dtype='float64')[:,0]/gQuery.tscale)
    except IndexError: # Shutter this whole time range.
        if verbose:
            print 'No data in {t0},{t1}'.format(t0=trange[0],t1=trange[1])
        return 0

    times = np.sort(np.unique(np.append(t,trange)))
    tranges = distinct_tranges(times,maxgap=0.05)
    stimcount = 0
    for trange in tranges:
        stimcount += gQuery.getValue(gQuery.stimcount(band,trange[0],trange[1]),
                                        verbose=verbose)+gQuery.getValue(
                                     gQuery.stimcount(band,trange[0],trange[1],
                                        null=False),verbose=verbose)
    return stimcount
예제 #4
0
파일: exptime.py 프로젝트: cmillion/gPhoton
def netdead(band,t0,t1,tstep=1.,refrate=79.,verbose=0):
	print 'Time range: ['+str(t0)+', '+str(t1)+']'
	refrate     = 79. # counts per second, nominal stim rate
	feeclkratio = 0.966 # not sure what detector property this adjusts for
	tec2fdead   = 5.52e-6 # TEC to deadtime correction (Method 2)
	stimcount = gQuery.getValue(gQuery.stimcount(band,t0,t1))
	totcount = (gQuery.getValue(gQuery.deadtime1(band,t0,t1)) +
		    gQuery.getValue(gQuery.deadtime2(band,t0,t1)))
	exptime = t1-t0
	# Method 0
	# Empirical formula
	dead0 = tec2fdead*(totcount/exptime)/feeclkratio
	minrate,maxrate = refrate*.4,refrate+2.
	# Method 2
	# Direct measurement of stims
	bins = np.linspace(0.,exptime-exptime%tstep,exptime//tstep+1)+t0
	h = np.zeros(len(bins))
	for i,t in enumerate(bins):
		print_inline(t1-t)
		h[i] = gQuery.getValue(gQuery.stimcount(band,t,t+tstep-0.0001))
	
	#h,xh = np.histogram(stimt-trange[0],bins=bins)
	ix = ((h<=maxrate) & (h>=minrate)).nonzero()[0]
	dead2 = (1.-((h[ix]/tstep)/feeclkratio)/refrate).mean()
	# Method 1
	# Empirical formula except with counts binned into 1s
	h = np.zeros(len(bins))
	for i,t in enumerate(bins):
		print_inline(t1-t)
		h[i] = gQuery.getValue(gQuery.deadtime1(band,t,t+tstep-0.0001)) + gQuery.getValue(gQuery.deadtime2(band,t,t+tstep-0.0001))

	dead1 = (tec2fdead*(h/tstep)/feeclkratio).mean()
	expt = compute_exptime(band,[t0,t1])
	print dead0,dead1,dead2
	return [t0, t1, dead0, dead1, dead2, expt, stimcount, totcount]
예제 #5
0
def exposure(band,trange,verbose=0,retries=20):
    """Compute the effective exposure time for a time range."""
    rawexpt = trange[1]-trange[0]
    if rawexpt<=0:
        return 0.
    shutdead = gQuery.getArray(gQuery.shutdead(band,trange[0],trange[1]),
                                            verbose=verbose,retries=retries)
    # NOTE: The deadtime correction in shutdead does not work properly in FUV
    # so we're doing it separately for now.
    deadtime = gQuery.getValue(gQuery.deadtime(band,trange[0],trange[1]),
                                            verbose=verbose,retries=retries)
    #return (rawexpt-shutdead[0][0])*(1.-shutdead[1][0])
    return (rawexpt-shutdead[0][0])*(1.-deadtime)
예제 #6
0
def netdead(band, t0, t1, tstep=1., refrate=79., verbose=0):
    print 'Time range: [' + str(t0) + ', ' + str(t1) + ']'
    refrate = 79.  # counts per second, nominal stim rate
    feeclkratio = 0.966  # not sure what detector property this adjusts for
    tec2fdead = 5.52e-6  # TEC to deadtime correction (Method 2)
    stimcount = gQuery.getValue(gQuery.stimcount(band, t0, t1))
    totcount = (gQuery.getValue(gQuery.deadtime1(band, t0, t1)) +
                gQuery.getValue(gQuery.deadtime2(band, t0, t1)))
    exptime = t1 - t0
    # Method 0
    # Empirical formula
    dead0 = tec2fdead * (totcount / exptime) / feeclkratio
    minrate, maxrate = refrate * .4, refrate + 2.
    # Method 2
    # Direct measurement of stims
    bins = np.linspace(0., exptime - exptime % tstep,
                       exptime // tstep + 1) + t0
    h = np.zeros(len(bins))
    for i, t in enumerate(bins):
        print_inline(t1 - t)
        h[i] = gQuery.getValue(gQuery.stimcount(band, t, t + tstep - 0.0001))

    #h,xh = np.histogram(stimt-trange[0],bins=bins)
    ix = ((h <= maxrate) & (h >= minrate)).nonzero()[0]
    dead2 = (1. - ((h[ix] / tstep) / feeclkratio) / refrate).mean()
    # Method 1
    # Empirical formula except with counts binned into 1s
    h = np.zeros(len(bins))
    for i, t in enumerate(bins):
        print_inline(t1 - t)
        h[i] = gQuery.getValue(gQuery.deadtime1(
            band, t, t + tstep - 0.0001)) + gQuery.getValue(
                gQuery.deadtime2(band, t, t + tstep - 0.0001))

    dead1 = (tec2fdead * (h / tstep) / feeclkratio).mean()
    expt = compute_exptime(band, [t0, t1])
    print dead0, dead1, dead2
    return [t0, t1, dead0, dead1, dead2, expt, stimcount, totcount]