bugGNU Astronomy Utilities - Bugs: bug #63064, Statistics crashes when all pixels...


You are not allowed to post comments on this tracker with your current authentication level.

bug #63064: Statistics crashes when all pixels are nan

Submitter:  Raul Infante-Sainz <infantesainz>
Submitted:  Fri 16 Sep 2022 07:43:47 AM UTC
Category:  Statistics Severity:  3 - Normal
Item Group:  Crash Status:  Fixed
Privacy:  Public Assigned to:  alteholz
Open/Closed:  Closed

Tue 19 Mar 2024 06:00:50 PM UTC, comment #3: 

Thanks Thorsten! A modified commit has been merged into the 'master' branch as Commit 0dd7bcc0f.

Please compare this commit with your original commit (the message and the changes in the code) for the future. Generally, I recommend to re-read the Gnuastro Coding Conventions (based on the GNU Coding conventions) and Commit guidelines.

Here is a summary of the main issues:

  • There was no title in the commit message.
  • The commit message paragraphs were not properly adjusted.
  • The comments within the code should be written for the code after your change and should not refer to old behavior (as in "according to #63064 this is not the desired behaviour ..."). For any other contributor (other than you and me), the "this" is not clear!
  • Have a look at other multi-line comments with the code, Gnuastro does not put a '*' at the start of such long comments.
  • Use a single command to print warnings in one line. Also, don't use 'printf' because it does not show the user which program produced the error, use 'error(EXIT_SUCESS, 0, ...)'. This will allow the user to easily identify which program produced the error.
  • Do not report a commit that is not yet working completely: as you mentioned it would crash when trying to print the histogram. This crash would return a non-zero value to the running shell, causing a crash in pipelines.
Mohammad Akhlaghi <makhlaghi>
Group administrator
Sat 02 Mar 2024 06:07:28 PM UTC, comment #2: 

Commit https://codeberg.org/alteholz/gnuastro/commit/259a6d2955d8d65043b5e26be94579e90c46acfa  converts the error complaints into info prints (which can be also avoided with --quiet).

After printing the values up to "Standard deviation" (which now appear as NAN), a histogram is normally added. I assume that an empty histogram is not needed. So due to the error resulting from this empty histogram the return code of aststatistics is still !=0. Thus the behaviour has not changed and software that only checks this rc is still happy.

What do you think?

Thorsten Alteholz <alteholz>
Group Member
Thu 22 Feb 2024 11:58:30 PM UTC, comment #1: 

Until the bug is fixed, the following condition can be used in a script: we are using the shell's 'if' to check if Statistics returned successfully or not. If not, the script can be prepared to deal with scenarios where all the inputs are NaN.

$ if aststatistics img.fits; then echo GOOD; else echo BAD; fi

Mohammad Akhlaghi <makhlaghi>
Group administrator
Fri 16 Sep 2022 07:43:47 AM UTC, original submission:  

I am trying to obtain the statistics of an image that all pixels are equal to nan. While this a strange case and the input image is obviously wrong, Statistics should give a consistent result as an output: nan values. Otherwise in a general pipeline where this situations could happen, it crashes. This is actually the current problem I am having with the following error:

aststatistics: img.fits (hdu: 1): all elements are blank

Maybe a warning to show that all elements are blank/nan is good. That warning could be disabled with the option '--quiet' while keep giving as an output nan values. Does it sound reasonable?

Raul Infante-Sainz <infantesainz>
Group Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by alteholz (Posted a comment)
  • -email is unavailable- added by makhlaghi (Posted a comment)
  • -email is unavailable- added by infantesainz (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-03-19 makhlaghi StatusNone Fixed
        Assigned toNone alteholz
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-6ae7.
    Corresponding source code