Helioviewer-Project/api

API endpoint that describes FITS to JP2 processing.

Opened this issue · 3 comments

Over in SunPy, issues sunpy/sunpy#6715 (and sunpy/sunpy#6709) deal with the conversion of JP2 image values - scaled in the range 0 to 255 - back to the original FITS values. Due to the processing done to derive a JP2 image from a prepped FITS file, reversing the process will lead to an approximation of the prepped FITS file at best.

This API endpoint would allow a user to get information about the processing steps used to convert a FITS file to a JP2 file. It would then be up to the user to take the processing information and write a function that inverts the FITS to JP2 processing to produce an approximate prepped FITS file. This API endpoint should also be included in https://github.com/Helioviewer-Project/python-api .

Can we discuss this further? I'm not sure what you want the API to return.
Information on how to process the FITS file doesn't sound "machine readable" to me.
If we want to describe the process for processing fits files, that sounds like something that can be written up on the blog.

Unless you're talking about returning the specific parameters used during the FITS. Meaning for example based on this quote:

The actual physical unit colour limits of these images are hardcoded in the hv jp2gen files e.g. for hmi has a min of 0=-250 and 255 = +250.

If we want to return 0 => -250 and 255 => +250, then that is machine readable information that we could return.

I read the sunpy issue and I understand what this is asking for.

We want a way to get the parameters used to scale down the data values from FITS into jp2. i.e. if the scaling is linear/logarithmic/other, and the parameters passed to the scaling function.

As @wafels mentioned in the other issue, some of this info is in jp2gen, but other info is upstream. I'll try to gather more info.

wafels commented

JP2Gen uses the instrument software processing pipeline to do the initial preparation of the data. To recover an approximation of the original FITS file then that pipeline would also have to be reversed. This is not possible in general. However, it should be possible to design an API endpoint that allows you to reverse the prepped data to JPEG2000 step.

In general, the scaling details are kept in JP2Gen HVS files, for example https://github.com/Helioviewer-Project/jp2gen/blob/master/idl/sdo/aia/hvs_version6_aia.pro .