gnuastro-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[task #15128] TPV and SIP keywords when WCS distortions are necessary


From: Mohammad Akhlaghi
Subject: [task #15128] TPV and SIP keywords when WCS distortions are necessary
Date: Sat, 16 May 2020 22:14:16 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0

Follow-up Comment #7, task #15128 (project gnuastro):

Sachin, as you dig deeper into WCSLIB and learn its inner structure, please
avoid direct manipulation of the raw 'wcsprm' elements in the main conversion
function. Rather, define functions to abstract these low-level steps-away. 

For example to read the distortion elements, define a function like this:


int
gal_wcs_distortion_read(struct wcsprm *wcs, double *distortion);


This function won't actually touch anything inside the WCS structure, it will
just read all the distortion coefficients from the 'wcsprm', and write them
into the 'distortion' array (that the caller has already allocated). It will
return an integer that specifies a code/macro specifying the distortion (for
example SIP, TPV, or other types which you can see from the WCSLIB manual
<https://www.atnf.csiro.au/people/mcalabre/WCS/wcslib.pdf>). We can define an
'enum' to assign integers to every distortion.

Later, when you want to write a new distortion into a wcsprm define another
function like this:


int
gal_wcs_distortion_write(struct wcsprm *wcs, double *distortion, int type);


You will then use this after converting TPV to SIP here, or writing a whole
new distortion in task #15637.

Once you have abstracted these two major operations into such general
functions, you can then write a clean and easily-readable function to convert
TPV to SIP and vice-versa.

Once the conversion function is written, we can add an even higher-level
function to read the distortion as SIP like this (it will internally convert a
TPV header to SIP if necessary, and always return a SIP distortion, the return
value can be 0 or 1 depending on its success):


int
gal_wcs_distortion_read_to_sip(struct wcsprm *wcs, double *distortion);


For example, you will need this in the final step of your GSoC project (task
#15636) where you want to use the distortions to apply a non-linear warping.
In that time, you don't want to worry about the format of the input's
distortion. So can use this function to always be sure that you have a SIP
distortion for example and easily focus on the main job there ;-).

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/task/?15128>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]