-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easier Output Saving for Proton Radiography #1134
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1134 +/- ##
==========================================
+ Coverage 97.07% 97.09% +0.02%
==========================================
Files 73 73
Lines 7106 7170 +64
==========================================
+ Hits 6898 6962 +64
Misses 208 208
Continue to review full report at Codecov.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
You could do: result.save(filename)
loaded_result = load(filename)
assert result == loaded_result Use https://docs.pytest.org/en/stable/tmpdir.html for the filename. We could also add a sample dataset as a regression test. It looks like our tests' data files currently live in |
Great, thanks! I added a test using Anything similar I can do in a jupyter notebook? |
Thank you for doing this! These are very useful capabilities to add. Do you think it would also be worth having the option to save and load data in HDF5 format? I'm wondering about that since HDF5 is probably the best format to use for long-term archiving of data sets on sites like Zenodo. |
Sure! |
@namurphy There is a nascent effort to introduce a community input/output standard for proton radiograph led by @phyzicist. The formats are all based on HDF5. One of the proposed formats for ParticleLists could be used for this kind of output. Is there a way we could include this as an optional dependency to allow the PlasmaPy proton radiography particle tracer to read and write these standards? |
https://github.com/picmi-standard/picmi may also be relevant-ish |
This reverts commit 335305c.
After looking into openPMD, I want to try and rework the pradformat spec to make it consistent. I'll leave HDF saving out of this PR, but I intend to add that once we've made changes to the pradformat spec. |
Getting to the review in a few minutes! pre-commit.ci autofix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refinement of test_saving_output
.
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
Outdated
Show resolved
Hide resolved
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
Outdated
Show resolved
Hide resolved
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
Outdated
Show resolved
Hide resolved
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
Outdated
Show resolved
Hide resolved
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
Outdated
Show resolved
Hide resolved
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Erik Everson <[email protected]>
Co-authored-by: Erik Everson <[email protected]>
Ok, I made those changes. I think that, if we're at the point of re-naming variables in the test for clarity, it's time to merge this PR and move on to other work. |
plasmapy/diagnostics/tests/test_charged_particle_radiography.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Erik Everson <[email protected]>
You have my continued thanks, @pheuer! |
…asier_saving_prad
I just have to make sure all of the cross-ref repairs to the change log entries work and then I'll merge it. |
Large runs with
SyntheticProtonRadiograph
can take a while to run, so it's often necessary to save the output for later analysis. By design, the way to do this is to save the particle positions in the detector plane, so different histograms can be made from the same dataset. So far, I personally have been doing this by just pickling the entireSyntheticProtonRadiograph
object. However, I've recently realized that pickling complex objects isn't great practice for long-term storage.This PR includes the following changes
The module
proton_radiography
is now renamedcharged_particle_radiography
The class
SyntheticProtonRadiograph
is now renamedTracker
, as inTracker
now stores the particle positions and some metadata in a dict structure after running.the
save_result()
method ofTracker
can save this dictonary to anumpy
npz
file.the
synthetic_radiograph
function is no longer a method ofTracker
but instead a stand-alone function incharged_particle_radiography.py
. This function takes either aTracker
object or an output dictionary (eg. like one loaded from anpz
file), then creates the synthetic radiograph in the same way as before.TODO