Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move STIPS from PYSYNPHOT to synphot/stsynphot #103

Merged
merged 18 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .rtd-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ dependencies:
# Docs
- sphinx
- docutils
- sphinx_rtd_theme
- stsci_rtd_theme

- pip:
# Docs
- astropy_helpers
- sphinx_astropy
- sphinx_astropy
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ addons:

env:
global:
# Define Conda Version
- MINICONDA_VERSION=py37_4.8.3

# The following versions are the 'default' for tests, unless
# overridden underneath. They are defined here in order to save having
# to repeat them for all configurations.
Expand Down Expand Up @@ -74,7 +77,7 @@ matrix:
- name: "Doc Build Test"
os: linux
env: SETUP_CMD='build_docs -w'
CONDA_DEPENDENCIES=$CONDA_DEPENDENCIES_DOC
CONDA_ENVIRONMENT='.rtd-environment.yml'

# Main test
# ---------------------------
Expand Down Expand Up @@ -127,21 +130,23 @@ before_install:
# download synphot data
- mkdir $TEST_DATA_PATH/synphot

- wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot1.tar.gz -O $TEST_DATA_PATH/synphot1.tar.gz
- wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot2.tar.gz -O $TEST_DATA_PATH/synphot2.tar.gz
- wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot5.tar.gz -O $TEST_DATA_PATH/synphot5.tar.gz
- wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot1.tar.gz -O $TEST_DATA_PATH/synphot1.tar.gz
- wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot2.tar.gz -O $TEST_DATA_PATH/synphot2.tar.gz
- wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot5.tar.gz -O $TEST_DATA_PATH/synphot5.tar.gz
- wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot6.tar.gz -O $TEST_DATA_PATH/synphot6.tar.gz

- tar -xzvf $TEST_DATA_PATH/synphot1.tar.gz -C $TEST_DATA_PATH/synphot/
- tar -xzvf $TEST_DATA_PATH/synphot2.tar.gz -C $TEST_DATA_PATH/synphot/
- tar -xzvf $TEST_DATA_PATH/synphot5.tar.gz -C $TEST_DATA_PATH/synphot/
- tar -xzvf $TEST_DATA_PATH/synphot6.tar.gz -C $TEST_DATA_PATH/synphot/

- export PYSYN_CDBS=$TEST_DATA_PATH/synphot/grp/hst/cdbs

# download pandeia_data data
- wget -qO- https://stsci.box.com/shared/static/5j506xzg9tem2l7ymaqzwqtxne7ts3sr.gz -O $TEST_DATA_PATH/pandeia_data-1.5_wfirst.gz
- wget -qO- https://stsci.box.com/shared/static/7voehzi5krrpml5wgyg8bo954ew7arh2.gz -O $TEST_DATA_PATH/pandeia_data-1.5.2rc2_roman.gz

- tar -xzvf $TEST_DATA_PATH/pandeia_data-1.5_wfirst.gz -C $TEST_DATA_PATH/
- export pandeia_refdata=$TEST_DATA_PATH/pandeia_data-1.5_wfirst
- tar -xzvf $TEST_DATA_PATH/pandeia_data-1.5.2rc2_roman.gz -C $TEST_DATA_PATH/
- export pandeia_refdata=$TEST_DATA_PATH/pandeia_data-1.5.2rc2_roman

# download webbpsf data
- wget -qO- https://stsci.box.com/shared/static/qcptcokkbx7fgi3c00w2732yezkxzb99.gz -O $TEST_DATA_PATH/webbpsf_data.gz
Expand Down
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ RUN wget -qO- https://stsci.box.com/shared/static/iufbhsiu0lts16wmdsi12cun25888n
ENV stips_data /opt/stips_data

# Extract PySynphot reference data
RUN wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot1.tar.gz | tar xvz
RUN wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot2.tar.gz | tar xvz
RUN wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot5.tar.gz | tar xvz
RUN wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot1.tar.gz | tar xvz
RUN wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot2.tar.gz | tar xvz
RUN wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot5.tar.gz | tar xvz
RUN wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot6.tar.gz | tar xvz
ENV PYSYN_CDBS /opt/grp/hst/cdbs

# Extract Pandeia reference data
RUN wget -qO- https://stsci.box.com/shared/static/5j506xzg9tem2l7ymaqzwqtxne7ts3sr.gz | tar -xvz
ENV pandeia_refdata /opt/pandeia_data-1.5_wfirst
RUN wget -qO- https://stsci.box.com/shared/static/7voehzi5krrpml5wgyg8bo954ew7arh2.gz | tar -xvz
ENV pandeia_refdata /opt/pandeia_data-1.5.2rc2_roman

# Extract WebbPSF reference data
# (note: version number env vars are declared close to where they are used
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
|Travis Status| |PyPI Status|

# STScI-STIPS

For documentation and installation instructions please visit https://stsci-stips.readthedocs.io
Expand Down
19 changes: 10 additions & 9 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ STIPS Requirements
* `numpy`: STIPS uses numpy extensively for almost everything that it does.
* `photutils`: STIPS uses photutils to determine the flux inside the half-light radius
in generated Sersic profiles.
* `pysynphot`: STIPS uses pysynphot to generate bandpasses, count rates, and
zero points. Note that pysynphot's data files (also known as the CDBS data tree) must also be
installed and available as indicated in pysynphot's documentation.
* `synphot` and `stsynphot`: STIPS uses synphot and stsynphot to generate
bandpasses, count rates, and zero points. Note that the reference data must
also be downloaded, as described below in "Doanloading Required Data".
* `scipy`: STIPS uses scipy to manipulate its internal images (zoom and rotate).

Finally, STIPS requires a set of data files whose location is marked by setting the environment
Expand Down Expand Up @@ -99,10 +99,11 @@ You will need to download the data and add them to your environmental path

2. `cd` into a directory you would like to store the data in and run the following commands::

# PySynphot reference data
wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot1.tar.gz | tar xvz
wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot2.tar.gz | tar xvz
wget -qO- http://ssb.stsci.edu/cdbs/tarfiles/synphot5.tar.gz | tar xvz
# Synphot and STSynphot reference data
wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot1.tar.gz | tar xvz
wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot2.tar.gz | tar xvz
wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot5.tar.gz | tar xvz
wget -qO- https://ssb.stsci.edu/trds/tarfiles/synphot6.tar.gz | tar xvz


# Pandeia reference data
Expand All @@ -115,9 +116,9 @@ You will need to download the data and add them to your environmental path

export WEBBPSF_PATH=/<path_to_data_dir>/webbpsf-data
export PYSYN_CDBS=/<path_to_data_dir>/grp/hst/cdbs
export pandeia_refdata=/<path_to_data_dir>/pandeia_data-x.x_wfirst
export pandeia_refdata=/<path_to_data_dir>/pandeia_data-x.x.x_roman

Make sure that you have the correct version number for `pandeia_refdata` (replace the "x.x").
Make sure that you have the correct version number for `pandeia_refdata` (replace the "x.x.x").

.. note::
The URL we provide in this section and the suggested pandeia reference data directory name
Expand Down
5 changes: 3 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ dependencies:
- astropy
- photutils
- healpy
- pysynphot
- synphot
- stsynphot
- esutil

# Major modules
Expand All @@ -57,7 +58,7 @@ dependencies:

- pip:
# Major modules
- pandeia.engine==1.5
- pandeia.engine==1.5.2
- jwst_backgrounds

# Minor modules
Expand Down
2 changes: 1 addition & 1 deletion stips/astro_image/astro_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __init__(self, **kwargs):


def __del__(self):
if os.path.exists(self.fname):
if hasattr(self, 'fname') and os.path.exists(self.fname):
os.remove(self.fname)

def copy(self):
Expand Down
44 changes: 18 additions & 26 deletions stips/data/CreatePhoenixGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,15 @@
sys.path.append(os.path.abspath(os.path.join(os.getcwd(), "..", "..")))

import numpy as np
import pysynphot as ps
import synphot as syn
import stsynphot as stsyn
from stips.utilities import InstrumentList
from .. import __version__ as stips_version_info
from astropy.io import fits as pyfits
from astropy import units as u

print("STIPS Version: {}".format(stips_version_info))

COMPFILES = sorted(glob.glob(os.path.join(os.environ["PYSYN_CDBS"],"mtab","*tmc.fits")))
GRAPHFILES = sorted(glob.glob(os.path.join(os.environ["PYSYN_CDBS"],"mtab","*tmg.fits")))
THERMFILES = sorted(glob.glob(os.path.join(os.environ["PYSYN_CDBS"],"mtab","*tmt.fits")))
wfc3_refs = {
'comptable': COMPFILES[-1],
'graphtable': GRAPHFILES[-1],
'thermtable': THERMFILES[-1],
'area': 45238.93416,
'waveset': (500,26000,10000.,'log')
}

area = {
'nircamlong': 253260.0,
'nircamshort': 253260.0,
'miri': 253260.0,
'wfc3ir': 45238.93416,
'wfi': 45238.93416
}
modes = {
'nircamshort': ['sw_imaging'],
'nircamlong': ['lw_imaging'],
Expand All @@ -66,6 +50,14 @@
'wfc3ir': {'imaging': "default"},
'wfi': {'imaging': "any"}
}
area = {
'nircamlong': 253260.0,
'nircamshort': 253260.0,
'miri': 253260.0,
'wfc3ir': 45238.93416,
'wfi': 45238.93416
}


def get_grid_points():
grid_file = os.path.abspath(os.path.join(os.environ['PYSYN_CDBS'], "grid", "phoenix", "catalog.fits"))
Expand All @@ -81,7 +73,7 @@ def get_grid_points():


if __name__ == '__main__':
norm_bandpass = ps.ObsBandpass('johnson,i')
norm_bandpass = syn.SpectralElement.from_filter('johnson_i')
coords = get_grid_points()
print(coords)
bandpasses = {}
Expand Down Expand Up @@ -110,23 +102,23 @@ def get_grid_points():
for k, teff in enumerate(coords[2]):
print("\t\t{}: Starting Teff = {}".format(time.ctime(), teff))
try:
spec = ps.Icat('phoenix', teff, Z, logg)
spec = stsyn.grid_to_spec('phoenix', teff, Z, logg)
counts = False
if sum(spec.flux) > 0:
counts = True
except ps.exceptions.ParameterOutOfBounds:
except syn.exceptions.ParameterOutOfBounds:
counts = False
for l, mag in enumerate(coords[3]):
print("\t\t\t{} of {}: {}: Starting Z = {}, log(g) = {}, Teff = {}, Mabs = {:>4}".format(n+1, total, time.ctime(), Z, logg, teff, mag), end='')
if counts:
spec_norm = spec.renorm(mag, 'vegamag', norm_bandpass)
norm_value = u.Magnitude(mag)
spec_norm = spec.normalize(norm_value, norm_bandpass)
for instrument in instruments:
ps.setref(area=area[instrument.lower()], waveset=(500, 260000, 10000., 'log'))
for mode in modes[instrument.lower()]:
for filter in filters[instrument.lower()][mode]:
if counts:
obs = ps.Observation(spec_norm, bandpasses[instrument.lower()][filter], binset=spec_norm.wave)
result_arrays[instrument.lower()][filter][i,j,k,l] = obs.countrate()
obs = syn.Observation(spec_norm, bandpasses[instrument.lower()][filter], binset=spec_norm.waveset)
result_arrays[instrument.lower()][filter][i,j,k,l] = obs.countrate(area[mode])
print(".", end='')
else:
result_arrays[instrument.lower()][filter][i,j,k,l] = 0.
Expand Down
Loading