AstarVienna / ScopeSim

A telescope observation simulator for Python.
GNU General Public License v3.0
16 stars 10 forks source link

Possible float shenanigans in wavelength unit conversions #470

Open teutoburg opened 2 months ago

teutoburg commented 2 months ago

This unit conversion could indeed go wrong. However, it already would go wrong if fractional wavelengths are used, e.g. wavemin=1333.3. Our code should not depend on float values being integer.

This means that even if we would hardcode this 1E4 here (and similarly elsewhere), that the code will still be broken in general. So we should not use such hacks and instead just let astropy handle it, as you did.

Per extension, it should not cause any problems if a value of 1000.0 becomes 999.9999999999 or 1000.000000001:

Perhaps we should find some floating point numbers that you cannot faithfully multiply/divide by (e.g.) 1E4. Maybe one number that rounds up and one that rounds down. Then we should use those in the basic_instrument test package to detect any errors that such a conversion causes. Or maybe have some test irdb packages that uses weird units like wavelengths in parsec and such.

_Originally posted by @hugobuddel in https://github.com/AstarVienna/ScopeSim/pull/405#discussion_r1741879120_