Skip to content

Instantly share code, notes, and snippets.

View gadamc's full-sized avatar

G Adam Cox gadamc

  • Q-CTRL
  • Seattle, WA
  • 01:46 (UTC -12:00)
View GitHub Profile
@gadamc
gadamc / getNoisePower.py
Created March 28, 2012 20:22
use KData and the KChamonixKAmpSite to measure the power spectrum of noise events.
#!/usr/bin/env python
import operator
from ROOT import *
#make sure you $> source /sps/edelweis/kdata/code/dev/config/setup_kdata.sh (or .csh if you use tcsh or csh)
gSystem.Load('libkds')
gSystem.Load('libkpta')
gSystem.Load('libkamping')
@gadamc
gadamc / gist:1853106
Created February 17, 2012 12:24
extract template with TF1
#!/usr/bin/env python
import couchdbkit
import pickle
s = couchdbkit.Server('https://edwdbik.fzk.de:6984')
db = s['pulsetemplates']
vr = db.view('analytical/bychandate', startkey=['chalA FID807', '2012-02-17 13:09:14'], limit=1, reduce=False, descending=True, include_docs=True)
doc = vr.first()['doc']
@gadamc
gadamc / gist:1853014
Created February 17, 2012 12:13
extract template with function
#!/usr/bin/env python
import couchdbkit
s = couchdbkit.Server('https://edwdbik.fzk.de:6984')
db = s['pulsetemplates']
vr = db.view('analytical/bychandate', startkey=['chalA FID807', '2012-02-17 13:09:14'], limit=1, reduce=False, descending=True, include_docs=True)
doc = vr.first()['doc']
exec(doc['formula']['python']) #defines template function
#!/usr/bin/env python
from couchdbkit import Server, Database
s = Server('https://edwdbik.fzk.de:6984')
db = s['automat']
vr = db.view('data/bypctime', reduce=False, descending=True, startkey=1318357552, endkey=1318357452, include_docs=True)
values = {}
ignorekeys = ['_id', '_rev', 'type', 'author', 'ipaddr', 'date', 'utctime']
#!/usr/bin/env python
from couchdbkit import Server, Database
s = Server('https://edwdbik.fzk.de:6984')
db = s['automat']
vr = db.view('cryo_2/getData2', reduce=False, descending=True, startkey=["T_PT1", 1318357552], endkey=["T_PT1", 1318357452])
values = []
for row in vr:
#the key returned by the view is a list of length two. the first element is the name of the variable and the second is the pc time
#!/usr/bin/env python
from couchdbkit import Server, Database
s = Server('https://edwdbik.fzk.de:6984')
db = s['automat']
vr = db.view('cryo_2/getData2', reduce=False, descending=True, startkey=["T_PT1", 1318357552], endkey=["T_PT1", 0], limit = 1)
value = vr.first()['value']
#!/usr/bin/env python
from couchdbkit import Server, Database
import matplotlib.pyplot as plt
import numpy as np
import ROOT
import random
import scipy.signal as sig
import copy
import pickle
from ROOT import TF1
import pickle
f = pickle.loads(doc['formula']['tf1'])
f.Draw() #now f is a TF1 object and the parameters should have already been set for you
pyFunction = doc['formula']['double exponential heat template']['python']['function']
exec pyFunction
#now you can call
par = [256, 1, t_rise1, t_fall1, fraction_t2, t_fall2]
valueAtT = chalA_FID803_template(T, par)
pyFunction = doc['formula']['double exponential heat template']['python']['function']
exec pyFunction
#now you can call
par = [256, 1, t_rise1, t_fall1, fraction_t2, t_fall2]
valueAtT = chalA_FID803_template(T, par)