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 default value for the compress parameter to write_map is True, meaning that the code will use one of the compression algorithms specified by the FITS standard. Since these algorithms are lossy when applied to maps containing floating-point values, the code will silently introduce an error in the data written to disk, as the following example shows:
importnumpyimportqubic.ioFILE_NAME='/tmp/compressed_map.fits'INPUT_PIXELS=numpy.random.normal(size=12*64*64)
qubic.io.write_map(FILE_NAME, INPUT_PIXELS, dtype=numpy.float64)
OUTPUT_PIXELS=qubic.io.read_map(FILE_NAME)
DIFF=OUTPUT_PIXELS-INPUT_PIXELSprint('Stddev of the difference: {0:.3f}'
.format(numpy.std(DIFF)))
# Result:# Stddev of the difference: 0.018
(Note that the code uses float64 instead of the default float32 type when calling write_map.) Setting compress=False in the above call to qubic.io.write_map makes the difference between INPUT_PIXELS and OUTPUT_PIXELS to vanish.
Since this behaviour might be surprising for people not versed with the FITS standard, I am suggesting a couple of workarounds:
Make compress default to False, and specify in the docstring for write_map that using True with floating-point maps will introduce an error in the pixel values (currently, the docstring does not mention the compress parameter anywhere but in the declaration);
Make the code emit a warning when compress is True and the datatype of the parameter map is a floating-point value.
The text was updated successfully, but these errors were encountered:
Just for the record, using healpy.write_map and healpy.read_map with .fits.gz works seamlessy and produces relevant compression ratios for partial-coverage maps.
The default value for the
compress
parameter towrite_map
is True, meaning that the code will use one of the compression algorithms specified by the FITS standard. Since these algorithms are lossy when applied to maps containing floating-point values, the code will silently introduce an error in the data written to disk, as the following example shows:(Note that the code uses
float64
instead of the defaultfloat32
type when callingwrite_map
.) Settingcompress=False
in the above call toqubic.io.write_map
makes the difference betweenINPUT_PIXELS
andOUTPUT_PIXELS
to vanish.Since this behaviour might be surprising for people not versed with the FITS standard, I am suggesting a couple of workarounds:
compress
default to False, and specify in the docstring forwrite_map
that usingTrue
with floating-point maps will introduce an error in the pixel values (currently, the docstring does not mention thecompress
parameter anywhere but in the declaration);compress
isTrue
and the datatype of the parametermap
is a floating-point value.The text was updated successfully, but these errors were encountered: