Skip to content

Instantly share code, notes, and snippets.

@gadamc
Last active December 13, 2015 19:49
Show Gist options
  • Save gadamc/4965877 to your computer and use it in GitHub Desktop.
Save gadamc/4965877 to your computer and use it in GitHub Desktop.
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])
import couchdbkit
db = couchdbkit.Server('https://edelweiss.cloudant.com')['datadb']
#gamma calibration- only gamma calibration data for FID807 in October 2012
vr = db.view('datasort/conditionbolorun', startkey=["calibration gamma", "FID807", "mj00"], endkey=["calibration gamma", "FID807", "mk00"], reduce=False)
for row in vr:
print 'File %s, File Size [MB] %f, Temperature [K] %f' % (row['value'][1], row['value'][2]/1024./1024., row['value'][0])
#wimp data runs - fond chateau ferme runs for FID810
vr = db.view('datasort/conditionbolorun', startkey=["fond chateau ferme", "FID810", "mj00"], endkey=["fond chateau ferme", "FID810", "mk00"], reduce=False)
for row in vr:
print 'Bolometer: %s, File %s, File Size [MB] %f, Temperature [K] %f' % (row['key'][1], row['value'][1], row['value'][2]/1024./1024., row['value'][0])
#note there is a restriction, due to the alphanumeric sorting of the mapreduce views in couchdb. You cannot get, for example, all
#of the calibration gamma data for FID805 to FID810 during the month of October with a single request such as:
vr = db.view('datasort/conditionbolorun', startkey=["calibration gamma", "FID805", "mj00"], endkey=["calibration gamma", "FID810", "mk00"], reduce=False)
# what you will get with that request is all gamma calibrations for FID805 from Oct. 2012 and later, followed by ALL calibration gamma
#data for FID806, 807, 808 and 809 for all dates, and then all gamma calibration data for FID810 up to Nov 1 2012.
#The best way is just to make this request multiple times for each FID you are interested in.
bigList = []
detList = ['FID805', 'FID806', 'FID807', 'FID808', 'FID809', 'FID810']
for detector in detList:
vr = db.view('datasort/conditionbolorun', startkey=["calibration gamma", detector, "mj00"], endkey=["calibration gamma", detector, "mk00"], reduce=False)
for row in vr:
bigList.append(row['value'][1])
#now 'biglist' is a list of kdata .root files.
import couchdbkit
db = couchdbkit.Server('https://edelweiss.cloudant.com')['datadb']
condList = []
vr = db.view('datasort/conditionrun', group_level=1)
for row in vr:
print 'There are %d kdata .root files with condition = %s' % (row['value'], row['key'])
condList.append(row['key'])
import couchdbkit
db = couchdbkit.Server('https://edelweiss.cloudant.com')['datadb']
#gamma calibration
vr = db.view('datasort/conditionrun', startkey=["calibration gamma", "mj00"], endkey=["calibration gamma", "mk00"], reduce=False)
for row in vr:
print 'File %s, File Size [MB] %f, Temperature [K] %f' % (row['value'][1], row['value'][2]/1024./1024., row['value'][0])
#wimp data runs
vr = db.view('datasort/conditionrun', startkey=["fond chateau ferme", "mj00"], endkey=["fond chateau ferme", "mk00"], reduce=False)
for row in vr:
print 'File %s, File Size [MB] %f, Temperature [K] %f' % (row['value'][1], row['value'][2]/1024./1024., row['value'][0])
#wimp data runs - ON a paritcular DAY!
vr = db.view('datasort/conditionrun', startkey=["fond chateau ferme", "mj15"], endkey=["fond chateau ferme", "mj15z"], reduce=False)
for row in vr:
print 'File %s, File Size [MB] %f, Temperature [K] %f' % (row['value'][1], row['value'][2]/1024./1024., row['value'][0])
#wimp data runs - ON a paritcular DAY and Samba machine!
vr = db.view('datasort/conditionrun', startkey=["fond chateau ferme", "mj15a000"], endkey=["fond chateau ferme", "mj15a999"], reduce=False)
for row in vr:
print 'File %s, File Size [MB] %f, Temperature [K] %f' % (row['value'][1], row['value'][2]/1024./1024., row['value'][0])
import couchdbkit
db = couchdbkit.Server('https://edelweiss.cloudant.com')['datadb']
#gamma calibration --- filter runs for temperatures betwen 17 and 19 mK.
lrdoc = db.list('datasort/conditionfilter', 'datasort/conditionrun', temperature=1, min=0.017, max=0.019, startkey=["calibration gamma", "mj00"], endkey=["calibration gamma", "mk00"], reduce=False)
#NOTE - you have to iterate over lrdoc['results'] and NOT lrdoc.
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])
#gamma calibration --- filter runs for file_size greater than 10 MB and less than 100 MB
lrdoc = db.list('datasort/conditionfilter', 'datasort/conditionrun', file_size=1, min=10*1024*1024, max=100*1024*1024, startkey=["calibration gamma", "mj00"], endkey=["calibration gamma", "mk00"], reduce=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment