taskGNU Astronomy Utilities - Tasks: task #16115, ds9.c: polygon expects ')' at end

 
 

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

task #16115: ds9.c: polygon expects ')' at end

Submitter:  Pedram Ashofteh-Ardakani <pedram>
Submitted:  Tue 01 Feb 2022 02:19:38 PM UTC
   
 
Should Start On:  Tue 01 Feb 2022 12:00:00 AM UTC Should be Finished on:  Tue 01 Feb 2022 12:00:00 AM UTC
Category:  Libraries Priority:  5 - Normal
Item Group:  Crash Status:  Done
Privacy:  Public Assigned to:  pedram
Percent Complete:  100% Open/Closed:  Closed
Effort:  0.00

Fri 04 Feb 2022 03:32:31 PM UTC, comment #5: 

The branch has been rebased and merged into 'master' as Commit 7ac0c80a1378a (or on Codeberg). Here are some comments to explain some minor changes I made before the merge:

  • 'status' was renamed to 'good_polygon_format' to help in readability.
  • The 'register' was removed from the definition of 'i'; and its definition is now up with the rest of the variables. This I know this sounds strange, but I originally done the same things my self ;-)! The issue is that according to the C standard, the 'register' is optional and acts only as a hint to the compiler for what to put in the CPU registries [1]. Generally, since the compilers check the code before us, and we have enabled all optimizations, the compilers are themselves better to distinguish which/when to put variables to put in the CPU registry then us. So to help in code readability, its best to simply ignore these things; which are mostly redundant now ;-): they were good in the days C was written because compilers weren't too advanced.
  • I also noticed that the line-width of your comment line breaks (when you press 'M-q') are too narrow: when I ran 'M-q' on them; they became wider (and still less than 75 characters). Did you use Emacs? In the top Gnuastro directory we have a '.dir-locals.el' file to unify Emacs's formatting. For some reason it hasn't be read!


[1] https://stackoverflow.com/questions/578202/register-keyword-in-c

Mohammad Akhlaghi <makhlaghi>
Group administrator
Tue 01 Feb 2022 04:28:17 PM UTC, comment #4: 

Made a mistake. The new commit 8dd6918408. Sorry.

Pedram Ashofteh-Ardakani <pedram>
Group Member
Tue 01 Feb 2022 04:21:14 PM UTC, comment #3: 

I made the newer commit 728c972530.

== Commit message ==
Library (ds9.c): better check for polygon format

Until now, the polygon formatting would pass the test even if the matching
parenthesis was found after the formatting parameters (properties following
the '#').

With this commit, we set a status variable, and only set it as successful
if we could find the matching parenthesis before '#'.

Pedram Ashofteh-Ardakani <pedram>
Group Member
Tue 01 Feb 2022 02:50:54 PM UTC, comment #2: 

Oh I forgot to mention, Zahra Sharbaf reported this bug.

It is ready for your review Mohammad.

Pedram Ashofteh-Ardakani <pedram>
Group Member
Tue 01 Feb 2022 02:47:20 PM UTC, comment #1: 

I fixed it in commit 74343cd38f.

== commit message ==

Library (ds9.c): fix "polygon expects ')' at end"

Until now, the ds9.c library looked for the ')' in the line that started
with 'polygon(' and then, only checked the last character to see if the
'polygon(' has a matching ')'.

This raised problems when the region file contained meta data following the
polygon command starting with '#'. It happens when the user customizes any
of the 'polygon' properties in ds9.

With this commit, the ds9.c library reads the entire line, and stops
whenever it spots the matching ')'. If not, throws the error same as
before.

Pedram Ashofteh-Ardakani <pedram>
Group Member
Tue 01 Feb 2022 02:19:38 PM UTC, original submission:  

The library complains that 'polygon' in ds9.reg file does not end with a ')' where it is followed by a '#'.

This happens when the ds9 user has fiddled with the region color, width, text, etc. and the '# color=...' meta data is added after the actual 'polygon' command.

steps to reproduce

1. Create a polygon region in ds9
2. Update polygon color
3. Save region as 'ds9.reg'
4. Try cropping by that polygon:


$ astcrop FILE.fits -h1 --polygon ds9.reg
astcrop:ds9.reg:4: line with polygon vertices doesn't end with ')'. It is expected for the line to have this format: 'polygon(AAA,BBB,...)'. Where 'AAA' and 'BBB' are numbers and '...' signifies that any number of points are possible


workaround

1. Open the 'ds9.reg' file with a text editor.
2. Remove the '#' and its following content after the 'polygon' coordinates
3. Try cropping again

Pedram Ashofteh-Ardakani <pedram>
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 makhlaghi (Posted a comment)
  • -email is unavailable- added by pedram
  • -email is unavailable- added by pedram (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-02-19 makhlaghi Percent Complete0% 100%
        Open/ClosedOpen Closed
    2022-02-04 makhlaghi StatusNone Done
        Assigned toNone pedram
    2022-02-01 pedram Carbon-Copy- Added makhlaghi

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code