def map_fun(df, mapping):
     """ Actual mapping function """
     df_map = tfs.TfsDataFrame(index=df.index, columns=mapping.keys())
     for var, magnets in mapping.iteritems():
         df_map[var] = df.loc[:, upper(magnets.index)].mul(
             magnets.values, axis="columns").sum(axis="columns")
     return df_map
Ejemplo n.º 2
0
    def _get_input_elements(self):
        """ Return variable names of input elements.

        Dev hint: Define _var_to_el and _twiss first!
        """
        v2e = self._var_to_el
        tw = self._twiss

        el_in = dict.fromkeys(v2e.keys())
        for order in el_in:
            el_order = []
            for var in v2e[order]:
                el_order += upper(v2e[order][var].index)
            el_in[order] = tw.loc[list(set(el_order)), "S"].sort_values().index.tolist()
        return el_in