Beispiel #1
0
def get_raw_data():
    import util
    fnames = ['data-controlled-test-2/T1Mar15e.CSV',
              'data-controlled-test-2/T1Apr15e.CSV']
    dfobs = [util.load_radon(itm) for itm in fnames]
    dfobs = pd.concat(dfobs)
    return dfobs
df[cols].plot()

for itm in cols:
    df[itm] /= df[itm].mean()
df[cols].plot()

df[['count rate plateout=20s', 'count rate']].plot()

df = detector_model(t)

# compare with experiment
import util
fnames = ['../data-controlled-test-2/T1Mar15e.CSV',
          '../data-controlled-test-2/T1Apr15e.CSV']

dfobs = [util.load_radon(itm) for itm in fnames]
dfobs = pd.concat(dfobs)

#
# ... how much do the calibration peaks vary?
#
# 1-min injections (expected to vary a bit)
ts0 = datetime.datetime(2015,3,18,13)
nspikes = 9
cp = datetime.timedelta(hours=6)
oneday = datetime.timedelta(days=1)

totcounts = [dfobs[ts0+ii*oneday:ts0+ii*oneday+cp].lld.sum() 
                for ii in range(nspikes)]
totcounts_spike = np.array(totcounts)
import util
import util_stan
import util_emcee

#
# .... load observations
#
t0 = datetime.datetime(2014,12,5,13,6)
t_injection = [t0 + datetime.timedelta(days=ii) for ii in range(5)]
# time range for deconvolution test
t_deconv = datetime.datetime(2014, 12, 10, 0)
# load data
data_dir = './data-controlled-test/'
fname = data_dir + '700L_test2.xlsx'
sheet_name = 'F1Dec14'
df700 = util.load_radon(fname, sheet_name)
#choose the data we wish to deconvolve
df = df700[t_deconv:]
df = df[['lld']]



background_count_rate = 10  #TODO: make this realistic

##choose a subset - faster computation for testing
#df = df.head(250)  #500 gives two peaks

#7am to 7am am, peak npeak (there are 5 total)
npeak = 1
tidx0 = t_deconv+datetime.timedelta(days=npeak)+datetime.timedelta(hours=7)
tidx1 = tidx0 + datetime.timedelta(days=1)
norm = df['count rate'].max()
for itm in cols:
    df[itm] = df[itm]/norm #df[itm].mean()
df[cols].plot()

for itm in cols:
    df[itm] /= df[itm].mean()
df[cols].plot()


df = detector_model(t)

# compare with experiment
import util
fname = '../data-controlled-test-2/T1Mar15e.CSV'
dfobs = util.load_radon(fname)
f, ax = plt.subplots()
t0 = datetime.datetime(2015,3,17,13)
dt = datetime.timedelta(hours=5)
dt -= datetime.timedelta(minutes=1)
for ii in range(6):
    dfrel = dfobs[t0:t0+dt]
    dfrel.index = (dfrel.index.values - dfrel.index.values[0]) / 1e9 / 60
    dfrel.lld.plot(ax=ax, label=str(ii))
    t0 += datetime.timedelta(days=1)
plt.legend()

df['observed count rate'] = dfrel.lld.values
# normalise
df['observed count rate'] = df['observed count rate'] /               \
                df['observed count rate'].mean() * df['count rate'].mean()