Helioviewer-Project / jp2gen

IDL based tools to convert FITS data into JPEG2000 files for use with Helioviewer Project clients.
2 stars 5 forks source link

JP2Gen TRACE JP2 files are badly formed, as seen by SunPy #31

Closed wafels closed 2 years ago

wafels commented 2 years ago

As noted in #28, the TRACE JP2 pipeline produces files which have the wrong dimensions

In [2]: m = sunpy.map.Map("/Users/ireland/2008_11_12__17_27_54_000__TRACE_TRACE_TRACE_171.jp2")
WARNING: SunpyUserWarning: This file contains more than 2 dimensions. Data will be truncated to the first two dimensions. [sunpy.map.mapbase]

In [6]: m.data.shape
Out[6]: (1024, 3)
In [7]: m.dimensions
Out[7]: PixelPair(x=<Quantity 3. pix>, y=<Quantity 1024. pix>)

I think the issue lies here: https://github.com/Helioviewer-Project/jp2gen/blob/master/idl/trace/hvs_trace.pro#L60 . The details structure gets the palette keyword. The value is an array of [3, 256]. The code that writes the JP2 file contains an option to use the palette in the details structure: https://github.com/Helioviewer-Project/jp2gen/blob/master/idl/gen/hv_write_jp2_lwg.pro#L581 . I think what is happening is that IDL then uses the palette to write out a JP2 file with RGB channels. I'll post this as an issue.

wafels commented 2 years ago

The fix seems to have worked - see attached. Figure_1

wafels commented 2 years ago

Fixed by #32. Closing