Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singular matrix in PixelGrid.reflux #36

Closed
rmjarvis opened this issue Sep 7, 2016 · 1 comment
Closed

Singular matrix in PixelGrid.reflux #36

rmjarvis opened this issue Sep 7, 2016 · 1 comment
Milestone

Comments

@rmjarvis
Copy link
Owner

rmjarvis commented Sep 7, 2016

Sometimes the PixelGrid matrix solution will involve a singular matrix according to numpy.linalg:

Building SimplePSF
Iteration 1: Fitting 367 stars
             Total chisq = 341418.36 / 89248 dof
Iteration 2: Fitting 367 stars
             Removed 3 outliers
             Total chisq = 42972.41 / 88515 dof
Iteration 3: Fitting 364 stars
             Removed 3 outliers
             Total chisq = 27166.78 / 87793 dof
Iteration 4: Fitting 361 stars
             Removed 3 outliers
             Total chisq = 23088.40 / 87059 dof
Iteration 5: Fitting 358 stars
             Removed 3 outliers
             Total chisq = 21235.73 / 86318 dof
Iteration 6: Fitting 355 stars
             Removed 2 outliers
             Total chisq = 20214.33 / 85828 dof
Iteration 7: Fitting 353 stars
ERROR: LinAlgError: Singular matrix [numpy.linalg.linalg]
Traceback (most recent call last):
  File "/astro/u/mjarvis/bin/piffify", line 5, in <module>
    pkg_resources.run_script('Piff==0.1', 'piffify')
  File "/opt/astro/SL64/anaconda/lib/python2.7/site-packages/pkg_resources.py", line 505, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/opt/astro/SL64/anaconda/lib/python2.7/site-packages/pkg_resources.py", line 1245, in run_script
    execfile(script_filename, namespace, namespace)
  File "/direct/astro+u/mjarvis/lib/python2.7/site-packages/Piff-0.1-py2.7.egg/EGG-INFO/scripts/piffify", line 93, in <module>
    main()
  File "/direct/astro+u/mjarvis/lib/python2.7/site-packages/Piff-0.1-py2.7.egg/EGG-INFO/scripts/piffify", line 90, in main
    piff.piffify(config, logger)
  File "/astro/u/mjarvis/lib/python2.7/site-packages/Piff-0.1-py2.7.egg/piff/config.py", line 130, in piffify
    psf.fit(stars, wcs, pointing, logger=logger)
  File "/astro/u/mjarvis/lib/python2.7/site-packages/Piff-0.1-py2.7.egg/piff/simplepsf.py", line 151, in fit
    for s in self.stars]
  File "/astro/u/mjarvis/lib/python2.7/site-packages/Piff-0.1-py2.7.egg/piff/pixelgrid.py", line 633, in reflux
    df = np.linalg.solve(alpha, beta)
  File "/astro/u/mjarvis/.local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 384, in solve
    r = gufunc(a, b, signature=signature, extobj=extobj)
  File "/astro/u/mjarvis/.local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 90, in _raise_linalgerror_singular
    raise LinAlgError("Singular matrix")
numpy.linalg.linalg.LinAlgError: Singular matrix

We should at least guard against this kind of thing and exclude the star that had the problem. (I'll go ahead and do that directly on master.) But probably the better solution would be to figure out why this happens and find a real workaround. Possibly using svd for the solution rather than the normal lud.

@rmjarvis
Copy link
Owner Author

This is already being caught and handled properly. And I'm pretty sure the changes in #88 make this significantly less common.

@rmjarvis rmjarvis added this to the Version 1.0 milestone Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant