spacetelescope / imexam

imexam is a python tool for simple image examination, and plotting, with similar functionality to IRAF's imexamine
http://imexam.readthedocs.io
BSD 3-Clause "New" or "Revised" License
74 stars 45 forks source link

adapt for API change for photutils areas (#193) #195

Closed sosey closed 4 years ago

sosey commented 4 years ago

Update the logic to account for differing APIs in photutils version >= 0.7

sosey commented 4 years ago

Fixes #193 and #194

sosey commented 4 years ago

Everything looks clean on my end, I'm going to merge this so I can make a formal release

hjmcc commented 4 years ago

Many thanks for the changes! We are almost there. Aperture sum works, curve of growth works. However, I see a new bug now in the radial plot ('r') mode:

----> 1 viewer.imexam()

~/anaconda3/envs/py37-astropy/lib/python3.7/site-packages/imexam/connect.py in imexam(self)
    148                 self._run_event_imexam()
    149             else:
--> 150                 self._run_imexam()
    151         else:
    152             warnings.warn("No valid image loaded in viewer")

~/anaconda3/envs/py37-astropy/lib/python3.7/site-packages/imexam/connect.py in _run_imexam(self)
    264                                     self._check_slice()
    265                                 self.exam.do_option(
--> 266                                     x, y, current_key)
    267                 except KeyError:
    268                     print(

~/anaconda3/envs/py37-astropy/lib/python3.7/site-packages/imexam/imexamine.py in do_option(self, x, y, key)
    190         """
    191         self.log.debug("pressed: {0}, {1:s}".format(key, self.imexam_option_funcs[key][0].__name__))
--> 192         self.imexam_option_funcs[key][0](x, y, self._data)
    193
    194     def get_options(self):

~/anaconda3/envs/py37-astropy/lib/python3.7/site-packages/imexam/imexamine.py in radial_profile(self, x, y, data, form, genplot, fig)
   1076             self.log.info("Background per pixel: {0:f}".format(sky_per_pix))
   1077
-> 1078             flux -= sky_per_pix
   1079
   1080             if getdata:

UFuncTypeError: Cannot cast ufunc 'subtract' output from dtype('float64') to dtype('uint16') with casting rule 'same_kind'

I am not sure what this is coming from, I will investigate. Thanks!

hjmcc commented 4 years ago

It could be that my FITS data (from a small telescope we are using here for teaching) has BITPIX=16 and something is not being converted correctly.

If I do this

flux = flux - float(sky_per_pix)

all works!

sosey commented 4 years ago

could be, do you have BSCALE and BZERO also in your data headers? It may not be translating the 16bit on read correctly, what are the values for those keywords in your data?

physical value = BSCALE * (storage value) + BZERO

hjmcc commented 4 years ago

Hmm, seems to be fine:

BZERO   =                32768 / offset data range to that of unsigned short    
BSCALE  =                    1 / default scaling factor

the data is BITPIX=16

Incidentally, the point of this project is to find a simple tool we can use with students to explore astronomical data, and this tool seems great...

sosey commented 4 years ago

hmm..I'll look at the flow of the sky pix then...

awesome! lemme know how it goes or if you see any shortcomings that we can fix, feel free to make issues for those too :)

hjmcc commented 4 years ago

thanks!

Sure, check out @hjmccracken on twitter for pictures of our observatory (in the centre of Paris!) . I have been looking for a long time for a simple tool to use with students, ds9 does a lot of stuff but it's not quite there.

Cheers henry

On Fri, 6 Dec 2019 at 21:36, Megan Sosey notifications@github.com wrote:

hmm..I'll look at the flow of the sky pix then...

awesome! lemme know how it goes or if you see any shortcomings that we can fix, feel free to make issues for those too :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/spacetelescope/imexam/pull/195?email_source=notifications&email_token=ABUMJMKNPL5XCGZDHBPJXFLQXKZUHA5CNFSM4JU6ZYIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGFI3GY#issuecomment-562728347, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUMJMI2CJJCOEPQHV7TJUTQXKZUHANCNFSM4JU6ZYIA .

sosey commented 4 years ago

I have been there! :) (ADASS 2011)