gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 8c1ccf0: MakeProfiles: --replace option uses t


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 8c1ccf0: MakeProfiles: --replace option uses the maximum value
Date: Fri, 18 Sep 2020 20:28:35 -0400 (EDT)

branch: master
commit 8c1ccf0138e08f69db32cb4263a7d6dce8f9016a
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    MakeProfiles: --replace option uses the maximum value
    
    Until now, the '--replace' option would always just put values in the same
    order that they came over the final canvas. However, in a multi-threaded
    scenario, the order of the written profiles on the final canvas changes in
    every run. As a result the output with '--replace' wasn't reproducible over
    the overlapping pixels.
    
    With this commit, instead of using the final value that is written over the
    pixel, we use the maximum value over that pixel. Because the maximum value
    doesn't depend on the order, the result is thus thread-safe.
    
    This bug was reported by Samane Raji and Zahra Sharbaf.
---
 NEWS                         |  3 ++-
 bin/mkprof/mkprof.c          |  2 +-
 doc/announce-acknowledge.txt |  1 +
 doc/gnuastro.texi            | 20 +++++++-------------
 4 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/NEWS b/NEWS
index c42f598..4449490 100644
--- a/NEWS
+++ b/NEWS
@@ -58,8 +58,9 @@ See the end of the file for license conditions.
      'usecolon' is zero, the string will be in the '_d_m_s' format.
 
 ** Bugs fixed
-  bug #59105: Column arithmetic operator degree-to-ra, returning to dec
   bug #59017: Segment's object IDs are not thread-safe (i.e., reproducible).
+  bug #59105: Column arithmetic operator degree-to-ra, returning to dec.
+  bug #59136: Makeprofiles with --replace is not thread-safe.
 
 
 
diff --git a/bin/mkprof/mkprof.c b/bin/mkprof/mkprof.c
index e4b83a1..12289c9 100644
--- a/bin/mkprof/mkprof.c
+++ b/bin/mkprof/mkprof.c
@@ -632,7 +632,7 @@ mkprof_write(struct mkprofparams *p)
          array. */
       if(ibq->overlaps && out)
         GAL_TILE_PO_OISET(float,float,ibq->overlap_i,ibq->overlap_m,1,0, {
-            *o  = p->replace ? ( *i==0.0f ? *o : *i ) :  (*i + *o);
+            *o  = p->replace ? ( *i>*o ? *i : *o ) :  (*i + *o);
             sum += *i;
           });
 
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 6221717..40919c8 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -3,6 +3,7 @@ Alphabetically ordered list to acknowledge in the next release.
 Sebastian Luna Valero
 Samane Raji
 Joanna Sakowska
+Zahra Sharbaf
 Sachin Kumar Singh
 
 
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index fe4143c..0a96bfb 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -17178,20 +17178,14 @@ See the explanations for this type of profile in 
@option{--fcol}.
 
 @item -R
 @itemx --replace
-Do not add the pixels of each profile over the background (possibly crowded by 
other profiles), replace them.
-By default, when two profiles overlap, the final pixel value is the sum of all 
the profiles that overlap on that pixel.
-When this option is given, the pixels are not added but replaced by the newer 
profile's pixel and any value under it is lost.
+Do not add the pixels of each profile over the background, or other profiles.
+But replace the values.
 
-@cindex CPU threads
-@cindex Threads, CPU
-When order matters, make sure to use this function with 
`@option{--numthreads=1}'.
-When multiple threads are used, the separate profiles are built asynchronously 
and not in order.
-Since order does not matter in an addition, this causes no problems by default 
but has to be considered when this option is given.
-Using multiple threads is no problem if the profiles are to be used as a mask 
with a blank or fixed value (see `@option{--mforflatpix}') since all their 
pixel values are the same.
-
-Note that only non-zero pixels are replaced.
-With radial profiles (for example S@'ersic or Moffat) only values above zero 
will be part of the profile.
-However, when using flat profiles with the `@option{--mforflatpix}' option, 
you should be careful not to give a @code{0.0} value as the flat profile's 
pixel value.
+By default, when two profiles overlap, the final pixel value is the sum of all 
the profiles that overlap on that pixel.
+This is the expected situation when dealing with physical object profiles like 
galaxies or stars/PSF.
+However, when MakeProfiles is used to build integer labeled images (for 
example in @ref{Aperture photometry}), this is not the expected situation: the 
sum of two labels will be a new label.
+With this option, the pixels are not added but the largest (maximum) value 
over that pixel is used.
+Because the maximum operator is independent of the order of values, the output 
is also thread-safe.
 
 @end table
 



reply via email to

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