-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fix some issues with SkyCalcTERCurve #245
base: main
Are you sure you want to change the base?
Conversation
Why is this even necessary?? The class should either have a wunit or not, but not like have it half of the time in meta
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev_master #245 +/- ##
==============================================
+ Coverage 75.16% 75.26% +0.09%
==============================================
Files 152 152
Lines 15637 15676 +39
==============================================
+ Hits 11754 11798 +44
+ Misses 3883 3878 -5
☔ View full report in Codecov by Sentry. |
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.
Other than my comment about the test raising an error:
My only "WTF/min" was in the table (row) indexing when the last row is duplicated. But that's probably because I haven't worked with astropy.table.Table
a lot before, and not because there's anything wrong in your implementation 😅. And the new test(s) should make sure it's correct anyway.
sto1 = str(to1) | ||
to2 = 1 / unit_to.to(unit_from) | ||
sto2 = str(to2) | ||
if len(sto2) < len(sto1): |
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.
if len(sto2) < len(sto1): | |
if len(str(to2)) < len(str(to1)): |
Save two lines and two temp variables? It's not like they're used again, nor are the expressions long...
|
||
2499.99 nm is less than 2.5 um, so there is no overlap anymore between | ||
the source spectrum and the to-be-scaled to spectrum, leading to an | ||
error. |
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.
Does it still "lead to an error"? Isn't that what was fixed here? Same for the comment at the bottom of this method.
To play Devil's advocate (or advocaat 😋): Alternative solution to the unit conversion issue: |
|
||
|
||
def save_unit_to(unit_from: u.Unit, unit_to: u.Unit): | ||
"""Like unit_from.to(unit_to), but u.um to u.nm == 1000, not 999.999..""" |
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.
Can you state the purpose of the function more explicitely, please? "Like this or that" is a bit vague. Also, the docstring suggests to me that the function should be called safe_unit_to
, or what is it that is being saved?
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.
I'm not very fond of that function sav/fe_unit_to
- I feel it shouldn't be necessary (why does Unit.to
do that anyway?). But I did a similar thing when I put in utils.seq
as an improvement over numpy.arange
, so I shouldn't say anything other than "use cautiously".
I don't actually know much about skycalc and sky emission in general. In principle, skycalc should provide a "complete" physical model of the sky emission, so manual rescaling makes little sense if you know how to handle the physical parameters. It was introduced with |
Thanks @teutoburg and @oczoske . I'll think about this a bit more. I'll probably merge it after applying your suggestions, but maybe I'll change my mind, it is a bit ugly this. |
This PR makes rescaling of a
SkycalcTERCurve
possible, but I'm not sure that is a reasonable thing to do. However, from a technical perspective, it should be possible to rescale aSkyCalcTERCurve
, but there were two bugs preventing this. So this PR has two components:SkycalcTERCurve
?SkycalcTERCurve
?Intro
Adding a
rescale_emission
argument to aSkycalcTERCurve
is now technically possible, see the tests:Bugs fixed
There where two problems, both related to the fact that synphot (by default) refuses to rescale a spectrum if the overlap between the spectrum and the filter it rescales to is not correct. That is, the spectrum returned by Skycalc, should overlap the desired filter, but is just too short:
(2.5 * u.um).to(u.nm).value
= 2499.9999999999995. This is fixed by 'improving' the unit conversion.Now irrespective of any rescaling, it is my opinion that fixing these two problems is worthwhile anyway.
@teutoburg, could you turn on your WTFs/minute-meter and determine how stupid these solutions are?
Physics
Our documentation seems to imply that it is possible to rescale the background. In particular, the getting started notebook explicitly states:
I think this makes some sense for the
AtmosphericTERCurve
, which is what that notebook uses. However, then users go and proceed to rescale the atmosphere when using MICADO or METIS, but theSkycalcTERCurve
that is used by default inArmazones.yaml
does not allow the background to be scaled.At least two people have complained about this, some with more detail than others, which led me to investigate this, and fix the bugs that prevented the background to be scaled.
However, I'm not sure it makes sense at all to rescale a SkycalcTERCurve background in this way:
And honestly, I don't understand what the rescaling does anyway. The unit is
mag
, but the background is not a point source. So it is not clear to me what it physically means to "rescale the background to magnitude 17 in the Ks band".@oczoske could you perhaps give your thoughts on the background rescaling?
TODO later:
Whatever we decide (whether rescaling of an AtmosphericTERCurve should be allowed or not), we should update the documentation, because now it is confusing to multiple users.