Skip to content

Save the pump-probe output to file#315

Open
CammilleCC wants to merge 2 commits intodevfrom
pp-savefile
Open

Save the pump-probe output to file#315
CammilleCC wants to merge 2 commits intodevfrom
pp-savefile

Conversation

@CammilleCC
Copy link
Copy Markdown
Member

@CammilleCC CammilleCC commented Sep 8, 2021

SPB requested to have a saved file for the pump-probe values. We now offer an ASCII and an NPZ output.

@dallanto
Copy link
Copy Markdown
Contributor

dallanto commented Sep 8, 2021

I could have sworn that this MR is open for a longer time, at least I'm sure I've looked at the code soon after you committed in July. LGTM 🙂

self._abs_difference_cb.setChecked(True)

self._reset_btn = QPushButton("Reset")
self.save_btn = QPushButton("Save to file")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would rather prefer a QAction in a toolbar on this window instead of a button to save to files.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, @CammilleCC I leave this up to you. I think either UI is acceptable.

Comment on lines +159 to +160
if not len(self._queue):
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if the button itself was disabled when there is no data to save, rather than silently exiting.

# Get the current data
if not len(self._queue):
return
data = self._queue[0]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed in #318, the GUI now receives a dict of all the data from the workers. So here we'd now need self._queue[0]["processed"].

Comment on lines +177 to +178
# Copy reference file from tmp folder to desired destination
os.makedirs(osp.dirname(filepath), exist_ok=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't seem to match the code? And why is it necessary to use os.makedirs() here? I thought we could trust that any directory returned by QFileDialog.getSaveFileName() already exists since the user would need to create it first in the dialog.

intensity_sub = pp.y

if position is None:
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should show an error dialog to make it clear to the user that nothing happened.

intensity_subtracted=intensity_sub)
elif filter is SaveFile.TXT:
# write out conversion to tabular ASCII
with open(filepath, 'w') as f:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use Python's csv library here?

@JamesWrigley
Copy link
Copy Markdown
Member

Apologies for my shockingly slow review 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants