Skip to content

Commit

Permalink
Merge pull request #29 from spacetelescope/version-0.4.0
Browse files Browse the repository at this point in the history
Version 0.4.0
  • Loading branch information
jbhagan committed Jan 16, 2020
2 parents b806961 + 31590b3 commit e15b592
Show file tree
Hide file tree
Showing 43 changed files with 752 additions and 707 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
@@ -0,0 +1,14 @@
language: python
python:
- '3.6'
install:
- pip install -r requirements.txt
script:
- pytest
deploy:
provider: pypi
user: "__token__"
password:
secure: SFxXFZpTEShqGKRO+2TXaXUKuREc2WWUuLPJVmX4mty8VKTyvQgl/8PqlBOtL1md0bOV7TdkFUqZzYAGVh98LJBmYiiecLfHZ+vQjYRnQuWCfLl1gSSJ5wZ4l0lsk6kzQ6R5rzI3uoawALO0c0aDMdzD1fO+qbxIFGa5alAaPI6uVdjgcPZ+YhKuXafM4leiAQQFZb9csMFhOiPE9vIv3+0qaaTxatTHcSpaSVxi7wEexYxS9q/1ribC9sU2lmDXkjp38+KT5eryTgozNgX+1Cj3otI6iuz8SQ6Ki44AZ241AzGp/cp4ExAXLM4Urlg+03U5GW12LIYXu/DoXcEgfHUnLOWEDmDJlzb4tm61FGJ36db+z98JruhSIKzN0Y4nf37y/QDgM6yWuEqBebRM4kPT/vwQu7RmZBPsxLCVMOxe/zCyYLaX6hvHqHWCGOR6nXoWFvKfDlLHtbrOFTgZOLjTePenWX5k65lk4l28Pj6R/9dZYlXLUpQI7cmbeaBAmGBp9SuoWgIySbEiSNPxUUfv2jn1L856p5hoNfT/AZmq8zkHZJrVXHAQt/WLEHmJ+fCmapdbP1C4jZZGZVHNsfNqY4rPlr97mlPj6dZY0SL876IE6s2TFfZw6kjitdWAxAFLcpPNwX2N7UKc+MsMSIoOqc5mmSlA0mI7CizPzfM=
on:
tags: true
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1,3 @@
# J. Brendan Hagan maintains this repository
# hagan@stsci.edu
* @jbhagan
10 changes: 8 additions & 2 deletions README.rst
@@ -1,9 +1,9 @@
JWST Coronagraph Visibility Tool
================================

Current version: 0.3.0 (beta).
Current version: 0.4.0 (beta).

`Download for macOS (31 MB) <https://github.com/spacetelescope/jwst_coronagraph_visibility/releases/download/0.3.0/jwst_coronagraph_visibility-0.3.0-macos.zip>`_ | `Download Python source <https://github.com/spacetelescope/jwst_coronagraph_visibility/archive/0.3.0.zip>`_ | ``$ pip install jwst-coronagraph-visibility``
`Download for macOS (31 MB) <https://github.com/spacetelescope/jwst_coronagraph_visibility/releases/download/0.4.0/jwst_coronagraph_visibility-0.4.0-macos.zip>`_ | `Download Python source <https://github.com/spacetelescope/jwst_coronagraph_visibility/archive/0.4.0.zip>`_ | ``$ pip install jwst-coronagraph-visibility``

**Report any issues at https://github.com/spacetelescope/jwst_coronagraph_visibility/issues/new or via email to the authors.**

Expand Down Expand Up @@ -35,6 +35,12 @@ Known Issues
Release Notes
-------------

0.4.0
^^^^^

* This release discontinues use of the ``jwxml`` package and now uses the STScI supported ``pysiaf`` package for all information using the SIAF. This releases uses version 0.6.3 of ``pysiaf`` which uses ``PRDOPSSOC-M-026`` as default for the JWST SIAF.
* CVT no longer supports python 2.7

0.3.0
^^^^^

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -55,7 +55,7 @@
# General information about the project.
project = 'JWST Coronagraph Visibility Tool'
copyright = '2016, Associated Universities for Research in Astronomy'
author = 'Chris Stark, Joseph Long'
author = 'Chris Stark, Joseph Long, J. Brendan Hagan'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -265,7 +265,7 @@
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'JWSTCoronagraphVisibilityTool.tex', 'JWST Coronagraph Visibility Tool Documentation',
'Chris Stark, Joseph Long', 'manual'),
'Chris Stark, Joseph Long, J. Brendan Hagan', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Expand Up @@ -2,7 +2,7 @@
JWST Coronagraph Visibility Tool
********************************

*Authors:* Christopher Stark <cstark@stsci.edu>, Joseph Long <jlong@stsci.edu>
*Authors:* Christopher Stark <cstark@stsci.edu>, Joseph Long, J. Brendan Hagan <hagan@stsci.edu>

Introduction
============
Expand Down Expand Up @@ -35,7 +35,7 @@ What are the prerequisites for installing the JWST Coronagraph Visibility Tool?

The JWST Coronagraph Visibility Tool depends on:

* Python 2.7, 3.4, or 3.5
* Python 3.4 (or greater)
* NumPy version 1.9.0 (or greater)
* Matplotlib version 1.4.2 (or greater)
* requests version 2.8.1 (or greater)
Expand Down
34 changes: 18 additions & 16 deletions jwst_coronagraph_visibility/gui.py
Expand Up @@ -49,10 +49,8 @@

SimbadResult = namedtuple('SimbadResult', ['ra', 'dec', 'id'])

from jwxml import SIAF
import jwxml
import pysiaf
from .skyvec2ins import skyvec2ins, ad2lb, lb2ad

from pprint import pprint

RED_GGPLOT = '#E24A33'
Expand Down Expand Up @@ -80,18 +78,18 @@ def compute_v2v3_offset(aperture_a, aperture_b):
to V2, V3 in two different apertures and computing the difference in
the resulting Tel frame coordinates
'''
x_a, y_a = aperture_a.Det2Tel(aperture_b.XDetRef, aperture_b.YDetRef)
x_b, y_b = aperture_b.Det2Tel(aperture_b.XDetRef, aperture_b.YDetRef)
x_a, y_a = aperture_a.det_to_tel(aperture_b.XDetRef, aperture_b.YDetRef)
x_b, y_b = aperture_b.det_to_tel(aperture_b.XDetRef, aperture_b.YDetRef)
return x_a - x_b, y_a - y_b

_NIRCAM_SIAF = SIAF('NIRCam')
_NIRCAM_SIAF = pysiaf.Siaf('NIRCam')
_MIRI_SIAF = pysiaf.Siaf('MIRI')

_NIRCAM_CORON_OFFSET_TEL = compute_v2v3_offset(
_NIRCAM_SIAF['NRCA5_MASKLWB'],
_NIRCAM_SIAF['NRCA5_FULL']
)

_MIRI_SIAF = SIAF('MIRI')

# These bad areas were defined in raw detector pixel coordinates by
# John Stansberry using a backlit image of NIRCam A5 through the
# long-wavelength bar coronagraph pupil wedge. Colin Cox translated them to
Expand Down Expand Up @@ -182,12 +180,16 @@ def compute_v2v3_offset(aperture_a, aperture_b):
NIRCAM_CORON_BAD_AREAS.flags.writeable = False

def query_simbad(query_string):
response = requests.get('http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oI?' + quote(query_string), timeout=QUERY_TIMEOUT_SEC)
#response = requests.get('http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oI?' + quote(query_string), timeout=QUERY_TIMEOUT_SEC)
try:
response = requests.get('http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oI?' + quote(query_string), timeout=QUERY_TIMEOUT_SEC)
except (requests.exceptions.ConnectionError):
return None
body = response.text
ra = dec = canonical_id = None
for line in body.split('\n'):
if line[:2] == '%J' and ra is None:
match = re.match('%J (\d+\.\d+) ([+\-]\d+\.\d+) .+', line)
match = re.match(r'%J (\d+\.\d+) ([+\-]\d+\.\d+) .+', line)
if match is None:
return None
ra, dec = map(float, match.groups())
Expand All @@ -204,7 +206,7 @@ def query_simbad(query_string):
def get_aperture(instrname, apername):
# siaf_path = os.path.join(bundle_dir, 'data', '{}_SIAF.xml'.format(instrname))
# assert os.path.exists(siaf_path), 'no SIAF for {} at {}'.format(instrname, siaf_path)
siaf = SIAF(instr=instrname)
siaf = pysiaf.Siaf(instrument = instrname)
return siaf[apername]

@contextmanager
Expand Down Expand Up @@ -1099,7 +1101,7 @@ def _update_detector(self):
self._mask_artists = []
ax.set_aspect('equal')

aper_corners_x, aper_corners_y = aperture.corners(frame='Idl')
aper_corners_x, aper_corners_y = aperture.corners(to_frame = 'idl')
verts = np.concatenate([aper_corners_x[:,np.newaxis], aper_corners_y[:,np.newaxis]], axis=1)
patch = patches.Polygon(verts, facecolor='none', edgecolor='red', alpha=0.5, linestyle='--', linewidth=3)
ax.add_artist(patch)
Expand Down Expand Up @@ -1146,7 +1148,7 @@ def _overlay_miri_ta_positions():
}
for ta_aper in ta_apers:
mask_ta_aper = ta_aper.format(mask_name)
ta_loc = aperture.Tel2Idl(_MIRI_SIAF[mask_ta_aper].V2Ref, _MIRI_SIAF[mask_ta_aper].V3Ref)
ta_loc = aperture.tel_to_idl(_MIRI_SIAF[mask_ta_aper].V2Ref, _MIRI_SIAF[mask_ta_aper].V3Ref)
mask_artists.append(patches.Circle(ta_loc, radius=ta_loc_spot_radius, color=GRAY_GGPLOT, alpha=0.25))
quadrant = mask_ta_aper[-2:]

Expand All @@ -1161,7 +1163,7 @@ def _overlay_miri_ta_positions():
if 'NRC' in aperture_name:
for quad_verts in NIRCAM_CORON_BAD_AREAS:
v2, v3 = quad_verts[:,0], quad_verts[:,1]
xidl, yidl = aperture.Tel2Idl(v2, v3)
xidl, yidl = aperture.tel_to_idl(v2, v3)
idl_verts = np.concatenate([xidl[:,np.newaxis], yidl[:,np.newaxis]], axis=1)
patch = patches.Polygon(idl_verts, facecolor='red', edgecolor='none', alpha=0.5)
mask_artists.append(patch)
Expand Down Expand Up @@ -1194,14 +1196,14 @@ def _overlay_miri_ta_positions():
-thick_extent_arcsec / arcsec_per_pixel,
-thin_extent_arcsec / arcsec_per_pixel
])
x_idl_verts, y_idl_verts = aperture.Sci2Idl(x_verts + aperture.XSciRef, y_verts + aperture.YSciRef)
x_idl_verts, y_idl_verts = aperture.sci_to_idl(x_verts + aperture.XSciRef, y_verts + aperture.YSciRef)
verts = np.concatenate([x_idl_verts[:,np.newaxis], y_idl_verts[:,np.newaxis]], axis=1)
patch = patches.Polygon(verts, alpha=0.5)
mask_artists.append(patch)
# self._mask_artists = self.detector_ax.add_artist(patch)
elif 'MIRI' in aperture_name:
y_angle = np.deg2rad(aperture.V3IdlYAngle)
corners_x, corners_y = aperture.corners(frame='Idl')
corners_x, corners_y = aperture.corners(to_frame='idl')
min_x, min_y = np.min(corners_x), np.min(corners_y)
max_x, max_y = np.max(corners_x), np.max(corners_y)

Expand Down
24 changes: 22 additions & 2 deletions jwst_coronagraph_visibility/skyvec2ins.py
Expand Up @@ -458,7 +458,7 @@ def detector_transform(nrolls, npoints, roll_rad, pa, separation_as, aper):
# That's where we want to stick the target
# The centers of the coronagraphic masks correspond to the XDetRef & YDetRef
# locations on the detector (according to Colin Cox)
cortelcoords = aper.Det2Tel(aper.XDetRef, aper.YDetRef)
cortelcoords = aper.det_to_tel(aper.XDetRef, aper.YDetRef)
# convert arcseconds to radians
cortelcoords_rad = np.asarray(cortelcoords) / 206264.806247
# At this point, we have the coronagraph mask location in
Expand Down Expand Up @@ -490,7 +490,7 @@ def detector_transform(nrolls, npoints, roll_rad, pa, separation_as, aper):
reftelcoords1_rad[j, i, 0],
reftelcoords1_rad[j, i, 1]
]) * 206264.806247 # arcseconds
tempidlcoords1 = aper.Tel2Idl(temptelcoords1[0], temptelcoords1[1])
tempidlcoords1 = _Tel2Idl(aper, temptelcoords1[0], temptelcoords1[1])
refidlcoords1[j, i] = tempidlcoords1

# Detector coordinates of star and companion
Expand All @@ -499,3 +499,23 @@ def detector_transform(nrolls, npoints, roll_rad, pa, separation_as, aper):

# END OF DETECTOR POS SECTION
return c1_x, c1_y

def _Tel2Idl(aper, V2, V3):
""" Convert Tel to Idl
input in arcsec, output in arcsec
This transformation involves going from global V2,V3 to local angles with respect to some
reference point, and possibly rotating the axes and/or flipping the parity of the X axis.
WARNING
--------
This is an implementation of the planar approximation, which is adequate for most
purposes but may not be for all. Error is about 1.7 mas at 10 arcminutes from the tangent
point. See JWST-STScI-1550 for more details.
"""

dV2 = np.asarray(V2, dtype=float) - aper.V2Ref
dV3 = np.asarray(V3, dtype=float) - aper.V3Ref
ang = np.deg2rad(aper.V3IdlYAngle)

XIdl = aper.VIdlParity * (dV2 * np.cos(ang) - dV3 * np.sin(ang))
YIdl = dV2 * np.sin(ang) + dV3 * np.cos(ang)
return XIdl, YIdl

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions jwst_coronagraph_visibility/tests/targets/Fomalhaut/c1_x.csv

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions jwst_coronagraph_visibility/tests/targets/Fomalhaut/c1_y.csv

Large diffs are not rendered by default.

0 comments on commit e15b592

Please sign in to comment.