Open ossama-othman opened 6 years ago
A more sophisticated check would involve checking the photo image data to determine if it would fit into a map with a smaller data type. This can be achieved by either of the following, or a combination of them:
DATAMIN
and DATAMAX
values, if available, from the photo image FITS file. Convert them to image array values by reversing the physical data = image data * BSCALE
+ BZERO
transformation (BSCALE
= 1 and BZERO
= 0, if not available). Alternatively, BSCALE
and BZERO
could be applied to the map data type minimum and maximum. The photo image data minimum and maximum values could then be compared to the map data type minimum and maximum to determine if they will fit. New scale and offset values could be calculated through the MaRC::scale_and_offset()
function, if choosing new values is an option.
MaRC blindly accepts the map data type specified by the user without checking to see if it is large enough to hold photo image data without loss of precision (e.g. photo data is a 4 byte integer, but the map data type is a 2 byte integer). At the very least, MaRC should warn the user about the potential loss of precision.
See #62 for a related issue.