Skip to content

Commit

Permalink
Added logging.csv columns
Browse files Browse the repository at this point in the history
Added threeroi_array and a_b ratio to logging.csv output.

Fixed issue with presenter - view refrencing for setting.comments.

Co-Authored-By: adenlam <adenlam@users.noreply.github.com>
Co-Authored-By: Henry Liu <henry@liuhenry.com>
  • Loading branch information
3 people committed May 26, 2020
1 parent 0cfcb6f commit 0962f2f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def center(self, tup):
@property
def logheader(self):
"""Defines the headers of the logging.csv file saved in '../Raw Data/' folder."""
return ["filename", "magnification", "atom number", "fitted shot", "tof_sequence", "time_sequence", "average_T (uK)", "Comments"]
return ["filename", "magnification", "atom number", "fitted shot", "tof_sequence", "time_sequence", "average_T (uK)", "threeroi", "a_b_ratio", "Comments"]


config = Config("config.ini")
3 changes: 2 additions & 1 deletion presenters/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def set_view(self, view):
plot_view=self.view.plot,
fit_view=self.view.tabs.shot_fit,
list_view=self.view.shot_list,
threeroi_view=self.view.tabs.three_roi_atom_count
threeroi_view=self.view.tabs.three_roi_atom_count,
settings_view=self.view.tabs.settings
)
self.sequence_presenter = SequencePresenter(
self, self.worker, plot_view=self.view.plot, fit_view=self.view.tabs.tof_fit
Expand Down
20 changes: 14 additions & 6 deletions presenters/shots.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

from config import config
from models import shots
from views.settings import Settings

class ShotPresenter:
def __init__(self, app, worker, *, plot_view, fit_view, list_view, threeroi_view):
def __init__(self, app, worker, *, plot_view, fit_view, list_view, threeroi_view, settings_view):
self.app = app
self.worker = worker
self.plot_view = plot_view
self.fit_view = fit_view
self.list_view = list_view
self.threeroi_view = threeroi_view
self.settings_view = settings_view
# Stores data for past (maxlen) shots
self.recent_shots = deque(maxlen=15)
self.current_shot = None
Expand All @@ -50,11 +50,16 @@ def process_shot(self, name, paths):
figure = Figure(figsize=(8, 5))
shot.plot(figure)
figure.savefig(_output_path(name), dpi=150)
# Saves fit params to log file

cmnts = Settings.get_comment
# Saves fit params to log file
cmnts = self.settings_view.get_comment()
abratio = ""
threeroi_array = []
if config.three_roi_enabled: # only appends value if threeroi is enabled
abratio = shot.three_roi_atom_number["a_b_ratio"]
threeroi_array = config.threeroi

logging.info("Updating logging.csv for shot %s with comment %s ", name, cmnts)
logging.info("Updating logging.csv for shot %s with comment %s " % (name, cmnts))

# Checks if log file already exists, if not creates a new one
if not path.exists(_output_log_path(name)):
Expand All @@ -68,7 +73,10 @@ def process_shot(self, name, paths):
writer.writerow({"filename" : name,
"magnification" : config.magnification,
"atom number" : shot.atom_number,
"fitted shot" : config.fit})
"fitted shot" : config.fit,
"threeroi" : threeroi_array,
"a_b_ratio" : abratio,
"Comments" : cmnts})

# Check if ToF or optimization
self.app.sequence_presenter.add_shot(shot)
Expand Down
4 changes: 2 additions & 2 deletions views/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ def __init__(self, master, presenter):
self.atom_number_fit = AtomNumberOptimization(self, self.presenter)
self.three_roi_atom_count = ThreeROI(self, self.presenter)
exp = ExperimentParams(self)
settings = Settings(self)
self.settings = Settings(self)

self.add(self.shot_fit, text="Gaussian", padding=10)
self.add(self.tof_fit, text="Temperature", padding=10)
self.add(self.atom_number_fit, text="Atom # Optimization", padding=10)
self.add(self.three_roi_atom_count, text="Three ROIs", padding=10)
self.add(exp, text="Experiment Settings", padding=10)
self.add(settings, text="Settings", padding=10)
self.add(self.settings, text="Settings", padding=10)
2 changes: 1 addition & 1 deletion views/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, master):
).grid(row=0, column=1)

# Defines comment box for saving in logging.csv
ttk.Label(frame, text="Logging comments").grid(row=2, column=0, columnspan=2)
ttk.Label(frame, text="Logging.csv comments").grid(row=2, column=0, columnspan=2)
self.comment_string = ""
self.var = tk.StringVar()
comments_entry = ttk.Entry(frame, textvariable=self.var)
Expand Down

0 comments on commit 0962f2f

Please sign in to comment.