Skip to content

Commit

Permalink
Merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
hover2pi committed Dec 29, 2021
2 parents cca4294 + 5ff77cf commit fb0189b
Show file tree
Hide file tree
Showing 15 changed files with 653 additions and 71 deletions.
14 changes: 7 additions & 7 deletions env/environment-3.7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ dependencies:
- flask=1.1.2
- gunicorn=20.1.0
- h5py=3.2.1
- ipython=7.22.0
- ipython=7.26.0
- jupyter=1.0.0
- matplotlib=3.1.3
- numpy=1.19.2
- numpydoc=1.1.0
- pandas=1.2.4
- pandas=1.3.2
- paramiko=2.7.2
- pip=20.3.3
- pytest=6.2.3
Expand All @@ -34,18 +34,18 @@ dependencies:
- asteval==0.9.25
- awscli
- bandit==1.7.0
- batman-package==2.4.6
- batman-package==2.4.8
- bibtexparser==1.2.0
- corner==2.2.1
- ddtrace==0.50.3
- ddtrace==0.52.1
- flask_wtf==0.14.3
- lmfit==1.0.1
- platon==5.3
- platon==4.0
- pysiaf==0.10.0
- pysynphot==1.0.1
- pysynphot==1.0.0
- PyYAML>=5.4
- sphinx_astropy==1.5
- svo-filters==0.4.1
- werkzeug==0.16.1
- werkzeug>=2.0
- git+https://github.com/spacetelescope/jwst_gtvt.git@cd6bc76f66f478eafbcc71834d3e735c73e03ed5
- git+https://github.com/astropy/astroquery.git@ccc96185beeff86f3a12a31a00a801afcebe1dbe
16 changes: 8 additions & 8 deletions env/environment-3.8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ dependencies:
- flask=1.1.2
- gunicorn=20.1.0
- h5py=3.2.1
- ipython=7.22.0
- ipython=7.26.0
- jupyter=1.0.0
- matplotlib=3.3.4
- numpy=1.19.2
- numpydoc=1.1.0
- pandas=1.2.4
- pandas=1.3.2
- paramiko=2.7.2
- pip=20.3.3
- pytest=6.2.3
- pytest=6.2.4
- python=3.8.5
- pyyaml
- scipy=1.6.2
Expand All @@ -34,17 +34,17 @@ dependencies:
- asteval==0.9.25
- awscli
- bandit==1.7.0
- batman-package==2.4.6
- batman-package==2.4.8
- bibtexparser==1.2.0
- corner==2.2.1
- ddtrace==0.50.3
- ddtrace==0.52.1
- flask_wtf==0.14.3
- lmfit==1.0.2
- platon==5.3
- platon==4.0
- pysiaf==0.10.0
- pysynphot==1.0.1
- pysynphot==1.0.0
- sphinx_astropy==1.5
- svo-filters==0.4.1
- werkzeug==0.16.1
- werkzeug>=2.0
- git+https://github.com/spacetelescope/jwst_gtvt.git@cd6bc76f66f478eafbcc71834d3e735c73e03ed5
- git+https://github.com/astropy/astroquery.git@ccc96185beeff86f3a12a31a00a801afcebe1dbe
16 changes: 8 additions & 8 deletions env/environment-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ dependencies:
- flake8=3.9.0
- flask=1.1.2
- h5py=2.10.0
- ipython=7.22.0
- ipython=7.26.0
- jupyter=1.0.0
- matplotlib=3.3.4
- numpy=1.19.2
- numpydoc=1.1.0
- pandas=1.2.3
- pandas=1.3.2
- paramiko=2.7.2
- pip=20.3.3
- pytest=6.2.3
- pytest=6.2.4
- python=3.9.1
- pyyaml
- scipy=1.6.2
Expand All @@ -32,19 +32,19 @@ dependencies:
- asteval==0.9.25
- awscli
- bandit==1.7.0
- batman-package==2.4.6
- batman-package==2.4.8
- bibtexparser==1.2.0
- corner==2.2.1
- ddtrace==0.50.3
- ddtrace==0.52.1
- docutils==0.15.2
- flask_wtf==0.14.3
- gunicorn==20.0.4
- lmfit==1.0.2
- platon==5.3
- platon==4.0
- pysiaf==0.10.0
- pysynphot==1.0.1
- pysynphot==1.0.0
- sphinx_astropy==1.5
- svo-filters==0.4.1
- werkzeug==0.16.1
- werkzeug>=2.0
- git+https://github.com/spacetelescope/jwst_gtvt.git@cd6bc76f66f478eafbcc71834d3e735c73e03ed5
- git+https://github.com/astropy/astroquery.git@ccc96185beeff86f3a12a31a00a801afcebe1dbe
8 changes: 7 additions & 1 deletion exoctk/contam_visibility/field_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
from exoctk import utils

EXOCTK_DATA = os.environ.get('EXOCTK_DATA')
TRACES_PATH = os.path.join(os.environ.get('EXOCTK_DATA'), 'exoctk_contam', 'traces')

# If this is not checked, base ExoCTK does not go through. If None,
# users are warned by the import that contam_visibility will not work
# already in utils.py.
if EXOCTK_DATA is not None:

TRACES_PATH = os.path.join(os.environ.get('EXOCTK_DATA'), 'exoctk_contam', 'traces')


def fieldSim(ra, dec, instrument, binComp='', testing=False):
Expand Down
4 changes: 3 additions & 1 deletion exoctk/contam_visibility/miniTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ def traceLength(inst):
FILE = 'modelOrder12_teff6000.sav'

trFile = os.path.join(TRACES_PATH, inst.replace(' ', '_'), FILE)
if 'NIRCam' in inst:
trFile = trFile.replace('NIRCam', 'NIRCam_F444W')
trData = readsav(trFile)['modelo12'] if 'NIRISS' in inst \
else fits.getdata(trFile, 1)
trData = trData[0]
print(np.shape(trData))

ax = 1 if 'NIRCam' in inst else 0
peak = trData.max()

Expand Down
2 changes: 1 addition & 1 deletion exoctk/contam_visibility/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def resolve_target(targetName):
data = get_target_data(targetName)
data = get_target_data(targetName)[0]
ra = data['RA']
dec = data['DEC']

Expand Down
7 changes: 6 additions & 1 deletion exoctk/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"""

from . import test_atmospheric_retrievals
from . import test_contam_visibility
from . import test_groups_integrations
from . import test_lightcurve_fitting
from . import test_limb_darkening
from . import test_log_exoctk
from . import test_modelgrid
from . import test_visibilityPA
from . import test_phase_constraint_overlap
from . import test_throughputs
from . import test_utils
160 changes: 160 additions & 0 deletions exoctk/tests/test_contam_visibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#! /usr/bin/env python

"""Tests for various modules within the ``contam_visibility``
subpackage.
Authors
-------
Matthew Bourque
Ben Falk
Use
---
These tests can be run via the command line (omit the ``-s`` to
suppress verbose output to stdout):
::
pytest -s test_contam_visibility.py
"""

import os
import sys

import numpy as np
import pytest

from exoctk.contam_visibility import field_simulator
from exoctk.contam_visibility import miniTools
from exoctk.contam_visibility import resolve
from exoctk.contam_visibility import visibilityPA

# Determine if tests are being run on Github Actions
ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~')


def test_checkVisPA():
"""Tests the ``checkVisPA`` function in the ``visibilityPA`` module"""

ra = '24.3544618'
dec = '-45.6777937'
pa_good, pa_bad, gd, figure = visibilityPA.checkVisPA(ra, dec)

assert isinstance(pa_good, list) and len(pa_good) > 0
assert isinstance(pa_bad, list) and len(pa_bad) > 0
assert isinstance(gd, list) and len(gd) > 0
assert isinstance(figure, object)


# Cant get this to work because having latex installation issues
# def test_contamVerify():
# """Tests the ``contamVerify`` function in the ``miniTools`` module"""

# ra = 24.3544618
# dec = -45.6777937
# instrument = 'NIRISS'
# APAlist = [1, 25, 181, 205]

# pdf = miniTools.contamVerify(ra, dec, instrument, APAlist, web=True)

# assert os.path.exists(pdf)


@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Need access to trace data FITS files. Please try running locally')
def test_fieldSim():
"""Tests the ``fieldSim`` function in the ``field_simulator`` module"""

ra = '04 25 29.0162'
dec = '-30 36 01.603'
instrument = 'NIRISS'

sim_cube = field_simulator.fieldSim(ra, dec, instrument)

assert isinstance(sim_cube, np.ndarray) and len(sim_cube) > 0


@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Test takes a long time to complete. Please try running locally')
def test_gtsFieldSim():
"""Tests the ``gtsFieldSim`` function in the ``field_simulator`` module"""

ra = '04 25 29.0162'
dec = '-30 36 01.603'
filt = 'F322W2'

sim_cube = field_simulator.gtsFieldSim(ra, dec, filt)

assert isinstance(sim_cube, np.ndarray) and len(sim_cube) > 0


@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Test takes a long time to complete. Please try running locally')
def test_lrsFieldSim():
"""Tests the ``lrsFieldSim`` function in the ``field_simulator`` module"""

ra = '04 25 29.0162'
dec = '-30 36 01.603'

sim_cube = field_simulator.lrsFieldSim(ra, dec)

assert isinstance(sim_cube, np.ndarray) and len(sim_cube) > 0


def test_resolve_target():
"""Tests the ``resolve_target`` function in the ``resolve`` module"""

ra, dec = resolve.resolve_target('Wasp-18 b')

assert ra == 24.3544618
assert dec == -45.6777937


@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Need access to trace data FITS files. Please try running locally')
def test_sossFieldSim():
"""Tests the ``sossFieldSim`` function in the ``field_simulator`` module"""

ra = '04 25 29.0162'
dec = '-30 36 01.603'

sim_cube = field_simulator.sossFieldSim(ra, dec)

assert isinstance(sim_cube, np.ndarray) and len(sim_cube) > 0


@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Need access to trace data FITS files. Please try running locally')
def test_traceLength():
"""Tests the ``traceLenght`` function in the ``miniTools`` module"""

instruments = 'NIRCam', 'NIRISS', 'MIRI'
expected_results = {}
expected_results['NIRCam'] = (0, 1342)
expected_results['NIRISS'] = (1693, 5935)
expected_results['MIRI'] = (41, 419)

for instrument in instruments:
target_trace_start, target_trace_stop = miniTools.traceLength(instrument)
assert expected_results[instrument] == (target_trace_start, target_trace_stop)


@pytest.mark.skipif(sys.version_info > (3, 9), reason='jwst_gtvt does not currently support python>=3.9.')
def test_using_gtvt():
"""Tests the ``using_gtvt`` function in the ``visibilityPA`` module"""

instrument = 'NIRISS'

# this ra/dec has bad PAs
ra = "-66"
dec = "44"
paMin, paMax, gd, fig, table, grouped_badPAs = visibilityPA.using_gtvt(ra, dec, instrument, targetName="Target", output="bokeh")
assert grouped_badPAs is not None

# this ra/dec has 100% coverage (no bad PAs)
ra = '88'
dec = '-64'
output = visibilityPA.using_gtvt(ra, dec, instrument, targetName="Target", output="bokeh")

assert output is not None
assert len(output) == 6

paMin, paMax, gd, fig, table, grouped_badPAs = output

assert len(grouped_badPAs) == 0
Loading

0 comments on commit fb0189b

Please sign in to comment.