barsukov 1.3.3__py3-none-any.whl → 1.3.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of barsukov might be problematic. Click here for more details.
- barsukov/__init__.py +1 -4
- barsukov/data/Change_phase.py +160 -0
- barsukov/data/Lock_in_emulator.py +175 -0
- barsukov/data/__init__.py +5 -0
- barsukov/data/constants.py +10 -0
- barsukov/data/fft.py +100 -55
- barsukov/data/lock_in_emulator_app.py +297 -0
- barsukov/data/noise.py +276 -0
- barsukov/exp/__init__.py +2 -0
- barsukov/exp/mwHP.py +11 -2
- barsukov/exp/smKE.py +148 -0
- barsukov/logger.py +4 -3
- barsukov/script.py +16 -4
- barsukov/time.py +1 -1
- {barsukov-1.3.3.dist-info → barsukov-1.3.5.dist-info}/METADATA +6 -2
- barsukov-1.3.5.dist-info/RECORD +20 -0
- {barsukov-1.3.3.dist-info → barsukov-1.3.5.dist-info}/WHEEL +1 -1
- barsukov-1.3.3.dist-info/RECORD +0 -14
- {barsukov-1.3.3.dist-info → barsukov-1.3.5.dist-info}/top_level.txt +0 -0
barsukov/exp/smKE.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
### BEGIN Dependencies ###
|
|
2
|
+
import numpy as np
|
|
3
|
+
import sys
|
|
4
|
+
from barsukov.exp.exp_utils import *
|
|
5
|
+
### END Dependencies
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class smKE:
|
|
9
|
+
def __init__(self, gpib=None, visa_rm=None, logger=None, gpib_card=0, log='default', script=None):
|
|
10
|
+
# Pass the Script object, if available.
|
|
11
|
+
# If Script has no visa_rm or if no Script is passed, you'll need to pass the visa_rm=visa.ResourceManager manually.
|
|
12
|
+
# If Script has no logger or if no Script is passed, you can pass the logger manually.
|
|
13
|
+
# If no logger is passed, will simply print to screen.
|
|
14
|
+
# Change log from 'default' to 'screen', 'file', 'both', 'no'.
|
|
15
|
+
# gpib_card is per default 0. You can change, if you have multiple.
|
|
16
|
+
|
|
17
|
+
self.script = script
|
|
18
|
+
self.logger = logger
|
|
19
|
+
self.eq_default_log = log
|
|
20
|
+
self.rm = visa_rm
|
|
21
|
+
self.gpib_card = gpib_card
|
|
22
|
+
self.gpib = gpib
|
|
23
|
+
|
|
24
|
+
self.msg_deco = f'[smKE {self.gpib_card}::{self.gpib}]'
|
|
25
|
+
self.eq = initialize_gpib(self) # This will initialize self.eq = visa.open_resource()
|
|
26
|
+
self.log( f'Initialized: {self.identify()}', log='important' ) # This is the 'welcome message' and a check if communication works.
|
|
27
|
+
|
|
28
|
+
# Digits, x_Min, x_Max, Range_min, Range_max, units, function
|
|
29
|
+
self.I_params = [10, -1.05, 1.05, 1e-6, 1, 'A', 'curr']
|
|
30
|
+
self.V_params = [10, -210.0, 210.0, 0, 210.0, 'V', 'volt'] #digits and range undetermined
|
|
31
|
+
self.R_params = [10, 0.0, 2.1e8, 'R'] #digits undetermined
|
|
32
|
+
|
|
33
|
+
### BEGIN The definition of the following functions may be specific to this equipment.
|
|
34
|
+
def query(self, cmd):
|
|
35
|
+
return self.eq.query(cmd)
|
|
36
|
+
|
|
37
|
+
def write(self, cmd):
|
|
38
|
+
return self.eq.write(cmd)
|
|
39
|
+
|
|
40
|
+
def identify(self):
|
|
41
|
+
return str(self.eq.query('*IDN?'))
|
|
42
|
+
### END The definition of the following functions may be specific to this equipment.
|
|
43
|
+
def disconnect(self):
|
|
44
|
+
eq_disconnect(self)
|
|
45
|
+
|
|
46
|
+
def reconnect(self):
|
|
47
|
+
eq_reconnect(self)
|
|
48
|
+
|
|
49
|
+
def log(self, msg, log=None):
|
|
50
|
+
if log is None: log=self.eq_default_log
|
|
51
|
+
log_in_eq(self, msg, log=log)
|
|
52
|
+
### END These functions could be shared across all equipment.\
|
|
53
|
+
|
|
54
|
+
def source(self, function=None, scale=None, level=None, cmpl_scale=None, cmpl_level=None, log=None):
|
|
55
|
+
if log is None: log=self.eq_default_log
|
|
56
|
+
if function is None:
|
|
57
|
+
try:
|
|
58
|
+
f = self.eq.query('sour:func?')
|
|
59
|
+
f = str(f)[:-1]
|
|
60
|
+
|
|
61
|
+
s = self.eq.query(f'sour:{f}:rang?')
|
|
62
|
+
s = float(s) / 1.05
|
|
63
|
+
exp = np.floor(np.log10(abs(s)))
|
|
64
|
+
s = np.ceil(s / 10**exp) * 10**exp
|
|
65
|
+
|
|
66
|
+
l = self.eq.query(f'sour:{f}:lev?')
|
|
67
|
+
l = float(l)
|
|
68
|
+
|
|
69
|
+
if f == 'CURR': source_param, compliance_param = self.I_params, self.V_params
|
|
70
|
+
if f == 'VOLT': source_param, compliance_param = self.V_params, self.I_params
|
|
71
|
+
|
|
72
|
+
cs = self.eq.query(f'sens:{source_param[6]}:rang?')
|
|
73
|
+
cs = float(cs)
|
|
74
|
+
|
|
75
|
+
cl = self.eq.query(f'sens:{source_param[6]}:prot?')
|
|
76
|
+
cl = float(cl)
|
|
77
|
+
|
|
78
|
+
self.log(f'Source function is {f}, scale is {s} {source_param[5]}, level is {l} {source_param[5]}. Compliance scale is {cs} {compliance_param[5]}, level is {cl} {compliance_param[5]}')
|
|
79
|
+
return f, s, l, cs, cl
|
|
80
|
+
|
|
81
|
+
except:
|
|
82
|
+
self.log(f'Error while reading source function.', log='important')
|
|
83
|
+
return np.nan
|
|
84
|
+
else:
|
|
85
|
+
if (function == 'curr') or (function == 'current'): source_param, compliance_param = self.I_params, self.V_params
|
|
86
|
+
else: source_param, compliance_param, = self.V_params, self.I_params
|
|
87
|
+
try:
|
|
88
|
+
if level > scale: level = scale #level must be equal to or less than scale
|
|
89
|
+
if cmpl_level > cmpl_scale: cmpl_level = cmpl_scale
|
|
90
|
+
|
|
91
|
+
f = source_param[6]
|
|
92
|
+
self.eq.write(f'sour:func {f}')
|
|
93
|
+
self.eq.write(f'sour:{f}:mode fix')
|
|
94
|
+
|
|
95
|
+
s = max(source_param[3], min(float(scale), source_param[4]))
|
|
96
|
+
self.eq.write(f'sour:{f}:rang {s}')
|
|
97
|
+
|
|
98
|
+
l = max(source_param[1], min(float(level), source_param[2]))
|
|
99
|
+
self.eq.write(f'sour:{f}:lev {l}')
|
|
100
|
+
|
|
101
|
+
cs = max(compliance_param[3], min(float(cmpl_scale), compliace_param[4]))
|
|
102
|
+
self.eq.write(f'sens:{compliance_param[6]}rang:auto off')
|
|
103
|
+
self.eq.write(f'sens:{compliance_param[6]}:rang: {cs}')
|
|
104
|
+
|
|
105
|
+
cl = max(compliance_param[1], min(float(cmpl_level), compliance_param[2]))
|
|
106
|
+
self.eq.write(f'sens:{compliance_param[6]}:prot:rsyn on')
|
|
107
|
+
self.eq.write(f'sens:{compliance_param[6]}:prot {cmpl_level}')
|
|
108
|
+
|
|
109
|
+
freal, sreal, lreal, csreal, clreal = self.source()
|
|
110
|
+
return freal, sreal, lreal, csreal, clreal
|
|
111
|
+
|
|
112
|
+
except:
|
|
113
|
+
self.log(f'Error while changing Source.', log='important')
|
|
114
|
+
return np.nan
|
|
115
|
+
|
|
116
|
+
def measure(self, function=None, four_wire=None, res_mode=None, res_guard=None, res_compensation=None, log=None):
|
|
117
|
+
if log is None: log=self.eq_default_log
|
|
118
|
+
if function is None:
|
|
119
|
+
try:
|
|
120
|
+
f = self.eq.query('sens:func?')
|
|
121
|
+
f = str(f)[:-1]
|
|
122
|
+
|
|
123
|
+
ws = self.eq.query('syst:rsen?')
|
|
124
|
+
ws = float(ws)
|
|
125
|
+
if ws: ws = 'on'
|
|
126
|
+
else: ws = 'off'
|
|
127
|
+
|
|
128
|
+
#self.log(f'Measure function
|
|
129
|
+
|
|
130
|
+
if 'RES' in f:
|
|
131
|
+
rm = self.eq.query('res:mode?')
|
|
132
|
+
rm = str(f)[:-1]
|
|
133
|
+
|
|
134
|
+
rg = self.eq.query('syst:guard?')
|
|
135
|
+
rg = str(f)[:-1]
|
|
136
|
+
|
|
137
|
+
rc = self.eq.query('res:ocom?')
|
|
138
|
+
if ws: ws = 'on'
|
|
139
|
+
else: ws = 'off'
|
|
140
|
+
|
|
141
|
+
except:
|
|
142
|
+
return 0
|
|
143
|
+
|
|
144
|
+
self.eq.write(f'sens:func:off:all')
|
|
145
|
+
self.eq.write(f'sens:func:on "{function}"')
|
|
146
|
+
self.eq.write(f'{function}:mode {source}')
|
|
147
|
+
self.eq.write(f'syst:rsen {sense_mode}')
|
|
148
|
+
self.eq.write(f'syst:guard {guard}')
|
barsukov/logger.py
CHANGED
|
@@ -73,7 +73,7 @@ class Logger:
|
|
|
73
73
|
full_folder_path = self.full_folder_path
|
|
74
74
|
|
|
75
75
|
### Create a file name like log_timeStamp_description_.txt ###
|
|
76
|
-
if
|
|
76
|
+
if description is not None and description != '':
|
|
77
77
|
description = f"_{description}"
|
|
78
78
|
else:
|
|
79
79
|
description = ''
|
|
@@ -104,10 +104,11 @@ class Logger:
|
|
|
104
104
|
|
|
105
105
|
def write_to_file(self, msg):
|
|
106
106
|
if self.file:
|
|
107
|
+
#add lock here
|
|
107
108
|
self.file.write(msg)
|
|
108
109
|
### flushing the log file to make sure it's written ###
|
|
109
110
|
self.file.flush()
|
|
110
|
-
os.fsync(self.file)
|
|
111
|
+
#os.fsync(self.file) ##.fileno()
|
|
111
112
|
else:
|
|
112
113
|
self.file_error = True
|
|
113
114
|
print(f'{time_stamp()} Logger is trying to write to a closed or non-existent file.')
|
|
@@ -119,7 +120,7 @@ class Logger:
|
|
|
119
120
|
log = 'screen'
|
|
120
121
|
elif log == 'important' and self.log_mode == 'file':
|
|
121
122
|
log = 'both'
|
|
122
|
-
elif (log == 'important') or(log == 'default') or (log is None):
|
|
123
|
+
elif (log == 'important') or (log == 'default') or (log is None):
|
|
123
124
|
log = self.log_mode
|
|
124
125
|
|
|
125
126
|
decorated_message = self.decorated_msg(msg)
|
barsukov/script.py
CHANGED
|
@@ -64,11 +64,10 @@ class Script():
|
|
|
64
64
|
os.makedirs(self.full_folder_path, exist_ok=True)
|
|
65
65
|
|
|
66
66
|
### Logger Attributes
|
|
67
|
-
self.start_logger = True
|
|
68
67
|
self.log_mode = log
|
|
69
68
|
self.log_full_folder_path = log_full_folder_path
|
|
70
69
|
self.log_full_file_path = log_full_file_path
|
|
71
|
-
self.init_logger(start=
|
|
70
|
+
self.init_logger(start=True)
|
|
72
71
|
self.logger_name = self.logger.full_file_path
|
|
73
72
|
|
|
74
73
|
### Equipment Attributes
|
|
@@ -130,6 +129,20 @@ class Script():
|
|
|
130
129
|
"""
|
|
131
130
|
from barsukov.exp.mwHP import mwHP as eq
|
|
132
131
|
return eq(gpib, logger=self.logger, script=self, **kwargs)
|
|
132
|
+
|
|
133
|
+
def smKE(self, gpib=None, **kwargs):
|
|
134
|
+
"""
|
|
135
|
+
Initializes and returns a mwHP equipment object with the specified parameters.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
gpib (str): gpib number of equipment. Defaults to 'None'.
|
|
139
|
+
**kwargs: Additional keyword arguments passed to the mwHP equipment initialization.
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
mwHP: A mwHP equipment object.
|
|
143
|
+
"""
|
|
144
|
+
from barsukov.exp.smKE import smKE as eq
|
|
145
|
+
return eq(gpib, logger=self.logger, script=self, **kwargs)
|
|
133
146
|
### END: Equipment devices
|
|
134
147
|
|
|
135
148
|
|
|
@@ -138,7 +151,6 @@ class Script():
|
|
|
138
151
|
# Prepares the Script object for serialization by removing non-seriable attributes (e.g. logger and rm).
|
|
139
152
|
# Returns a dict: A dictionary representing the serializable state of the Script object.
|
|
140
153
|
seriable_data = self.__dict__.copy()
|
|
141
|
-
seriable_data['start_log'] = False
|
|
142
154
|
del seriable_data['logger']
|
|
143
155
|
del seriable_data['rm']
|
|
144
156
|
return seriable_data
|
|
@@ -148,6 +160,6 @@ class Script():
|
|
|
148
160
|
# Restores the Script object from its serialized state, including reinitializing the logger and rm.
|
|
149
161
|
# Args: seriable_data (dict): A dictionary representing the serialized state of the Script object
|
|
150
162
|
self.__dict__.update(seriable_data)
|
|
151
|
-
self.init_logger(
|
|
163
|
+
self.init_logger(start=False)
|
|
152
164
|
if self.equipment is True: self.init_rm()
|
|
153
165
|
### END: OBJ2FILE TOOLS:
|
barsukov/time.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: barsukov
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.5
|
|
4
4
|
Summary: Experiment Automation Package
|
|
5
5
|
Author-email: Igor Barsukov <igorb@ucr.edu>, Steven Castaneda <scast206@ucr.edu>
|
|
6
6
|
Project-URL: Homepage, https://barsukov.ucr.edu
|
|
@@ -16,6 +16,10 @@ Requires-Dist: scipy>=0.9.0
|
|
|
16
16
|
|
|
17
17
|
Barsukov is a Python library for experiment automation.
|
|
18
18
|
|
|
19
|
+
## For Developers
|
|
20
|
+
|
|
21
|
+
To push to PyPi, commit to main on Github Desktop, click the history tab, right click and create tag, format the tag v\*.\*.\* and push to the repository (ctrl+p).
|
|
22
|
+
|
|
19
23
|
## Installation
|
|
20
24
|
|
|
21
25
|
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install barsukov.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
barsukov/__init__.py,sha256=7frhJ1d67SdEKCZKmi4Zr-2QnQzFA-YK2Pki4IQYKEw,202
|
|
2
|
+
barsukov/logger.py,sha256=BBqeid3kX7RJLKmHS4E1jH3KmlIrU3vaR4udSkk4gd4,6529
|
|
3
|
+
barsukov/obj2file.py,sha256=nivCmCEpmOSaG4VpQgIDb-7hsvdEq45Iuu5HOfRxbcw,3923
|
|
4
|
+
barsukov/script.py,sha256=JdTL-w-4FLh5k6T1IHnxX3zT4CQzDUfAs6usHHMUE30,6775
|
|
5
|
+
barsukov/time.py,sha256=apjdgwCXDNBAMyVfsAvfcORz4BkU2--d1BDLHIl_ar4,1038
|
|
6
|
+
barsukov/data/Change_phase.py,sha256=jOCjO4vvk39PEWhOTnLwaPZd769gCDz71nfKwIgSz6I,6998
|
|
7
|
+
barsukov/data/Lock_in_emulator.py,sha256=XbzB-RQUVP5qiCyoAN_r1jG98ZRXN9YGxxvlM0m2XbY,7099
|
|
8
|
+
barsukov/data/__init__.py,sha256=f6krjlrpD4BhytHkKp5UttzPR1ZGmoNZODxBX6Wcay0,183
|
|
9
|
+
barsukov/data/constants.py,sha256=SsnqLCjD1M_To7vpr2yXLE4djw4Yc7302t8cKhPWLgQ,156
|
|
10
|
+
barsukov/data/fft.py,sha256=C-PRVySyMYmSJva_S8OwjJBB26pp45ttndjgcaYXZkE,5655
|
|
11
|
+
barsukov/data/lock_in_emulator_app.py,sha256=-oZEBClSHol0iXpOgL0NRaKvy5DpyGthaPmkU9oPkc4,11586
|
|
12
|
+
barsukov/data/noise.py,sha256=MsLifk1Uyq6mjMcYq8ovuskOTRwsrZNqYRRs37IONOc,10504
|
|
13
|
+
barsukov/exp/__init__.py,sha256=DBzvcR0flW6ouWFdmOxngPzyFx_6t5ECztspJ8uX89M,39
|
|
14
|
+
barsukov/exp/exp_utils.py,sha256=7qVQJbJGbsNW0JZQ7A1cmI73J6vi_aN8Zu6WMq2-7LE,4789
|
|
15
|
+
barsukov/exp/mwHP.py,sha256=KAaQPeNI67_xxx-6JesfViHRkWPUqkufdrkwoVZzBnY,12591
|
|
16
|
+
barsukov/exp/smKE.py,sha256=EAhl1WjNv5dP_eZDPfQ-4qdtH8KOvLhNLM666VIvLuM,6107
|
|
17
|
+
barsukov-1.3.5.dist-info/METADATA,sha256=6CAGLrrJQaFi4B6-EP7zXeIrfjGr6B474sVTI73on30,975
|
|
18
|
+
barsukov-1.3.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
barsukov-1.3.5.dist-info/top_level.txt,sha256=Js5sHbNjP0UNMB9O5HtCHZqlfHabuNS8nTsHbg-1DDQ,9
|
|
20
|
+
barsukov-1.3.5.dist-info/RECORD,,
|
barsukov-1.3.3.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
barsukov/__init__.py,sha256=GVsEnM_uD4x1XN_PIKdD-VSRMNUnvPr2iCWuEHwM6sU,293
|
|
2
|
-
barsukov/logger.py,sha256=nrkS1Pg3WGEjRJQ5MbplhyGYGbfFGkgyxgx1qdSu1x0,6489
|
|
3
|
-
barsukov/obj2file.py,sha256=nivCmCEpmOSaG4VpQgIDb-7hsvdEq45Iuu5HOfRxbcw,3923
|
|
4
|
-
barsukov/script.py,sha256=nrKwEl60u9ces3B8FwRfY4VmlEx5bNvk_hoPaylldP0,6359
|
|
5
|
-
barsukov/time.py,sha256=fSf5JKqr6Pd5691qQcFuBsjDd9alMrfASnndlstLits,1039
|
|
6
|
-
barsukov/data/__init__.py,sha256=IMnOEliXsRMPWeCTprPSddRKg9kwfV-neQiwUwHdpqs,19
|
|
7
|
-
barsukov/data/fft.py,sha256=f9aPLeusVpWiWmXO5n4XwkfQ9xJQhZVFdyhFoT9DB2A,4365
|
|
8
|
-
barsukov/exp/__init__.py,sha256=urLfGpap40kN9ULi53JB0NT-iMsZDSFdBmdSq3ckB0E,19
|
|
9
|
-
barsukov/exp/exp_utils.py,sha256=7qVQJbJGbsNW0JZQ7A1cmI73J6vi_aN8Zu6WMq2-7LE,4789
|
|
10
|
-
barsukov/exp/mwHP.py,sha256=eoX82jon5nIsExvRHO1PIOQAWWWhJYY4N21VtoLXuSw,12136
|
|
11
|
-
barsukov-1.3.3.dist-info/METADATA,sha256=W5yH8yp2NKZgWqTi2TLUFW3xYSo7lzfy7IS7bNj7Y4k,791
|
|
12
|
-
barsukov-1.3.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
13
|
-
barsukov-1.3.3.dist-info/top_level.txt,sha256=Js5sHbNjP0UNMB9O5HtCHZqlfHabuNS8nTsHbg-1DDQ,9
|
|
14
|
-
barsukov-1.3.3.dist-info/RECORD,,
|
|
File without changes
|