BUG: photometry fails when several sources are in the same group
See original GitHub issueI’m running into a bug where the photometry routine tries to access a model attribute that does not exist. As far as I can tell, that’s happening when more than one source is found in the same group, but the naming scheme of the parameters of the combined model is confusing to me, so I don’t really know what’s going on.
This happens with the current checkout of the master branch and astropy 3.1.2 as well as the current astropy master. A minimal example is below:
(photutils)melkor:/melkor/d1/guenther/soft/python> ipython
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import numpy as np
...: from astropy.table import Table
...: from astropy.modeling import models
...: from photutils.psf import prepare_psf_model
...: from photutils import BasicPSFPhotometry, DAOGroup
...:
...: psffunc = models.Moffat2D(amplitude=1, gamma=2, alpha=2.8, x_0=0, y_0=0)
...:
...: psffunc.gamma.frozen = True
...: psffunc.alpha.frozen = True
...: psffunc.amplitude.frozen = True # Fix to one and add scaling factor to
...: avoid confusion between amplitude and flux
...:
...: psfmodel = prepare_psf_model(psffunc, xname='x_0', yname='y_0', fluxname
...: =None)
...: photometry = BasicPSFPhotometry(group_maker=DAOGroup(5), bkg_estimator=N
...: one,
...: psf_model=psfmodel, fitshape=(11,11),
...: aperture_radius=5)
...: photometry.do_photometry(np.zeros((100, 100)), init_guesses=Table({'x_0'
...: : [10, 11, 12], 'y_0': [10, 11, 12]}))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-c99a4ea837ff> in <module>
14 psf_model=psfmodel, fitshape=(11,11),
15 aperture_radius=5)
---> 16 photometry.do_photometry(np.zeros((100, 100)), init_guesses=Table({'x_0': [10, 11, 12], 'y_0': [10, 11, 12]}))
/nfs/melkor/d1/guenther/soft/anaconda/envs/photutils/lib/python3.7/site-packages/photutils-0.7.dev3439-py3.7-linux-x86_64.egg/photutils/psf/photometry.py in do_photometry(self, image, init_guesses)
289
290 star_groups = self.group_maker(init_guesses)
--> 291 output_tab, self._residual_image = self.nstar(image, star_groups)
292
293 star_groups = star_groups.group_by('group_id')
/nfs/melkor/d1/guenther/soft/anaconda/envs/photutils/lib/python3.7/site-packages/photutils-0.7.dev3439-py3.7-linux-x86_64.egg/photutils/psf/photometry.py in nstar(self, image, star_groups)
351 image[usepixel])
352 param_table = self._model_params2table(fit_model,
--> 353 len(star_groups.groups[n]))
354 result_tab = vstack([result_tab, param_table])
355
/nfs/melkor/d1/guenther/soft/anaconda/envs/photutils/lib/python3.7/site-packages/photutils-0.7.dev3439-py3.7-linux-x86_64.egg/photutils/psf/photometry.py in _model_params2table(self, fit_model, star_group_size)
466 param_tab[param_tab_name][i] = getattr(fit_model,
467 param_name +
--> 468 '_' + str(i)).value
469 else:
470 for param_tab_name, param_name in self._pars_to_output.items():
/nfs/melkor/d1/guenther/soft/anaconda/envs/photutils/lib/python3.7/site-packages/astropy/modeling/core.py in __getattr__(self, attr)
2881 # This workaround allows descriptors to work correctly when they are
2882 # not initially found in the class __dict__
-> 2883 value = getattr(self.__class__, attr)
2884 if hasattr(value, '__get__'):
2885 # Object is a descriptor, so we should really return the result of
/nfs/melkor/d1/guenther/soft/anaconda/envs/photutils/lib/python3.7/site-packages/astropy/modeling/core.py in __getattr__(cls, attr)
2273 return getattr(cls, attr)
2274
-> 2275 raise AttributeError(attr)
2276
2277 def __repr__(cls):
AttributeError: x_0_2_0
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Photometric Colour Calibration Error | PixInsight Forum
Its telling me there's an unknown error with the catalog server etc. ... I get the same (or similar) faults on different Vizier...
Read more >Photometric accuracy
Table 7: Internal photometric errors per magnitude bins derived for each CFHTLS Wide field. The simulated sources include only stars and are detected...
Read more >10.2.5 Photometry - Gaia Archive
Sources demoted to only two astrometric parameters are either very faint or have some intrinsic problem (e.g., binarity) and can therefore not be...
Read more >Photometric Calibration and the Monitor Telescope
The limits to photometric accuracy are usually set by the accumulation of several small sources of error, each of comparable magnitude. Some of...
Read more >32.6 Photometric Accuracies
Table 32.4 summarizes the approximate levels of photometric inaccuracy introduced by these error sources, for both the pre- and post-COSTAR ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Mmmm. There must be a better way to map (compound) parameters in the psf model to the parameters we want to fit. Looking a the string of the parameter name is obviously brittle. However, that’s more than a little fix and I don’t have time to work on that now, unfortunately.
Anyway, I looked the #558 and did not realize that this is a dublicate, but with your links I now realize that, so I’ll close this issue.
Fixed in #1135.