Skip to content
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

Add Support for Loading Tristan v2 Spectra #20

Merged
merged 15 commits into from
Aug 26, 2024

Conversation

bcaddy
Copy link
Collaborator

@bcaddy bcaddy commented Aug 9, 2024

Summary

Add support for loading and plotting spectra from Tristan v2 data files.

Spectra

Iseult now reads in and displays Tristan v2 spectra. Tristan v2 spectra are binned in X, Y, and Z instead of just X as is done in Tristan v1. To account for this Iseult sums over the Y and Z axis to reduce Tristan v2 data to the same format as Tristan v1 data.

  • Added two new optional CLI arguments, -i, --ion-spectra and -e, --electron-spectra to indicate which Tristan v2 spectra dataset should be treated as the ion and electron datasets respectively. By default Iseult treats the first dataset with a charge of -1 as the electron dataset and the first dataset with a +1 charge as the ion dataset.

Other

  • Added .vscode/ to .gitignore to avoid committing VS Code preferences
  • Add types to all CLI arguments that didn't have them
  • Replaced MainApp.ReloadPath() and MainApp.pathOK() with the new MainApp.checkAndFindFilePaths() function. The old functions did nearly the same thing utilizing outdated libraries. The new function simplifies the logic and reduces repeated code.

Cloning Instructions

$ git clone [email protected]:bcaddy/Iseult.git bob-iseult
$ cd bob-iseult
$ git checkout --track origin/master-tv2Spectra

if you already have that repo cloned locally then

$ cd path/to/bob-iseult
$ git checkout --track origin/master-tv2Spectra

@bcaddy bcaddy marked this pull request as draft August 9, 2024 17:13
@bcaddy bcaddy mentioned this pull request Aug 12, 2024
@bcaddy bcaddy linked an issue Aug 12, 2024 that may be closed by this pull request
@bcaddy bcaddy force-pushed the master-tv2Spectra branch 2 times, most recently from 05d1a6c to 6e45abb Compare August 14, 2024 18:32
@bcaddy bcaddy linked an issue Aug 14, 2024 that may be closed by this pull request
@bcaddy bcaddy mentioned this pull request Aug 14, 2024
@bcaddy bcaddy marked this pull request as ready for review August 14, 2024 19:48
@bcaddy bcaddy linked an issue Aug 16, 2024 that may be closed by this pull request
@ntoles
Copy link
Collaborator

ntoles commented Aug 17, 2024

There is a difference in what Tristan v1 and v2 save as spectra. v1 saves number of particles in an energy bin divided by gamma. This is why in spectra.py line 172-3 multiplies back by gamma before doing plots.

            self.spece[:,i] *= self.gamma
            self.specp[:,i] *= self.gamma

v2 saves just the number of particles per bin without this division by gamma. I see two possibilities to rectify this. Either divide spece and specp by gamma after reading v2 data, so that the rest of the code is unchanged; or only do this multiplication by gamma in spectra.py for data in v1 format.

@bcaddy
Copy link
Collaborator Author

bcaddy commented Aug 19, 2024

Done, I converted the v2 data to v1 format. I used ebins not gamma since there is no dataset named gamma in Tristan v2 and I think we decided that ebins was the same thing.

bcaddy added 15 commits August 19, 2024 11:30
Tests for:
- __find_tristan_v2_spectra
- __handle_tristan_v2_spectra
Those two functions were nearly identical so I combined them into a
single function, MainApp.checkAndFindFilePaths(). Also, switched to
using pathlib instead of os.path for all operations which simplified
the code significantly; I had to tweak a few other spots to accountt
for switching to pathlib
Also, fixed the test data type and tests for the new gamma factor in
loading spectra
@bcaddy bcaddy force-pushed the master-tv2Spectra branch from aec8bcc to a099f69 Compare August 19, 2024 15:30
@ntoles
Copy link
Collaborator

ntoles commented Aug 21, 2024

Testing on this data:
/scratch/gpfs/ar3676/2_test/output

When I select measurement coordinates for the spectrum that are between 40 and 80, i get errors that there is no electrons in that region and no spectrum is plotted.
"RUNTIME WARNING: spectra.py can't find the electrons in the integration region, spectra will be incorrect"

There should be 20 bins in x in this run, so it should be possible to zoom in.
To reproduce. Right click on spectral plot (lower left), Measurements tab, unclick "Energy Region relative to shock?", type 40 and 80 into electron Energy Int region. Same for ions as well, though it can be different.

Could you check?

@ntoles
Copy link
Collaborator

ntoles commented Aug 26, 2024

Seems to work correctly!

@ntoles ntoles merged commit 7c4cb7e into PrincetonUniversity:master Aug 26, 2024
1 check passed
@bcaddy bcaddy deleted the master-tv2Spectra branch August 26, 2024 19:20
@bcaddy bcaddy mentioned this pull request Aug 27, 2024
6 tasks
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.

click cancel in menu fails Reload not working Not Starting with v2 Data
2 participants