Skip to content

Instantly share code, notes, and snippets.

View gadamc's full-sized avatar

G Adam Cox gadamc

  • Q-CTRL
  • Seattle, WA
  • 00:05 (UTC -12:00)
View GitHub Profile
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']
#!/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
@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
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import struct
class ipebb21mode(object):
def __init__ (self, filename):
@gadamc
gadamc / test.C
Created August 22, 2011 15:05
example of using the FIR filter and filling in a KAmpEvent file.
//start root.
//compile this file
// root [0] .L test.C+g
//run the program
// root [1] test();
//Of course, this won't work because you have to point KDataReader and KDataWriter
//to the appropriate files.
#ifndef __CINT__
#include "KDataReader.h"
//______________________________________________________________________
//
// KCurl.cxx
// Author: Adam Cox <mailto:[email protected]>
//
// *Copyright 2011 Karlsruhe Inst. of Technology. All Rights Reserved.
//
//
// Created Friday 04. February 2011
//
# Q E_recoil sigma_ion sigma_heat voltage_bias
0.707166 6.45045 1.02629 1.04127 8
1.01045 8.87014 0.726222 2.31162 8
0.974034 9.7642 0.814962 0.822313 8
1.4773 5.81705 0.666992 2.03295 8
1.10082 9.46519 0.765231 0.803824 6.4
0.738693 27.9404 0.839768 0.838095 8
0.759251 12.9018 0.734915 0.864414 6.4
0.997683 10.3843 0.789633 0.999154 8
1.08581 9.43259 0.80085 0.848234 8
@gadamc
gadamc / couchMod.py
Created August 1, 2011 14:21
short script to modify some docs on our couch
#!/usr/bin/env python
from couchdbkit import Server, Database
import sys, os, copy
s = Server('http://***:***@127.0.0.1:5984')
db = s['edwdb']
vr = db.view('proc/daqdoc', reduce=False)
@gadamc
gadamc / podio_bigdump.py
Created July 28, 2011 18:46
podio_bigdump
#!/usr/bin/env python
from pypodio2 import api
import sys, shutil, os, json
c = api.OAuthClient(sys.argv[1],sys.argv[2], sys.argv[3], sys.argv[4])
orginfo = c.transport.get(url = '/org/')
def writerawtext(filename, data):
try:
@gadamc
gadamc / gist:1082583
Created July 14, 2011 14:43
plot t_bolo v co
#!/usr/bin/env python
from couchdbkit import Server, Database
from ROOT import TFile, TH1D
import numpy as np
import sys
s = Server(sys.argv[1])
db = s[sys.argv[2]]
fout = TFile('tbolo_co_july8to14.root','recreate')