Example #1
0
    def current_focus(self):
        """Method calculates the focus of the lenses array currently inserted
        in the transfocator

        Returns
        -------
        float
            Returns the current focus of the beryllium lens array already
            inserted in the transfocator.

        """
        #makeing a list of lenses already in the transfocator, looping through
        #and adding them to the list if they are
        already_in = []
        for lens in self.xrt_lenses:
            if lens.inserted:
                already_in.append(lens)
        for lens in self.tfs_lenses:
            if lens.inserted == True:
                already_in.append(lens)
        logger.debug(
            "There are %s lenses already inserted in the Transfocator" %
            (len(already_in)))
        #makr the list of already-inserted lenses a LensCOnnect of arbitrary length
        already_in = LensConnect(*already_in)
        #get the current focal length/image
        focus = already_in.image(0.0)
        logger.debug("The current focus of the inserted lenses is %s" % focus)
        return focus
Example #2
0
    def find_best_combo(self, i, n=4, obj=0.0):
        """Method calculates the best lens array to meet the user's target
        image.

        Parameters
        ----------
        i : float
            The target image of the lens array
        n : int
            The maximum number of lenses in the array. Note: will automatically
            be set to 5 unless otherwise specified by the user.
        obj : float
            Location of the lens object along the beam pipeline measured in
            meters.  Parameter will be set to 0 unles otherwise specified by
            the user
        """

        #create a calculator
        calc = Calculator(self.xrt_lenses, self.tfs_lenses,
                          self.xrt_limit.value, self.tfs_limit.value)
        #create a list of all the possible combinations of the lenses in the
        #calculator and puts them in order with the array with the image
        #closest to the target image first and so on
        combos = calc.find_combinations(i, n, obj)

        #create a list for the best combination of lenses
        best_combo = []
        #extend the list to add the xrt and tfs lenses as Lenses
        best_combo.extend(combos[0].xrt.lenses)
        best_combo.extend(combos[0].tfs.lenses)
        #instantiate the best combo as a LensConnect objet
        best_combo = LensConnect(*best_combo)
        return best_combo
Example #3
0
    def combinations(self, include_prefocus=True):
        """
        All possible combinations of the given lenses

        Parameters
        ----------
        include_prefocus : bool
            Use only combinations that include a prefocusing lens. If False,
            only combinations of Transfocator lenses are returned

        Returns
        -------
        combos: list
            List of LensConnect objects
        """
        combos = list()
        tfs_combos = list()
        # Warn operators if we received no transfocator lenses
        if include_prefocus and not self.xrt_lenses:
            logger.warning("No XRT lens given to calculator, but prefocusing "
                           "was requested")
            include_prefocus = False
        # Initially only consider transfocator lenses
        for i in range(1, len(self.tfs_lenses)+1):
            list_combos = list(itertools.combinations(self.tfs_lenses, i))
            # Create LensConnect objects from all of our possible combinations
            tfs_combos.extend([LensConnect(*combo) for combo in list_combos])
        logger.debug("Found %s combinations of Transfocator lenses",
                     len(tfs_combos))
        # If we don't want to prefocus return only Transfocator lenses
        if not include_prefocus:
            return tfs_combos
        # Loop through all the prefocusing lenses
        for prefocus in self.xrt_lenses:
            c = LensConnect(prefocus)
            for combo in tfs_combos:
                # Create combinations of prefocusing and transfocating lenses
                combos.append(LensConnect.connect(c, combo))
        logger.debug("Found %s total combinations of lenses", len(combos))
        return combos
Example #4
0
class TransfocatorCombo(object):
    """Class creates and keeps track of the lens array lists and calculates the
    image of the combined xrt/tfs beryllium lens array

    Attributes
    ----------
    xrt : list
        A list of the xrt lenses with all the attributes of the LensConnect
        class
    tfs : list
        A list of the tfs lenses with all the attributes of the LensConnect
        class
    """

    #define TransfocatorCombo attributes
    #Note: onely one xrt can be entered for this but multiple tfs lenses can be
    #entered
    def __init__(self, xrt, tfs):
        self.xrt = LensConnect(xrt)
        self.tfs = LensConnect(*tfs)

    def image(self, z_obj):
        """Method calculates the image of the combined tfs and xrt lens array
        
        Returns
        -------
        float
            Returns the image of the xrt/tfs lens array
        """
        #
        xrt_image = self.xrt.image(z_obj)
        total_image = self.tfs.image(xrt_image)
        logger.debug(
            "the xrt image of the array is %s and the image of the combined xrt/tfs array is %s"
            % (xrt_image, total_image))
        return total_image
Example #5
0
def array():
    first = FakeLens(500.0, 100.0, 50.0)
    second = FakeLens(500.0, 275.0, 25.0)
    return LensConnect(second, first)
Example #6
0
def lens_array():
    first = Lens("TST:TFS:LENS:01:", name='Lens 1')
    second = Lens("TST:TFS:LENS:02:", name='Lens 2')
    third = Lens("TST:TFS:LENS:03:", name='Lens 3')
    return LensConnect(first, second, third)
Example #7
0
 def __init__(self, xrt, tfs):
     self.xrt = LensConnect(xrt)
     self.tfs = LensConnect(*tfs)