taskGNU Astronomy Utilities - Tasks: task #16222, Arithmetic operators to convert...

 
 

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

task #16222: Arithmetic operators to convert areas for example mag/arcsec2 to counts/pix

Submitter:  Mohammad Akhlaghi <makhlaghi>
Submitted:  Tue 28 Jun 2022 05:53:47 PM UTC
   
 
Should Start On:  Mon 27 Jun 2022 11:00:00 PM UTC Should be Finished on:  Mon 27 Jun 2022 11:00:00 PM UTC
Category:  Arithmetic Priority:  5 - Normal
Item Group:  Enhancement Status:  Postponed
Privacy:  Public Assigned to:  None
Percent Complete:  0% Open/Closed:  Open
Effort:  0.00

Jump to the original submission

Mon 24 Apr 2023 07:59:11 PM UTC, comment #7: 

Thanks a lot Bharat, the commit looks good.

There is just one thing that worries me: the 'gal_wcs_pixel_scale' function which is called on every conversion. This function is computationally much more complex than the actual unit conversion. So if someone wants to convert thousands of values, 'gal_wcs_pixel_scale' will be called thousands of times.

A more robust way is to estimate the pixel scale once (before 'arithmetic_function_binary_flt' starts to parse the set of inputs), and pass the pixel scale to 'gal_units_arcsecsq_to_pixnum' instead of the WCS ;-).

By the way, can you also implement the inverse operation?

Mohammad Akhlaghi <makhlaghi>
Group administrator
Sun 26 Mar 2023 08:21:26 AM UTC, comment #6: 

Okay, sir.
In the following commit, I have provided a crude solution for converting arcsecsq to pixnum. Whenever you got some time, I would love to hear your feedback so that I can improve the code(^_^).
 
The commit can be found at the following link
https://github.com/Bharat-bhandari/gnuastro1/compare/task%2316222?expand=1

Bharat <bharat>
Sat 25 Mar 2023 12:18:51 AM UTC, comment #5: 

I am very busy in the next few days, so how about confirming the equation in the Matrix chat room for comments from others? In the meantime go on with the rest of the steps beyond that function: even if the equation is wrong, the necessary steps before and after it will be the same ;-).

Just one tip: for simple powers (like 2), it is more optimal to use 'a*a' instead of 'pow(a,2)'.

Mohammad Akhlaghi <makhlaghi>
Group administrator
Fri 24 Mar 2023 08:08:44 PM UTC, comment #4: 

Thanks Mohammad sir, this clears most of my doubts.

Now,for converting arcsecsq to number of pixels, I am using this formula. number of pixels = (arcseconds squared) / (pixel scale)^2

Added this code in lib/units.c.

.
double
gal_units_arcsecsq_to_pixnum(double area_arcsec2, double pixelscale)
{
  return area_arcsec2/pow(pixelscale,2);
}
.

required code will going to update in lib/arithmetic.c, gnuastro/arithmetic.h and gnuastro/units.h

Am I going in right direction?

PS :- I apologize for asking so many questions. Since it's my first open source contribution, so going a bit more comprehensive (^_^).

Bharat <bharat>
Tue 21 Mar 2023 02:54:23 PM UTC, comment #3: 

Thanks for your interest in this task Bharat.

These generic operators are defined in the Arithmetic library, you can see its source in lib/arithmetic.c. The 'astarithmetic' executable (in 'bin/arithmetic', simply calls the Arithmetic library for many operations, including the unit conversion ones).

Within the Arithmetic library, you will see that the unit conversion operators have some special wrapper functions (like 'arithmetic_counts_to_from_sb', which actually call the functions within the Gnuastro units library (starting with 'gal_units_*'). I hope this helps ;-).

Mohammad Akhlaghi <makhlaghi>
Group administrator
Sun 19 Mar 2023 06:16:53 PM UTC, comment #2: 

Hello Mohammad Sir👋,
I'm trying to solve this issue, but a bit confused here
Specifically, where can the related code be found in path/to/bin/arithmetic, bin/convertt, or bin/fits..  As the task is similar to unit convertion operator.
A brief suggestion, or any tips about the task would be really helpful sir😀

Bharat <bharat>
Thu 09 Mar 2023 06:15:21 PM UTC, comment #1: 

Hello! I have reviewed the task and believe that I can make an attempt to solve the issue.
Thank you.


Bharat <bharat>
Tue 28 Jun 2022 05:53:47 PM UTC, original submission:  

It would be very useful to have operators for converting arcsec^2 to number of pixels, and vice-versa. Based on an input WCS. We currently have the necessary operators to convert magnitudes to counts and vice-versa, but we don't have any for converting common area units.

For example:


$ astarithmetic 1 arcsecsq-to-pixnum --wcsfile=image.fits


This will be useful when we need to convert mag/arcsec^2 into image units: counts/pixel. In fact since this is a common conversion, we can have a high-level operator for it, maybe something like this:


$ astarithmetic 25 surfbright-to-countsperpix --wcsfile=image.fits


Of course, if an image with WCS is already present in the Arithmetic command, there is no need to use '--wcsfile'.

These can also be available for column arithmetic in Table.

Mohammad Akhlaghi <makhlaghi>
Group administrator

 

(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 bharat (Posted a comment)
  • -email is unavailable- added by makhlaghi (Submitted the item)
  • -email is unavailable- added by makhlaghi
  •  

    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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-06-28 makhlaghi Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code