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

Fixes STIX file loading and lightcurve/spectrogram plotting #98

Merged
merged 6 commits into from Jun 6, 2023

Conversation

natsat0919
Copy link
Contributor

This PR fixes the functions for handling STIX spectral and SRM files, this means that the Sunxspex class will be apple to correctly load in the new/final version of STIX files. I'm mainly fixing formatting of keywords and data, change of time units, format of energy bins and counts that are given in the spectral files. I have also fixed the incorrect plotting of background and event time-ranges for STIX lightcurves and spectrograms (examples in issue #97).

@DanRyanIrish
Copy link
Member

Hi @natsat0919. Thanks so much for contributing this PR. Your changes appear to be breaking a lot of the tests. Can you clarify why this is? Is it possible you've made changes in certain places that a valid for STIX but not other instruments?

@natsat0919
Copy link
Contributor Author

Hi @DanRyanIrish, I'm missing a changelog file that I'll add. I'm still trying to figure out why the other tests are failing, but I think that it's because of changing the fundamental loading function for STIX files and the tests aren't adjusted to that? The changes that I have done were only for STIX (mainly in the stix_spec_code.py), so it shouldn't affect any other instruments

@settwi
Copy link
Contributor

settwi commented May 25, 2023

Following up on our discussion @natsat0919 and @KriSun95: I think we should be careful and explicit as to which kind of "spectrogram" we load in, i.e. the one produced by IDL or the one from the data center, and pay particular attention to the statistical errors that are being used. I would be happy to review some of the code in this PR and see how we can make sure that distinction is clear. Or we can merge the PR and do that later. Thoughts?

@natsat0919
Copy link
Contributor Author

natsat0919 commented May 25, 2023

@settwi I agree, we definitely need to get that sorted as a priority. I think right now is the best to get this out as the basic working version (just updating what we already have) and build up from there? "Luckily", this code only works for the data centre spectrograms, so it will be obvious if the IDL spectrograms are loaded in. Also the STIX srm and spectral files tests are outdated (hence I got so many fails) so I'm sorting that out as well. Meanwhile, we can think what's the best way to implement the "distinction" when loading in?

@codecov-commenter
Copy link

codecov-commenter commented May 26, 2023

Codecov Report

Patch coverage: 38.09% and project coverage change: +0.04 🎉

Comparison is base (22935b5) 55.01% compared to head (1ea95e9) 55.06%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #98      +/-   ##
==========================================
+ Coverage   55.01%   55.06%   +0.04%     
==========================================
  Files          19       19              
  Lines        3119     3122       +3     
==========================================
+ Hits         1716     1719       +3     
  Misses       1403     1403              
Impacted Files Coverage Δ
sunxspex/sunxspex_fitting/instruments.py 21.84% <0.00%> (-0.06%) ⬇️
sunxspex/sunxspex_fitting/stix_spec_code.py 22.50% <0.00%> (-1.31%) ⬇️
sunxspex/sunxspex_fitting/io.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@KriSun95
Copy link
Collaborator

This looks great, thanks @natsat0919 ! I've had a play about with the changes and it works fine for me. Playing about with it has pointed out a small but important bug elsewhere (that I need to fixed) but I can't see anything wrong with this PR. I definitely agree with both you and @settwi about moving on to think about how to separate loading in of the two STIX file formats for the spectra (data centre and IDL).

I'll return to this later today, add a review for the PR, and then move on to approve the merge if there are no other objections.

Copy link
Collaborator

@KriSun95 KriSun95 left a comment

Choose a reason for hiding this comment

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

This looks great and gives us a good foundation to actually start working with/support STIX data. We can use this contribution to test any future changes using real data and use it as a good starting point.

@DanRyanIrish
Copy link
Member

Do we consider this PR ready to merge?

@natsat0919
Copy link
Contributor Author

@DanRyanIrish yes, I just did some very minor refactoring changes after Kris's approval. It should be ready to merge

@samaloney samaloney merged commit c40792c into sunpy:master Jun 6, 2023
8 of 10 checks passed
settwi pushed a commit to settwi/sunkit-spex that referenced this pull request Sep 18, 2023
* Fix STIX file loading to be compatible with the final format of STIX files
* Fix STIX lightcurve and spectrogram plotting
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.

None yet

6 participants