You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The unit conversion class UnitConverterWithSpectral can deal with spectral density conversions, e.g. Fnu to Flam and so on. However, these conversions require knowledge about the wavelength/frequency at which to do the conversion. The unit conversion class knows about the spectral axis of the data that is being converted, so when we convert an array of values where the length of the array is the same as that of the spectral axis, everything is fine. However, there are cases where we might end up converting an array with a different size - for example sometimes to_unit is called with two values, when converting the min/max limits of the axes. In this case, it's not 100% clear what should happen, but there are a couple of options:
Convert using the first wavelength/frequency in the spectral axis array
Convert twice - using both the first and last value in the spectral axis array and then determining the smallest and largest result, which will ensure that the limits cover the whole span of resulting values.
I think the second option is probably preferable? I am going to pre-emptively update #2889 to match this, but happy to change it back to the first option if people prefer.
To identify, when to_unit is being called for limits, we have to rely on checking that the length of the values passed is 2. Obviously there is a corner case where this will cause an issue which is if someone loads in a real spectrum with only two wavelengths/frequencies, but I think we can probably agree that's going to be very rare?
Then the question is how we deal with scalars or arrays that don't have the same shape as the spectral axis. These should probably just raise an exception since they aren't valid, but currently exceptions seem to just get swallowed up and aren't apparent to the user. Are we ok with that? In principle I don't think arrays with the wrong length should ever happen (besides length 2 as mentioned above) but it would be good to properly raise an error if they do.
The text was updated successfully, but these errors were encountered:
This was #2891 by @astrofrog that got accidentally deleted.
This is a spin-off from a discussion in #2889 (comment)
The unit conversion class
UnitConverterWithSpectral
can deal with spectral density conversions, e.g. Fnu to Flam and so on. However, these conversions require knowledge about the wavelength/frequency at which to do the conversion. The unit conversion class knows about the spectral axis of the data that is being converted, so when we convert an array of values where the length of the array is the same as that of the spectral axis, everything is fine. However, there are cases where we might end up converting an array with a different size - for example sometimesto_unit
is called with two values, when converting the min/max limits of the axes. In this case, it's not 100% clear what should happen, but there are a couple of options:I think the second option is probably preferable? I am going to pre-emptively update #2889 to match this, but happy to change it back to the first option if people prefer.
To identify, when
to_unit
is being called for limits, we have to rely on checking that the length of the values passed is 2. Obviously there is a corner case where this will cause an issue which is if someone loads in a real spectrum with only two wavelengths/frequencies, but I think we can probably agree that's going to be very rare?Then the question is how we deal with scalars or arrays that don't have the same shape as the spectral axis. These should probably just raise an exception since they aren't valid, but currently exceptions seem to just get swallowed up and aren't apparent to the user. Are we ok with that? In principle I don't think arrays with the wrong length should ever happen (besides length 2 as mentioned above) but it would be good to properly raise an error if they do.
The text was updated successfully, but these errors were encountered: