Commit 58a211f9 authored by Nick Sauerwein's avatar Nick Sauerwein
Browse files

organisation tools of data added

parent 56423c8e
...@@ -3,6 +3,8 @@ import matplotlib.pyplot as plt ...@@ -3,6 +3,8 @@ import matplotlib.pyplot as plt
import numpy as np import numpy as np
def make_statistic(xs ,ys, error_x): def make_statistic(xs ,ys, error_x):
xs = np.array(xs)
ys = np.array(ys)
from uncertainties import unumpy from uncertainties import unumpy
arg = np.argsort(xs) arg = np.argsort(xs)
...@@ -46,17 +48,10 @@ def make_statistic(xs ,ys, error_x): ...@@ -46,17 +48,10 @@ def make_statistic(xs ,ys, error_x):
i = i+1 i = i+1
return unumpy.uarray(x_mean, x_error), unumpy.uarray(y_mean, y_error), n return unumpy.uarray(x_mean, x_error), unumpy.uarray(y_mean, y_error), n
def errorplot(ux, uy): def errorplot(ux, uy, ecolor = 'y', **args):
plt.errorbar(unumpy.nominal_values(ux), unumpy.nominal_values(uy), xerr = unumpy.std_devs(ux),yerr = unumpy.std_devs(uy), fmt= '--o', elinewidth = 10, ecolor = 'y')
plt.errorbar(unumpy.nominal_values(ux), unumpy.nominal_values(uy), xerr = unumpy.std_devs(ux),yerr = unumpy.std_devs(uy), fmt= '--o', elinewidth = 10, ecolor = ecolor,alpha = 0.8, **args)
def extract(measurements, list_of_ids):
m = measurements
for i in list_of_ids:
try:
m = np.array([measure[i] for measure in m])
except:
print ("possible ids are: ",[item[0] for item in m[0].items()])
assert (False)
return m
\ No newline at end of file
...@@ -37,6 +37,137 @@ def print_dict(dictionary, ident = '', braces=1, plot = True): ...@@ -37,6 +37,137 @@ def print_dict(dictionary, ident = '', braces=1, plot = True):
else: else:
print (ident+'%s = %s' %(key, value)) print (ident+'%s = %s' %(key, value))
def get_subfolders(base_folder):
from glob import glob
subfolders = []
while True:
folders = glob(base_folder+"*/")
if folders == []:
break
subfolders += folders
base_folder += '*/'
return subfolders
def find_configs(base_folder, output = True):
subfolders = get_subfolders(base_folder)
configs = []
for folder in subfolders:
new_configs = IO(folder).search(output = False)
for config in new_configs:
config['folder'] = folder
configs += new_configs
return configs
def get_differences(dics, headids = []):
if len(dics) < 2:
return []
ids = []
ref_dic = dics[0]
for dic in dics[1:]:
for name, item in dic.items():
if headids + [name] in ids:
continue
if not name in ref_dic:
ids += [headids + [name]]
continue
if ref_dic[name] == item:
continue
if isinstance(item, dict):
subdiff = get_differences(extract(dics,name),headids = headids + [name])
for diff in subdiff:
if diff in ids:
continue
ids += [diff]
continue
ids += [headids + [name]]
ref_dic = dics[-1]
for dic in dics[:-1]:
for name, item in dic.items():
if headids + [name] in ids:
continue
if not name in ref_dic:
ids += [headids + [name]]
continue
if ref_dic[name] == item:
continue
if isinstance(item, dict):
subdiff = get_differences(extract(dics,name),headids = headids + [name])
for diff in subdiff:
if diff in ids:
continue
ids += [diff]
continue
ids += [headids + [name]]
return ids
def extract(measurements, list_of_ids):
try:
measurements = list(measurements)
except:
pass
if type(list_of_ids) == str:
list_of_ids = [list_of_ids]
if type(measurements) is not list:
measurements = [measurements]
ms = measurements
for i in list_of_ids:
ms_new = []
one_contains = False
for m in ms:
if isinstance(m,dict) and i in m:
ms_new += [m[i]]
one_contains = True
else:
ms_new += [None]
if not one_contains:
print (ms)
ms_wo_none = filter(None.__ne__, ms)
import itertools
print ("id ",i," doesn't exsist. Choose from: ",set(itertools.chain(*[m.keys() for m in ms_wo_none])))
assert (False)
ms = ms_new
return ms
def print_data(data, plot = True): def print_data(data, plot = True):
print_dict(data, plot = plot) print_dict(data, plot = plot)
......
...@@ -35,7 +35,9 @@ class FaradayCup: ...@@ -35,7 +35,9 @@ class FaradayCup:
return config return config
def measure(self): def measure(self):
import time as ttime
ttime.sleep(0.2)
sig_time, sig_uvolt = self.drs.readChannel(self.channel) sig_time, sig_uvolt = self.drs.readChannel(self.channel)
import datetime import datetime
time = datetime.datetime.now() time = datetime.datetime.now()
......
...@@ -21,6 +21,7 @@ class Laser: ...@@ -21,6 +21,7 @@ class Laser:
self.drs = DRS4 self.drs = DRS4
self.set_config(config) self.set_config(config)
self.plot_server = None self.plot_server = None
self.old_comp_lin = 0
def set_config(self, config): def set_config(self, config):
self.max_angle = config['max_angle'] self.max_angle = config['max_angle']
...@@ -48,8 +49,11 @@ class Laser: ...@@ -48,8 +49,11 @@ class Laser:
return 100 * np.cos((phi - self.max_angle)/90*np.pi) return 100 * np.cos((phi - self.max_angle)/90*np.pi)
def set_lin_comp(self, pos): def set_lin_comp(self, pos):
print (self.old_comp_lin, pos)
if self.old_comp_lin == pos:
return
caput('F10HU-LMOT705:MOT.VAL', pos) caput('F10HU-LMOT705:MOT.VAL', pos)
self.old_comp_lin = pos
import time import time
time.sleep(2) time.sleep(2)
...@@ -57,9 +61,8 @@ class Laser: ...@@ -57,9 +61,8 @@ class Laser:
return caget('F10HU-LMOT705:MOT.VAL') return caget('F10HU-LMOT705:MOT.VAL')
def measure(self): def measure(self):
import time import time as tttime
tttime.sleep(0.24)
time.sleep(0.05)
import datetime import datetime
time = datetime.datetime.now() time = datetime.datetime.now()
sig_time, sig_uvolt = self.drs.readChannel(self.channel) sig_time, sig_uvolt = self.drs.readChannel(self.channel)
......
No preview for this file type
No preview for this file type
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib
from math import sqrt
SPINE_COLOR = 'black'
def latexify(fig_width=None, fig_height=None, columns=1):
"""Set up matplotlib's RC params for LaTeX plotting.
Call this before plotting a figure.
Parameters
----------
fig_width : float, optional, inches
fig_height : float, optional, inches
columns : {1, 2}
"""
# code adapted from http://www.scipy.org/Cookbook/Matplotlib/LaTeX_Examples
# Width and max height in inches for IEEE journals taken from
# computer.org/cms/Computer.org/Journal%20templates/transactions_art_guide.pdf
assert(columns in [1,2])
if fig_width is None:
fig_width = 3 if columns==1 else 5 # width in inches
if fig_height is None:
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_height = fig_width*golden_mean # height in inches
MAX_HEIGHT_INCHES = 8.0
if fig_height > MAX_HEIGHT_INCHES:
print("WARNING: fig_height too large:" + fig_height +
"so will reduce to" + MAX_HEIGHT_INCHES + "inches.")
fig_height = MAX_HEIGHT_INCHES
params = {'backend': 'ps',
'text.latex.preamble': [r'\usepackage{gensymb}', r'\usepackage{siunitx}'],
'axes.labelsize': 12, # fontsize for x and y labels (was 10)
'axes.titlesize': 12,
'font.size': 12, # was 10
'legend.fontsize': 12, # was 10
'xtick.labelsize': 12,
'ytick.labelsize': 12,
'lines.linewidth': 1,
'text.usetex': True,
'figure.figsize': [fig_width,fig_height],
'font.family': 'serif',
'mathtext.default': 'regular'
}
matplotlib.rcParams.update(params)
def format_axes(ax):
plt.tight_layout()
ax.locator_params(nbins=6)
for spine in ['top', 'right']:
ax.spines[spine].set_visible(False)
for spine in ['left', 'bottom']:
ax.spines[spine].set_color(SPINE_COLOR)
ax.spines[spine].set_linewidth(0.5)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
for axis in [ax.xaxis, ax.yaxis]:
axis.set_tick_params(direction='out', color=SPINE_COLOR)
return ax
\ No newline at end of file
...@@ -2,21 +2,12 @@ ...@@ -2,21 +2,12 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 1,
"metadata": { "metadata": {
"hideCode": false, "hideCode": false,
"hidePrompt": false "hidePrompt": false
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [ "source": [
"import numpy as np\n", "import numpy as np\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
...@@ -42,20 +33,20 @@ ...@@ -42,20 +33,20 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 220, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"configuration in morning loaded\n" "druck 10 bar loaded\n"
] ]
} }
], ],
"source": [ "source": [
"import DataManager as dm\n", "import DataManager as dm\n",
"io = dm.IO('Data/EXP170823/')\n", "io = dm.IO('Data/EXP170906/')\n",
"\n", "\n",
"\n", "\n",
"config = io.load(-1)\n", "config = io.load(-1)\n",
...@@ -71,15 +62,12 @@ ...@@ -71,15 +62,12 @@
}, },
"outputs": [ "outputs": [
{ {
"ename": "IndexError", "name": "stdout",
"evalue": "list index out of range", "output_type": "stream",
"output_type": "error", "text": [
"traceback": [ "-3 before play with compressor\n",
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "-2 druck 5 bar\n",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", "-1 druck 10 bar\n"
"\u001b[0;32m<ipython-input-3-5e36e5d4c126>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mconfigs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m \u001b[0;34m,\u001b[0m\u001b[0mconfigs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'comment'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/lwfaserver/DataManager.py\u001b[0m in \u001b[0;36mload\u001b[0;34m(self, name_id, kind, gui, elog)\u001b[0m\n\u001b[1;32m 226\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 227\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname_id\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 228\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfilen\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mfilen\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mglob\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0miglob\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mkind\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m'*.npy'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname_id\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 229\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname_id\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m'.npy'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 230\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mIndexError\u001b[0m: list index out of range"
] ]
} }
], ],
...@@ -91,50 +79,69 @@ ...@@ -91,50 +79,69 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 221, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"[Interferometer]\n", "[Laser]\n",
" y_calib = 1.0\n", " comp_lin = 38.02\n",
" BitsOfImage = 12\n", " attenuation = 100.0\n",
" num_av = 10\n", " channel = 1\n",
" zmin = -7.0\n", " max_angle = -22.9\n",
" zmax = 7.0\n", "[Periscope]\n",
" x_tomo = 0.2\n", " pos_l_x = 0.0\n",
" pos_l_z = -0.4000116604477615\n",
" deltaz_Mz = -1.0045767257462686\n",
" pos_g_origin_z = 12.5\n",
" pos_g_origin_x = -12.0\n",
" pos_l_y = -5.8302238805652e-06\n",
" sync_camera = False\n",
" pos_g_origin_y = 5.05\n",
" deltaz_Cz = -12.900011660447761\n",
"[ScreenCamera]\n",
" binning = 10\n", " binning = 10\n",
" z0 = 8.45\n",
" calibrated = True\n",
" TriggerMode = True\n", " TriggerMode = True\n",
" ExposureTimeAbs = 35.0\n", " ExposureTimeAbs = 3000.0\n",
" live_preview = True\n", " y0 = 6.8\n",
"time = 2017-09-06_15-32-43.353404\n",
"comment = druck 10 bar\n",
"[DelayGenerator]\n",
" jet_triggered = True\n",
" rate = 11.904761904761903\n",
" t_sleep = 0.05\n",
" mode = single shot\n",
"[Interferometer]\n",
" binning = 10\n",
" z0 = 9.65\n", " z0 = 9.65\n",
" Ly = 13.0\n",
" x0 = 4.1\n",
" Tomography = False\n", " Tomography = False\n",
" Ly = 13.0\n",
" BitsOfImage = 12\n",
" zmax = 7.0\n",
" zmin = -7.0\n",
" y_calib = 1.0\n",
" num_av = 10\n",
" x0 = 7.699999999999999\n",
" live_preview = True\n",
" num_dir = 7\n",
" xmax = 4.0\n",
" take_data = True\n", " take_data = True\n",
" TriggerMode = True\n",
" shift = 219\n", " shift = 219\n",
" xmax = 4.0\n", " ExposureTimeAbs = 35.0\n",
" xmin = 0.0\n", " xmin = 0.0\n",
" num_dir = 7\n", " x_tomo = 0.2\n",
"[BladePositioning]\n",
" pos_R = 342.65001\n",
" pos_L = -2.799999\n",
"time = 2017-08-23_10-20-57.606862\n",
"[PlasmaCamHorizontal]\n", "[PlasmaCamHorizontal]\n",
" z0 = 7.0\n",
" y0 = 6.3999999999999995\n",
" binning = 2\n", " binning = 2\n",
" z0 = 7.0\n",
" calibrated = False\n", " calibrated = False\n",
" TriggerMode = True\n", " TriggerMode = True\n",
" ExposureTimeAbs = 19999.999494757503\n", " ExposureTimeAbs = 80999.99795376789\n",
"[DelayGenerator]\n", " y0 = 6.3999999999999995\n"
" rate = 10.1010101010101\n",
" jet_triggered = True\n",
" t_sleep = 0.05\n",
" mode = single shot\n",
"comment = configuration in morning\n"
] ]
} }
], ],
...@@ -151,7 +158,7 @@ ...@@ -151,7 +158,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 194, "execution_count": 3,
"metadata": { "metadata": {
"collapsed": true, "collapsed": true,
"scrolled": true "scrolled": true
...@@ -173,16 +180,16 @@ ...@@ -173,16 +180,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"{'time': '2017-09-04_11-06-00.979017'}" "{'time': '2017-09-08_15-11-03.270338'}"
] ]
}, },
"execution_count": 17, "execution_count": 4,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -283,7 +290,9 @@ ...@@ -283,7 +290,9 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 230, "execution_count": 230,
"metadata": {}, "metadata": {
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"focus.cam.close()\n", "focus.cam.close()\n",
...@@ -302,7 +311,7 @@ ...@@ -302,7 +311,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 196, "execution_count": 5,
"metadata": { "metadata": {
"hideCode": false, "hideCode": false,
"hidePrompt": false, "hidePrompt": false,
...@@ -324,8 +333,8 @@ ...@@ -324,8 +333,8 @@
"try:\n", "try:\n",
" para_config = config['ParabolicMirror']\n", " para_config = config['ParabolicMirror']\n",
"except:\n", "except:\n",
" para_config = {'pos_Pay': 3,\n", " para_config = {'pos_Pay': 3.99396444, \n",
" 'pos_Paz': 3}\n", " 'pos_Paz': 5.16051188}\n",
" \n", " \n",
"para = ParabolicMirror(para_config, home = False)" "para = ParabolicMirror(para_config, home = False)"
] ]
...@@ -342,7 +351,7 @@ ...@@ -342,7 +351,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 197, "execution_count": 6,
"metadata": { "metadata": {
"hideCode": false, "hideCode": false,
"hidePrompt": false, "hidePrompt": false,
...@@ -871,7 +880,7 @@ ...@@ -871,7 +880,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 120, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -880,26 +889,12 @@ ...@@ -880,26 +889,12 @@
"text": [