Skip to content

Instantly share code, notes, and snippets.

View gadamc's full-sized avatar

G Adam Cox gadamc

  • Q-CTRL
  • Seattle, WA
  • 17:03 (UTC -12:00)
View GitHub Profile
@gadamc
gadamc / gist:1234620
Created September 22, 2011 11:54
example of using a KAmper -- the KSimpleKamper1
void runTest(const char* input, const char * out)
{
KDataReader f(input);
TH1D hAmpHA("hAmpHeatA", "hAmpHeatA", 10000,-5000, 5000);
TH1D hAmpHC("hAmpHeatC", "hAmpHeatC", 10000,-5000, 5000);
TH1D hAmpIA("hAmpIonA", "hAmpIonA", 10000,-5000, 5000);
TH1D hAmpIB("hAmpIonB", "hAmpIonB", 10000,-5000, 5000);
TH1D hAmpIC("hAmpIonC", "hAmpIonC", 10000,-5000, 5000);
TH1D hAmpID("hAmpIonD", "hAmpIonD", 10000,-5000, 5000);
#!/usr/bin/env python
import sys, os, subprocess
import KDataPy.database as kdb
def main(arg):
startRunName = arg[0] #like lg23b001
endRunName = arg[1] #something that is alpha-numerically greater than startRunName, like lg24a005
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)
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
from couchdbkit import Server, Database
import datetime
s = Server('https://edelweiss.cloudant.com')
db = s['pulsetemplates']
channelName = 'chalA FID807'
myDate = datetime.datetime(2012, 1, 23 ) #see python's datetime documentation
myDateString = str(myDate)
vr = db.view('analytical/bychandate', reduce=False, limit=1, include_docs=True, descending=True, startkey=[ channelName, myDateString], endkey=[channelName, 0])
doc = vr.first()['doc']
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)
#!/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
#!/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
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('data/bypctime', reduce=False, descending=True, startkey=1318357552, endkey=1318357452, include_docs=True)
values = {}
ignorekeys = ['_id', '_rev', 'type', 'author', 'ipaddr', 'date', 'utctime']