Skip to content

Instantly share code, notes, and snippets.

View gadamc's full-sized avatar

G Adam Cox gadamc

  • Q-CTRL
  • Seattle, WA
  • 22:48 (UTC -12:00)
View GitHub Profile
@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
@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 / 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() )
#!/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 / data.json
Last active December 11, 2015 20:48
simple use of json schema
{
"type": "measurement",
"grouping": "EXO(2008)",
"sample": {
"m_name": "Norddeutsche Affinerie, NSOV copper",
"m_description": "Norddeutsche Affinerie, NSOV copper made May 2002",
"m_id": "1",
#you'll need to easy_install jsonschema and couchdbkit
#
# -- download the schema description by
# running this from your terminal
#
# wget https://raw.github.com/gadamc/persephone/schema/_attachments/schema/data.schema.ietf_draft_v3.aarm_spec_v1.01.json -O schema.json
#
import json, cPickle, jsonschema, couchdbkit
@gadamc
gadamc / gist:4658511
Created January 28, 2013 19:58
example create KData raw file.
{
gSystem.Load("libkds");
Int_t nEvents = 500;
Int_t nBolos = 3;
Int_t nPulses = 4;
Int_t pulseSize = 512;
Int_t nMuonModules = 5;
UInt_t totSize;
@gadamc
gadamc / logstats.py
Created January 28, 2013 23:13
create a log file from SVN and use the following python code to edit it and make some plots
#!/usr/bin/env python
import datetime
import re
from ROOT import TH1D, TFile
fname = 'mylog'
tlf = open(fname,'r')
@gadamc
gadamc / makelinks.py
Created January 29, 2013 22:31
simply python script to get the files in a local directory and set up symbolic links to those files in another director
@gadamc
gadamc / findboloandfilter.py
Last active December 13, 2015 19:49
find all run condition options
import couchdbkit
db = couchdbkit.Server('https://edelweiss.cloudant.com')['datadb']
lrdoc = db.list('datasort/conditionfilter', 'datasort/conditionbolorun', temperature=1, min=0.018, max=0.0185, startkey=["fond chateau ferme", "FID808", "mj00"], endkey=["fond chateau ferme", "FID808", "mk32"], reduce=False)
for row in lrdoc['results']:
print 'File %s, File Size [MB] %f, Temperature [K] %f' % (row['value'][1], row['value'][2]/1024./1024., row['value'][0])