### Install pysiaf Source: https://github.com/spacetelescope/pysiaf/blob/main/docs/pysiaf/index.rst Instructions for installing the pysiaf package using pip or by cloning the repository and installing locally. It also addresses a common installation issue related to lxml version compatibility. ```bash pip install pysiaf ``` ```bash git clone https://github.com/spacetelescope/pysiaf cd pysiaf python setup.py install ``` ```bash pip install . ``` ```bash pip uninstall lxml pip install lxml==3.6.4 ``` -------------------------------- ### Initialize pysiaf and Plotting Setup Source: https://github.com/spacetelescope/pysiaf/blob/main/examples/check_detector_channels.ipynb Initializes the pysiaf library and sets up matplotlib for inline plotting. This is a common setup for all subsequent examples. ```Python import pysiaf import matplotlib.pyplot as plt %matplotlib inline ``` -------------------------------- ### Clone and Install pysiaf Source: https://github.com/spacetelescope/pysiaf/blob/main/README.md Clones the pysiaf repository from GitHub and installs it locally. ```Shell git clone https://github.com/spacetelescope/pysiaf cd pysiaf pip install . ``` -------------------------------- ### Install pysiaf in Develop Mode Source: https://github.com/spacetelescope/pysiaf/blob/main/README.md Installs the pysiaf package in editable mode for development. ```Shell pip install -e . ``` -------------------------------- ### Install pysiaf Source: https://github.com/spacetelescope/pysiaf/blob/main/README.md Installs the pysiaf package using pip. Supports Python 3.10+. ```Shell pip install pysiaf ``` -------------------------------- ### Finding Available Apertures Source: https://github.com/spacetelescope/pysiaf/blob/main/docs/pysiaf/index.rst Illustrates how to get a list of all available aperture names for an instrument and how to find specific apertures by matching a substring. ```Python import pysiaf siaf = pysiaf.Siaf('NIRSpec') print (len(siaf.apernames)) siaf.find_apernames('S200') ``` -------------------------------- ### Get PRD Version Source: https://github.com/spacetelescope/pysiaf/blob/main/docs/pysiaf/index.rst Demonstrates how to retrieve the current Product Requirements Document (PRD) version used by pysiaf. ```Python import pysiaf print(pysiaf.JWST_PRD_VERSION) ``` -------------------------------- ### pysiaf API Reference Documentation Links Source: https://github.com/spacetelescope/pysiaf/blob/main/docs/pysiaf/index.rst Links to the various API reference files available for the pysiaf project, covering different aspects of its functionality. ```APIDOC .. toctree:: :maxdepth: 1 aperture.rst compare.rst polynomial.rst projection.rst read.rst rotations.rst siaf.rst tools.rst write.rst ``` -------------------------------- ### Troubleshoot lxml ImportError Source: https://github.com/spacetelescope/pysiaf/blob/main/README.md Downgrades the lxml package to resolve an ImportError related to libxml2 version incompatibility. ```Shell pip uninstall lxml pip install lxml==3.6.4 ``` -------------------------------- ### Fetch and Checkout Contributor Branch Source: https://github.com/spacetelescope/pysiaf/wiki/How-to-use-the-feature-branch-of-someone-else's-pull-request This snippet demonstrates how to add a contributor's fork as a remote repository, fetch their branch, and check it out locally for code review. ```git git remote add coworker https://github.com/coworker/pysiaf.git git fetch coworker git checkout --track coworker/branchname ``` -------------------------------- ### SIAF Instrument and Aperture Handling Source: https://github.com/spacetelescope/pysiaf/blob/main/README.md Demonstrates how to read SIAF XML files for a specified instrument, select a single aperture by name, and access its parameters like V2Ref and V3Ref. It also shows how to retrieve other attributes of an aperture. ```Python import pysiaf import numpy as np 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))) ``` -------------------------------- ### pysiaf Contribution Workflow Source: https://github.com/spacetelescope/pysiaf/blob/main/docs/pysiaf/index.rst Steps for contributing to the pysiaf project, from forking the repository to merging a pull request. Emphasizes not committing sensitive information and following a structured process for code changes. ```text 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, if you are allowed to do so. 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. ``` -------------------------------- ### Check JWST PRD Version Source: https://github.com/spacetelescope/pysiaf/blob/main/README.md Retrieves and prints the current version of the JWST Project Reference Database (PRD) used by the pysiaf package. ```Python import pysiaf print(pysiaf.JWST_PRD_VERSION) ``` -------------------------------- ### Sky Coordinate Transformations Source: https://github.com/spacetelescope/pysiaf/blob/main/docs/pysiaf/index.rst Explains how to perform transformations to and from sky coordinates (RA, Dec) by first defining an attitude matrix representing the observatory's orientation. ```Python import pysiaf from pysiaf.utils.rotations import attitude_matrix # Assume v2, v3, ra, dec, pa are defined # attmat = attitude_matrix(v2, v3, ra, dec, pa) # nis_cen.set_attitude_matrix(attmat) # sci_x, sci_y are defined from previous example # sky_ra, sky_dec = nis_cen.sci_to_sky(sci_x, sci_y) ``` -------------------------------- ### SIAF Frame Transformations Source: https://github.com/spacetelescope/pysiaf/blob/main/docs/pysiaf/index.rst Shows how to load SIAF data for a specific instrument, access aperture parameters, and perform coordinate transformations between Science (sci) and Ideal (idl) frames. ```Python import pysiaf import numpy as np 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) ``` -------------------------------- ### MIRIFU Configuration Data Source: https://github.com/spacetelescope/pysiaf/blob/main/pysiaf/source_data/MIRI/delivery/miri_siaf_aperture_definition.txt This data represents configuration parameters for the MIRIFU instrument's CHANNEL3B and SLIT modes. It includes identifiers, types, and a series of numerical values that likely define instrumental characteristics or calibration data. ```Python MIRIFU_CHANNEL3B , COMPOUND , 0. , -1 , None , None , None , None , None , None , None , None , None , None , None , None , -504.0859 , -319.1972 , -506.4087 , -506.9549 , -501.7622 , -501.1985 , -315.7690 , -319.1972 , -321.9363 , -321.9363 MIRIFU_3BSLICE01 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 301B , 1 , -503.8258 , -316.2850 , -506.6063 , -506.6404 , -501.0121 , -501.0121 , -315.7446 , -316.1298 , -316.8327 , -316.8327 MIRIFU_3BSLICE02 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 302B , 2 , -503.8605 , -316.6733 , -506.5960 , -506.6301 , -501.0927 , -501.0927 , -316.1353 , -316.5206 , -317.2184 , -317.2184 MIRIFU_3BSLICE03 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 303B , 3 , -503.8951 , -317.0616 , -506.5687 , -506.6028 , -501.1621 , -501.1621 , -316.5284 , -316.9137 , -317.6054 , -317.6054 MIRIFU_3BSLICE04 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 304B , 4 , -503.9298 , -317.4499 , -506.5831 , -506.6172 , -501.1889 , -501.1889 , -316.9162 , -317.3016 , -317.9978 , -317.9978 MIRIFU_3BSLICE05 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 305B , 5 , -503.9645 , -317.8382 , -506.6086 , -506.6428 , -501.1589 , -501.1589 , -317.3027 , -317.6881 , -318.3975 , -318.3975 MIRIFU_3BSLICE06 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 306B , 6 , -503.9992 , -318.2265 , -506.5919 , -506.6260 , -501.2461 , -501.2461 , -317.6947 , -318.0801 , -318.7821 , -318.7821 MIRIFU_3BSLICE07 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 307B , 7 , -504.0339 , -318.6148 , -506.6135 , -506.6476 , -501.1840 , -501.1840 , -318.0817 , -318.4672 , -319.1863 , -319.1863 MIRIFU_3BSLICE08 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 308B , 8 , -504.0685 , -319.0031 , -506.7349 , -506.7690 , -501.2039 , -501.2039 , -318.4557 , -318.8411 , -319.5798 , -319.5798 MIRIFU_3BSLICE09 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 309B , 9 , -504.1032 , -319.3914 , -506.7969 , -506.8310 , -501.4506 , -501.4506 , -318.8374 , -319.2227 , -319.9429 , -319.9429 MIRIFU_3BSLICE10 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 310B , 10 , -504.1379 , -319.7797 , -506.8748 , -506.9089 , -501.5508 , -501.5508 , -319.2168 , -319.6021 , -320.3253 , -320.3253 MIRIFU_3BSLICE11 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 311B , 11 , -504.1726 , -320.1679 , -506.8922 , -506.9263 , -501.5477 , -501.5477 , -319.6044 , -319.9897 , -320.7217 , -320.7217 MIRIFU_3BSLICE12 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 312B , 12 , -504.2073 , -320.5562 , -506.9274 , -506.9615 , -501.4754 , -501.4754 , -319.9895 , -320.3748 , -321.1276 , -321.1276 MIRIFU_3BSLICE13 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 313B , 13 , -504.2420 , -320.9445 , -506.9433 , -506.9774 , -501.5292 , -501.5292 , -320.3773 , -320.7626 , -321.5164 , -321.5164 MIRIFU_3BSLICE14 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 314B , 14 , -504.2766 , -321.3328 , -506.9737 , -507.0078 , -501.5279 , -501.5279 , -320.7632 , -321.1485 , -321.9127 , -321.9127 ``` -------------------------------- ### MIRIFU Instrument Data Source: https://github.com/spacetelescope/pysiaf/blob/main/pysiaf/source_data/MIRI/delivery/miri_siaf_aperture_definition.txt This snippet presents raw data for the MIRIFU instrument, detailing configurations for various slices and channels. It includes parameters such as slice names, types, and a series of numerical coordinates. ```Python MIRIFU_3CSLICE13 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 313C , 13 , -504.1189 , -320.9252 , -506.7941 , -506.8284 , -501.4108 , -501.3740 , -320.3589 , -320.7441 , -321.4993 , -321.1081 MIRIFU_3CSLICE14 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 314C , 14 , -504.1544 , -321.3134 , -506.8425 , -506.8768 , -501.4187 , -501.3818 , -320.7421 , -321.1273 , -321.8945 , -321.5033 MIRIFU_3CSLICE15 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 315C , 15 , -504.1900 , -321.7015 , -506.9268 , -506.9612 , -501.4119 , -501.3751 , -321.1202 , -321.5053 , -322.2918 , -321.9006 MIRIFU_3CSLICE16 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 316C , 16 , -504.2255 , -322.0896 , -507.0293 , -507.0635 , -501.5875 , -501.5508 , -321.4957 , -321.8807 , -322.6632 , -322.2721 MIRIFU_CHANNEL4A , COMPOUND , 0. , -1 , None , None , None , None , None , None , None , None , None , None , None , None , -502.7341 , -319.7380 , -505.5546 , -506.8113 , -500.3141 , -498.9470 , -315.3317 , -323.1375 , -324.0244 , -316.3576 MIRIFU_4ASLICE01 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 401A , 1 , -502.1315 , -316.1939 , -505.5880 , -505.6927 , -498.8883 , -498.7741 , -315.3265 , -315.9770 , -317.0231 , -316.3845 MIRIFU_4ASLICE02 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 402A , 2 , -502.2411 , -316.8383 , -505.6593 , -505.7640 , -499.0580 , -498.9439 , -315.9822 , -316.6326 , -317.6532 , -317.0145 MIRIFU_4ASLICE03 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 403A , 3 , -502.3506 , -317.4826 , -505.7958 , -505.9005 , -499.1357 , -499.0216 , -316.6278 , -317.2783 , -318.2974 , -317.6588 MIRIFU_4ASLICE04 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 404A , 4 , -502.4602 , -318.1270 , -505.9832 , -506.0878 , -499.3127 , -499.1986 , -317.2659 , -317.9166 , -318.9267 , -318.2879 MIRIFU_4ASLICE05 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 405A , 5 , -502.5698 , -318.7714 , -506.1491 , -506.2535 , -499.4732 , -499.3593 , -317.9074 , -318.5582 , -319.5585 , -318.9197 MIRIFU_4ASLICE06 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 406A , 6 , -502.6794 , -319.4158 , -506.2663 , -506.3708 , -499.5284 , -499.4144 , -318.5563 , -319.2071 , -320.2059 , -319.5672 MIRIFU_4ASLICE07 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 407A , 7 , -502.7889 , -320.0602 , -506.3713 , -506.4757 , -499.6183 , -499.5042 , -319.2071 , -319.8579 , -320.8481 , -320.2095 MIRIFU_4ASLICE08 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 408A , 8 , -502.8985 , -320.7046 , -506.4240 , -506.5286 , -499.7641 , -499.6501 , -319.8654 , -320.5161 , -321.4823 , -320.8436 MIRIFU_4ASLICE09 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 409A , 9 , -503.0081 , -321.3490 , -506.5860 , -506.6904 , -499.8959 , -499.7818 , -320.5079 , -321.1587 , -322.1185 , -321.4798 MIRIFU_4ASLICE10 , SLIT , 0. , -1 , None , None , None , None , None , None , None , None , None , None , 410A , 10 , -503.1176 , -321.9933 , -506.7043 , -506.8087 , -500.0862 , -499.9723 , -321.1567 , -321.8076 , -322.7466 , -322.1077 ``` -------------------------------- ### pysiaf.utils.rotations Module Documentation Source: https://github.com/spacetelescope/pysiaf/blob/main/docs/pysiaf/rotations.rst This section provides the API documentation for the pysiaf.utils.rotations module. It details all public and private members, including functions and classes, along with their respective functionalities and parameters. ```APIDOC .. automodule:: pysiaf.utils.rotations :members: :undoc-members: ```