diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index f37ea48..646e0af 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -14,9 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - astropy-version: [4.1.*] - python-version: [3.7] - numpy-version: [1.17.4] + python-version: [3.11] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -25,10 +23,8 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install "numpy==$NUMPY_VERSION" - python -m pip install "astropy==$ASTROPY_VERSION" # Non declared build dependencies - python -m pip install Cython + python -m pip install Cython numpy # Tools to benchmark python -m pip install -r requirements.txt # Prefetch as workaround for https://github.com/skyfielders/python-skyfield/issues/262 diff --git a/.gitignore b/.gitignore index 7c8fa0b..cf9ceef 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .pydevproject .settings .idea +.vscode *.html *.pyc *~ diff --git a/coordinates_benchmark/tools/kapteyn.py b/coordinates_benchmark/tools/kapteyn.py deleted file mode 100644 index bb8afad..0000000 --- a/coordinates_benchmark/tools/kapteyn.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst -""" -Coordinate conversions with the kapteyn Python package. - -kapteyn.celestial is very feature-complete and has great docs. -Check this out: - -http://www.astro.rug.nl/software/kapteyn/celestial.html -http://www.astro.rug.nl/software/kapteyn/celestial.html#celestial.sky2sky -http://www.astro.rug.nl/software/kapteyn/celestial.html#celestial.skyparser - -http://www.astro.rug.nl/software/kapteyn/celestialbackground.html -http://www.astro.rug.nl/software/kapteyn/celestialbackground.html#composing-other-transformations -""" -from __future__ import absolute_import, division, print_function - -import numpy as np -from astropy.table import Table -from kapteyn import celestial - -SUPPORTED_SYSTEMS = 'fk5 fk4 icrs galactic ecliptic'.split() - - -def system_spec(system): - """Convert generic system specification tags to Kapteyn specific specification strings.""" - d = dict() - d['fk5'] = 'fk5' - d['fk4'] = 'fk4,J2000_OBS' - d['icrs'] = 'icrs' - d['galactic'] = 'galactic' - d['ecliptic'] = 'ecliptic,J2000' - return str(d[system]) - - -def transform_celestial(coords, systems): - """Convert an array of in_coords from in_system to out_system""" - # Use kapteyn package specific specifiers for in- and out-systems - skyin, skyout = system_spec(systems['in']), system_spec(systems['out']) - - coords = celestial.sky2sky(skyin, skyout, coords['lon'], coords['lat']) - coords = np.array(coords) - - out = Table() - out['lon'] = coords[:, 0] - out['lat'] = coords[:, 1] - - return out diff --git a/coordinates_benchmark/tools/pyslalib.py b/coordinates_benchmark/tools/pyslalib.py deleted file mode 100644 index 6ca9a1a..0000000 --- a/coordinates_benchmark/tools/pyslalib.py +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst -""" -Coordinate conversions with the pyslalib Python package. - -https://github.com/scottransom/pyslalib -""" -from __future__ import absolute_import, division, print_function - -import numpy as np -from astropy.table import Table -from pyslalib import slalib - -SUPPORTED_SYSTEMS = 'fk5 fk4 icrs galactic ecliptic'.split() - - -def transform_celestial(coords, systems): - lons, lats = np.radians(coords['lon']), np.radians(coords['lat']) - - out = Table() - out['lon'] = np.zeros(len(coords), dtype='float64') - out['lat'] = np.zeros(len(coords), dtype='float64') - - for ii, (lon, lat) in enumerate(zip(lons, lats)): - - # First convert to FK5 J2000 in all cases - if systems['in'] == 'fk4': - lon, lat = slalib.sla_fk45z(lon, lat, 2000.0012775136652) - elif systems['in'] == 'icrs': - lon, lat = slalib.sla_hfk5z(lon, lat, 2000)[:2] - elif systems['in'] == 'galactic': - lon, lat = slalib.sla_galeq(lon, lat) - elif systems['in'] == 'ecliptic': - lon, lat = slalib.sla_ecleq(lon, lat, 51544) - - # Now convert from FK5 J2000 to out system - if systems['out'] == 'fk4': - # FK5 -> FK4 at BEPOCH 2000 assuming no proper motion or parallax - lon, lat = slalib.sla_fk54z(lon, lat, 2000.0012775136652)[:2] - elif systems['out'] == 'icrs': - # FK5 -> Hipparcos (i.e. ICRF, which is as close as SLALIB - # gets to ICRS) at epoch 2000 and with no proper motion - lon, lat = slalib.sla_fk5hz(lon, lat, 2000) - elif systems['out'] == 'galactic': - # FK5 -> Galactic - lon, lat = slalib.sla_eqgal(lon, lat) - elif systems['out'] == 'ecliptic': - # FK5 -> Ecliptic at TDB (MJD) 51544 (i.e. J2000) - lon, lat = slalib.sla_eqecl(lon, lat, 51544) - - out[ii]['lon'] = np.degrees(lon) - out[ii]['lat'] = np.degrees(lat) - - return out diff --git a/coordinates_benchmark/tools/pytpm.py b/coordinates_benchmark/tools/pytpm.py deleted file mode 100644 index 3f35cc0..0000000 --- a/coordinates_benchmark/tools/pytpm.py +++ /dev/null @@ -1,60 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst -""" -Coordinate conversions with the pytpm Python package. - -https://github.com/phn/pytpm -http://phn.github.com/pytpm -""" -from __future__ import absolute_import, division, print_function - -import numpy as np -from astropy.table import Table -import pytpm -from pytpm import tpm - -SUPPORTED_SYSTEMS = 'fk5 fk4 galactic ecliptic'.split() - - -def get_state(system): - # The table of TPM states is here - # http://phn.github.com/pytpm/conversions.html#function-convert-convertv6 - - # We set the epoch and equinox to get consistent results with - # astrolib.coords.Position, see Position._set_tpmstate there. - d = dict() - d['fk5'] = dict(state=tpm.TPM_S06, epoch=tpm.J2000, equinox=tpm.J2000) - d['fk4'] = dict(state=tpm.TPM_S05, epoch=tpm.B1950, equinox=tpm.B1950) - d['galactic'] = dict(state=tpm.TPM_S04, epoch=tpm.J2000, equinox=tpm.byear2jd(1958)) - d['ecliptic'] = dict(state=tpm.TPM_S03, epoch=tpm.J2000, equinox=tpm.jyear2jd(1984)) - # d['icrs'] = TPM_S06 - return d[system] - - -def transform_celestial(coords, systems): - # Convert coords to a list of tpm.V6C objects called in_coords - lon, lat = np.radians(coords['lon']), np.radians(coords['lat']) - dummy = np.zeros_like(lon) - in_coords = pytpm.convert.cat2v6(lon, lat, dummy, dummy, dummy, dummy) - - # Do the coordinate transformation - in_state, out_state = get_state(systems['in']), get_state(systems['out']) - out_coords = pytpm.convert.convertv6(in_coords, s1=in_state['state'], s2=out_state['state'], - equinox=in_state['equinox']) # epoch=in_state['epoch'], - - # Maybe we have to precess here fore some systems? - # http://phn.github.com/pytpm/functions.html#pytpm.convert.precessv6 - - #import IPython; IPython.embed(); 1/0 - - # Convert list of tpm.V6C objects out_coords first - # to a list of dicts, then to lon, lat numpy arrays - out_coords = pytpm.convert.v62cat(out_coords) # , C=tpm.CB - lon = np.array([_['alpha'] for _ in out_coords]) - lat = np.array([_['delta'] for _ in out_coords]) - lon, lat = np.degrees(lon), np.degrees(lat) - - out = Table() - out['lon'] = lon - out['lat'] = lat - - return out diff --git a/coordinates_benchmark/utils.py b/coordinates_benchmark/utils.py index 769bb43..534b596 100644 --- a/coordinates_benchmark/utils.py +++ b/coordinates_benchmark/utils.py @@ -25,7 +25,7 @@ for _ in CELESTIAL_CONVERSIONS if _[0] != _[1]] -TOOLS = sorted('astropy kapteyn novas pyast palpy pyephem pyslalib pytpm skyfield'.split()) +TOOLS = sorted('astropy novas pyast palpy pyephem skyfield'.split()) TOOL_PAIRS = [_ for _ in itertools.product(TOOLS, TOOLS) if _[0] < _[1]] @@ -136,7 +136,7 @@ def celestial_results(tool, systems, symmetric=False): # TODO: switch internally to radians and get rid of this helper function! def angular_separation_deg_to_arcsec(lon1, lat1, lon2, lat2): - from astropy.coordinates.angle_utilities import angular_separation + from astropy.coordinates import angular_separation from astropy.coordinates import Angle lon1 = np.radians(lon1) lat1 = np.radians(lat1) diff --git a/docs/Tools.rst b/docs/Tools.rst index 5862d08..6a44a5d 100644 --- a/docs/Tools.rst +++ b/docs/Tools.rst @@ -12,12 +12,6 @@ astropy.coordinates `astropy.coordinates `_: Uses `erfa `_ for some computations, but re-implements many things using Python / numpy. -kapteyn.celestial -+++++++++++++++++ - -`kapteyn.celestial `_: -Part of the `Kapteyn `_ package. - NOVAS +++++ @@ -51,26 +45,6 @@ PyEphem `xephem `_ coordinate routines, which are interfaced as C extensions. Currently a re-write using Cython is underway in the `version4` branch on github. -PySlalib -++++++++ - -`pyslalib `_ - -`f2py `_ and `numpy `_ -wrappers of the fortran version of the astro library `SLALIB `_ - -PyTPM -+++++ - -`pytpm `_ is `Cython `_ interface to the -`TPM `_ C library with a high-level -``convert.convertv6`` function interface. Unmaintained. - -We are using the version from github main. - -Note that ``pytpm`` is unmaintained and is known to give incorrect results in this case: -https://github.com/phn/pytpm/issues/2 - Licenses and Features --------------------- @@ -84,14 +58,11 @@ Licenses and Features Package License Lib License Array Alt/Az ================= ============= ============= ===== ====== astropy BSD --- No No -kapteyn.celestial BSD --- Yes No novas Public Domain Public Domain No Yes palpy GPL GPL Some Yes pyast LGPL LGPL Yes Yes pyephem LGPL LGPL No Yes -pyslalib GPL GPL No Yes pysofa MIT SOFA No Yes -pytpm BSD ??? No Yes ================= ============= ============= ===== ====== Notes: @@ -100,8 +71,6 @@ Notes: Please report any inaccuracies, especially concerning the license status. -The following packages have been removed from the ``coordinates-benchmark``: - Other tools that are currently not included +++++++++++++++++++++++++++++++++++++++++++ diff --git a/requirements.txt b/requirements.txt index cf41670..0a848cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,8 @@ -https://github.com/astrojuanlu/pytpm/archive/master.zip; python_version >= "3" git+http://github.com/astropy/astropy.git#egg=astropy novas pyephem -https://github.com/scottransom/pyslalib/archive/master.zip starlink-pyast palpy -kapteyn<=2.3; python_version < "3" -http://www.astro.rug.nl/software/kapteyn/kapteyn-3.0.tar.gz; python_version >= "3" skyfield click matplotlib