Writes bus data in MATPOWER format.

def write_bus_data(self, file):
        """ Writes bus data in MATPOWER format.
        """
#        labels = ["bus_id", "type", "Pd", "Qd", "Gs", "Bs", "area", "Vm", "Va",
#            "baseKV", "Vmax", "Vmin"]

        bus_attrs = ["_i", "type", "p_demand", "q_demand", "g_shunt","b_shunt",
            "area", "v_magnitude", "v_angle", "v_base", "zone",
            "v_max", "v_min", "p_lmbda", "q_lmbda", "mu_vmin", "mu_vmax"]

        file.write("\n%%%% bus data\n")
        file.write("%%\tbus_i\ttype\tPd\tQd\tGs\tBs\tarea\tVm\tVa\tbaseKV"
                   "\tzone\tVmax\tVmin\tlam_P\tlam_Q\tmu_Vmax\tmu_Vmin")
        file.write("\n%sbus = [\n" % self._prefix)


        for bus in self.case.buses:
            vals = [getattr(bus, a) for a in bus_attrs]
            d = {PQ: 1, PV: 2, REFERENCE: 3, ISOLATED: 4}
            vals[1] = d[vals[1]]

            assert len(vals) == 17

            file.write("\t%d\t%d\t%g\t%g\t%g\t%g\t%d\t%.8g\t%.8g\t%g\t%d\t%g"
                       "\t%g\t%.4f\t%.4f\t%.4f\t%.4f;\n" % tuple(vals[:]))
        file.write("];\n")