Qudi
|
A general class which saves all kinds of data in a general sense. More...
Public Member Functions | |
def | __init__ (self, config, kwargs) |
def | on_activate (self) |
Definition, configuration and initialisation of the SaveLogic. | |
def | on_deactivate (self) |
def | dailylog (self) |
Returns the daily log handler. | |
def | dailylog_set_level (self, level) |
Sets the log level of the daily log handler. More... | |
def | save_data (self, data, filepath=None, parameters=None, filename=None, filelabel=None, timestamp=None, filetype='text', fmt='%.15e', delimiter='\t', plotfig=None) |
General save routine for data. More... | |
def | save_array_as_text (self, data, filename, filepath='', fmt='%.15e', header='', delimiter='\t', comments='#', append=False) |
def | get_daily_directory (self) |
Creates the daily directory. More... | |
def | get_path_for_module (self, module_name) |
Method that creates a path for 'module_name' where data are stored. More... | |
Public Attributes | |
lock | |
active_poi_name | |
os_system | |
data_dir | |
Static Public Attributes | |
log_into_daily_directory = ConfigOption('log_into_daily_directory', False, missing='warn') | |
dictionary | mpl_qd_style |
A general class which saves all kinds of data in a general sense.
def save_logic.SaveLogic.dailylog_set_level | ( | self, | |
level | |||
) |
Sets the log level of the daily log handler.
level | int: log level, see logging |
def save_logic.SaveLogic.get_daily_directory | ( | self | ) |
Creates the daily directory.
If the daily directory does not exits in the specified <root_dir> path in the config file, then it is created according to the following scheme:
<root_dir>\<year>\<month>\<yearmonthday>
and the filepath is returned. There should be always a filepath returned.
def save_logic.SaveLogic.get_path_for_module | ( | self, | |
module_name | |||
) |
Method that creates a path for 'module_name' where data are stored.
string | module_name: Specify the folder, which should be created in the daily directory. The module_name can be e.g. 'Confocal'. |
def save_logic.SaveLogic.save_data | ( | self, | |
data, | |||
filepath = None , |
|||
parameters = None , |
|||
filename = None , |
|||
filelabel = None , |
|||
timestamp = None , |
|||
filetype = 'text' , |
|||
fmt = '%.15e' , |
|||
delimiter = '\t' , |
|||
plotfig = None |
|||
) |
General save routine for data.
dictionary | data: Dictionary containing the data to be saved. The keys should be strings containing the data header/description. The corresponding items are one or more 1D arrays or one 2D array containing the data (list or numpy.ndarray). Example: data = {'Frequency (MHz)': [1,2,4,5,6]} data = {'Frequency': [1, 2, 4], 'Counts': [234, 894, 743, 423]} data = {'Frequency (MHz),Counts':[[1,234], [2,894],...[30,504]]} |
string | filepath: optional, the path to the directory, where the data will be saved. If the specified path does not exist yet, the saving routine will try to create it. If no path is passed (default filepath=None) the saving routine will create a directory by the name of the calling module inside the daily data directory. If no calling module can be inferred and/or the requested path can not be created the data will be saved in a subfolder of the daily data directory called UNSPECIFIED |
dictionary | parameters: optional, a dictionary with all parameters you want to save in the header of the created file. string filename: optional, if you really want to fix your own filename. If passed, the whole file will have the name <filename> |
If nothing is specified the save logic will generate a filename either based on the module name from which this method was called, or it will use the passed filelabel if that is speficied. You also need to specify the ending of the filename! string filelabel: optional, if filelabel is set and no filename was specified, the savelogic will create a name which looks like
YYYY-MM-DD_HHh-MMm-SSs_<filelabel>.dat
The timestamp will be created at runtime if no user defined timestamp was passed.
datetime | timestamp: optional, a datetime.datetime object. You can create this object with datetime.datetime.now() in the calling module if you want to fix the timestamp for the filename. Be careful when passing a filename and a timestamp, because then the timestamp will be ignored. |
string | filetype: optional, the file format the data should be saved in. Valid inputs are 'text', 'xml' and 'npz'. Default is 'text'. |
string | or list of strings fmt: optional, format specifier for saved data. See python documentation for "Format Specification Mini-Language". If you want for example save a float in scientific notation with 6 decimals this would look like '%.6e'. For saving integers you could use 'd', 's' for strings. The default is '%.15e' for numbers and 's' for str. If len(data) > 1 you should pass a list of format specifiers; one for each item in the data dict. If only one specifier is passed but the data arrays have different data types this can lead to strange behaviour or failure to save right away. |
string | delimiter: optional, insert here the delimiter, like ' ' for new line, '' for tab, ',' for a comma ect. |
1D data should be passed in a dictionary where the data trace should be assigned to one identifier like
{'<identifier>':[list of values]} {'Numbers of counts':[1.4, 4.2, 5, 2.0, 5.9 , ... , 9.5, 6.4]}
You can also pass as much 1D arrays as you want:
{'Frequency (MHz)':list1, 'signal':list2, 'correlations': list3, ...}
2D data should be passed in a dictionary where the matrix like data should be assigned to one identifier like
{'<identifier>':[[1,2,3],[4,5,6],[7,8,9]]}
which will result in: <identifier> 1 2 3 4 5 6 7 8 9
YOU ARE RESPONSIBLE FOR THE IDENTIFIER! DO NOT FORGET THE UNITS FOR THE SAVED TIME TRACE/MATRIX.
|
static |