Conversation
and |
|
|
Tests are passing after setting the unit to ADU in |
|
Yes, I think just like we assume that data in a FITS file are in ADU if there's no BUNIT, then we should assume they're in ADU when created from an NDData with no unit. |
|
Ok, it works and I replaced various places where BUNIT was parsed. I'm not completely happy with the changes in |
|
I'm not clear why the code at the end of |
|
Yes, that's the part I'm not happy with, but the problem with the previous version is that as it does the computation without units it doesn't update |
|
But the previous version used Although a quick look through |
|
In the previous version |
|
So the other option I was thinking is ae59e96 which I just pushed. I'm happy to revert to the original version if you prefer it, and setting manually |
|
Because we use |
|
That's also an option, but then something must be done for the setter method as well. |
|
Can't you simply raise an exception in the Sorry this seems to have opened a can of worms but I think it's clearly the correct idea to use |
This was suggested by @chris-simpson in Trac#828, cc @KathleenLabrie as well.
This PR allows to read the unit from BUNIT and set it to
NDAstroData.unit, and the opposite when writing files.However there is a problem with this. When a
NDDataobject has a unit, then it uses this unit in computations (using AstropyQuantityobjects). Which means that all operands should have a unit. Adding or subtracting a scalar or a Numpy array without a unit raises aUnitConversionError.There are I think 3 solutions:
Another thing to mention here is that currently there is a small performance overhead when doing arithmetic with NDData, because it uses
self.data * self.unitto attach the unit which makes a copy of the array. This could be fixed by changing the code in Astropy to useself.data << self.unitwhich does not make a copy: astropy/astropy#11107