get line data from solved power flow
339026
def get_linedata(self, sort_names=False):
        
        if not self.pflow.solved:
            logger.error('Power flow not solved when getting line data.')
            return tuple([False] * 7)
        idx = self.Line.idx
        fr = self.Line.bus1
        to = self.Line.bus2

        Sloss = self.Line.S1 + self.Line.S2

        Pfr = list(self.Line.S1.real())
        Qfr = list(self.Line.S1.imag())
        Pto = list(self.Line.S2.real())
        Qto = list(self.Line.S2.imag())

        Ploss = list(Sloss.real())
        Qloss = list(Sloss.imag())

        if sort_names:
            ret = (list(x) for x in zip(*sorted(
                zip(idx, fr, to, Pfr, Qfr, Pto, Qto, Ploss, Qloss),
                key=itemgetter(0))))
        else:
            ret = idx, fr, to, Pfr, Qfr, Pto, Qto, Ploss, Qloss

        return ret
1103215
def _varname_flow(self):
        """"""
        if not self.n:
            return

        mpq = self.system.dae.m + 2 * self.system.Bus.n
        nl = self.n

        # Pij
        xy_idx = range(mpq, mpq + nl)
        self.system.varname.append(
            listname='unamey',
            xy_idx=xy_idx,
            var_name='Pij',
            element_name=self.name)
        self.system.varname.append(
            listname='fnamey',
            xy_idx=xy_idx,
            var_name='P_{ij}',
            element_name=self.name)

        # Pji
        xy_idx = range(mpq + nl, mpq + 2 * nl)
        self.system.varname.append(
            listname='unamey',
            xy_idx=xy_idx,
            var_name='Pji',
            element_name=self.name)
        self.system.varname.append(
            listname='fnamey',
            xy_idx=xy_idx,
            var_name='P_{ji}',
            element_name=self.name)

        # Qij
        xy_idx = range(mpq + 2 * nl, mpq + 3 * nl)
        self.system.varname.append(
            listname='unamey',
            xy_idx=xy_idx,
            var_name='Qij',
            element_name=self.name)
        self.system.varname.append(
            listname='fnamey',
            xy_idx=xy_idx,
            var_name='Q_{ij}',
            element_name=self.name)

        # Qji
        xy_idx = range(mpq + 3 * nl, mpq + 4 * nl)
        self.system.varname.append(
            listname='unamey',
            xy_idx=xy_idx,
            var_name='Qji',
            element_name=self.name)
        self.system.varname.append(
            listname='fnamey',
            xy_idx=xy_idx,
            var_name='Q_{ji}',
            element_name=self.name)

        # Iij Real
        xy_idx = range(mpq + 4 * nl, mpq + 5 * nl)
        self.system.varname.append(
            listname='unamey',
            xy_idx=xy_idx,
            var_name='Iij_Re',
            element_name=self.name)
        self.system.varname.append(
            listname='fnamey',
            xy_idx=xy_idx,
            var_name='\\Re(I_{ij})',
            element_name=self.name)

        # Iij Imag
        xy_idx = range(mpq + 5 * nl, mpq + 6 * nl)
        self.system.varname.append(
            listname='unamey',
            xy_idx=xy_idx,
            var_name='Iij_Im',
            element_name=self.name)
        self.system.varname.append(
            listname='fnamey',
            xy_idx=xy_idx,
            var_name='\\Im(I_{ij})',
            element_name=self.name)

        # Iji Real
        xy_idx = range(mpq + 6 * nl, mpq + 7 * nl)
        self.system.varname.append(
            listname='unamey',
            xy_idx=xy_idx,
            var_name='Iji_Re',
            element_name=self.name)
        self.system.varname.append(
            listname='fnamey',
            xy_idx=xy_idx,
            var_name='\\Re(I_{ji})',
            element_name=self.name)

        # Iji Imag
        xy_idx = range(mpq + 7 * nl, mpq + 8 * nl)
        self.system.varname.append(
            listname='unamey',
            xy_idx=xy_idx,
            var_name='Iji_Im',
            element_name=self.name)
        self.system.varname.append(
            listname='fnamey',
            xy_idx=xy_idx,
            var_name='\\Im(I_{ji})',
            element_name=self.name)
835478
def get_lines(handle, line):
    
    for i, l in enumerate(handle):
        if i == line:
            return l
451038
def get_line(self, section, line):
        """"""
        try:
            section = self._get_section(section, create=False)
        except KeyError:
            return []
        return section.find_lines(line)
1353992
def getline(self):
        """"""
        if self.index >= len(self.lines):
            line = ''
        else:
            line = self.lines[self.index]
            self.index += 1
        return line
1209706
def s_supply(self, bus):
        
        Sg = array([complex(g.p, g.q) for g in self.generators if
                   (g.bus == bus) and not g.is_load], dtype=complex64)

        if len(Sg):
            return sum(Sg)
        else:
            return 0 + 0j
600967
def layerData(self):
        
        output = {}
        
        output['visible'] = self.isVisible()
        output['zValue']  = self.zValue()
        output['current'] = self.isCurrent()
        
        return output
600470
def compute_flows(self):
        
        system = self.system
        config = self.config
        dae = system.dae

        if config.compute_flows:
            # compute and append series injections on buses

            exec(system.call.bus_injection)
            bus_inj = dae.g[:2 * system.Bus.n]

            exec(system.call.seriesflow)
            system.Area.seriesflow(system.dae)
            system.Area.interchange_varout()
            dae.y = matrix([
                dae.y, bus_inj, system.Line._line_flows, system.Area.inter_varout
            ])
1301218
def get_data(self):
        """"""
        return self.x, self.y, self.w, self.h
684508
def _extract_dqdv(cell_data, extract_func, last_cycle):
    """"""

    from cellpy.utils.ica import dqdv
    list_of_cycles = cell_data.get_cycle_numbers()
    if last_cycle is not None:
        list_of_cycles = [c for c in list_of_cycles if c <= int(last_cycle)]
        logger.debug(f"only processing up to cycle {last_cycle}")
        logger.debug(f"you have {len(list_of_cycles)} cycles to process")
    out_data = []
    for cycle in list_of_cycles:
        try:
            c, v = extract_func(cycle)
            v, dq = dqdv(v, c)
            v = v.tolist()
            dq = dq.tolist()
        except NullData as e:
            v = list()
            dq = list()
            logger.info(" Ups! Could not process this (cycle %i)" % cycle)
            logger.info(" %s" % e)

        header_x = "dQ cycle_no %i" % cycle
        header_y = "voltage cycle_no %i" % cycle
        dq.insert(0, header_x)
        v.insert(0, header_y)

        out_data.append(v)
        out_data.append(dq)
    return out_data
173297
def retrieveVals(self):
        """"""
        for iface in self._ifaceList:
            if self._reqIfaceList is None or iface in self._reqIfaceList:
                if (self.graphEnabled('wanpipe_traffic') 
                    or self.graphEnabled('wanpipe_errors')):
                    stats = self._ifaceStats.get(iface)
                    if stats:
                        graph_name = 'wanpipe_traffic_%s' % iface
                        if self.hasGraph(graph_name):
                            for field in ('rxpackets', 'txpackets'):
                                self.setGraphVal(graph_name, field, 
                                                 stats.get(field))
                        graph_name = 'wanpipe_errors_%s' % iface
                        if self.hasGraph(graph_name):
                            for field in ('rxerrs', 'txerrs', 'rxframe', 'txcarrier',
                                'rxdrop', 'txdrop', 'rxfifo', 'txfifo'):
                                self.setGraphVal(graph_name, field, 
                                                 stats.get(field))
                if (self.graphEnabled('wanpipe_pri_errors') 
                    or self.graphEnabled('wanpipe_rxlevel')):
                    try:
                        stats = self._wanpipeInfo.getPRIstats(iface)
                    except:
                        stats = None
                    if stats:
                        graph_name = 'wanpipe_pri_errors_%s' % iface
                        if self.hasGraph(graph_name):
                            for field in ('linecodeviolation', 
                                          'farendblockerrors',
                                          'crc4errors', 'faserrors'):
                                self.setGraphVal(graph_name, field, 
                                                 stats.get(field))
                        if self.hasGraph('wanpipe_rxlevel'):
                            self.setGraphVal('wanpipe_pri_rxlevel', 
                                             iface, stats.get('rxlevel'))
273185
def do_get(self, line):
        
        pid, output_file = self._split_args(line, 2, 0)
        self._command_processor.science_object_get(pid, output_file)
        self._print_info_if_verbose(
            'Downloaded "{}" to file: {}'.format(pid, output_file)
        )
601528
def post_process_data(self, voltage=None, incremental_capacity=None,
                          voltage_step=None):
        """"""

        logging.debug("post-processing data")

        if voltage is None:
            voltage = self.voltage_processed
            incremental_capacity = self.incremental_capacity
            voltage_step = self.voltage_inverted_step

        if self.post_smoothing:
            logging.debug(" - post smoothing (gaussian)")
            logging.debug(f"    * using voltage fwhm: {self.voltage_fwhm}")
            points_fwhm = int(self.voltage_fwhm / voltage_step)

            sigma = np.amax([1, points_fwhm / 2])

            self.incremental_capacity = gaussian_filter1d(
                incremental_capacity, sigma=sigma, order=self.gaussian_order,
                mode=self.gaussian_mode,
                cval=self.gaussian_cval,
                truncate=self.gaussian_truncate
            )

        if self.normalize:
            logging.debug(" - normalizing")
            area = simps(incremental_capacity, voltage)
            self.incremental_capacity = incremental_capacity * self.normalizing_factor / abs(area)

        fixed_range = False
        if isinstance(self.fixed_voltage_range, np.ndarray):
            fixed_range = True
        else:
            if self.fixed_voltage_range:
                fixed_range = True
        if fixed_range:
            logging.debug(" - using fixed voltage range (interpolating)")
            v1, v2, number_of_points = self.fixed_voltage_range
            v = np.linspace(v1, v2, number_of_points)
            f = interp1d(x=self.voltage_processed, y=self.incremental_capacity,
                         kind=self.interpolation_method, bounds_error=False,
                         fill_value=np.NaN)

            self.incremental_capacity = f(v)
            self.voltage_processed = v
457137
def _get_line(self) -> str:
        """"""
        line = self.in_lines[self.index]
        self.index += 1
        return line
1131370
def init(self):
        
        system = self.system
        config = self.config
        dae = self.system.dae
        if system.pflow.solved is False:
            return

        t, s = elapsed()

        # Assign indices for post-powerflow device variables
        system.xy_addr1()

        # Assign variable names for bus injections and line flows if enabled
        system.varname.resize_for_flows()
        system.varname.bus_line_names()

        # Reshape dae to retain power flow solutions
        system.dae.init1()

        # Initialize post-powerflow device variables
        for device, init1 in zip(system.devman.devices, system.call.init1):
            if init1:
                system.__dict__[device].init1(system.dae)

        # compute line and area flow
        if config.compute_flows:
            dae.init_fg()
            self.compute_flows()  # TODO: move to PowerSystem

        t, s = elapsed(t)

        if system.dae.n:
            logger.debug('Dynamic models initialized in {:s}.'.format(s))
        else:
            logger.debug('No dynamic model loaded.')

        # system.dae flags initialize
        system.dae.factorize = True
        system.dae.mu = 1.0
        system.dae.kg = 0.0
224655
def _extract_line_features(self):
        
        for line in self.line_iterator:
            m = COMPILED_AUTH_LOG_REGEX.match(line)

            data = {
                'raw': line
            }

            if m:
                data.update({
                    'timestamp': self._to_epoch(m.group(1)),
                    'hostname': m.group(2),
                    'program': m.group(3),
                    'processid': m.group(4),
                    'message': m.group(5),
                })

            self.parsed_lines.append(data)
1029869
def update_line(self, trace, xdata, ydata, side='left', draw=False,
                    update_limits=True):
        

        x = self.conf.get_mpl_line(trace)
        x.set_data(xdata, ydata)
        datarange = [xdata.min(), xdata.max(), ydata.min(), ydata.max()]
        self.conf.set_trace_datarange(datarange, trace=trace)
        axes = self.axes
        if side == 'right':
            axes = self.get_right_axes()

        if update_limits:
            self.set_viewlimits()
        if draw:
            self.draw()