barsukov 0.0.5__py3-none-any.whl → 1.0.9__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.
barsukov/script.py CHANGED
@@ -1,82 +1,153 @@
1
- from barsukov.time import *
2
- from barsukov.logger import Logger
3
-
4
- import sys
5
- import os
6
-
7
- class Script():
8
- def __init__(self,
9
- ### Please ALWAYS specify the following:
10
- operator='Anon', # ib, Rundong, Sasha, Ameerah, Alex, or AlexH if ambiguous
11
- station='No Stn', # qd, ppms, mseppms, data, orange, ...
12
- sample='No Sample', # Use sample name from the sample table, e.g. "cro2410a1" or "yig2207"
13
- description='No Description', # Briefly: what are you doing. Sets the folder name.
14
- # i.e. 'Testing modulation' or 'fH OOP long average'
15
- project_folder = os.getcwd(), # Full path to your project folder. Please follow this convention:
16
- # D:/Rundong/Projects/AFM sims/2024-07-06 Autooscillations
17
- # Will grab the current directory if not specified.
18
-
19
- ### Optional:
20
- log='both', # This is the default log setting which will be passed to the logger.
21
- ### It will be overriden by other objects,
22
- ### which in turn will be overriden by methods.
23
- ### Choose here and everywhere from screen, file, both, no.
24
-
25
- ### Usually, it's better not to change these:
26
- log_full_folder_path=None,
27
- log_full_file_path=None
28
- ):
29
-
30
- self.operator = operator
31
- self.station = station
32
- self.sample = sample
33
- self.description = description
34
- self.project_folder = project_folder
35
-
36
- self.rm = None
37
-
38
- ### Creating the sub-project folder
39
- self.folder_name = date() + '_' + self.station + '_' + self.operator + '_' + self.sample + '_' + self.description
40
- self.full_folder_path = os.path.join(self.project_folder, self.folder_name)
41
- os.makedirs(self.full_folder_path, exist_ok=True)
42
-
43
- ### Starting the logger
44
- if log_full_folder_path is None:
45
- self.logger = Logger(
46
- description=self.operator + '_' + self.description,
47
- full_file_path=log_full_file_path,
48
- log=log, # Script.log becomes Logger's default
49
- start_file=True)
50
- else:
51
- self.logger = Logger(
52
- description=self.operator + '_' + self.description,
53
- full_folder_path=log_full_folder_path,
54
- full_file_path=log_full_file_path,
55
- log=log, # Script.log becomes Logger's default
56
- start_file=True)
57
-
58
- self.logger.log(f'Script object initialized. Logger started.', log='both')
59
-
60
- def log(self, msg, log='default'): # default means the default of the logger
61
- self.logger.log(msg, log=log)
62
-
63
-
64
- ### BEGIN: Equipment related stuff
65
-
66
- def init_rm(self):
67
- # Imports pyvisa as method library #
68
- import pyvisa as visa # ----------------XXX Can this be done like this??????????????
69
- try:
70
- self.rm = visa.ResourceManager()
71
- except:
72
- self.rm = None
73
- self.log('Script could not import pyvisa.', log='important')
74
- sys.exit()
75
- self.log(f'Script started pyvisa.ResourceManager.', log='both')
76
- return self.rm
77
-
78
- ### BEGIN Equipment devices
79
-
80
- def mwHP(self, **kwargs):
81
- from barsukov.exp.mwHP import mwHP as eq
82
- return eq(**kwargs, script=self, logger=self.logger)
1
+ ### BEGIN Dependencies ###
2
+ import sys
3
+ import os
4
+ from barsukov.time import *
5
+ from barsukov.logger import Logger
6
+ ### END Dependencies
7
+
8
+
9
+ class Script():
10
+ """
11
+ A class that represents a scientific experiment script, managing logging, file handing, and device initialization.
12
+
13
+ Args:
14
+ RECOMMENDED:
15
+ operator (str): The name of the operator (default: 'Anon').
16
+ station (str): The station of the experiment (default: 'No-Station').
17
+ sample (str): The sample being tested (default: 'No-Sample').
18
+ description (str): A brief description of the experiment (default: 'No-Description').
19
+ project_folder (str): The base folder for the project files (default: current directory).
20
+
21
+ OPTIONAL:
22
+ log (str, optional): The logging configuration (default: 'both')
23
+ This is the default log setting which will be passed to the logger.
24
+ It will be overriden by other objects, which in turn will be overriden by methods.
25
+ Choose here and everywhere from 'screen', 'file', 'both', 'no'.
26
+
27
+ BEST NOT TO CHANGE:
28
+ log_full_folder_path (str, optional): Path to save logs (default: current directory).
29
+ log_full_file_path (str, optional): Full path for log file (default: None).
30
+
31
+ Attributes:
32
+ operator (str): The operator's name (e.g., 'ib', 'Rundong', 'Sasha', 'Ameerah', 'Steven', 'Alex', or 'AlexH' if ambiguous).
33
+ station (str): The station where the experiment is conducted (e.g., 'qd', 'ppms', 'mseppms', 'data', 'orange', ...).
34
+ sample (str): The sample being used in the experiment (e.g. 'cro2410a1').
35
+ description (str): A brief description of the experiment (e.g., 'Testing modulation').
36
+ project_folder (str): Absolute path to the directory (e.g., 'D:/Rundong/Projects/AFM sims/2024-07-06 Autooscillations').
37
+ folder_name (str): A generated folder name based on the experiment details.
38
+ full_folder_path (str): The full path to the experiment folder.
39
+ logger (Logger): A Logger instance for logging experiment data.
40
+ rm (ResourceManager or None): The pyvisa ResourceManager used for controlling instruments.
41
+ """
42
+ ### BEGIN: Initializing tools
43
+ def __init__(self,
44
+ operator='Anon',
45
+ station='No-Station',
46
+ sample='No-Sample',
47
+ description='No-Description',
48
+ project_folder = os.getcwd(),
49
+ log='both',
50
+ log_full_folder_path=os.getcwd(),
51
+ log_full_file_path=None,
52
+ ):
53
+
54
+ ### Description Attributes
55
+ self.operator = operator
56
+ self.station = station
57
+ self.sample = sample
58
+ self.description = description
59
+ self.project_folder = project_folder
60
+
61
+ ### Creating the sub-project folder
62
+ self.folder_name = f"{date()}_{self.station}_{self.operator}_{self.sample}_{self.description}"
63
+ self.full_folder_path = os.path.join(self.project_folder, self.folder_name)
64
+ os.makedirs(self.full_folder_path, exist_ok=True)
65
+
66
+ ### Logger Attributes
67
+ self.start_logger = True
68
+ self.log_mode = log
69
+ self.log_full_folder_path = log_full_folder_path
70
+ self.log_full_file_path = log_full_file_path
71
+ self.init_logger(start=self.start_logger)
72
+ self.logger_name = self.logger.full_file_path
73
+
74
+ ### Equipment Attributes
75
+ self.rm = None
76
+ self.equipment = None
77
+
78
+ def init_logger(self, start):
79
+ ### Starting the logger
80
+ self.logger = Logger(
81
+ description=f"{self.operator}_{self.description}",
82
+ full_folder_path=self.log_full_folder_path,
83
+ full_file_path=self.log_full_file_path,
84
+ log=self.log_mode, # Script.log becomes Logger's default
85
+ start_file=start)
86
+ self.logger.log(f'Script object initialized. Logger started.', log='both')
87
+
88
+
89
+ def log(self, msg, log='default'):
90
+ """
91
+ Logs a message using the Script object's logger.
92
+
93
+ Args:
94
+ msg (str): The message to log.
95
+ log (str, optional): The log destination (e.g., 'screen', 'file', 'both'). Defaults to the 'default' of the logger
96
+ """
97
+ self.logger.log(msg, log=log)
98
+ ### END: Initializing tools
99
+
100
+
101
+ ### BEGIN: Equipment related stuff
102
+ def init_rm(self):
103
+ # Initializes the pyvisa ResourceManager for controlling instruments.
104
+ # Returns ResourceManager The pyvisa ResourceManager object.
105
+ # Raises SystemExit If pyvisa cannot be imported or the ResourceManager cannot be initialized.
106
+ self.equipment = True
107
+ import pyvisa as visa
108
+ try:
109
+ self.rm = visa.ResourceManager()
110
+ except:
111
+ self.rm = None
112
+ self.log('Script could not import pyvisa.', log='important')
113
+ sys.exit()
114
+ self.log(f'Script started pyvisa.ResourceManager.', log='both')
115
+ return self.rm
116
+ ### END: Equipment related stuff
117
+
118
+
119
+ ### BEGIN: Equipment devices
120
+ def mwHP(self, gpib=None, **kwargs):
121
+ """
122
+ Initializes and returns a mwHP equipment object with the specified parameters.
123
+
124
+ Args:
125
+ gpib (str): gpib number of equipment. Defaults to 'None'.
126
+ **kwargs: Additional keyword arguments passed to the mwHP equipment initialization.
127
+
128
+ Returns:
129
+ mwHP: A mwHP equipment object.
130
+ """
131
+ from barsukov.exp.mwHP import mwHP as eq
132
+ return eq(gpib, logger=self.logger, script=self, **kwargs)
133
+ ### END: Equipment devices
134
+
135
+
136
+ ### BEGIN: OBJ2FILE TOOLS:
137
+ def __getstate__(self):
138
+ # Prepares the Script object for serialization by removing non-seriable attributes (e.g. logger and rm).
139
+ # Returns a dict: A dictionary representing the serializable state of the Script object.
140
+ seriable_data = self.__dict__.copy()
141
+ seriable_data['start_log'] = False
142
+ del seriable_data['logger']
143
+ del seriable_data['rm']
144
+ return seriable_data
145
+
146
+
147
+ def __setstate__(self, seriable_data):
148
+ # Restores the Script object from its serialized state, including reinitializing the logger and rm.
149
+ # Args: seriable_data (dict): A dictionary representing the serialized state of the Script object
150
+ self.__dict__.update(seriable_data)
151
+ self.init_logger(self.start_logger)
152
+ if self.equipment is True: self.init_rm()
153
+ ### END: OBJ2FILE TOOLS:
barsukov/time.py CHANGED
@@ -1,16 +1,37 @@
1
- ### BEGIN Dependencies ###
2
- import datetime
3
- from pytz import timezone
4
- ### END Dependencies ###
5
-
6
- TIMEZONE = timezone('America/Los_Angeles')
7
-
8
- def time_stamp(): # YYYY-MM-DD_HH-MM-SSS, last digit is 1/10th of the second
9
- now = datetime.datetime.now(TIMEZONE)
10
- formatted_datetime = now.strftime(f"%Y-%m-%d_%H-%M-%S") + str(int( now.microsecond / 100000 ))
11
- return formatted_datetime
12
-
13
- def date(): # YYYY-MM-DD
14
- now = datetime.datetime.now(TIMEZONE)
15
- formatted_datetime = now.strftime(f"%Y-%m-%d")
16
- return formatted_datetime
1
+ ### BEGIN Dependencies ###
2
+ import datetime
3
+ from pytz import timezone
4
+ ### END Dependencies ###
5
+
6
+ TIMEZONE = timezone('America/Los_Angeles')
7
+
8
+ def time_stamp():
9
+ """
10
+ Generates a timestamp in the format 'YYYY-MM-DD_HH-MM-SSS', where the last digit represents 1/10th of a second based on the current date and time.
11
+
12
+ returns:
13
+ str: A string representing the current date and time in the format 'YYYY-MM-DD_HH-MM-SSS'.
14
+
15
+ Example:
16
+ >>> time_stamp()
17
+ '2025-01-28_17-27-210'
18
+ """
19
+ now = datetime.datetime.now(TIMEZONE)
20
+ formatted_datetime = now.strftime(f"%Y-%m-%d_%H-%M-%S") + str(int( now.microsecond / 100000 ))
21
+ return formatted_datetime
22
+
23
+
24
+ def date():
25
+ """
26
+ Generates the current date in the format 'YYYY-MM-DD'.
27
+
28
+ Returns:
29
+ str: A string representing the current date in the format 'YYYY-MM-DD'.
30
+
31
+ Example:
32
+ >>> date()
33
+ '2025-01-28'
34
+ """
35
+ now = datetime.datetime.now(TIMEZONE)
36
+ formatted_datetime = now.strftime(f"%Y-%m-%d")
37
+ return formatted_datetime
@@ -1,48 +1,47 @@
1
- Metadata-Version: 2.2
2
- Name: barsukov
3
- Version: 0.0.5
4
- Summary: Experiment Automation Package
5
- Author-email: Igor Barsukov <igorb@ucr.edu>
6
- Maintainer-email: Steven Castaneda <scast206@ucr.edu>
7
- Project-URL: Homepage, https://barsukov.ucr.edu
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.8
11
- Description-Content-Type: text/markdown
12
- Requires-Dist: pytz>=2014.10
13
- Requires-Dist: numpy>=1.20.0
14
- Requires-Dist: scipy>=1.15.1
15
-
16
- # Barsukov
17
-
18
- Barsukov is a Python library for experiment automation.
19
-
20
- ## Installation
21
-
22
- Use the package manager [pip](https://pip.pypa.io/en/stable/) to install barsukov.
23
-
24
- ```bash
25
- pip install barsukov
26
- ```
27
-
28
- ## Usage
29
-
30
- ```python
31
- #
32
- #
33
- #
34
- #
35
- #
36
- #
37
- #
38
- ```
39
-
40
- ## Contributing
41
-
42
- -
43
- -
44
- -
45
-
46
- ## License
47
-
48
- [MIT](https://choosealicense.com/licenses/mit/)
1
+ Metadata-Version: 2.2
2
+ Name: barsukov
3
+ Version: 1.0.9
4
+ Summary: Experiment Automation Package
5
+ Author-email: Igor Barsukov <igorb@ucr.edu>, Steven Castaneda <scast206@ucr.edu>
6
+ Project-URL: Homepage, https://barsukov.ucr.edu
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: pytz>=2014.10
12
+ Requires-Dist: numpy>=1.0.0
13
+ Requires-Dist: scipy>=0.9.0
14
+
15
+ # Barsukov
16
+
17
+ Barsukov is a Python library for experiment automation.
18
+
19
+ ## Installation
20
+
21
+ Use the package manager [pip](https://pip.pypa.io/en/stable/) to install barsukov.
22
+
23
+ ```bash
24
+ pip install barsukov
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```python
30
+ #
31
+ #
32
+ #
33
+ #
34
+ #
35
+ #
36
+ #
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ -
42
+ -
43
+ -
44
+
45
+ ## License
46
+
47
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,14 @@
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.0.9.dist-info/METADATA,sha256=OUhd6M4Wnqi7sWE7jyokT01gh7-djeGW6jeh40alpHM,791
12
+ barsukov-1.0.9.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
13
+ barsukov-1.0.9.dist-info/top_level.txt,sha256=Js5sHbNjP0UNMB9O5HtCHZqlfHabuNS8nTsHbg-1DDQ,9
14
+ barsukov-1.0.9.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- barsukov/__init__.py,sha256=5m-RSzmBVqzfuBuo2Eqj-DCiKgOfKhqvGr9E5mPTdl4,257
2
- barsukov/logger.py,sha256=kWSiJJSjI4EtCxW5fyAww-6BQAFnCk-Gv8OIdtXH5pg,5275
3
- barsukov/obj2file.py,sha256=kNEDM7wcAUbeg7qbztZrKsxcOQEi2JmB-qQzaOO50Cc,3879
4
- barsukov/script.py,sha256=CaO3g3uW08Lt2h_4Gxcx7gTWRVg2FZoWSlEzD7YhHH0,3379
5
- barsukov/time.py,sha256=6YVvay-ISO5VpyHG8WGUelGfaN1N18ktRrP37MVbdyU,552
6
- barsukov/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- barsukov/data/fft.py,sha256=VwY1h0ZB8xy_mxoI8zPESRLM7nk5NbiGi3wC6vg6T-k,4452
8
- barsukov/exp/__init__.py,sha256=urLfGpap40kN9ULi53JB0NT-iMsZDSFdBmdSq3ckB0E,19
9
- barsukov/exp/exp_utils.py,sha256=jpmSt-4XGwK4QWR8SEi1s0JPwUavO8Smmc4y6bO0giU,4091
10
- barsukov/exp/mwHP.py,sha256=auZmIgxtbZyzS_x0jk5uhNHioAuJKnAUHeB-fJoSF3w,19023
11
- barsukov-0.0.5.dist-info/METADATA,sha256=FTDVG2ZLzSrh8bHj34Fi93MibQYLXoq9z3J2X3MVwh0,858
12
- barsukov-0.0.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
13
- barsukov-0.0.5.dist-info/top_level.txt,sha256=Js5sHbNjP0UNMB9O5HtCHZqlfHabuNS8nTsHbg-1DDQ,9
14
- barsukov-0.0.5.dist-info/RECORD,,