Skip to content

Instantly share code, notes, and snippets.

View gadamc's full-sized avatar

G Adam Cox gadamc

  • Q-CTRL
  • Seattle, WA
  • 02:24 (UTC -12:00)
View GitHub Profile
@gadamc
gadamc / csvtocouch.py
Created June 5, 2013 18:57
Example on how to read a CSV file using DictReader and then upload them to couchdb (with couchdbkit)
#!/usr/bin/env python
from couchdbkit import Server
from csv import DictReader
import time, sys, subprocess, math, os, datetime, pytz, calendar, json
#______________
# parseDoc
def parseDoc(doc):
for k,v in doc.items():
@gadamc
gadamc / data.txt
Last active December 17, 2015 23:39
Alpine Data Labs 30.2% (60) 34.2% (68) 35.7% (71) 1.94 199
Bright.com 25.4% (54) 48.4% (103) 26.3% (56) 1.99 213
Cloudant 93.3% (1349) 3.5% (50) 3.3% (47) 2.90 1446
Cloudera 30.1% (241) 47.2% (378) 22.7% (182) 2.07 801
Cloudmeter 87.2% (444) 7.9% (40) 5.3% (27) 2.83 509
CloudPhysics 75.6% (341) 14.9% (67) 10.4% (47) 2.67 451
Concurrent 16.2% (22) 42.6% (58) 41.2% (56) 1.75 136
Continuum Analytics 59.6% (133) 17.0% (38) 23.3% (52) 2.36 223
Datameer 57.5% (226) 21.1% (83) 21.4% (84) 2.36 393
DataSift 12.5% (12) 47.9% (46) 39.6% (38) 1.73 96
//paste this into a ROOT macro, or the interpreter directly
gSystem.Load("libkds")
KHLAEvent *ehla = KEventFactory::NewHLAEvent()
KAmpEvent *eamp = KEventFactory::NewAmpEvent()
eamp->SetEventTriggerStamp(100)
eamp->AddBolo()
// (class KAmpBolometerRecord*)0x7fbbeacd1ee0
First, I start with a reminder of the raw data structure and amp level data structure. (I won't include the Muon Modules…). TCA = TClonesArray
KRawEvent
-- TCA of KRawBolometerRecords
- detector name, mass, etc..
- TRefArray links to KRawBoloPulseRecords
- TRef link to KRawSambaRecord
@gadamc
gadamc / optfilter_plots.py
Last active December 14, 2015 09:50
plot optimal filter output spectra
#!/usr/bin/env python
import couchdbkit
import ROOT
import sys
import KDataPy.samba_utilities as sutil
import KDataPy.util as kutil
from os import listdir
from os.path import isfile, join
import numpy as np
@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])
@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 / 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 / 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;
#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