Skip to content

Instantly share code, notes, and snippets.

View gadamc's full-sized avatar

G Adam Cox gadamc

  • Q-CTRL
  • Seattle, WA
  • 01:26 (UTC -12:00)
View GitHub Profile
#!/usr/bin/env python
import KDataPy.database as kdb
import datetime, time
db = kdb.radon('http://10.0.1.11:5984')
startTime = datetime.datetime(2010, 10, 18, 13, 0, 0)
endTime = startTime + datetime.timedelta(hours=-5)
endTime_epoch = time.mktime(endTime.timetuple())
@gadamc
gadamc / plotbolo.py
Created November 27, 2012 13:33
Example using the KDataPy.util.plotbolo function
import KDataPy.util as kut
import ROOT
ROOT.gSystem.Load('libkds')
ROOT.gSystem.Load('libkpta')
chainHeat =ROOT.KPulseAnalysisChain()
chainHeat.AddProcessor(ROOT.KBaselineRemoval() )
chainIon1 =ROOT.KPulseAnalysisChain()
chainIon1.AddProcessor(ROOT.KBaselineRemoval() )
@gadamc
gadamc / gist:3911142
Created October 18, 2012 11:19
Install KData on a Mac
Step 1 - Install XCode on your mac. Go to the app store on your computer (or click here: https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12). You might have to sign up for an Apple Developer's ID, which is free.
Step 1b - Install XQuartz. http://xquartz.macosforge.org/landing/
Step 2 - Install Enthought's Python distribution (includes Numpy/SciPy/MatplotLib). http://www.enthought.com/products/epd_free.php. Install the 64-bit distribution (assuming that your mac is relatively new...)
Step 3 - Install Homebrew (this makes it easy to install FFTW and other tools! Homebrew is awesome... )
type this in your command line:
$> ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
... this will do a bunch of stuff
@gadamc
gadamc / example.py
Created August 13, 2012 21:39
example
#!/usr/bin/env python
import couchdbkit
import operator
import pywt
import numpy as np
import string, os, sys
import KDataPy.util as kutil
import ROOT
import matplotlib.pyplot as plt
#!/usr/bin/env python
from KDataPy.database import kdatadb
import KDataPy.util
import ROOT
import scipy.signal as sig
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
#acquire data location from the database
-0.264 0.125 2.53
-0.66 0.399 2.2
-0.235 0.31 2.46
-9.14 1.8 0.127
-0.488 0.45 3.07
0.286 -0.0161 -0.509
-0.219 0.358 2.87
-0.317 1.4 1.02
-0.212 2.06 1.05
0.00549 -0.149 -0.802
#!/usr/bin/env python
import KDataPy.util
import ROOT
filename = '/sps/edelweis/kdata/data/raw/ma22a000_000.root'
bas = ROOT.KBaselineRemoval() #create a new baseline removal object
bas.SetBaselineStart(0) #use the methods of the object to set the characteristics
bas.SetBaselineStop(0.4)
@gadamc
gadamc / getRun12CalibConstants.py
Created April 18, 2012 15:02
get Run12 calibration and voltage constants for ERA / KData analysis
#!/usr/bin/env python
from couchdbkit import Server, Database
s = Server('http://edwdbik.fzk.de:5984')
db = s['analysis']
vr = db.view('constants/run12', include_docs=True)
constantDoc = {}
for row in vr:
constantDoc[row['key']] = row['doc']
#!/usr/bin/env python
from ROOT import *
import sys,os, glob
runName = sys.argv[1]
fileList = glob.glob(runName+'_0[0-3][0-9].amp.root')
ml = TList()
for f in fileList:
print f
@gadamc
gadamc / getNoisePowerAndShowPulses.py
Created March 29, 2012 08:47
same as getNoisePower, but it will plot out each noise pulse that the ERA peak finder finds.
#!/usr/bin/env python
import operator
from ROOT import *
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
#make sure you $> source /sps/edelweis/kdata/code/dev/config/setup_kdata.sh (or .csh if you use tcsh or csh)