gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 8ce8b42: Specific suffixes for one modular war


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 8ce8b42: Specific suffixes for one modular warping in ImageWarp
Date: Wed, 18 Jan 2017 18:20:38 +0000 (UTC)

branch: master
commit 8ce8b426a99d96f0a3ef402f759cd5cd9d42b4dc
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Specific suffixes for one modular warping in ImageWarp
    
    Until now, ImageWarp would use the `_warped.fits' suffix for automatic
    output. But its some time that it also allows modular warpings (like
    rotation, alignment, scaling and so on). Thus, when the user only wants one
    of these operations, it is much more meaningful if the suffix also reflects
    that particular warp.
    
    A check is now added, so when there is only one element in the modular
    warpings linked list, the suffix will be determined based on its
    type. Otherwise, it will fall back to the generic `--warped.fits' suffix.
    
    A short description of the `--output' option and Automatic output was also
    added to the first paragraph after the examples in the "Invoking ImageWarp"
    section of the book.
    
    This task was suggested by Lee Kelvin.
    
    This finishes task #14309.
---
 bin/imgwarp/astimgwarp.conf |    1 -
 bin/imgwarp/ui.c            |   60 ++++++++++++++++++++++++++++++++++++++-----
 doc/gnuastro.texi           |   11 +++++---
 3 files changed, 61 insertions(+), 11 deletions(-)

diff --git a/bin/imgwarp/astimgwarp.conf b/bin/imgwarp/astimgwarp.conf
index 1017118..dd5a1d0 100644
--- a/bin/imgwarp/astimgwarp.conf
+++ b/bin/imgwarp/astimgwarp.conf
@@ -21,5 +21,4 @@
  hdu           0
 
 # Output:
- scale         1.0
  maxblankfrac  0.8
\ No newline at end of file
diff --git a/bin/imgwarp/ui.c b/bin/imgwarp/ui.c
index e3fbebf..95a053c 100644
--- a/bin/imgwarp/ui.c
+++ b/bin/imgwarp/ui.c
@@ -838,21 +838,69 @@ prepare_modular_matrix(struct imgwarpparams *p)
 /**************************************************************/
 /***************       Sanity Check         *******************/
 /**************************************************************/
+/* When only one transformation is required, set the suffix for automatic
+   output to more meaningful string. */
+char *
+ui_set_suffix(struct optionwarpsll *owll)
+{
+  /* We only want the more meaningful suffix when the list is defined AND
+     when its only has one node (the `next' element is NULL). */
+  if(owll && owll->next==NULL)
+    switch(owll->type)
+      {
+      case ALIGN_WARP:
+        return "_aligned.fits";
+
+      case ROTATE_WARP:
+        return "_rotated.fits";
+
+      case SCALE_WARP:
+        return "_scaled.fits";
+
+      case FLIP_WARP:
+        return "_flipped.fits";
+
+      case SHEAR_WARP:
+        return "_sheared.fits";
+
+      case TRANSLATE_WARP:
+        return "_translated.fits";
+
+      case PROJECT_WARP:
+        return "_projected.fits";
+
+      default:
+        return "_warped.fits";
+      }
+  else
+    return "_warped.fits";
+}
+
+
+
+
+
 void
 sanitycheck(struct imgwarpparams *p)
 {
+  char *suffix;
   double *d, *df, *m=p->matrix;
 
   /* Make sure the input file exists. */
   gal_checkset_check_file(p->up.inputname);
 
-  /* Set the output name: */
+  /* Set the output name. This needs to be done before
+     `prepare_modular_matrix' because that function will free the linked
+     list of modular warpings (`p->up.owll'). */
   if(p->cp.output)
     gal_checkset_check_remove_file(p->cp.output, p->cp.dontdelete);
   else
-    gal_checkset_automatic_output(p->up.inputname, "_warped.fits",
-                                  p->cp.removedirinfo, p->cp.dontdelete,
-                                  &p->cp.output);
+    {
+      suffix=ui_set_suffix(p->up.owll);
+      gal_checkset_automatic_output(p->up.inputname, suffix,
+                                    p->cp.removedirinfo, p->cp.dontdelete,
+                                    &p->cp.output);
+    }
 
   /* If an actual matrix is given, then it will be used and all modular
      warpings will be ignored. */
@@ -922,8 +970,8 @@ preparearrays(struct imgwarpparams *p)
 
   /* Read in the input image: */
   numnul=gal_fits_hdu_to_array(p->up.inputname, p->cp.hdu,
-                                     &p->inputbitpix, &array, &p->is0,
-                                     &p->is1);
+                               &p->inputbitpix, &array, &p->is0,
+                               &p->is1);
   if(p->inputbitpix==DOUBLE_IMG)
     p->input=array;
   else
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 422b5bc..42ee507 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -9206,9 +9206,9 @@ One line examples:
 
 @example
 $ astimgwarp matrix.txt image.fits
-$ astimgwarp --align rawimage.fits
-$ astimgwarp --scale 1.82 --translate 2.1 image.fits
 $ astimgwarp --rotate=37.92 --scale=0.8 image.fits
+$ astimgwarp --scale 1.82 --translate 2.1 image.fits
+$ astimgwarp --align rawimage.fits --output=aligned.fits
 $ astimgwarp --matrix=0.2,0,0.4,0,0.2,0.4,0,0,1 image.fits
 $ astimgwarp --matrix="0.7071,-0.7071  0.7071,0.7071" image.fits
 @end example
@@ -9217,8 +9217,11 @@ ImageWarp can accept two arguments, one (an image) is 
mandatory if any
 processing is to be done. An optional argument is a plain text file, which
 must contain the warp/transform matrix, see @ref{Warping basics}. When this
 text file is specified, then all options related to the matrix will be
-ignored (see below for the options). The general options to all Gnuastro
-programs (including ImageWarp) can be seen in @ref{Common options}.
+ignored (see below for the options). As in all Gnuastro programs, when an
+output is not explicitly set with the @option{--output} option, the output
+filename will be set automatically based on the operation, see
address@hidden output}. For the full list of general options to all
+Gnuastro programs (including ImageWarp), please see @ref{Common options}.
 
 To be the most accurate the input image will be converted to double
 precision floating points and all the processing will be done in this



reply via email to

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