-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi.
I'm getting the following error when trying to use sip_tpv.sip_to_tpv()
`LinAlgError Traceback (most recent call last)
in
----> 1 sip_tpv.sip_to_pv(header)
~/.local/lib/python3.10/site-packages/sip_tpv/sip_to_pv.py in sip_to_pv(header, tpv_format, preserve)
56 pvrange, tpvx, tpvy = sym_tpvexprs()
57 cd, ac, bc = get_sip_keywords(header)
---> 58 sipx, sipy = real_sipexprs(cd, ac, bc)
59 add_pv_keywords(header, sipx, sipy, pvrange, tpvx, tpvy,
60 int(header['B_ORDER']))
~/.local/lib/python3.10/site-packages/sip_tpv/pvsiputils.py in real_sipexprs(cd, ac, bc)
262 """
263 x, y = symbols("x y")
--> 264 cdinverse = cd**-1
265 uprime, vprime = cdinverse*Matrix([x, y])
266 usum = uprime
~/.local/lib/python3.10/site-packages/numpy/matrixlib/defmatrix.py in pow(self, other)
229
230 def pow(self, other):
--> 231 return matrix_power(self, other)
232
233 def ipow(self, other):
~/.local/lib/python3.10/site-packages/numpy/core/overrides.py in matrix_power(*args, **kwargs)
~/.local/lib/python3.10/site-packages/numpy/linalg/linalg.py in matrix_power(a, n)
648
649 elif n < 0:
--> 650 a = inv(a)
651 n = abs(n)
652
~/.local/lib/python3.10/site-packages/numpy/core/overrides.py in inv(*args, **kwargs)
~/.local/lib/python3.10/site-packages/numpy/linalg/linalg.py in inv(a)
550 signature = 'D->D' if isComplexType(t) else 'd->d'
551 extobj = get_linalg_error_extobj(_raise_linalgerror_singular)
--> 552 ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
553 return wrap(ainv.astype(result_t, copy=False))
554
~/.local/lib/python3.10/site-packages/numpy/linalg/linalg.py in _raise_linalgerror_singular(err, flag)
87
88 def _raise_linalgerror_singular(err, flag):
---> 89 raise LinAlgError("Singular matrix")
90
91 def _raise_linalgerror_nonposdef(err, flag):
LinAlgError: Singular matrix
`
This arrises using the attached header.
Steps to reproduce:
header.txt
from sip_tpv import sip_to_tpv
from astropy.io import fits
header = fits.Header.fromtextfile('header.txt')
sip_to_pv(header)The header was generated using the wcs.utils.fit_wcs_from_points function in astropy. Then writing that wcs object to header using the "relax=True" parameter (in order to actually write the keywords to the header)
Any ideas as to what is causing the crash? Am I just not running it correctly?
Thanks in advanced.