spacetelescope/pysiaf

Name: pysiaf

Owner: Space Telescope Science Institute

Description: Handling of Science Instrument Aperture Files (SIAF) for space telescopes

Created: 2018-02-21 20:46:32.0

Updated: 2018-05-18 15:20:33.0

Pushed: 2018-05-18 16:53:21.0

Homepage:

Size: 11068

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

pysiaf

Handling of Science Instrument Aperture Files (SIAF) for space telescopes. SIAF files contain detailed geometric focal plane descriptions and relationships for the science instruments. They are maintained in the JWST/HST PRD (Project Reference Database).
pysiaf is a python package to access, interpret, maintain, and generate SIAF, in particular for JWST. Tools for applying the frame transformations, plotting, comparison, and validation are provided.

Functionalities
Example usage

Check which PRD version is in use:

`print(pysiaf.JWST_PRD_VERSION)`

Frame transformations (det, sci, idl, tel are supported frames):

import pysiaf
instrument = 'NIRISS'

# read SIAFXML
siaf = pysiaf.Siaf(instrument)  

# select single aperture by name
nis_cen = siaf['NIS_CEN']  

# access SIAF parameters
print('{} V2Ref = {}'.format(nis_cen.AperName, nis_cen.V2Ref))
print('{} V3Ref = {}'.format(nis_cen.AperName, nis_cen.V3Ref))

for attribute in ['InstrName', 'AperShape']:
    print('{} {} = {}'.format(nis_cen.AperName, attribute, getattr(nis_cen, attribute)))


# coordinates in Science frame
sci_x = np.array([0, 2047, 2047, 0])
sci_y = np.array([0, 0, 2047, 2047])  

# transform from Science frame to Ideal frame
idl_x, idl_y = nis_cen.sci_to_idl(sci_x, sci_y)

Plotting (only a small subset of options is illustrated):

import pylab as pl

pl.figure(figsize=(4, 4), facecolor='w', edgecolor='k'); pl.clf()

# plot single aperture
nis_cen.plot()

# plot all apertures in SIAF
for aperture_name, aperture in siaf.apertures.items():
    aperture.plot()
pl.show()
# plot 'master' apertures
from pysiaf.siaf import plot_master_apertures
pl.figure(figsize=(8, 8), facecolor='w', edgecolor='k'); pl.clf()
plot_master_apertures(mark_ref=True)
pl.show()
# plot HST apertures
siaf = pysiaf.Siaf('HST')
aperture_names = ['FGS1', 'FGS2', 'FGS3', 'IUVIS1FIX', 'IUVIS2FIX', 'JWFC1FIX', 'JWFC2FIX']

pl.figure(figsize=(4, 4), facecolor='w', edgecolor='k')
for aperture_name in aperture_names:
    siaf[aperture_name].plot(color='r', fill_color='darksalmon', mark_ref=True)
ax = pl.gca()
ax.set_aspect('equal')
ax.invert_yaxis()
pl.show()
Disclaimer

All parameter values in pysiaf are subject to change. JWST values are preliminary until the JWST observatory commissioning has concluded.

Distortion and other transformations in pysiaf are of sufficient accuracy for operations, but do not necessarily have science-grade quality. For instance, generally only one filter solution is carried per aperture. For science-grade transformations, please consult the science pipelines and their reference files (see https://jwst-docs.stsci.edu/display/JDAT/JWST+Data+Reduction+Pipeline)

For science observation planning, the focal plane geometry implemented in the latest APT (http://www.stsci.edu/hst/proposing/apt) takes precedence.

The STScI Telescopes Branch provides full support of pysiaf for S&OC operational systems only.

Documentation

The primary reference for a description of JWST SIAF is Cox & Lallo, 2017, JWST-STScI-001550: Description and Use of the JWST Science Instrument Aperture File.

pysiaf will be documented at TBD.

Contributing

Please open a new issue or new pull request for bugs, feedback, or new features you would like to see. If there is an issue you would like to work on, please leave a comment and we will be happy to assist. New contributions and contributors are very welcome!
Do you have feedback and feature requests? Is there something missing you would like to see? Please open an issue or send an email to the maintainers. This package follows the Spacetelescope Code of Conduct strives to provide a welcoming community to all of our users and contributors.

The following describes the typical work flow for contributing to the pysiaf project (adapted from JWQL):

  1. Do not commit any sensitive information (e.g. STScI-internal path structures, machine names, user names, passwords, etc.) to this public repository. Git history cannot be erased.
  2. Create a fork off of the spacetelescope pysiaf repository on your personal github space.
  3. Make a local clone of your fork.
  4. Ensure your personal fork is pointing upstream to https://github.com/spacetelescope/pysiaf
  5. Open an issue on spacetelescope pysiaf that describes the need for and nature of the changes you plan to make. This is not necessary for minor changes and fixes.
  6. Create a branch on that personal fork.
  7. Make your software changes.
  8. Push that branch to your personal GitHub repository, i.e. to origin.
  9. On the spacetelescope pysiaf repository, create a pull request that merges the branch into spacetelescope:master.
  10. Assign a reviewer from the team for the pull request.
  11. Iterate with the reviewer over any needed changes until the reviewer accepts and merges your branch.
  12. Delete your local copy of your branch.
References

The pysiaf prototype was developed on gitlab (STScI internal access only) and is kept there for reference: https://grit.stsci.edu/ins-tel/jwst_siaf_prototype

pysiaf partially recycles code from https://github.com/mperrin/jwxml

Installation

This package was developed in a python 3.5 environment.

pip install pysiaf

Clone the repository:
git clone https://github.com/spacetelescope/pysiaf
Install pysiaf:
cd pysiaf
python setup.py install or
pip install .

Known installation issue

If you get an error upon
import pysiaf
that traces back to
import lxml.etree as ET
and states

`ImportError [...] Library not loaded: libxml2.2.dylib   
Reason: Incompatible library version: etree.[...] requires version 12.0.0 or later,
but libxml2.2.dylib provides version 10.0.0`,       

this can probably be fixed by downgrading the version of lxml, e.g.

`pip uninstall lxml`  
`pip install lxml==3.6.4`

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.