gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 0ee49ae5: MakeProfiles: WCS-options ignored ev


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 0ee49ae5: MakeProfiles: WCS-options ignored even if background doesn't have WCS
Date: Tue, 28 Jun 2022 13:13:09 -0400 (EDT)

branch: master
commit 0ee49ae5305597daf61aed91df6f4a7ac7a64639
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    MakeProfiles: WCS-options ignored even if background doesn't have WCS
    
    Until now, when an image was given to the '--background' option of
    MakeProfiles and it didn't have WCS, MakeProfiles would fall back to using
    the WCS-options to define a WCS for its output! This is not the expected
    behavior and could cause many confusions (as mentioned below).
    
    With this commit, in such cases, the WCS-options are not used and a warning
    is printed to let the user know about it.
    
    This bug was found with the help of Raul Infante-Sainz, while investigating
    why the radial profile script produces surface brightness measurements even
    though the input didn't have any WCS! After investigating the steps, the
    culprit was found to be this bug in MakeProfiles.
    
    This fixes bug #62680.
---
 NEWS              |  3 +++
 bin/mkprof/ui.c   | 25 ++++++++++++++++++++++---
 doc/gnuastro.texi | 12 +++++++++---
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index c46533e5..27865415 100644
--- a/NEWS
+++ b/NEWS
@@ -173,6 +173,9 @@ See the end of the file for license conditions.
               when '--instd' not used. Found and fixed by Raul Infante-Sainz.
   bug #62679: MakeProfiles kernel only normalized when zeropoint is
               zero. Found by Raul Infante-Sainz.
+  bug #62680: MakeProfiles using WCS-options when --background is given and
+              the background doesn't have WCS. Found with the help of Raul
+              Infante-Sainz.
 
 
 
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index bf15aa93..e1fa9ea6 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -1647,10 +1647,29 @@ ui_prepare_canvas(struct mkprofparams *p)
     }
 
 
-  /* Make the WCS structure of the output data structure if it has not
-     been set yet. */
+  /* Make the WCS structure of the output data structure (if it has not
+     been set when reading the background image). */
   if(p->wcs==NULL)
-    ui_prepare_wcs(p);
+    {
+      if(p->backname)
+        {
+          /* If the background image didn't have WCS, the output shouldn't
+             have any either! So let the user know. */
+          if(p->cp.quiet==0)
+            error(EXIT_SUCCESS, 0, "WARNING: no WCS in image given to "
+                  "'--background': %s! The output will therefore also "
+                  "not have any WCS. If you want to use the "
+                  "MakeProfiles WCS options ('--crpix', '--crval' and "
+                  "etc) to manually set the WCS of your output image, "
+                  "please do _not_ use '--background' and give the "
+                  "final size (in pixels) of your desired output through "
+                  "the '--mergedsize' option. You can suppress this "
+                  "warning with the '--quiet' option",
+                  gal_fits_name_save_as_string(p->backname, p->backhdu));
+        }
+      else
+        ui_prepare_wcs(p);
+    }
 
 
   /* Set the name, comments and units of the final merged output. */
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index e38cb6c9..1ad9a8a4 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -23385,7 +23385,7 @@ Besides the main/merged image containing all the 
profiles in the catalog, it is
 
 If an image is given to the @option{--background} option, the pixels of that 
image are used as the background value for every pixel hence flux value of each 
profile pixel will be added to the pixel in that background value.
 You can disable this with the @code{--clearcanvas} option (which will 
initialize the background to zero-valued pixels and build profiles over that).
-With the @option{--background} option, the values to all options relating to 
the ``canvas'' (output size and WCS) will be ignored if specified, for example 
@option{--oversample}, @option{--mergedsize}, and @option{--prepforconv}.
+With the @option{--background} option, the values to all options relating to 
the ``canvas'' (output size and WCS) will be ignored if specified: 
@option{--oversample}, @option{--mergedsize}, @option{--prepforconv}, 
@option{--crpix}, @option{--crval}, @option{--cdelt}, @option{--cdelt}, 
@option{--pc}, @option{cunit} and @option{ctype}.
 
 The sections below discuss the options specific to MakeProfiles based on 
context: the input catalog settings which can have many rows for different 
profiles are discussed in @ref{MakeProfiles catalog}, in @ref{MakeProfiles 
profile settings}, we discuss how you can set general profile settings (that 
are the same for all the profiles in the catalog).
 Finally @ref{MakeProfiles output dataset} and @ref{MakeProfiles log file} 
discuss the outputs of MakeProfiles and how you can configure them.
@@ -23440,7 +23440,8 @@ See @ref{Selecting table columns} for a thorough 
discussion on the values to the
 The value for the profile center in the catalog (the @option{--ccol} option) 
can be a floating point number so the profile center can be on any sub-pixel 
position.
 Note that pixel positions in the FITS standard start from 1 and an integer is 
the pixel center.
 So a 2D image actually starts from the position (0.5, 0.5), which is the 
bottom-left corner of the first pixel.
-When a @option{--background} image with WCS information is provided or you 
specify the WCS parameters with the respective options, you may also use RA and 
Dec to identify the center of each profile (see the @option{--mode} option 
below).
+When a @option{--background} image with WCS information is provided, or you 
specify the WCS parameters with the respective options@footnote{The options to 
set the WCS are the following: @option{--crpix}, @option{--crval}, 
@option{--cdelt}, @option{--cdelt}, @option{--pc}, @option{cunit} and 
@option{ctype}.
+Just recall that these options are only used if @option{--background} is not 
given: if the image you give to @option{--background} doesn't have WCS, these 
options will not be used and you can't use WCS-mode coordinates like RA or 
Dec.}, you may also use RA and Dec to identify the center of each profile (see 
the @option{--mode} option below).
 
 In MakeProfiles, profile centers do not have to be in (overlap with) the final 
image.
 Even if only one pixel of the profile within the truncation radius overlaps 
with the final image size, the profile is built and included in the final image.
@@ -23792,7 +23793,7 @@ The extension that contains the image should be 
specified with the @option{--bac
 When a background image is specified, it will be used to derive all the 
information about the output image.
 Hence, the following options will be ignored: @option{--mergedsize}, 
@option{--oversample}, @option{--crpix}, @option{--crval} (generally, all other 
WCS related parameters) and the output's data type (see @option{--type} in 
@ref{Input output options}).
 
-The image will act like a canvas to build the profiles on: profile pixel 
values will be summed with the background image pixel values.
+The background image will act like a canvas to build the profiles on: profile 
pixel values will be summed with the background image pixel values.
 With the @option{--replace} option you can disable this behavior and replace 
the profile pixels with the background pixels.
 If you want to use all the image information above, except for the pixel 
values (you want to have a blank canvas to build the profiles on, based on an 
input image), you can call @option{--clearcanvas}, to set all the input image's 
pixels to zero before starting to build the profiles over it (this is done in 
memory after reading the input, so nothing will happen to your input file).
 
@@ -23918,6 +23919,11 @@ If you look into the headers of a FITS image with WCS 
for example you will see a
 You can see the FITS headers with Gnuastro's @ref{Fits} program using a 
command like this: @command{$ astfits -p image.fits}.
 
 If the values given to any of these options does not correspond to the number 
of dimensions in the output dataset, then no WCS information will be added.
+Also recall that if you use the @option{--background} option, all of these 
options are ignored.
+Such that if the image given to @option{--background} doesn't have any WCS, 
the output of MakeProfiles will also not have any WCS, even if these options 
are given@footnote{If you want to add profiles @emph{and} WCS over the 
background image (to produce your output), you need more than one command:
+1. You should use @option{--mergedsize} in MakeProfiles to manually set the 
output number of pixels equal to your desired background image (so the 
background is zero).
+In this mode, you can use these WCS-related options to define the WCS.
+2. Then use Arithmetic to add the pixels of your mock image to the background 
(see @ref{Arithmetic}.}.
 
 @table @option
 



reply via email to

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