Skip to content

Commit

Permalink
Various testing spot checks... (#122)
Browse files Browse the repository at this point in the history
* Drop the draft creation from JOSS on GitHub actions--not needed anymore

* Make unit tests use astropy 5.1 only, per #121

* Numpy version incompatibility check...

* The tests were reading the pip version of muler! that is a fail!

* numpy backwards breaking bug

* numpy compatibiliy deprecation

* Got to try different numpy versions

* another numpy backwards breaking change

* same for nirspec

* Astropy 5.1 has a numpy conflict, apparently?

* Force the most recent versions after all
  • Loading branch information
gully authored Dec 19, 2022
1 parent a9ed824 commit 3b6f7cd
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 63 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/draft-pdf.yml

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/muler-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
specutils-version: [1.5, 1.6, 1.7]
astropy-version: [4.3, 5.0]
python-version: [3.9]
specutils-version: [1.5, 1.9.1]
astropy-version: [5.2]
numpy-version: [1.18, 1.24]

steps:
- uses: actions/checkout@v2
Expand All @@ -27,8 +27,8 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi
pip install astropy==${{ matrix.astropy-version }} specutils==${{ matrix.specutils-version }}
if [ -f docs/requirements_actions.txt ]; then pip install -r docs/requirements_actions.txt; fi
pip install astropy==${{ matrix.astropy-version }} specutils==${{ matrix.specutils-version }}
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -41,4 +41,4 @@ jobs:
python -c "import sys; print('Python version: ', sys.version)"
python -c "import specutils; print('specutils version: ', specutils.__version__)"
python -c "import astropy; print('astropy version: ', astropy.__version__)"
pytest -vs
pytest -vs
18 changes: 18 additions & 0 deletions docs/requirements_actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sphinx>=3.2.1
sphinx-material
scipy
pandas
nbsphinx
gwcs
celerite2
matplotlib
requests
ipykernel
importlib_resources
h5py
celerite2
tqdm
bokeh # needed for gollum to install on RTD
gollum==0.2.1
numpydoc
sphinx-gallery
10 changes: 5 additions & 5 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ channels:
- defaults
- conda-forge
dependencies:
- python=3.8
- python=3.9
- numpy
- scipy
- matplotlib
- astropy<5.0
- astropy=5.2
- astroquery
- specutils>=1.2
- tqdm
- gwcs<0.17
- ndcube<2.0
- gwcs
- ndcube
- pandas
- bokeh
- jupyter
Expand All @@ -35,3 +34,4 @@ dependencies:
- pip:
- sphinx-material
- celerite2
- specutils==1.9.1
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@

setuptools.setup(
name="muler",
version="0.3.4",
version="0.4.0",
author="gully",
author_email="[email protected]",
description="A Python package for working with data from IGRINS and HPF",
description="A Python package for working with data from various echelle spectrographs",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/OttoStruve/muler",
install_requires=[
"numpy",
"scipy",
"astropy>=4.1",
"specutils>=1.5",
"astropy>=5.2",
"specutils>=1.9",
"pandas",
"importlib_resources",
"matplotlib",
Expand Down
2 changes: 1 addition & 1 deletion src/muler/echelle.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def neg_log_like(params, gp):
spectral_axis=self.wavelength.value * self.wavelength.unit,
flux=mean_model * self.flux.unit,
uncertainty=None,
mask=np.zeros_like(mean_model, dtype=np.bool),
mask=np.zeros_like(mean_model, dtype=bool),
meta=copy.deepcopy(self.meta),
wcs=None,
)
Expand Down
20 changes: 10 additions & 10 deletions src/muler/hpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ def __init__(self, *args, file=None, order=19, cached_hdus=None, **kwargs):
hdr = hdus[0].header

## Target Spectrum
lamb = hdus[7].data[order].astype(np.float64) * u.AA
flux = hdus[1].data[order].astype(np.float64) * u.ct
unc = hdus[4].data[order].astype(np.float64) * u.ct
lamb = hdus[7].data[order].astype(float) * u.AA
flux = hdus[1].data[order].astype(float) * u.ct
unc = hdus[4].data[order].astype(float) * u.ct
if pipeline == "HPF":
unc = np.sqrt(unc.value) * u.ct

meta_dict = {
"x_values": np.arange(0, 2048, 1, dtype=np.int),
"x_values": np.arange(0, 2048, 1, dtype=int),
"pipeline": pipeline,
"m": grating_order,
"header": hdr,
Expand All @@ -122,9 +122,9 @@ def __init__(self, *args, file=None, order=19, cached_hdus=None, **kwargs):
)

## Sky Spectrum
lamb = hdus[8].data[order].astype(np.float64) * u.AA
flux = hdus[2].data[order].astype(np.float64) * u.ct
unc = hdus[5].data[order].astype(np.float64) * u.ct
lamb = hdus[8].data[order].astype(float) * u.AA
flux = hdus[2].data[order].astype(float) * u.ct
unc = hdus[5].data[order].astype(float) * u.ct
if pipeline == "HPF":
unc = np.sqrt(unc.value) * u.ct
uncertainty = StdDevUncertainty(unc)
Expand All @@ -142,9 +142,9 @@ def __init__(self, *args, file=None, order=19, cached_hdus=None, **kwargs):
)

## LFC Spectrum
lamb = hdus[9].data[order].astype(np.float64) * u.AA
flux = hdus[3].data[order].astype(np.float64) * u.ct
unc = hdus[6].data[order].astype(np.float64) * u.ct
lamb = hdus[9].data[order].astype(float) * u.AA
flux = hdus[3].data[order].astype(float) * u.ct
unc = hdus[6].data[order].astype(float) * u.ct
if pipeline == "HPF":
unc = np.sqrt(unc.value) * u.ct
uncertainty = StdDevUncertainty(unc)
Expand Down
16 changes: 8 additions & 8 deletions src/muler/igrins.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(
if cached_hdus is not None:
hdus = cached_hdus[0]
if "rtell" in file:
sn = hdus['SNR'].data[order]
sn = hdus["SNR"].data[order]
sn_hdus = None
else:
sn_hdus = cached_hdus[1]
Expand All @@ -99,7 +99,7 @@ def __init__(
wave_hdus = fits.open(wavefile)
else:
hdus = fits.open(str(file))
sn = hdus['SNR'].data[order]
sn = hdus["SNR"].data[order]
sn_hdus = None
if wavefile is not None:
wave_hdus = fits.open(wavefile)
Expand All @@ -110,13 +110,13 @@ def __init__(
"You have passed in a wavefile and a spec_a0v format file, which has its own wavelength solution. Ignoring the wavefile."
)
elif ".spec_a0v.fits" in file:
lamb = hdus["WAVELENGTH"].data[order].astype(np.float64) * u.micron
flux = hdus["SPEC_DIVIDE_A0V"].data[order].astype(np.float64) * u.ct
lamb = hdus["WAVELENGTH"].data[order].astype(float) * u.micron
flux = hdus["SPEC_DIVIDE_A0V"].data[order].astype(float) * u.ct
elif ("spec.fits" in file) and (wavefile is not None):
lamb = (
wave_hdus[0].data[order].astype(np.float64) * 1e-3 * u.micron
wave_hdus[0].data[order].astype(float) * 1e-3 * u.micron
) # Note .wave.fits and .wavesol_v1.fts files store their wavelenghts in nm so they need to be converted to microns
flux = hdus[0].data[order].astype(np.float64) * u.ct
flux = hdus[0].data[order].astype(float) * u.ct
elif ("spec.fits" in file) and (wavefile is None):
raise Exception(
"wavefile must be specified when passing in spec.fits files, which do not come with an in-built wavelength solution."
Expand All @@ -128,7 +128,7 @@ def __init__(
+ " is the wrong file type. It must be either .spec_a0v.fits or .spec.fits."
)
meta_dict = {
"x_values": np.arange(0, 2048, 1, dtype=np.int),
"x_values": np.arange(0, 2048, 1, dtype=int),
"m": grating_order,
"header": hdr,
}
Expand Down Expand Up @@ -214,7 +214,7 @@ def read(file, precache_hdus=True, wavefile=None):
wavefile : (str)
"""
#still works
# still works
assert (".spec_a0v.fits" in file) or (".spec.fits" in file)
hdus = fits.open(file, memmap=False)
if ".spec_a0v.fits" in file:
Expand Down
10 changes: 5 additions & 5 deletions src/muler/nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def __init__(self, *args, file=None, order=63, **kwargs):
hdu0 = hdu[1]

## Target Spectrum
lamb = hdu0.data["wave (A)"].astype(np.float64) * u.AA
flux = hdu0.data["flux (cnts)"].astype(np.float64) * u.ct
unc = hdu0.data["noise (cnts)"].astype(np.float64) * u.ct
lamb = hdu0.data["wave (A)"].astype(float) * u.AA
flux = hdu0.data["flux (cnts)"].astype(float) * u.ct
unc = hdu0.data["noise (cnts)"].astype(float) * u.ct

uncertainty = StdDevUncertainty(unc)
mask = np.array(
Expand All @@ -100,7 +100,7 @@ def __init__(self, *args, file=None, order=63, **kwargs):
hdr = None

meta_dict = {
"x_values": hdu0.data["col"].astype(np.int),
"x_values": hdu0.data["col"].astype(int),
"pipeline": pipeline,
"m": grating_order,
"header": hdr,
Expand All @@ -117,7 +117,7 @@ def __init__(self, *args, file=None, order=63, **kwargs):
)

## Sky Spectrum
flux = hdu0.data["sky (cnts)"].astype(np.float64) * u.ct
flux = hdu0.data["sky (cnts)"].astype(float) * u.ct

sky_spectrum = KeckNIRSPECSpectrum(
spectral_axis=lamb,
Expand Down

0 comments on commit 3b6f7cd

Please sign in to comment.