gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 5ce68548: Table: new eq-j2000-on-flat operator


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 5ce68548: Table: new eq-j2000-on-flat operator for plotting RA and Dec
Date: Sun, 3 Sep 2023 20:50:04 -0400 (EDT)

branch: master
commit 5ce68548935c7461c65da581675d157949dd0384
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Table: new eq-j2000-on-flat operator for plotting RA and Dec
    
    Until now, Gnuastro didn't have an easy way to plot RA and Dec (while
    accounting for the curvature of the sky; which can be significant when the
    distances go larger than a degree or so).
    
    With this commit, a new column arithmetic operator called
    'eq-j2000-on-flat' has been added to do this on a given RA and Dec
    column. Allowing users to easily plot the points with any plotting tool
    they prefer.
---
 NEWS                   |  20 +++-
 bin/fits/fits.c        |  12 +--
 bin/fits/keywords.c    |   8 +-
 bin/fits/ui.c          |   4 +-
 bin/table/arithmetic.c | 151 ++++++++++++++++++++++++---
 bin/table/arithmetic.h |   1 +
 bin/warp/ui.c          |   2 +-
 doc/gnuastro.texi      | 132 +++++++++++++++++++++---
 lib/gnuastro/wcs.h     |  66 ++++++++++--
 lib/wcs.c              | 275 ++++++++++++++++++++++++++++++++++---------------
 10 files changed, 536 insertions(+), 135 deletions(-)

diff --git a/NEWS b/NEWS
index 43c09116..0a8e3244 100644
--- a/NEWS
+++ b/NEWS
@@ -42,9 +42,6 @@ See the end of the file for license conditions.
 
   Arithmetic:
   - New operators (see book for a full description):
-    - to-1d: convert the input operand into a 1D array, no matter how many
-      dimensions it has. Suggested by Faezeh Bidjarchian.
-    - trim: remove all fully-blank outer regions of the input dataset.
     - pool-min: Min-pooling to reduce the size of the input by calculating
       the minimum of a the pixels within the pooling window (accounting for
       a stride). See the new "Pooling opeators" section of the book for
@@ -54,6 +51,9 @@ See the end of the file for license conditions.
     - pool-sum: Similar to 'pool-min' but using sum.
     - pool-mean: Similar to 'pool-min' but using mean.
     - pool-median: Similar to 'pool-min' but using median.
+    - to-1d: convert the input operand into a 1D array, no matter how many
+      dimensions it has. Suggested by Faezeh Bidjarchian.
+    - trim: remove all fully-blank outer regions of the input dataset.
 
   ConvertType:
   - It is now possible to write TIFF files in the output (until now,
@@ -71,6 +71,15 @@ See the end of the file for license conditions.
   - '$_all' in column arithmetic: when an arithmetic expression contains
     this string, it will be repeated independently for all the columns of
     the input table.
+  - New operators in Table's column arithmetic:
+    - eq-j2000-on-flat: convert the RA and Dec columns in a table to a
+      flat-RA and flat-Dec (accounting for a reference point as well as any
+      type of projection that is available in the FITS WCS standard). This
+      is necessary when you are plotting points in a report or paper cover
+      more than a couple of square degrees on the sky. Without this
+      operator, significant distortions will appear when you plot spherical
+      coordinates (RA,Dec) on a flat plane (your paper's plot). See the
+      documentation for this operator in the book for more.
 
   astscript-zeropoint:
   --mksrc: use a custom Makefile for estimating the zeropoint, not the
@@ -89,6 +98,8 @@ See the end of the file for license conditions.
   - gal_pool_median: median-pooling function, see 'pool-min' above.
   - gal_tiff_write: write 'gal_data_t' to a TIFF file; written by
     Fathma Mehnoor.
+  - gal_wcs_projection_name_to_id: convert projection names to IDs.
+  - gal_wcs_projection_name_from_id: convert projection IDs to their name.
 
 ** Removed features
 
@@ -163,6 +174,9 @@ See the end of the file for license conditions.
     function. This was necessary because this function assumes flat
     coordinates and can lead to wrong results when used with a polygon
     defined by RA,Dec for example.
+  - gal_wcs_distortion_name_to_id: new name of gal_wcs_distortion_from_string.
+  - gal_wcs_distortion_name_from_id: new name of gal_wcs_distortion_to_string.
+  - gal_wcs_coordsys_name_to_id: new name of gal_wcs_coordsys_from_string.
 
 
 ** Bugs fixed
diff --git a/bin/fits/fits.c b/bin/fits/fits.c
index ce3308b8..44f9f363 100644
--- a/bin/fits/fits.c
+++ b/bin/fits/fits.c
@@ -569,9 +569,9 @@ fits_skycoverage(struct fitsparams *p)
                  width[1], width[2]);
           break;
         default:
-          error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
-                "the problem. 'ndim' value %zu is not recognized", __func__,
-                PACKAGE_BUGREPORT, ndim);
+          error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
+                "fix the problem. 'ndim' value %zu is not recognized",
+                __func__, PACKAGE_BUGREPORT, ndim);
         }
 
       /* For the range type of coverage. */
@@ -925,9 +925,9 @@ fits(struct fitsparams *p)
 
     /* Not recognized. */
     default:
-      error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to address "
-            "the problem. The code %d is not recognized for p->mode",
-            __func__, PACKAGE_BUGREPORT, p->mode);
+      error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to "
+            "address the problem. The code %d is not recognized for "
+            "p->mode", __func__, PACKAGE_BUGREPORT, p->mode);
     }
 
   return r;
diff --git a/bin/fits/keywords.c b/bin/fits/keywords.c
index 7900249e..87f39fc5 100644
--- a/bin/fits/keywords.c
+++ b/bin/fits/keywords.c
@@ -623,10 +623,10 @@ keywords_wcs_convert(struct fitsparams *p)
               "conversion.\n\n"
               "The requested conversion can't be done analytically, so a "
               "solution has to be found by fitting the parameters over a "
-              "grid of pixels. We will use a default grid of %zux%zu pixels "
-              "and will proceed with the conversion. But it would be more "
-              "accurate if it is the size of the image that this WCS is "
-              "associated with",
+              "grid of pixels. We will use a default grid of %zux%zu "
+              "pixels and will proceed with the conversion. But it would "
+              "be more accurate if it is the size of the image that this "
+              "WCS is associated with",
               defaultsize[1], defaultsize[0]);
       dsize=defaultsize;
     }
diff --git a/bin/fits/ui.c b/bin/fits/ui.c
index 463e0256..ae26e547 100644
--- a/bin/fits/ui.c
+++ b/bin/fits/ui.c
@@ -441,13 +441,13 @@ ui_read_check_mode_keyword(struct fitsparams *p)
 
       /* Give an ID to recognized coordinate systems. */
       if(p->wcscoordsys)
-        p->coordsysid=gal_wcs_coordsys_from_string(p->wcscoordsys);
+        p->coordsysid=gal_wcs_coordsys_name_to_id(p->wcscoordsys);
 
       /* Identify the requested distortion. Note that this also acts as a
          sanity check because it will crash with an error if the given
          string isn't recognized. */
       if(p->wcsdistortion)
-        p->distortionid=gal_wcs_distortion_from_string(p->wcsdistortion);
+        p->distortionid=gal_wcs_distortion_name_to_id(p->wcsdistortion);
 
       /* Make sure the value of '--keyvalue' is actually present. */
       if(p->keyvalue && p->keyvalue->v[0]=='\0')
diff --git a/bin/table/arithmetic.c b/bin/table/arithmetic.c
index 4ccc5f1f..f2a8de38 100644
--- a/bin/table/arithmetic.c
+++ b/bin/table/arithmetic.c
@@ -140,9 +140,14 @@ arithmetic_operator_name(int operator)
       case ARITHMETIC_TABLE_OP_IMGTOWCS: out="img-to-wcs"; break;
       case ARITHMETIC_TABLE_OP_DATETOSEC: out="date-to-sec"; break;
       case ARITHMETIC_TABLE_OP_DISTANCEFLAT: out="distance-flat"; break;
-      case ARITHMETIC_TABLE_OP_DATETOMILLISEC: out="date-to-millisec"; break;
-      case ARITHMETIC_TABLE_OP_DISTANCEONSPHERE: out="distance-on-sphere"; 
break;
-      case ARITHMETIC_TABLE_OP_SORTEDTOINTERVAL: out="sorted-to-interval"; 
break;
+      case ARITHMETIC_TABLE_OP_DATETOMILLISEC:
+        out="date-to-millisec"; break;
+      case ARITHMETIC_TABLE_OP_DISTANCEONSPHERE:
+        out="distance-on-sphere"; break;
+      case ARITHMETIC_TABLE_OP_SORTEDTOINTERVAL:
+        out="sorted-to-interval"; break;
+      case ARITHMETIC_TABLE_OP_EQJ2000ONFLAT:
+        out="eq-j2000-on-flat"; break;
       default:
         error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
               "the problem. %d is not a recognized operator code", __func__,
@@ -199,6 +204,8 @@ arithmetic_set_operator(struct tableparams *p, char *string,
         { op=ARITHMETIC_TABLE_OP_WCSTOIMG; *num_operands=0; }
       else if( !strcmp(string, "img-to-wcs"))
         { op=ARITHMETIC_TABLE_OP_IMGTOWCS; *num_operands=0; }
+      else if( !strcmp(string, "eq-j2000-on-flat"))
+        { op=ARITHMETIC_TABLE_OP_EQJ2000ONFLAT; *num_operands=0; }
       else if( !strcmp(string, "date-to-sec"))
         { op=ARITHMETIC_TABLE_OP_DATETOSEC; *num_operands=0; }
       else if( !strcmp(string, "date-to-millisec"))
@@ -634,12 +641,16 @@ arithmetic_wcs(struct tableparams *p, gal_data_t **stack, 
int operator)
 
       /* For image coordinates, we don't need much precision. */
       for(i=0;i<ndim;++i)
-        coord[i]=gal_data_copy_to_new_type_free(coord[i], GAL_TYPE_FLOAT32);
+        coord[i]=gal_data_copy_to_new_type_free(coord[i],
+                                                GAL_TYPE_FLOAT32);
 
       /* Set the names, units and comments for each dataset. */
-      arithmetic_update_metadata(coord[0],"X","pixel","Converted from WCS");
-      arithmetic_update_metadata(coord[1],"Y","pixel","Converted from WCS");
-      arithmetic_update_metadata(coord[2],"Z","pixel","Converted from WCS");
+      arithmetic_update_metadata(coord[0], "X", "pixel",
+                                 "Converted from WCS");
+      arithmetic_update_metadata(coord[1], "Y", "pixel",
+                                 "Converted from WCS");
+      arithmetic_update_metadata(coord[2], "Z", "pixel",
+                                 "Converted from WCS");
     }
   else
     {
@@ -666,6 +677,95 @@ arithmetic_wcs(struct tableparams *p, gal_data_t **stack, 
int operator)
 
 
 
+static void
+arithmetic_curved_on_flat(struct tableparams *p, gal_data_t **stack,
+                          int operator)
+{
+  struct wcsprm *wcs=NULL;
+  char *ctype[2], *cunit[2];
+  gal_data_t *w1, *w2, *proj, *refw1, *refw2;
+  double ref[2], cdelt[2]={1.0f,1.0f}, pc[4]={-1,0,0,1};
+  char **strarr, ctype1[9], ctype2[9]; /* 9=8+1 (keylength + '\0') */
+
+  /* Pop the necessary datasets from the stack (order is important). */
+  proj=arithmetic_stack_pop(stack, operator, NULL); /* 1st: projection.*/
+  refw2=arithmetic_stack_pop(stack, operator, NULL);/* 2nd: Ref. Dec. */
+  refw1=arithmetic_stack_pop(stack, operator, NULL);/* 3rd: Ref. RA. */
+  w2=arithmetic_stack_pop(stack, operator, NULL);   /* 4th: RA column. */
+  w1=arithmetic_stack_pop(stack, operator, NULL);   /* 5th: Dec column. */
+
+  /* Basic sanity checks. */
+  strarr=proj->array;
+  if(proj->size!=1 || refw1->size!=1 || refw2->size!=1)
+    error(EXIT_FAILURE, 0, "the first, second and third popped operands "
+          "from the '%s' operator should have a single element (they "
+          "should not be columns, but a single value), but they "
+          "respectively have %zu, %zu, %zu columns. Recall that the "
+          "first popped operand is the right-most operand (closest to "
+          "the operator", arithmetic_operator_name(operator),
+          proj->size, refw1->size, refw2->size);
+  if(proj->type!=GAL_TYPE_STRING)
+    error(EXIT_FAILURE, 0, "the first popped operand to the '%s' "
+          "operator must be a string, not numeric. It should be the "
+          "three character projection identifier of the WCS standard "
+          "in FITS (for example 'TAN' or 'MOL')",
+          arithmetic_operator_name(operator));
+  if(gal_wcs_projection_name_to_id(strarr[0])==GAL_WCS_PROJECTION_INVALID)
+    error(EXIT_FAILURE, 0, "the first popped operand to the '%s' "
+          "operator ('%s') could not be interpretted as a pre-defined "
+          "projection in the WCS stanadard of FITS",
+          arithmetic_operator_name(operator), strarr[0]);
+
+  /* Convert the numeric inputs into the float64 and put the reference
+     values into the expected array.*/
+  refw1=gal_data_copy_to_new_type_free(refw1, GAL_TYPE_FLOAT64);
+  refw2=gal_data_copy_to_new_type_free(refw2, GAL_TYPE_FLOAT64);
+  w1=gal_data_copy_to_new_type_free(w1, GAL_TYPE_FLOAT64);
+  w2=gal_data_copy_to_new_type_free(w2, GAL_TYPE_FLOAT64);
+  ref[0]=((double *)(refw1->array))[0];
+  ref[1]=((double *)(refw2->array))[0];
+
+  /* Construct the CTYPEi strings */
+  sprintf(ctype1, "%s---%s", "RA", strarr[0]);
+  sprintf(ctype2, "%s--%s", "DEC", strarr[0]);
+  ctype[0]=ctype1;
+  ctype[1]=ctype2;
+  cunit[0]="deg";
+  cunit[1]="deg";
+
+  /* Build the WCS structure for the conversion. */
+  wcs=gal_wcs_create(ref, ref, cdelt, pc, cunit, ctype, 2,
+                     GAL_WCS_LINEAR_MATRIX_PC);
+
+  /* For a check:
+  int nkeyrec;
+  char *wcsstr;
+  wcsstr=gal_wcs_write_wcsstr(wcs, &nkeyrec);
+  printf("%s\n", wcsstr); exit(0);
+  */
+
+  /* Put the second world coordinate as the next token of the first, and do
+     the conversion. */
+  w1->next=w2;
+  gal_wcs_world_to_img(w1, wcs, 1);
+
+  /* Put the output datasets in the stack in reverse order. */
+  w1->next=w2->next=NULL;
+  gal_list_data_add(stack, w1);
+  gal_list_data_add(stack, w2);
+
+  /* Clean up (the coordinate conversion was done in place, so 'w1' and
+     'w2' are the output datasets). */
+  gal_wcs_free(wcs);
+  gal_data_free(proj);
+  gal_data_free(refw1);
+  gal_data_free(refw2);
+}
+
+
+
+
+
 static double
 arithmetic_distance_flat(double a1, double a2, double b1, double b2)
 {
@@ -678,7 +778,8 @@ arithmetic_distance_flat(double a1, double a2, double b1, 
double b2)
 
 
 static void
-arithmetic_distance(struct tableparams *p, gal_data_t **stack, int operator)
+arithmetic_distance(struct tableparams *p, gal_data_t **stack,
+                    int operator)
 {
   size_t i, j;
   double *o, *a1, *a2, *b1, *b2;
@@ -747,9 +848,10 @@ arithmetic_distance(struct tableparams *p, gal_data_t 
**stack, int operator)
       if(a->size==1 || b->size==1) /* One of them is a single point. */
         for(i=0;i<a->size;++i)
           for(j=0;j<b->size;++j)
-            o[a->size>b->size?i:j] = distance_func(a1[i], a2[i], b1[j], b2[j]);
+            o[a->size>b->size?i:j] = distance_func(a1[i], a2[i], b1[j],
+                                                   b2[j]);
       else                     /* Both have the same length. */
-        for(i=0;i<a->size;++i) /* (all were originally from the same table) */
+        for(i=0;i<a->size;++i) /* (all were originally from same table) */
           o[i] = distance_func(a1[i], a2[i], b1[i], b2[i]);
     }
 
@@ -1013,6 +1115,10 @@ arithmetic_operator_run(struct tableparams *p,
           arithmetic_wcs(p, stack, token->operator);
           break;
 
+        case ARITHMETIC_TABLE_OP_EQJ2000ONFLAT:
+          arithmetic_curved_on_flat(p, stack, token->operator);
+          break;
+
         case ARITHMETIC_TABLE_OP_DATETOSEC:
         case ARITHMETIC_TABLE_OP_DATETOMILLISEC:
           arithmetic_datetosec(p, stack, token->operator);
@@ -1050,9 +1156,11 @@ gal_data_t *
 arithmetic_read_at_usage(struct tableparams *p,
                          struct arithmetic_token *token)
 {
-  char *c;
-  size_t i;
+  uint8_t pid;
+  size_t i, one=1;
+  gal_data_t *tmp;
   int hasnewline=0;
+  char *c, **strarr;
 
   /* If the number is blank, then we have a name and should return the
      first column in the table that has the given name. */
@@ -1064,6 +1172,25 @@ arithmetic_read_at_usage(struct tableparams *p,
             && strcasecmp(p->colarray[i]->name, token->id_at_usage)==0 )
           return p->colarray[i];
 
+      /* If control reaches here, then the requested name didn't exist in
+         the table, if the next token is the equatorial on flat operator,
+         then we should also check known projection identifiers. */
+      if( token->next
+          && token->next->operator==ARITHMETIC_TABLE_OP_EQJ2000ONFLAT )
+        {
+          /* If the projection  */
+          pid=gal_wcs_projection_name_to_id(token->id_at_usage);
+          if(pid!=GAL_WCS_PROJECTION_INVALID)
+            {
+              tmp=gal_data_alloc(NULL, GAL_TYPE_STRING, 1, &one, NULL, 0,
+                                 p->cp.minmapsize, p->cp.quietmmap, NULL,
+                                 NULL, NULL);
+              strarr=tmp->array;
+              gal_checkset_allocate_copy(token->id_at_usage, &strarr[0]);
+              return tmp;
+            }
+        }
+
       /* If control reaches here, then the requested name didn't exist in
          the table. This may happen because the user broke an arithmetic
          command into muliple lines and forgot to put a back-slash. If so,
diff --git a/bin/table/arithmetic.h b/bin/table/arithmetic.h
index 652ce137..da192a48 100644
--- a/bin/table/arithmetic.h
+++ b/bin/table/arithmetic.h
@@ -40,6 +40,7 @@ enum arithmetic_operators
   ARITHMETIC_TABLE_OP_IMGTOWCS,
   ARITHMETIC_TABLE_OP_DATETOSEC,
   ARITHMETIC_TABLE_OP_DISTANCEFLAT,
+  ARITHMETIC_TABLE_OP_EQJ2000ONFLAT,
   ARITHMETIC_TABLE_OP_DATETOMILLISEC,
   ARITHMETIC_TABLE_OP_DISTANCEONSPHERE,
   ARITHMETIC_TABLE_OP_SORTEDTOINTERVAL,
diff --git a/bin/warp/ui.c b/bin/warp/ui.c
index 69af5f7e..c44379cb 100644
--- a/bin/warp/ui.c
+++ b/bin/warp/ui.c
@@ -1216,7 +1216,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
warpparams *p)
           disttype=gal_wcs_distortion_identify(p->input->wcs);
           if(disttype!=GAL_WCS_DISTORTION_INVALID)
             printf(" matrix: '%s' distortion from WCS of input.\n",
-                   gal_wcs_distortion_to_string(disttype));
+                   gal_wcs_distortion_name_from_id(disttype));
         }
       else
         {
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 6e44a27c..f08adb9a 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -16940,6 +16940,61 @@ $ asttable table.fits -cID,RA -cDEC \
 @item img-to-wcs
 Similar to @code{wcs-to-img}, except that image/dataset coordinates are 
converted to WCS coordinates.
 
+@item eq-j2000-on-flat
+Convert the input RA and Dec (in Julian year 2000.0 equatorial coordinates; 
which are the most common) into RA and Dec on a flat surface based on the given 
reference coordinate.
+At the reference coordinate the output will be the same as the input, as you 
move away from the reference point, distortions due to the particular 
projection will be properly accounted for.
+For example if you simply plot RA and Dec without this operator, a circular 
annulus on the sky will become elongated as the declination of its center goes 
farther from the equator.
+
+The full details of the operands are given below, but let's start with a 
practical example to show the concept.
+Let's assume you want to plot a set of RA and Dec points (defined on a 
spherical surface) in a paper (a flat surface) and that @file{table.fits} 
contains the RA and Dec in columns that are called @code{RA} and @code{DEC}.
+With the command below, the points will be converted to flat-RA and flat-Dec 
using the Gnomonic projection (which is known as @code{TAN} in the FITS WSC 
standard; see the description of the first popped operand below):
+
+@example
+$ asttable table.fits \
+           -c'arith RA set-r DEC set-d \
+                    r d r meanvalue d meanvalue TAN \
+                    eq-j2000-on-flat'
+@end example
+
+As you see, the RA and Dec (@code{r} and @code{d}) are the last two operators 
that are popped.
+Before them, the reference point's coordinates are calculated from the mean of 
the RA and Decs (`@code{r meanvalue}' and `@code{d meanvalue}'), and the first 
popped operand is the projection (@code{TAN}).
+We are using the mean RA and Dec as the reference point since we are assuming 
that this is the only set of points you want to convert.
+In case you have to plot multiple sets of points in the same plot, you should 
give the same reference point in each separate conversion; like the example 
below:
+
+@example
+$ ref_ra=123.45
+$ ref_dec=-6.789
+$ asttable table-1.fits --output=flat-1.txt \
+           -c'arith RA DEC '$ref_ra' '$ref_dec' TAN \
+                    eq-j2000-on-flat'
+$ asttable table-2.fits --output=flat-2.txt \
+           -c'arith RA DEC '$ref_ra' '$ref_dec' TAN \
+                    eq-j2000-on-flat'
+@end example
+
+This operator takes 5 operands:
+
+@enumerate
+@item
+The @emph{first} popped operand (closest to the operator) is the standard FITS 
WCS projection to use; and should contain a single element (not a column).
+The full list of projections can be seen in the description of the 
@option{--ctype} option in @ref{Align pixels with WCS considering distortions}.
+The most common projection for smaller fields of view is @code{TAN} 
(Gnomonic), but when your input catalog contains large portions of the sky, 
projections like @code{MOL} (Mollweide) should be used.
+This is because distortions caused by the @code{TAN} projection can become 
very significant after a couple of degrees from the reference point.
+
+@item
+The @emph{second} popped operand is the reference point's declination; and 
should contain a single value (not a column).
+
+@item
+The @emph{third} popped operand is the reference point's right ascension; and 
should contain a single value (not a column).
+
+@item
+The @emph{fourth} popped operand is the declination column of your input table 
(the points that will be converted).
+
+@item
+The @emph{fifth} popped operand is the right ascension column of your input 
table (the points that will be converted).
+
+@end enumerate
+
 @item distance-flat
 Return the distance between two points assuming they are on a flat surface.
 Note that each point needs two coordinates, so this operator needs four 
operands (currently it only works for 2D spaces).
@@ -38059,11 +38114,73 @@ Identifiers of the linear transformation matrix: 
either in the @code{PCi_j} or t
 For more, see the description of @option{--wcslinearmatrix} in @ref{Input 
output options}.
 @end deffn
 
+@deffn  {Global integer} GAL_WCS_PROJECTION_AZP
+@deffnx {Global integer} GAL_WCS_PROJECTION_SZP
+@deffnx {Global integer} GAL_WCS_PROJECTION_TAN
+@deffnx {Global integer} GAL_WCS_PROJECTION_STG
+@deffnx {Global integer} GAL_WCS_PROJECTION_SIN
+@deffnx {Global integer} GAL_WCS_PROJECTION_ARC
+@deffnx {Global integer} GAL_WCS_PROJECTION_ZPN
+@deffnx {Global integer} GAL_WCS_PROJECTION_ZEA
+@deffnx {Global integer} GAL_WCS_PROJECTION_AIR
+@deffnx {Global integer} GAL_WCS_PROJECTION_CYP
+@deffnx {Global integer} GAL_WCS_PROJECTION_CEA
+@deffnx {Global integer} GAL_WCS_PROJECTION_CAR
+@deffnx {Global integer} GAL_WCS_PROJECTION_MER
+@deffnx {Global integer} GAL_WCS_PROJECTION_SFL
+@deffnx {Global integer} GAL_WCS_PROJECTION_PAR
+@deffnx {Global integer} GAL_WCS_PROJECTION_MOL
+@deffnx {Global integer} GAL_WCS_PROJECTION_AIT
+@deffnx {Global integer} GAL_WCS_PROJECTION_COP
+@deffnx {Global integer} GAL_WCS_PROJECTION_COE
+@deffnx {Global integer} GAL_WCS_PROJECTION_COD
+@deffnx {Global integer} GAL_WCS_PROJECTION_COO
+@deffnx {Global integer} GAL_WCS_PROJECTION_BON
+@deffnx {Global integer} GAL_WCS_PROJECTION_PCO
+@deffnx {Global integer} GAL_WCS_PROJECTION_TSC
+@deffnx {Global integer} GAL_WCS_PROJECTION_CSC
+@deffnx {Global integer} GAL_WCS_PROJECTION_QSC
+@deffnx {Global integer} GAL_WCS_PROJECTION_HPX
+@deffnx {Global integer} GAL_WCS_PROJECTION_XPH
+The various types of recognized FITS WCS projections; for more details see 
@ref{Align pixels with WCS considering distortions}.
+@end deffn
 
 @deffn Macro GAL_WCS_FLTERROR
 Limit of rounding for floating point errors.
 @end deffn
 
+@deftypefun int gal_wcs_distortion_name_to_id (char @code{*name})
+Convert the given string (assumed to be a FITS-standard, string-based 
distortion identifier) to a Gnuastro's integer-based distortion identifier (one 
of the @code{GAL_WCS_DISTORTION_*} macros defined above).
+The sting-based distortion identifiers have three characters and are all in 
capital letters.
+@end deftypefun
+
+@deftypefun int gal_wcs_distortion_name_from_id (int @code{id})
+Convert the given Gnuastro integer-based distortion identifier (one of the 
@code{GAL_WCS_DISTORTION_*} macros defined above) to the string-based 
distortion identifier) of the FITS standard.
+The sting-based distortion identifiers have three characters and are all in 
capital letters.
+@end deftypefun
+
+@deftypefun int gal_wcs_coordsys_name_to_id (char @code{*name})
+Convert the given string to Gnuastro's integer-based WCS coordinate system 
identifier (one of the @code{GAL_WCS_COORDSYS_*}, listed above).
+The expected strings can be seen in the description of the 
@option{--wcscoordsys} option of the Fits program, see @ref{Keyword inspection 
and manipulation}.
+@end deftypefun
+
+@deftypefun int gal_wcs_distortion_name_to_id (char @code{*name})
+Convert the given string (assumed to be a FITS-standard, string-based 
distortion identifier) to a Gnuastro's integer-based distortion identifier (one 
of the @code{GAL_WCS_DISTORTION_*} macros defined above).
+The sting-based distortion identifiers have three characters and are all in 
capital letters.
+@end deftypefun
+
+@deftypefun int gal_wcs_projection_name_from_id (int @code{id})
+Convert the given Gnuastro integer-based projection identifier (one of the 
@code{GAL_WCS_PROJECTION_*} macros defined above) to the string-based 
distortion identifier) of the FITS standard.
+The string-based projection identifiers have three characters and are all in 
capital letters.
+For a description of the various projections, see @ref{Align pixels with WCS 
considering distortions}.
+@end deftypefun
+
+@deftypefun int gal_wcs_projection_name_to_id (char @code{*name})
+Convert the given string (assumed to be a FITS-standard, string-based 
projection identifier) to a Gnuastro's integer-based projection identifier (one 
of the @code{GAL_WCS_PROJECTION_*} macros defined above).
+The string-based projection identifiers have three characters and are all in 
capital letters.
+For a description of the various projections, see @ref{Align pixels with WCS 
considering distortions}.
+@end deftypefun
+
 @deftypefun {struct wcsprm *} gal_wcs_create (double @code{*crpix}, double 
@code{*crval}, double @code{*cdelt}, double @code{*pc}, char @code{**cunit}, 
char @code{**ctype}, size_t @code{ndim}, int @code{linearmatrix})
 Given all the most common standard components of the WCS standard, construct a 
@code{struct wcsprm}, initialize and set it for future processing.
 See the FITS WCS standard for more on these keywords.
@@ -38231,11 +38348,6 @@ Also, set the @code{wcs->altlin=2} (for the 
@code{CDi_j} formalism).
 With these changes @code{gal_wcs_write_in_fitsptr} (and thus 
@code{gal_wcs_write} and @code{gal_fits_img_write} and its derivatives) will 
have an output file in the format of @code{CDi_j}.
 @end deftypefun
 
-@deftypefun int gal_wcs_coordsys_from_string (char @code{*coordsys})
-Convert the given string to Gnuastro's integer-based WCS coordinate system 
identifier (one of the @code{GAL_WCS_COORDSYS_*}, listed above).
-The expected strings can be seen in the description of the 
@option{--wcscoordsys} option of the Fits program, see @ref{Keyword inspection 
and manipulation}.
-@end deftypefun
-
 @deftypefun int gal_wcs_coordsys_identify (struct wcsprm @code{*wcs})
 Read the given WCS structure and return its coordinate system as one of 
Gnuastro's WCS coordinate system identifiers (the macros 
@code{GAL_WCS_COORDSYS_*}, listed above).
 @end deftypefun
@@ -38246,16 +38358,6 @@ The Gnuastro WCS distortion identifiers are defined in 
the @code{GAL_WCS_COORDSY
 Since the returned dataset is newly allocated, if you do not need the original 
dataset after this, use the WCSLIB library function @code{wcsfree} to free the 
input, for example, @code{wcsfree(inwcs)}.
 @end deftypefun
 
-@deftypefun int gal_wcs_distortion_from_string (char @code{*distortion})
-Convert the given string (assumed to be a FITS-standard, string-based 
distortion identifier) to a Gnuastro's integer-based distortion identifier (one 
of the @code{GAL_WCS_DISTORTION_*} macros defined above).
-The sting-based distortion identifiers have three characters and are all in 
capital letters.
-@end deftypefun
-
-@deftypefun int gal_wcs_distortion_to_string (int @code{distortion})
-Convert the given Gnuastro integer-based distortion identifier (one of the 
@code{GAL_WCS_DISTORTION_*} macros defined above) to the string-based 
distortion identifier) of the FITS standard.
-The sting-based distortion identifiers have three characters and are all in 
capital letters.
-@end deftypefun
-
 @cindex WCS distortion
 @cindex Distortion, WCS
 @deftypefun {int} gal_wcs_distortion_identify (struct wcsprm @code{*wcs})
diff --git a/lib/gnuastro/wcs.h b/lib/gnuastro/wcs.h
index 17a18d66..58c03350 100644
--- a/lib/gnuastro/wcs.h
+++ b/lib/gnuastro/wcs.h
@@ -92,6 +92,63 @@ enum gal_wcs_linear_matrix
   GAL_WCS_LINEAR_MATRIX_CD,
 };
 
+/* Macros for various projections (these names come from the 'prj.h' file
+   of WCSLIB (in '/usr/local/include/wcslib' for version 8.1). */
+enum gal_wcs_projections
+{
+  GAL_WCS_PROJECTION_INVALID,   /* Invalid (=0 by C standard). */
+  GAL_WCS_PROJECTION_AZP,       /* zenithal/azimuthal perspective */
+  GAL_WCS_PROJECTION_SZP,       /* slant zenithal perspective */
+  GAL_WCS_PROJECTION_TAN,       /* gnomonic */
+  GAL_WCS_PROJECTION_STG,       /* stereographic */
+  GAL_WCS_PROJECTION_SIN,       /* orthographic/synthesis */
+  GAL_WCS_PROJECTION_ARC,       /* zenithal/azimuthal equidistant */
+  GAL_WCS_PROJECTION_ZPN,       /* zenithal/azimuthal polynomial */
+  GAL_WCS_PROJECTION_ZEA,       /* zenithal/azimuthal equal area */
+  GAL_WCS_PROJECTION_AIR,       /* Airy */
+  GAL_WCS_PROJECTION_CYP,       /* cylindrical perspective */
+  GAL_WCS_PROJECTION_CEA,       /* cylindrical equal area */
+  GAL_WCS_PROJECTION_CAR,       /* Plate carree */
+  GAL_WCS_PROJECTION_MER,       /* Mercator */
+  GAL_WCS_PROJECTION_SFL,       /* Sanson-Flamsteed */
+  GAL_WCS_PROJECTION_PAR,       /* parabolic */
+  GAL_WCS_PROJECTION_MOL,       /* Mollweide */
+  GAL_WCS_PROJECTION_AIT,       /* Hammer-Aitoff */
+  GAL_WCS_PROJECTION_COP,       /* conic perspective */
+  GAL_WCS_PROJECTION_COE,       /* conic equal area */
+  GAL_WCS_PROJECTION_COD,       /* conic equidistant */
+  GAL_WCS_PROJECTION_COO,       /* conic orthomorphic */
+  GAL_WCS_PROJECTION_BON,       /* Bonne */
+  GAL_WCS_PROJECTION_PCO,       /* polyconic */
+  GAL_WCS_PROJECTION_TSC,       /* tangential spherical cube */
+  GAL_WCS_PROJECTION_CSC,       /* COBE spherical cube */
+  GAL_WCS_PROJECTION_QSC,       /* quadrilateralized spherical cube */
+  GAL_WCS_PROJECTION_HPX,       /* HEALPix */
+  GAL_WCS_PROJECTION_XPH,       /* HEALPix polar, aka "butterfly" */
+};
+
+
+
+
+
+/*************************************************************
+ ***********               Macros                  ***********
+ *************************************************************/
+int
+gal_wcs_distortion_name_to_id(char *distortion);
+
+char *
+gal_wcs_distortion_name_from_id(int distortion);
+
+int
+gal_wcs_coordsys_name_to_id(char *coordsys);
+
+uint8_t
+gal_wcs_projection_name_to_id(char *str);
+
+char *
+gal_wcs_projection_name_from_id(uint8_t id);
+
 
 
 
@@ -140,9 +197,6 @@ gal_wcs_write_in_fitsptr(fitsfile *fptr, struct wcsprm 
*wcs);
 /*************************************************************
  ***********              Distortions              ***********
  *************************************************************/
-int
-gal_wcs_coordsys_from_string(char *coordsys);
-
 int
 gal_wcs_coordsys_identify(struct wcsprm *inwcs);
 
@@ -154,12 +208,6 @@ gal_wcs_coordsys_convert(struct wcsprm *inwcs, int 
coordsysid);
 /*************************************************************
  ***********              Distortions              ***********
  *************************************************************/
-int
-gal_wcs_distortion_from_string(char *distortion);
-
-char *
-gal_wcs_distortion_to_string(int distortion);
-
 int
 gal_wcs_distortion_identify(struct wcsprm *wcs);
 
diff --git a/lib/wcs.c b/lib/wcs.c
index 86c52ecf..15deaa76 100644
--- a/lib/wcs.c
+++ b/lib/wcs.c
@@ -54,6 +54,191 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
+
+
+
+
+
+/*************************************************************
+ ***********               Macros                  ***********
+ *************************************************************/
+int
+gal_wcs_distortion_name_to_id(char *distortion)
+{
+  if(      !strcmp(distortion,"TPD") ) return GAL_WCS_DISTORTION_TPD;
+  else if( !strcmp(distortion,"SIP") ) return GAL_WCS_DISTORTION_SIP;
+  else if( !strcmp(distortion,"TPV") ) return GAL_WCS_DISTORTION_TPV;
+  else if( !strcmp(distortion,"DSS") ) return GAL_WCS_DISTORTION_DSS;
+  else if( !strcmp(distortion,"WAT") ) return GAL_WCS_DISTORTION_WAT;
+  else
+    error(EXIT_FAILURE, 0, "WCS distortion name '%s' not recognized, "
+          "currently recognized names are 'TPD', 'SIP', 'TPV', 'DSS' and "
+          "'WAT'", distortion);
+
+  /* Control should not reach here. */
+  error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
+        "problem. Control should not reach the end of this function",
+        __func__, PACKAGE_BUGREPORT);
+  return GAL_WCS_DISTORTION_INVALID;
+}
+
+
+
+
+
+char *
+gal_wcs_distortion_name_from_id(int distortion)
+{
+  /* Return the proper literal string. */
+  switch(distortion)
+    {
+    case GAL_WCS_DISTORTION_TPD: return "TPD";
+    case GAL_WCS_DISTORTION_SIP: return "SIP";
+    case GAL_WCS_DISTORTION_TPV: return "TPV";
+    case GAL_WCS_DISTORTION_DSS: return "DSS";
+    case GAL_WCS_DISTORTION_WAT: return "WAT";
+    default:
+      error(EXIT_FAILURE, 0, "WCS distortion id '%d' isn't recognized",
+            distortion);
+    }
+
+  /* Control should not reach here. */
+  error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
+        "problem. Control should not reach the end of this function",
+        __func__, PACKAGE_BUGREPORT);
+  return NULL;
+}
+
+
+
+
+
+int
+gal_wcs_coordsys_name_to_id(char *coordsys)
+{
+  if(      !strcmp(coordsys,"eq-j2000") ) return GAL_WCS_COORDSYS_EQJ2000;
+  else if( !strcmp(coordsys,"eq-b1950") ) return GAL_WCS_COORDSYS_EQB1950;
+  else if( !strcmp(coordsys,"ec-j2000") ) return GAL_WCS_COORDSYS_ECJ2000;
+  else if( !strcmp(coordsys,"ec-b1950") ) return GAL_WCS_COORDSYS_ECB1950;
+  else if( !strcmp(coordsys,"galactic") ) return GAL_WCS_COORDSYS_GALACTIC;
+  else if( !strcmp(coordsys,"supergalactic") )
+    return GAL_WCS_COORDSYS_SUPERGALACTIC;
+  else
+    error(EXIT_FAILURE, 0, "WCS coordinate system name '%s' not "
+          "recognized, currently recognized names are 'eq-j2000', "
+          "'eq-b1950', 'galactic' and 'supergalactic'", coordsys);
+
+  /* Control should not reach here. */
+  error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
+        "problem. Control should not reach the end of this function",
+        __func__, PACKAGE_BUGREPORT);
+  return GAL_WCS_COORDSYS_INVALID;
+}
+
+
+
+
+
+uint8_t
+gal_wcs_projection_name_to_id(char *str)
+{
+  if(      !strcmp(str, "AZP") ) return GAL_WCS_PROJECTION_AZP;
+  else if( !strcmp(str, "SZP") ) return GAL_WCS_PROJECTION_SZP;
+  else if( !strcmp(str, "TAN") ) return GAL_WCS_PROJECTION_TAN;
+  else if( !strcmp(str, "STG") ) return GAL_WCS_PROJECTION_STG;
+  else if( !strcmp(str, "SIN") ) return GAL_WCS_PROJECTION_SIN;
+  else if( !strcmp(str, "ARC") ) return GAL_WCS_PROJECTION_ARC;
+  else if( !strcmp(str, "ZPN") ) return GAL_WCS_PROJECTION_ZPN;
+  else if( !strcmp(str, "ZEA") ) return GAL_WCS_PROJECTION_ZEA;
+  else if( !strcmp(str, "AIR") ) return GAL_WCS_PROJECTION_AIR;
+  else if( !strcmp(str, "CYP") ) return GAL_WCS_PROJECTION_CYP;
+  else if( !strcmp(str, "CEA") ) return GAL_WCS_PROJECTION_CEA;
+  else if( !strcmp(str, "CAR") ) return GAL_WCS_PROJECTION_CAR;
+  else if( !strcmp(str, "MER") ) return GAL_WCS_PROJECTION_MER;
+  else if( !strcmp(str, "SFL") ) return GAL_WCS_PROJECTION_SFL;
+  else if( !strcmp(str, "PAR") ) return GAL_WCS_PROJECTION_PAR;
+  else if( !strcmp(str, "MOL") ) return GAL_WCS_PROJECTION_MOL;
+  else if( !strcmp(str, "AIT") ) return GAL_WCS_PROJECTION_AIT;
+  else if( !strcmp(str, "COP") ) return GAL_WCS_PROJECTION_COP;
+  else if( !strcmp(str, "COE") ) return GAL_WCS_PROJECTION_COE;
+  else if( !strcmp(str, "COD") ) return GAL_WCS_PROJECTION_COD;
+  else if( !strcmp(str, "COO") ) return GAL_WCS_PROJECTION_COO;
+  else if( !strcmp(str, "BON") ) return GAL_WCS_PROJECTION_BON;
+  else if( !strcmp(str, "PCO") ) return GAL_WCS_PROJECTION_PCO;
+  else if( !strcmp(str, "TSC") ) return GAL_WCS_PROJECTION_TSC;
+  else if( !strcmp(str, "CSC") ) return GAL_WCS_PROJECTION_CSC;
+  else if( !strcmp(str, "QSC") ) return GAL_WCS_PROJECTION_QSC;
+  else if( !strcmp(str, "HPX") ) return GAL_WCS_PROJECTION_HPX;
+  else if( !strcmp(str, "XPH") ) return GAL_WCS_PROJECTION_XPH;
+  else                           return GAL_WCS_PROJECTION_INVALID;
+}
+
+
+
+
+
+char *
+gal_wcs_projection_name_from_id(uint8_t id)
+{
+  switch(id)
+    {
+    case GAL_WCS_PROJECTION_AZP: return "AZP";
+    case GAL_WCS_PROJECTION_SZP: return "SZP";
+    case GAL_WCS_PROJECTION_TAN: return "TAN";
+    case GAL_WCS_PROJECTION_STG: return "STG";
+    case GAL_WCS_PROJECTION_SIN: return "SIN";
+    case GAL_WCS_PROJECTION_ARC: return "ARC";
+    case GAL_WCS_PROJECTION_ZPN: return "ZPN";
+    case GAL_WCS_PROJECTION_ZEA: return "ZEA";
+    case GAL_WCS_PROJECTION_AIR: return "AIR";
+    case GAL_WCS_PROJECTION_CYP: return "CYP";
+    case GAL_WCS_PROJECTION_CEA: return "CEA";
+    case GAL_WCS_PROJECTION_CAR: return "CAR";
+    case GAL_WCS_PROJECTION_MER: return "MER";
+    case GAL_WCS_PROJECTION_SFL: return "SFL";
+    case GAL_WCS_PROJECTION_PAR: return "PAR";
+    case GAL_WCS_PROJECTION_MOL: return "MOL";
+    case GAL_WCS_PROJECTION_AIT: return "AIT";
+    case GAL_WCS_PROJECTION_COP: return "COP";
+    case GAL_WCS_PROJECTION_COE: return "COE";
+    case GAL_WCS_PROJECTION_COD: return "COD";
+    case GAL_WCS_PROJECTION_COO: return "COO";
+    case GAL_WCS_PROJECTION_BON: return "BON";
+    case GAL_WCS_PROJECTION_PCO: return "PCO";
+    case GAL_WCS_PROJECTION_TSC: return "TSC";
+    case GAL_WCS_PROJECTION_CSC: return "CSC";
+    case GAL_WCS_PROJECTION_QSC: return "QSC";
+    case GAL_WCS_PROJECTION_HPX: return "HPX";
+    case GAL_WCS_PROJECTION_XPH: return "XPH";
+    default:                     return GAL_BLANK_STRING;
+    }
+
+  /* If control reaches here there is a bug! */
+  error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at '%s' to fix "
+        "the problem. Control should not have reached this part of "
+        "the function", __func__, PACKAGE_BUGREPORT);
+  return GAL_BLANK_STRING;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 /*************************************************************
  ***********               Read WCS                ***********
  *************************************************************/
@@ -672,31 +857,6 @@ gal_wcs_write(struct wcsprm *wcs, char *filename,
 /*************************************************************
  ***********           Coordinate system           ***********
  *************************************************************/
-int
-gal_wcs_coordsys_from_string(char *coordsys)
-{
-  if(      !strcmp(coordsys,"eq-j2000") ) return GAL_WCS_COORDSYS_EQJ2000;
-  else if( !strcmp(coordsys,"eq-b1950") ) return GAL_WCS_COORDSYS_EQB1950;
-  else if( !strcmp(coordsys,"ec-j2000") ) return GAL_WCS_COORDSYS_ECJ2000;
-  else if( !strcmp(coordsys,"ec-b1950") ) return GAL_WCS_COORDSYS_ECB1950;
-  else if( !strcmp(coordsys,"galactic") ) return GAL_WCS_COORDSYS_GALACTIC;
-  else if( !strcmp(coordsys,"supergalactic") )
-    return GAL_WCS_COORDSYS_SUPERGALACTIC;
-  else
-    error(EXIT_FAILURE, 0, "WCS coordinate system name '%s' not "
-          "recognized, currently recognized names are 'eq-j2000', "
-          "'eq-b1950', 'galactic' and 'supergalactic'", coordsys);
-
-  /* Control should not reach here. */
-  error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
-        "problem. Control should not reach the end of this function",
-        __func__, PACKAGE_BUGREPORT);
-  return GAL_WCS_COORDSYS_INVALID;
-}
-
-
-
-
 /* Identify the coordinate system of the WCS. */
 int
 gal_wcs_coordsys_identify(struct wcsprm *wcs)
@@ -961,8 +1121,8 @@ wcs_coordsys_insys_pole_in_outsys(int insys, int outsys, 
double *lng2p1,
 
 
 static void
-wcs_coordsys_ctypes(int coordsys, char **clng, char **clat, char **radesys,
-                    double *equinox)
+wcs_coordsys_ctypes(int coordsys, char **clng, char **clat,
+                    char **radesys, double *equinox)
 {
   switch( coordsys)
     {
@@ -1074,57 +1234,6 @@ gal_wcs_coordsys_convert(struct wcsprm *wcs, int 
outcoordsys)
 /*************************************************************
  ***********              Distortions              ***********
  *************************************************************/
-int
-gal_wcs_distortion_from_string(char *distortion)
-{
-  if(      !strcmp(distortion,"TPD") ) return GAL_WCS_DISTORTION_TPD;
-  else if( !strcmp(distortion,"SIP") ) return GAL_WCS_DISTORTION_SIP;
-  else if( !strcmp(distortion,"TPV") ) return GAL_WCS_DISTORTION_TPV;
-  else if( !strcmp(distortion,"DSS") ) return GAL_WCS_DISTORTION_DSS;
-  else if( !strcmp(distortion,"WAT") ) return GAL_WCS_DISTORTION_WAT;
-  else
-    error(EXIT_FAILURE, 0, "WCS distortion name '%s' not recognized, "
-          "currently recognized names are 'TPD', 'SIP', 'TPV', 'DSS' and "
-          "'WAT'", distortion);
-
-  /* Control should not reach here. */
-  error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
-        "problem. Control should not reach the end of this function",
-        __func__, PACKAGE_BUGREPORT);
-  return GAL_WCS_DISTORTION_INVALID;
-}
-
-
-
-
-
-char *
-gal_wcs_distortion_to_string(int distortion)
-{
-  /* Return the proper literal string. */
-  switch(distortion)
-    {
-    case GAL_WCS_DISTORTION_TPD: return "TPD";
-    case GAL_WCS_DISTORTION_SIP: return "SIP";
-    case GAL_WCS_DISTORTION_TPV: return "TPV";
-    case GAL_WCS_DISTORTION_DSS: return "DSS";
-    case GAL_WCS_DISTORTION_WAT: return "WAT";
-    default:
-      error(EXIT_FAILURE, 0, "WCS distortion id '%d' isn't recognized",
-            distortion);
-    }
-
-  /* Control should not reach here. */
-  error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
-        "problem. Control should not reach the end of this function",
-        __func__, PACKAGE_BUGREPORT);
-  return NULL;
-}
-
-
-
-
-
 /* Check the type of distortion present and return the appropriate
    integer based on `enum gal_wcs_distortion`.
 
@@ -1257,8 +1366,8 @@ gal_wcs_distortion_convert(struct wcsprm *inwcs, int 
outdisptype,
           default:
             error(EXIT_FAILURE, 0, "%s: conversion from %s to %s is not "
                   "yet supported. Please contact us at '%s'", __func__,
-                  gal_wcs_distortion_to_string(indisptype),
-                  gal_wcs_distortion_to_string(outdisptype),
+                  gal_wcs_distortion_name_from_id(indisptype),
+                  gal_wcs_distortion_name_from_id(outdisptype),
                   PACKAGE_BUGREPORT);
               }
         break;
@@ -1276,8 +1385,8 @@ gal_wcs_distortion_convert(struct wcsprm *inwcs, int 
outdisptype,
           default:
             error(EXIT_FAILURE, 0, "%s: conversion from %s to %s is not "
                   "yet supported. Please contact us at '%s'", __func__,
-                  gal_wcs_distortion_to_string(indisptype),
-                  gal_wcs_distortion_to_string(outdisptype),
+                  gal_wcs_distortion_name_from_id(indisptype),
+                  gal_wcs_distortion_name_from_id(outdisptype),
                   PACKAGE_BUGREPORT);
           }
         break;
@@ -1288,7 +1397,7 @@ gal_wcs_distortion_convert(struct wcsprm *inwcs, int 
outdisptype,
       case GAL_WCS_DISTORTION_WAT:
         error(EXIT_FAILURE, 0, "%s: input %s distortion is not yet "
               "supported. Please contact us at '%s'", __func__,
-              gal_wcs_distortion_to_string(indisptype),
+              gal_wcs_distortion_name_from_id(indisptype),
               PACKAGE_BUGREPORT);
 
       /* A bug! This distortion is not yet recognized. */



reply via email to

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