DiCarloLab-Delft / PycQED_py3

Python3 version of PycQED using QCoDeS as backend
MIT License
67 stars 40 forks source link

Error: name 'datadir' is not defined #729

Closed dangokuson closed 3 months ago

dangokuson commented 3 months ago

I'm testing the MeasurementControl - adaptive sampling use cases.ipynb file but it saids that NameError: name 'datadir' is not defined.

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[6], line 16
     14 label = '1D uniform'
     15 dat = MC.run(label, mode="1D")
---> 16 ma2.Basic1DAnalysis(label=label, close_figs=False)

File ~/workspace/projects/PycQED_py3/pycqed/analysis_v2/simple_analysis.py:54, in Basic1DAnalysis.__init__(self, t_start, t_stop, label, data_file_path, options_dict, extract_only, do_fitting, close_figs, auto, hide_lines, hide_pnts, plt_sorted_x, legend_labels)
     38 def __init__(
     39     self,
     40     t_start: str = None,
   (...)
     52     legend_labels: list = None
     53 ):
---> 54     super().__init__(
     55         t_start=t_start,
     56         t_stop=t_stop,
     57         label=label,
     58         data_file_path=data_file_path,
     59         options_dict=options_dict,
     60         extract_only=extract_only,
     61         do_fitting=do_fitting,
     62         close_figs=close_figs,
     63     )
     64     # self.single_timestamp = False
     65     self.params_dict = {
     66         "xlabel": "sweep_name",
     67         "xunit": "sweep_unit",
   (...)
     72         "measured_values": "measured_values",
     73     }

File ~/workspace/projects/PycQED_py3/pycqed/analysis_v2/base_analysis.py:173, in BaseDataAnalysis.__init__(self, t_start, t_stop, label, data_file_path, close_figs, options_dict, extract_only, do_fitting, save_qois)
    167 self.data_file_path = None
    168 if t_start is None and t_stop is None and data_file_path is None:
    169     # Nothing specified -> find last file with label
    170     # This is quite a hacky way to support finding the last file
    171     # with a certain label, something that was trivial in the old
    172     # analysis. A better solution should be implemented.
--> 173     self.t_start = a_tools.latest_data(scan_label,
    174                                        return_timestamp=True)[0]
    175 elif data_file_path is not None:
    176     # Data file path specified ignore timestamps
    177     self.extract_from_file = True

File ~/workspace/projects/PycQED_py3/pycqed/analysis/analysis_toolbox.py:129, in latest_data(contains, older_than, newer_than, or_equal, return_timestamp, raise_exc, folder, return_all)
    113 """
    114 finds the latest taken data with <contains> in its name.
    115 returns the full path of the data directory.
   (...)
    126     the requirements (Cristian)
    127 """
    128 if (folder is None):
--> 129     search_dir = datadir
    130 else:
    131     search_dir = folder

NameError: name 'datadir' is not defined

How to solve it?

MiniSean commented 3 months ago

In order for the data acquisition to work a directory needs to be set before running an acquisition cycle (like MC.run()). This can be done as follows:

from pycqed.analysis import analysis_toolbox
analysis_toolbox.datadir = "path/to/desired/data/directory"