Last active
September 11, 2015 08:57
-
-
Save stefan789/5d1d10d6c9dd75aef6db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import json | |
import cloudant | |
import datetime as dt | |
import pytz | |
berlin = pytz.timezone("Europe/Berlin") | |
# set up db and define functions | |
#acct = cloudant.Account(uri="http://10.155.59.88:5984") | |
acct = cloudant.Account(uri="http://raid.nedm1:5984") | |
res = acct.login(USER, PW) | |
assert res.status_code == 200 | |
db = acct["nedm%2Ffluxgate"] | |
des = db.design("slow_control_time_label") | |
the_view = des.view("slow_control_time_label") | |
# get view data from db | |
results = the_view.get(params=dict(descending=False, | |
endkey = end, | |
startkey = start | |
)).json() | |
# extract date and components from view results and convert to numpy array | |
dateresults = np.asarray([(dt.datetime(*i["key"][:-1], tzinfo=pytz.utc)) for i in results["rows"] if i["key"][6]=="Bx1"]) | |
Bx1 = np.asarray([(i["value"]) for i in results["rows"] if i["key"][6]=="Bx1"]) | |
By1 = np.asarray([(i["value"]) for i in results["rows"] if i["key"][6]=="By1"]) | |
Bz1 = np.asarray([(i["value"]) for i in results["rows"] if i["key"][6]=="Bz1"]) | |
Bx2 = np.asarray([(i["value"]) for i in results["rows"] if i["key"][6]=="Bx2"]) | |
By2 = np.asarray([(i["value"]) for i in results["rows"] if i["key"][6]=="By2"]) | |
Bz2 = np.asarray([(i["value"]) for i in results["rows"] if i["key"][6]=="Bz2"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment