-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix cube fitting compatibility with unit conversion #3190
Conversation
f6db3d7
to
b804c4d
Compare
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.
Tested this out, I do see the fix that now the component units are always in 'surface brightness' if the cube is surface brightness, and do not change based on what is selected for the spectral y axis, so that's fixed. However, I'm still not getting any results in the table or plotted when I run a cube fit on this loaded data using one of the test fixtures to create a cube:
cube = _create_spectrum1d_cube_with_fluxunit(shape=(25, 25, 4), fluxunit=u.Jy / u.sr, with_uncerts=True)
Hm, the model fit plots fine with the example notebook data, but now that you mention it I don't see table results. I'll look into it on Monday. |
From a comment in the code: |
Screen.Recording.2024-09-16.at.9.46.45.AM.mov@cshanahan1 hm, I see the model plot fine with that cube (I fit a constant to it). Are you sure you didn't need to go into the data menu and add the model to the viewer? Or did it fail to appear with the I do see an error trying to add a Linear model component, trying to fix that... |
bd1f425
to
4c824f6
Compare
Note that this merging this PR on top of #3156 resolves the test failures (other than the known axis label failure there). |
still seeing some out of sync units. I loaded a Jy/sr cube, changed the flux unit to MJy, and the model fitting plugin shows Jy as the flux unit. This happened when MJy was set before creating the component for the first time, so I shouldn't have to re-estimate parameters, but even when doing that the incorrect unit remains EDIT from Ricky: Sorry @cshanahan1 I accidentally edited this reply instead of quoting it, and lost your screenshot/recording. The danger of admin power 😬 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3190 +/- ##
==========================================
- Coverage 88.50% 88.21% -0.29%
==========================================
Files 124 124
Lines 18448 18487 +39
==========================================
- Hits 16327 16308 -19
- Misses 2121 2179 +58 ☔ View full report in Codecov by Sentry. |
Linear fitting to cube or single spectrum does not break anymore! |
Fixed, toggling the cube fit was triggering the dataset selected logic, which was resetting the units. I removed all the unit setting from there in favor of setting it when the first component is initialized (and whenever user changes units or toggles cube fit). |
I see it now respecting flux unit selection when i change between Jy/MJy, but breaks on erg / (Angstrom s cm2 sr). Is it missing a spectral_density equivalency? |
Oh, likely, I think I know where....one sec. Good catch. |
@cshanahan1 I added a test, but I won't be able to test changing the unit to |
Tested this one final time and couldn't break it. Talked on slack with ricky about a few points of confusion i had and he cleared those up so I'll approve, looks good! |
…n/model fitting interaction
Fix test Codestyle
127f7be
to
35d2d96
Compare
@@ -930,7 +984,8 @@ def _fit_model_to_cube(self, add_data): | |||
models_to_fit, | |||
self.model_equation, | |||
run_fitter=True, | |||
window=None | |||
window=None, | |||
n_cpu=1 # Remove this after debugging! |
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.
pssst
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.
FIxed.
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.
Did one last look over and round of testing, all looks good to me and works as I'd expect!
Opening as draft since I still need to work on the unit conversion part, but I wanted to see the diff and remind myself what I'd changed so far.