Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-gwcs for openSUSE:Factory 
checked in at 2022-10-28 19:30:18
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-gwcs (Old)
 and      /work/SRC/openSUSE:Factory/.python-gwcs.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-gwcs"

Fri Oct 28 19:30:18 2022 rev:9 rq:1031604 version:0.18.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-gwcs/python-gwcs.changes  2022-03-17 
17:01:51.825702135 +0100
+++ /work/SRC/openSUSE:Factory/.python-gwcs.new.2275/python-gwcs.changes        
2022-10-28 19:30:41.858982562 +0200
@@ -1,0 +2,11 @@
+Thu Oct 27 17:04:18 UTC 2022 - Ben Greiner <c...@bnavigator.de>
+
+- Update to 0.18.2
+  * Corrected the reported requested forward SIP accuracy and
+    reported fit residuals by to_fits_sip() and to_fits(). [#413,
+    #419]
+  * Fixed a bug due to which the check for divergence in
+    _fit_2D_poly() and hence in to_fits() and to_fits_sip() was
+    ignored. [#414]
+
+-------------------------------------------------------------------

Old:
----
  gwcs-0.18.1.tar.gz

New:
----
  gwcs-0.18.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-gwcs.spec ++++++
--- /var/tmp/diff_new_pack.Ve2J06/_old  2022-10-28 19:30:42.394985250 +0200
+++ /var/tmp/diff_new_pack.Ve2J06/_new  2022-10-28 19:30:42.402985291 +0200
@@ -16,10 +16,8 @@
 #
 
 
-%{?!python_module:%define python_module() python3-%{**}}
-%define skip_python2 1
 Name:           python-gwcs
-Version:        0.18.1
+Version:        0.18.2
 Release:        0
 Summary:        Generalized World Coordinate System
 License:        BSD-3-Clause
@@ -29,8 +27,8 @@
 BuildRequires:  %{python_module asdf >= 2.8.1}
 BuildRequires:  %{python_module asdf-astropy >= 0.2.0}
 BuildRequires:  %{python_module asdf_wcs_schemas}
-BuildRequires:  %{python_module astropy >= 4.1}
-BuildRequires:  %{python_module base >= 3.6}
+BuildRequires:  %{python_module astropy >= 5.1}
+BuildRequires:  %{python_module base >= 3.8}
 BuildRequires:  %{python_module numpy}
 BuildRequires:  %{python_module scipy}
 BuildRequires:  %{python_module setuptools_scm}
@@ -40,7 +38,7 @@
 Requires:       python-asdf >= 2.8.1
 Requires:       python-asdf-astropy >= 0.2.0
 Requires:       python-asdf_wcs_schemas
-Requires:       python-astropy >= 4.1
+Requires:       python-astropy >= 5.1
 Requires:       python-numpy
 Requires:       python-scipy
 BuildArch:      noarch

++++++ gwcs-0.18.1.tar.gz -> gwcs-0.18.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/CHANGES.rst new/gwcs-0.18.2/CHANGES.rst
--- old/gwcs-0.18.1/CHANGES.rst 2022-03-15 16:23:14.000000000 +0100
+++ new/gwcs-0.18.2/CHANGES.rst 2022-09-07 19:01:21.000000000 +0200
@@ -1,3 +1,17 @@
+0.18.2 (2022-09-07)
+-------------------
+Bug Fixes
+^^^^^^^^^
+
+- Corrected the reported requested forward SIP accuracy and reported fit
+  residuals by ``to_fits_sip()`` and ``to_fits()``. [#413, #419]
+
+- Fixed a bug due to which the check for divergence in ``_fit_2D_poly()`` and
+  hence in ``to_fits()`` and ``to_fits_sip()`` was ignored. [#414]
+
+New Features
+^^^^^^^^^^^^
+
 0.18.1 (2022-03-15)
 -------------------
 Bug Fixes
@@ -13,6 +27,10 @@
 - Updated code in ``region.py`` with latest improvements and bug fixes
   from ``stsci.skypac.regions.py`` [#382]
 
+- Added support to ``_compute_lon_pole()`` for computation of ``lonpole``
+  for all projections from ``astropy.modeling.projections``. This also
+  extends support for different projections in ``wcs_from_fiducial()``. [#389]
+
 New Features
 ^^^^^^^^^^^^
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/PKG-INFO new/gwcs-0.18.2/PKG-INFO
--- old/gwcs-0.18.1/PKG-INFO    2022-03-15 16:23:23.236593700 +0100
+++ new/gwcs-0.18.2/PKG-INFO    2022-09-07 19:01:34.642974100 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: gwcs
-Version: 0.18.1
+Version: 0.18.2
 Summary: Generalized World Coordinate System
 Home-page: https://github.com/spacetelescope/gwcs
 Author: gwcs developers
@@ -9,10 +9,8 @@
 Project-URL: Tracker, https://github.com/spacetelescope/gwcs/issues
 Project-URL: Documentation, https://gwcs.readthedocs.io/en/stable/
 Project-URL: Source Code, https://github.com/spacetelescope/jwst
-Platform: UNKNOWN
-Requires-Python: >=3.6
+Requires-Python: >=3.8
 Provides-Extra: docs
 Provides-Extra: test
 
 Tools for managing the WCS of astronomical observations in a general 
(non-FITS) way
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/docs/index.rst 
new/gwcs-0.18.2/docs/index.rst
--- old/gwcs-0.18.1/docs/index.rst      2022-03-15 16:23:14.000000000 +0100
+++ new/gwcs-0.18.2/docs/index.rst      2022-09-07 19:01:21.000000000 +0200
@@ -1,3 +1,5 @@
+.. _gwcs:
+
 GWCS Documentation
 ==================
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/api.py new/gwcs-0.18.2/gwcs/api.py
--- old/gwcs-0.18.1/gwcs/api.py 2022-03-15 16:23:14.000000000 +0100
+++ new/gwcs-0.18.2/gwcs/api.py 2022-09-07 19:01:21.000000000 +0200
@@ -312,10 +312,15 @@
         Convert world coordinates to pixel values.
         """
         result = self.invert(*world_objects, with_units=True)
-        if not utils.isnumerical(result[0]):
-            result = [i.value for i in result]
-        if self.input_frame.naxes == 1:
-            return result[0]
+
+        if self.input_frame.naxes > 1:
+            first_res = result[0]
+            if not utils.isnumerical(first_res):
+                result = [i.value for i in result]
+        else:
+            if not utils.isnumerical(result):
+                result = result.value
+
         return result
 
     def world_to_array_index(self, *world_objects):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/converters/tests/test_wcs.py 
new/gwcs-0.18.2/gwcs/converters/tests/test_wcs.py
--- old/gwcs-0.18.1/gwcs/converters/tests/test_wcs.py   2022-03-15 
16:23:14.000000000 +0100
+++ new/gwcs-0.18.2/gwcs/converters/tests/test_wcs.py   2022-09-07 
19:01:21.000000000 +0200
@@ -2,7 +2,6 @@
 # -*- coding: utf-8 -*-
 import os.path
 import pytest
-import warnings
 
 astropy = pytest.importorskip('astropy', minversion='3.0')
 
@@ -103,12 +102,6 @@
 def create_test_frames():
     """Creates an array of frames to be used for testing."""
 
-    # Suppress warnings from astropy that are caused by having 'dubious' dates
-    # that are too far in the future. It's not a concern for the purposes of
-    # unit tests. See issue #5809 on the astropy GitHub for discussion.
-    from astropy._erfa import ErfaWarning
-    warnings.simplefilter("ignore", ErfaWarning)
-
     frames = [
         cf.CelestialFrame(reference_frame=coord.ICRS()),
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/coordinate_frames.py 
new/gwcs-0.18.2/gwcs/coordinate_frames.py
--- old/gwcs-0.18.1/gwcs/coordinate_frames.py   2022-03-15 16:23:14.000000000 
+0100
+++ new/gwcs-0.18.2/gwcs/coordinate_frames.py   2022-09-07 19:01:21.000000000 
+0200
@@ -280,6 +280,8 @@
     def coordinates(self, *args):
         """ Create world coordinates object"""
         coo = tuple([arg * un if not hasattr(arg, "to") else arg.to(un) for 
arg, un in zip(args, self.unit)])
+        if self.naxes == 1:
+            return coo[0]
         return coo
 
     def coordinate_to_quantity(self, *coords):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/tests/test_api.py 
new/gwcs-0.18.2/gwcs/tests/test_api.py
--- old/gwcs-0.18.1/gwcs/tests/test_api.py      2022-03-15 16:23:14.000000000 
+0100
+++ new/gwcs-0.18.2/gwcs/tests/test_api.py      2022-09-07 19:01:21.000000000 
+0200
@@ -10,7 +10,9 @@
 from astropy import time
 from astropy import coordinates as coord
 from astropy.wcs.wcsapi import HighLevelWCSWrapper
+import astropy.modeling.models as m
 import gwcs.coordinate_frames as cf
+import gwcs
 
 
 # Shorthand the name of the 2d gwcs fixture
@@ -492,3 +494,21 @@
 
     assert len(wao_components) == 2
     assert not {c[0] for c in wao_components}.difference({"SPATIAL", 
"SPATIAL1"})
+
+
+def test_coordinate_frame_api():
+    forward = m.Linear1D(slope=0.1*u.deg/u.pix, intercept=0*u.deg)
+
+    output_frame = cf.CoordinateFrame(1, "SPATIAL", (0,), unit=(u.deg,), 
name="sepframe")
+    input_frame = cf.CoordinateFrame(1, "PIXEL", (0,), unit=(u.pix,))
+
+    wcs = gwcs.WCS(forward_transform=forward, input_frame=input_frame, 
output_frame=output_frame)
+
+    world = wcs.pixel_to_world(0)
+    assert isinstance(world, u.Quantity)
+
+    pixel = wcs.world_to_pixel(world)
+    assert isinstance(pixel, float)
+
+    pixel2 = wcs.invert(world)
+    assert u.allclose(pixel2, 0*u.pix)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/tests/test_api_slicing.py 
new/gwcs-0.18.2/gwcs/tests/test_api_slicing.py
--- old/gwcs-0.18.1/gwcs/tests/test_api_slicing.py      2022-03-15 
16:23:14.000000000 +0100
+++ new/gwcs-0.18.2/gwcs/tests/test_api_slicing.py      2022-09-07 
19:01:21.000000000 +0200
@@ -1,6 +1,7 @@
+
 import astropy.units as u
 from astropy.coordinates import Galactic, SkyCoord, SpectralCoord
-from astropy.wcs.wcsapi.sliced_low_level_wcs import SlicedLowLevelWCS
+from astropy.wcs.wcsapi.wrappers import SlicedLowLevelWCS
 from numpy.testing import assert_allclose, assert_equal
 
 EXPECTED_ELLIPSIS_REPR = """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/tests/test_utils.py 
new/gwcs-0.18.2/gwcs/tests/test_utils.py
--- old/gwcs-0.18.1/gwcs/tests/test_utils.py    2022-03-15 16:23:14.000000000 
+0100
+++ new/gwcs-0.18.2/gwcs/tests/test_utils.py    2022-09-07 19:01:21.000000000 
+0200
@@ -35,13 +35,15 @@
 def test_lon_pole():
     tan = models.Pix2Sky_TAN()
     car = models.Pix2Sky_CAR()
+    azp = models.Pix2Sky_AZP(mu=-1.35, gamma=25.8458)
     sky_positive_lat = coord.SkyCoord(3 * u.deg, 1 * u.deg)
     sky_negative_lat = coord.SkyCoord(3 * u.deg, -1 * u.deg)
     assert_quantity_allclose(gwutils._compute_lon_pole(sky_positive_lat, tan), 
180 * u.deg)
     assert_quantity_allclose(gwutils._compute_lon_pole(sky_negative_lat, tan), 
180 * u.deg)
     assert_quantity_allclose(gwutils._compute_lon_pole(sky_positive_lat, car), 
0 * u.deg)
     assert_quantity_allclose(gwutils._compute_lon_pole(sky_negative_lat, car), 
180 * u.deg)
-    assert_quantity_allclose(gwutils._compute_lon_pole((0, 34 * u.rad), tan), 
180 * u.deg)
+    assert_quantity_allclose(gwutils._compute_lon_pole((0, 0.34 * u.rad), 
tan), 180 * u.deg)
+    assert_quantity_allclose(gwutils._compute_lon_pole((1 * u.rad, 0.34 * 
u.rad), azp), 180 * u.deg)
     assert_allclose(gwutils._compute_lon_pole((1, -34), tan), 180)
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/tests/test_wcs.py 
new/gwcs-0.18.2/gwcs/tests/test_wcs.py
--- old/gwcs-0.18.1/gwcs/tests/test_wcs.py      2022-03-15 16:23:14.000000000 
+0100
+++ new/gwcs-0.18.2/gwcs/tests/test_wcs.py      2022-09-07 19:01:21.000000000 
+0200
@@ -32,9 +32,9 @@
 spec = cf.SpectralFrame(name='wave', unit=[u.m, ], axes_order=(2, ), 
axes_names=('lambda', ))
 time = cf.TemporalFrame(name='time', unit=[u.s, ], axes_order=(3, ), 
axes_names=('time', ), reference_frame=Time("2020-01-01"))
 
-pipe = [(detector, m1),
-        (focal, m2),
-        (icrs, None)
+pipe = [wcs.Step(detector, m1),
+        wcs.Step(focal, m2),
+        wcs.Step(icrs, None)
         ]
 
 # Create some data.
@@ -75,15 +75,19 @@
     gw = wcs.WCS(output_frame='icrs')
     assert len(gw._pipeline) == 2
     assert gw.pipeline[0].frame == "detector"
-    assert gw.pipeline[0][0] == "detector"
+    with pytest.warns(DeprecationWarning, match="Indexing a WCS.pipeline step 
is deprecated."):
+        assert gw.pipeline[0][0] == "detector"
     assert gw.pipeline[1].frame == "icrs"
-    assert gw.pipeline[1][0] == "icrs"
+    with pytest.warns(DeprecationWarning, match="Indexing a WCS.pipeline step 
is deprecated."):
+        assert gw.pipeline[1][0] == "icrs"
     assert np.in1d(gw.available_frames, ['detector', 'icrs']).all()
     gw = wcs.WCS(output_frame=icrs, input_frame=detector)
     assert gw._pipeline[0].frame == "detector"
-    assert gw._pipeline[0][0] == "detector"
+    with pytest.warns(DeprecationWarning, match="Indexing a WCS.pipeline step 
is deprecated."):
+        assert gw._pipeline[0][0] == "detector"
     assert gw._pipeline[1].frame == "icrs"
-    assert gw._pipeline[1][0] == "icrs"
+    with pytest.warns(DeprecationWarning, match="Indexing a WCS.pipeline step 
is deprecated."):
+        assert gw._pipeline[1][0] == "icrs"
     assert np.in1d(gw.available_frames, ['detector', 'icrs']).all()
     with pytest.raises(NotImplementedError):
         gw(1, 2)
@@ -154,7 +158,7 @@
     x, y = 1, 2
     fx, fy = tr_forward(1, 2)
     assert_allclose(w.pipeline[0].transform(x, y), (fx, fy))
-    assert_allclose(w.pipeline[0][1](x, y), (fx, fy))
+    assert_allclose(w.pipeline[0].transform(x, y), (fx, fy))
     assert_allclose((x, y), tr_back(*w(x, y)))
     assert(w.get_transform('detector', 'detector') is None)
 
@@ -368,9 +372,14 @@
 def test_wcs_from_points():
     np.random.seed(0)
     hdr = fits.Header.fromtextfile(get_pkg_data_filename("data/acs.hdr"), 
endcard=False)
-    with warnings.catch_warnings() as w:
-        warnings.simplefilter("ignore")
+    with pytest.warns(astwcs.FITSFixedWarning) as caught_warnings:
+        # this raises a warning unimportant for this testing the pix2world
+        #   FITSFixedWarning(u'The WCS transformation has more axes (2) than
+        #        the image it is associated with (0)')
+        #   FITSFixedWarning: 'datfix' made the change
+        #       'Set MJD-OBS to 53436.000000 from DATE-OBS'. [astropy.wcs.wcs]
         w = astwcs.WCS(hdr)
+        assert len(caught_warnings) == 2
     y, x = np.mgrid[:2046:20j, :4023:10j]
     ra, dec = w.wcs_pix2world(x, y, 1)
     fiducial = coord.SkyCoord(ra.mean()*u.deg, dec.mean()*u.deg, frame="icrs")
@@ -517,7 +526,14 @@
 class TestImaging(object):
     def setup_class(self):
         hdr = fits.Header.fromtextfile(get_pkg_data_filename("data/acs.hdr"), 
endcard=False)
-        self.fitsw = astwcs.WCS(hdr)
+        with pytest.warns(astwcs.FITSFixedWarning) as caught_warnings:
+            # this raises a warning unimportant for this testing the pix2world
+            #   FITSFixedWarning(u'The WCS transformation has more axes (2) 
than
+            #        the image it is associated with (0)')
+            #   FITSFixedWarning: 'datfix' made the change
+            #       'Set MJD-OBS to 53436.000000 from DATE-OBS'. 
[astropy.wcs.wcs]
+            self.fitsw = astwcs.WCS(hdr)
+            assert len(caught_warnings) == 2
         a_coeff = hdr['A_*']
         a_order = a_coeff.pop('A_ORDER')
         b_coeff = hdr['B_*']
@@ -544,9 +560,9 @@
         sky_cs = cf.CelestialFrame(reference_frame=coord.ICRS(), name='sky')
         det = cf.Frame2D(name='detector')
         wcs_forward = wcslin | tan | n2c
-        pipeline = [('detector', distortion),
-                    ('focal', wcs_forward),
-                    (sky_cs, None)
+        pipeline = [wcs.Step('detector', distortion),
+                    wcs.Step('focal', wcs_forward),
+                    wcs.Step(sky_cs, None)
                     ]
 
         self.wcs = wcs.WCS(input_frame=det,
@@ -555,7 +571,6 @@
 
         self.xv, self.yv = xv, yv
 
-    @pytest.mark.filterwarnings('ignore')
     def test_distortion(self):
         sipx, sipy = self.fitsw.sip_pix2foc(self.xv, self.yv, 1)
         sipx = np.array(sipx) + 2048
@@ -759,7 +774,11 @@
     assert fw_hdr[f'CTYPE{ra_axis}'] == 'RA---TAN'
     assert fw_hdr['WCSAXES'] == 2
 
-    fw = astwcs.WCS(fw_hdr)
+    with pytest.warns(astwcs.FITSFixedWarning, match='The WCS transformation 
has more axes'):
+        # this raises a warning unimportant for this testing the pix2world
+        #   FITSFixedWarning(u'The WCS transformation has more axes (3) than
+        #        the image it is associated with (2)')
+        fw = astwcs.WCS(fw_hdr)
     gskyval = w(1, 45, 55)[1:]
     assert np.allclose(gskyval, fw.all_pix2world([[1, 45, 55]], 0)[0][1:])
 
@@ -805,8 +824,7 @@
     assert np.allclose(w(x, y, z), fits_wcs_user_bb.wcs_pix2world(x, y, z, 0),
                        rtol=1e-6, atol=1e-7)
 
-
-@pytest.mark.skip(reason="Fails round-trip for -TAB axis 5")
+@pytest.mark.filterwarnings('ignore:.*The WCS transformation has more axes.*')
 def test_to_fits_tab_7d(gwcs_7d_complex_mapping):
     # gWCS:
     w = gwcs_7d_complex_mapping
@@ -874,7 +892,11 @@
     w = gwcs_spec_cel_time_4d
 
     # create FITS headers and -TAB headers
-    hdr, _ = w.to_fits(degree=3)
+    with pytest.warns(UserWarning, match='SIP distortion is not supported when 
the number'):
+        # UserWarning: SIP distortion is not supported when the number
+        # of axes in WCS is larger than 2. Setting 'degree'
+        # to 1 and 'max_inv_pix_error' to None.
+        hdr, _ = w.to_fits(degree=3)
 
     # check that FITS WCS is not using SIP
     assert not hdr['?_ORDER']
@@ -982,6 +1004,7 @@
     hdulist = fits.HDUList(
         [fits.PrimaryHDU(np.ones(w.pixel_n_dim * (2, )), hdr), bt]
     )
+
     fits_wcs = astwcs.WCS(hdulist[0].header, hdulist)
 
     # test points:
@@ -1004,7 +1027,11 @@
     hdulist = fits.HDUList(
         [fits.PrimaryHDU(np.ones(w.pixel_n_dim * (2, )), hdr), bt[0]]
     )
-    fits_wcs = astwcs.WCS(hdulist[0].header, hdulist)
+    with pytest.warns(astwcs.FITSFixedWarning, match='The WCS transformation 
has more axes'):
+        # this raises a warning unimportant for this testing the pix2world
+        #   FITSFixedWarning(u'The WCS transformation has more axes (3) than
+        #        the image it is associated with (2)')
+        fits_wcs = astwcs.WCS(hdulist[0].header, hdulist)
 
     # test points:
     (xmin, xmax), (ymin, ymax) = w.bounding_box
@@ -1181,12 +1208,11 @@
     assert all(u.allclose(u.Quantity(b), [0, 2] * u.pix) for b in bb)
 
 
-@pytest.mark.filterwarnings("error:.*Indexing a WCS.pipeline step is 
deprecated.*:DeprecationWarning")
 def test_initialize_wcs_with_list():
     # test that you can initialize a wcs with a pipeline that is a list
     # containing both Step() and (frame, transform) tuples
 
-    # make pipline consisting of tuples and Steps
+    # make pipeline consisting of tuples and Steps
     shift1 = models.Shift(10 * u .pix) & models.Shift(2 * u.pix)
     shift2 = models.Shift(3 * u.pix)
     pipeline = [('detector', shift1), wcs.Step('extra_step', shift2)]
@@ -1195,4 +1221,6 @@
     pipeline.append(extra_step)
 
     # make sure no warnings occur when creating wcs with this pipeline
-    wcs.WCS(pipeline)
+    with warnings.catch_warnings():
+        warnings.simplefilter("error")
+        wcs.WCS(pipeline)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/utils.py 
new/gwcs-0.18.2/gwcs/utils.py
--- old/gwcs-0.18.1/gwcs/utils.py       2022-03-15 16:23:14.000000000 +0100
+++ new/gwcs-0.18.2/gwcs/utils.py       2022-09-07 19:01:21.000000000 +0200
@@ -12,6 +12,7 @@
 from astropy import coordinates as coords
 from astropy import units as u
 from astropy.time import Time, TimeDelta
+from astropy.wcs import Celprm
 
 
 # these ctype values do not include yzLN and yzLT pairs
@@ -94,50 +95,61 @@
 
 def _compute_lon_pole(skycoord, projection):
     """
-    Compute the longitude of the celestial pole of a standard frame in the
-    native frame.
+    Compute the longitude of the celestial pole of a standard
+    frame in the native frame.
 
-    This angle then can be used as one of the Euler angles (the other two 
being skyccord)
-    to rotate the native frame into the standard frame ``skycoord.frame``.
+    This angle then can be used as one of the Euler angles
+    (the other two being skycoord) to rotate the native frame into the
+    standard frame ``skycoord.frame``.
 
     Parameters
     ----------
     skycoord : `astropy.coordinates.SkyCoord`, or
                sequence of floats or `~astropy.units.Quantity` of length 2
-        The fiducial point of the native coordinate system.
-        If tuple, its length is 2
+        The celestial longitude and latitude of the fiducial point - typically
+        right ascension and declination. These are given by the ``CRVALia``
+        keywords in ``FITS``.
+
     projection : `astropy.modeling.projections.Projection`
-        A Projection instance.
+        A `~astropy.modeling.projections.Projection` model instance.
 
     Returns
     -------
-    lon_pole : float or `~astropy/units.Quantity`
-        Native longitude of the celestial pole [deg].
+    lonpole : float or `~astropy/units.Quantity`
+        Native longitude of the celestial pole in degrees.
 
-    TODO: Implement all projections
-        Currently this only supports Zenithal and Cylindrical.
     """
     if isinstance(skycoord, coords.SkyCoord):
-        lat = skycoord.spherical.lat
+        lon = skycoord.spherical.lon.value
+        lat = skycoord.spherical.lat.value
         unit = u.deg
+
     else:
         lon, lat = skycoord
+        unit = None
+        if isinstance(lon, u.Quantity):
+            lon = lon.to(u.deg).to_value()
+            unit = u.deg
+
         if isinstance(lat, u.Quantity):
+            lat = lat.to(u.deg).to_value()
             unit = u.deg
-        else:
-            unit = None
-    if isinstance(projection, projections.Zenithal):
-        lon_pole = 180
-    elif isinstance(projection, projections.Cylindrical):
-        if lat >= 0:
-            lon_pole = 0
-        else:
-            lon_pole = 180
-    else:
-        raise UnsupportedProjectionError("Projection {0} is not 
supported.".format(projection))
+
+    cel = Celprm()
+    cel.ref = [lon, lat]
+    cel.prj.code = projection.prjprm.code
+    pvrange = projection.prjprm.pvrange
+    if pvrange:
+        i1 = pvrange // 100
+        i2 = i1 + (pvrange % 100) + 1
+        cel.prj.pv = i1 * [None] + list(projection.prjprm.pv[i1:i2])
+    cel.set()
+
+    lonpole = cel.ref[2]
     if unit is not None:
-        lon_pole = lon_pole * unit
-    return lon_pole
+        lonpole = lonpole * unit
+
+    return lonpole
 
 
 def get_projcode(wcs_info):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs/wcs.py new/gwcs-0.18.2/gwcs/wcs.py
--- old/gwcs-0.18.1/gwcs/wcs.py 2022-03-15 16:23:14.000000000 +0100
+++ new/gwcs-0.18.2/gwcs/wcs.py 2022-09-07 19:01:21.000000000 +0200
@@ -480,8 +480,9 @@
 
         Returns
         -------
-        result : tuple
-            Returns a tuple of scalar or array values for each axis.
+        result : tuple or value
+            Returns a tuple of scalar or array values for each axis. Unless
+            ``input_frame.naxes == 1`` when it shall return the value.
 
         """
         with_units = kwargs.pop('with_units', False)
@@ -1826,12 +1827,11 @@
         yx, yy = ntransform(0, 1)
         pixarea = np.abs((xx - x0) * (yy - y0) - (xy - y0) * (yx - x0))
         plate_scale = np.sqrt(pixarea)
-        max_error = max_pix_error * plate_scale
 
         # The fitting section.
         fit_poly_x, fit_poly_y, max_resid = _fit_2D_poly(
             ntransform, npoints,
-            degree, max_error,
+            degree, max_pix_error, plate_scale,
             u, v, undist_x, undist_y,
             ud, vd, undist_xd, undist_yd,
             verbose=verbose
@@ -1851,7 +1851,7 @@
         if max_inv_pix_error:
             fit_inv_poly_u, fit_inv_poly_v, max_inv_resid = 
_fit_2D_poly(ntransform,
                                                             npoints, 
inv_degree,
-                                                            max_inv_pix_error,
+                                                            max_inv_pix_error, 
1,
                                                             U, V, u-U, v-V,
                                                             Ud, Vd, ud-Ud, 
vd-Vd,
                                                             verbose=verbose)
@@ -1885,7 +1885,7 @@
             hdr['B_ORDER'] = fit_poly_x.degree
             _store_2D_coefficients(hdr, sip_poly_x, 'A')
             _store_2D_coefficients(hdr, sip_poly_y, 'B')
-            hdr['sipmxerr'] = (max_resid * plate_scale, 'Max diff from GWCS 
(equiv pix).')
+            hdr['sipmxerr'] = (max_resid, 'Max diff from GWCS (equiv pix).')
 
             if max_inv_pix_error:
                 hdr['AP_ORDER'] = fit_inv_poly_u.degree
@@ -1926,7 +1926,7 @@
                 mat_kind = 'CD'
                 del hdr['CDELT?']
 
-            hdr['sipmxerr'] = (max_resid * plate_scale, 'Max diff from GWCS 
(equiv pix).')
+            hdr['sipmxerr'] = (max_resid, 'Max diff from GWCS (equiv pix).')
 
         # Construct CD matrix while remapping input axes.
         # We do not update comments to typical comments for CD matrix elements
@@ -2742,7 +2742,7 @@
         fit_inv_poly_u, fit_inv_poly_v, max_inv_resid = _fit_2D_poly(
             ntransform,
             npoints, None,
-            max_inv_pix_error,
+            max_inv_pix_error, 1,
             undist_x, undist_y, u, v,
             undist_xd, undist_yd, ud, vd,
             verbose=True
@@ -2754,7 +2754,7 @@
                                 (Shift(crpix[0]) & Shift(crpix[1])))
 
 
-def _fit_2D_poly(ntransform, npoints, degree, max_error,
+def _fit_2D_poly(ntransform, npoints, degree, max_error, plate_scale,
                  xin, yin, xout, yout,
                  xind, yind, xoutd, youtd,
                  verbose=False):
@@ -2779,7 +2779,9 @@
 
     prev_max_error = float(np.inf)
     if verbose:
-        print(f'maximum_specified_error: {max_error}')
+        print(f'Maximum_specified_error: {max_error}')
+    max_error *= plate_scale
+
     for deg in deglist:
         poly_x = Polynomial2D(degree=deg)
         poly_y = Polynomial2D(degree=deg)
@@ -2790,20 +2792,23 @@
                                                fit_poly_y(xin, yin))
         if max_resid > prev_max_error:
             raise RuntimeError('Failed to achieve required error tolerance')
+        prev_max_error = max_resid
+
         if verbose:
-            print(f'Degree = {deg}, max_resid = {max_resid}')
+            print(f'Degree = {deg}, max_resid = {max_resid / plate_scale}')
         if max_resid < max_error:
             # Check to see if double sampling meets error requirement.
             max_resid = _compute_distance_residual(xoutd, youtd,
                                                    fit_poly_x(xind, yind),
                                                    fit_poly_y(xind, yind))
             if verbose:
-                print(f'Double sampling check: maximum residual={max_resid}')
+                print(f'Double sampling check: maximum residual={max_resid / 
plate_scale}')
             if max_resid < max_error:
                 if verbose:
-                    print('terminating condition met')
+                    print('Terminating condition met')
                 break
-    return fit_poly_x, fit_poly_y, max_resid
+
+    return fit_poly_x, fit_poly_y, max_resid / plate_scale
 
 
 def _make_sampling_grid(npoints, bounding_box, crpix):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs.egg-info/PKG-INFO 
new/gwcs-0.18.2/gwcs.egg-info/PKG-INFO
--- old/gwcs-0.18.1/gwcs.egg-info/PKG-INFO      2022-03-15 16:23:22.000000000 
+0100
+++ new/gwcs-0.18.2/gwcs.egg-info/PKG-INFO      2022-09-07 19:01:34.000000000 
+0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: gwcs
-Version: 0.18.1
+Version: 0.18.2
 Summary: Generalized World Coordinate System
 Home-page: https://github.com/spacetelescope/gwcs
 Author: gwcs developers
@@ -9,10 +9,8 @@
 Project-URL: Tracker, https://github.com/spacetelescope/gwcs/issues
 Project-URL: Documentation, https://gwcs.readthedocs.io/en/stable/
 Project-URL: Source Code, https://github.com/spacetelescope/jwst
-Platform: UNKNOWN
-Requires-Python: >=3.6
+Requires-Python: >=3.8
 Provides-Extra: docs
 Provides-Extra: test
 
 Tools for managing the WCS of astronomical observations in a general 
(non-FITS) way
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/gwcs.egg-info/requires.txt 
new/gwcs-0.18.2/gwcs.egg-info/requires.txt
--- old/gwcs-0.18.1/gwcs.egg-info/requires.txt  2022-03-15 16:23:23.000000000 
+0100
+++ new/gwcs-0.18.2/gwcs.egg-info/requires.txt  2022-09-07 19:01:34.000000000 
+0200
@@ -1,5 +1,5 @@
 asdf>=2.8.1
-astropy>=4.1
+astropy>=5.1
 numpy
 scipy
 asdf_wcs_schemas
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gwcs-0.18.1/setup.cfg new/gwcs-0.18.2/setup.cfg
--- old/gwcs-0.18.1/setup.cfg   2022-03-15 16:23:23.236593700 +0100
+++ new/gwcs-0.18.2/setup.cfg   2022-09-07 19:01:34.642974100 +0200
@@ -14,12 +14,12 @@
 
 [options]
 zip_safe = False
-python_requires = >=3.6
+python_requires = >=3.8
 setup_requires = 
        setuptools_scm
 install_requires = 
        asdf >= 2.8.1
-       astropy >= 4.1
+       astropy >= 5.1
        numpy
        scipy
        asdf_wcs_schemas

Reply via email to