Skip to content

Commit

Permalink
Merge pull request #345 from mkelley/fix-and-test-stsci-sun-urls-2022.06
Browse files Browse the repository at this point in the history
Fix and test STScI Sun URLs
  • Loading branch information
mkelley authored Jul 24, 2022
2 parents 8241a98 + a1fb6b2 commit 997d64d
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 20 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/ci_cron_weekly.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# GitHub Actions workflow that runs on a cron schedule.
# Check URLs and run latest deps with remote tests

name: Weekly CI Tests

Expand All @@ -8,9 +9,18 @@ on:
- cron: '0 6 * * 1'

jobs:
# Weekly testing to catch links that stop working for some reason.
doc_test:
weekly:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: Check links in docs using tox
toxenv: linkcheck
- name: Check dev versions of key dependencies
toxenv: py39-test-devdeps
toxposargs: --remote-data

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -19,10 +29,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install base dependencies
run: |
python -m pip install --upgrade pip tox
- name: Check links in docs using tox
run: |
tox -e linkcheck
- name: Test with tox
env:
ADS_DEV_KEY: ${{ secrets.ADS_DEV_KEY }}
run: tox ${{ matrix.toxargs}} -e ${{ matrix.toxenv}} -- ${{ matrix.toxposargs}}
7 changes: 3 additions & 4 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ jobs:
python: 3.8
toxenv: py38-test-alldeps

- name: Python 3.8 with all optional dependencies, remote tests, and coverage checking
- name: Python 3.8 with all optional dependencies and coverage checking
os: ubuntu-latest
python: 3.8
toxenv: py38-test-alldeps-cov
toxposargs: --remote-data

# - name: Windows - Python 3.8 with all optional dependencies
# os: windows-latest
Expand Down Expand Up @@ -88,8 +87,8 @@ jobs:
python -m pip install --upgrade pip
python -m pip install tox codecov
- name: Test with tox
run: |
tox -e ${{ matrix.toxenv }}
run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}

# This is an example of how to upload coverage to codecov
# - name: Upload coverage to codecov
# if: "contains(matrix.toxenv, '-cov')"
Expand Down
3 changes: 1 addition & 2 deletions sbpy/calib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
import numpy as np
from astropy.utils.state import ScienceState
from astropy.utils.data import get_pkg_data_filename
from astropy.table import Table, QTable
from astropy.io import ascii
from astropy.table import Table
import astropy.units as u

from ..spectroscopy.sources import SpectralSource, SynphotRequired
Expand Down
12 changes: 8 additions & 4 deletions sbpy/calib/solar_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ class SolarSpectra:
'filename': 'e490-00a_2014_hires.csv',
'wave_unit': 'um',
'flux_unit': 'W/(m2 um)',
'description': 'E490-00a (2014) low resolution reference solar spectrum (Table 4)',
'description': ('E490-00a (2014) low resolution reference solar '
'spectrum (Table 4)'),
'bibcode': 'doi:10.1520/E0490'
}

Kurucz1993 = {
'filename': 'ftp://ftp.stsci.edu/cdbs/grid/k93models/standards/sun_kurucz93.fits',
'filename': ('https://archive.stsci.edu/hlsps/reference-atlases/cdbs/'
'grid/k93models/standards/sun_kurucz93.fits'),
'description': 'Kurucz (1993) model, scaled by Colina et al. (1996)',
'bibcode': '1993KurCD..13.....K'
}

Castelli1996 = {
'filename': 'ftp://ftp.stsci.edu/cdbs/grid/k93models/standards/sun_castelli.fits',
'description': 'Castelli model, scaled and presented by Colina et al. (1996)',
'filename': ('https://archive.stsci.edu/hlsps/reference-atlases/cdbs/'
'grid/k93models/standards/sun_castelli.fits'),
'description': ('Castelli model, scaled and presented by Colina et '
'al. (1996)'),
'bibcode': '1996AJ....112..307C'
}

Expand Down
21 changes: 20 additions & 1 deletion sbpy/calib/tests/test_sun.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def test_meta(self):
sun = Sun.from_builtin('E490_2014')
assert sun.meta is None

@pytest.mark.skipif('True')
@pytest.mark.remote_data
def test_kurucz_nan_error(self):
"""sbpy#113
Expand All @@ -149,6 +148,26 @@ def test_kurucz_nan_error(self):
fluxd = sun.observe(V, unit=u.ABmag)
assert np.isclose(fluxd.value, -26.77, atol=0.005)

@pytest.mark.remote_data
def test_castelli96(self):
"""Verify Castelli1996 calibration.
According to the FITS header:
HISTORY Created Thu 15:49:31 16-Nov-95
COMMENT solar model spectrum calculated by F. Castelli.
COMMENT Absolute flux normalized to a V flux of 184.2 ergs/s/cm^2/A
COMMENT For more details see Colina, Bohlin & Castelli 1996
CAL/SCS-008
2022-06-05: sbpy calculates 184.5 ergs/s/cm^2/A; agreement within 0.2%
"""

sun = Sun.from_builtin('Castelli1996')
V = bandpass('johnson v')
fluxd = sun.observe(V, unit='erg/(s cm2 AA)')
assert np.isclose(fluxd.value, 184.2, rtol=0.002)

def test_show_builtin(self, capsys):
Sun.show_builtin()
captured = capsys.readouterr()
Expand Down
2 changes: 1 addition & 1 deletion sbpy/data/ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def from_oo(cls, orbit, epochs=None, location='500', scope='full',
1 Ceres 2458529.2336329385 ... 1.326517587380005e-05 70.34353031031534
1 Ceres 2458529.2752996054 ... 1.1193369555934085e-05 70.35298818987367 """

if not pyoorb:
if pyoorb is None:
raise RequiredPackageUnavailable('pyoorb')

# create a copy of orbit
Expand Down
2 changes: 1 addition & 1 deletion sbpy/data/tests/test_orbit_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_oo_propagate(self):

elements = ['a', 'e', 'i', 'Omega', 'w', 'M']
assert all([u.isclose(oo_orbit[k][0], future_orbit[k][0])
for k in elements])
for k in elements])
assert u.isclose(oo_orbit['epoch'][0].utc.jd,
future_orbit['epoch'][0].utc.jd)
assert oo_orbit['epoch'].scale == 'utc'
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ isolated_build = true
pypi_filter = https://raw.githubusercontent.com/astropy/ci-helpers/main/pip_pinnings.txt

# Pass through the following environemnt variables which are needed for the CI
passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI TEST_READ_HUGE_FILE FC_GFORTRAN
passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI TEST_READ_HUGE_FILE FC_GFORTRAN ADS_DEV_KEY

# For coverage, we need to pass extra options to the C compiler
setenv =
Expand Down

0 comments on commit 997d64d

Please sign in to comment.