Metadata-Version: 2.1
Name: transfocate
Version: 0.5.8
Summary: Automated Calculation of Transfocator Focusing Optics
Author: SLAC National Accelerator Laboratory
License: Copyright (c) 2023, The Board of Trustees of the Leland Stanford Junior
        University, through SLAC National Accelerator Laboratory (subject to receipt
        of any required approvals from the U.S. Dept. of Energy). All rights reserved.
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        (1) Redistributions of source code must retain the above copyright notice,
            this list of conditions and the following disclaimer.
        
        (2) Redistributions in binary form must reproduce the above copyright notice,
            this list of conditions and the following disclaimer in the documentation
            and/or other materials provided with the distribution.
        
        (3) Neither the name of the Leland Stanford Junior University, SLAC National
            Accelerator Laboratory, U.S. Dept. of Energy nor the names of its
            contributors may be used to endorse or promote products derived from this
            software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, THE UNITED STATES GOVERNMENT,
        OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
        EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
        OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
        IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
        OF SUCH DAMAGE.
        
        You are under no obligation whatsoever to provide any bug fixes, patches, or
        upgrades to the features, functionality or performance of the source code
        ("Enhancements") to anyone; however, if you choose to make your Enhancements
        available either publicly, or directly to SLAC National Accelerator Laboratory,
        without imposing a separate written license agreement for such Enhancements,
        then you hereby grant the following license: a non-exclusive, royalty-free
        perpetual license to install, use, modify, prepare derivative works, incorporate
        into other computer software, distribute, and sublicense such Enhancements or
        derivative works thereof, in binary and source code form.
        
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
License-File: LICENSE.md
License-File: AUTHORS.rst
Requires-Dist: databroker
Requires-Dist: bluesky
Requires-Dist: matplotlib
Requires-Dist: numpy
Requires-Dist: openpyxl
Requires-Dist: ophyd
Requires-Dist: pandas
Requires-Dist: pcdsdevices
Requires-Dist: prettytable
Requires-Dist: reportlab
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Provides-Extra: docs
Requires-Dist: docs-versions-menu; extra == "docs"
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinxcontrib-jquery; extra == "docs"
Requires-Dist: sphinx_rtd_theme; extra == "docs"
Requires-Dist: ipython; extra == "docs"

transfocate
===========
.. image:: https://travis-ci.org/pcdshub/transfocate.svg?branch=master
    :target: https://travis-ci.org/pcdshub/transfocate

* ophyd Devices for transfocator access in hutch-python
* Automated calculation of beryllium lens focusing optics for MFX Transfocator
* Automated checkout tools for verifying PLC interlock status
* Report generation for the latter

Note about RP
-------------

This module is not under Radiation Protection's defined scope for items which require
a permit to complete.

Note about the IOC
------------------

ioc-mfx-tfs-lens holds some important state for this ophyd support and calculations to work properly.
If you experience zero division exceptions when performing calculations, chances are that the IOC
has some invalid values stored.

Automated Checkout tools
=========================

These scripts use the IOC-defined bypass tools, meaning that no lenses will be
moved and photon energy does _not_ need to change.

** Do not run these scripts without permission from MFX. **

Performing a checkout
---------------------

First, load an IPython session with this module:

.. code-block:: bash

    $ source /reg/g/pcds/pyps/conda/pcds_conda
    $ ipython -i -m transfocate.automated_checkout

If the above times out, re-run the script.  It's ophyd related and will be
resolved eventually.  Otherwise, continue on.

Manual mode
-----------

To perform a scan for a single XRT lens, use:

.. code-block:: python

    >>> sweep_and_plot_xrt(xrt_lens, num_steps=100)

This will choose different combinations of TFS lenses to span the region, and
scan energy in 100 discrete steps.
To perform a scan for _all_ XRT lenses, use:

.. code-block:: python

    >>> sweep_and_plot_xrt_all(num_steps=100)

Per-lens data and plots will be saved to Excel and PNG/PDF files, respectively.
This can be combined into a full checkout report with the following:

.. code-block:: python

    >>> generate_report()

Automatic mode
---------------------

Automatic mode will perform ``sweep_and_plot_xrt_all()`` and
``generate_report()`` for you.

Report generation
---------------------

Report generation will use the files generated from the scan steps above.
It will only use existing files from the current directory.
It can be used on its own - after exiting the IPython session and reloading
it - without scanning again.

Now, you'll have the option to perform the steps automatically or manually.

Authors
=======

Teddy Rendahl, Taryn Imamura, Ken Lauer, and anyone else listed in `git blame`.
