Ejemplo n.º 1
0
    def plot(self):
        """Plot chart"""
        self.plt.clearPointData()
        self.plt.ax.clear()
        chart = self.Preferences.getboolean("Psychr", "chart")
        self.plt.config(self.Preferences)
        filename = conf_dir+"%s_%i.json" % (
            PsychroState().__class__.__name__, self.inputs.P.value)
        if os.path.isfile(filename):
            with open(filename, "r") as archivo:
                data = json.load(archivo)
                self.status.setText(QtWidgets.QApplication.translate(
                    "pychemqt", "Loading cached data..."))
                QtWidgets.QApplication.processEvents()
        else:
            self.progressBar.setVisible(True)
            self.status.setText(QtWidgets.QApplication.translate(
                "pychemqt", "Calculating data..."))
            QtWidgets.QApplication.processEvents()
            data = PsychroState.calculatePlot(self)
            with open(filename, "w") as file:
                json.dump(data, file, indent=4)

            self.progressBar.setVisible(False)
        self.status.setText(
            QtWidgets.QApplication.translate("pychemqt", "Plotting..."))
        QtWidgets.QApplication.processEvents()

        # Saturation line
        t = [Temperature(ti).config() for ti in data["t"]]
        Hs = data["Hs"]
        format = formatLine(self.Preferences, "Psychr", "saturation")
        if chart:
            self.plt.plot(t, Hs, **format)
        else:
            self.plt.plot(Hs, t, **format)

        # Iso dew bulb temperaure lines, vertial lines in normal h-Tdb plot,
        # vertical in mollier diagram
        format = formatLine(self.Preferences, "Psychr", "isotdb")
        for i, T in enumerate(t):
            if chart:
                self.plt.plot([T, T], [0, Hs[i]], **format)
            else:
                self.plt.plot([0, Hs[i]], [T, T], **format)

        # Iso humidity lines, horizontal lines in normal h-Tdb plot, vertical
        # in mollier diagram
        H = data["H"]
        th = data["th"]
        tm = Temperature(self.Preferences.getfloat("Psychr", "isotdbEnd"))
        format = formatLine(self.Preferences, "Psychr", "isow")
        for i, H in enumerate(H):
            ts = Temperature(th[i]).config()
            if chart:
                self.plt.plot([ts, tm.config()], [H, H], **format)
            else:
                self.plt.plot([H, H], [ts, tm.config()], **format)

        # Iso relative humidity lines
        format = formatLine(self.Preferences, "Psychr", "isohr")
        for Hr, H0 in list(data["Hr"].items()):
            if chart:
                self.plt.plot(t, H0, **format)
                self.drawlabel("isohr", t, H0, Hr, "%")
            else:
                self.plt.plot(H0, t, **format)
                self.drawlabel("isohr", H0, t, Hr, "%")

        # Iso wet bulb temperature lines
        format = formatLine(self.Preferences, "Psychr", "isotwb")
        for T, (H, Tw) in list(data["Twb"].items()):
            value = Temperature(T).config()
            Tw_conf = [Temperature(Twi).config() for Twi in Tw]
            txt = Temperature.text()
            if chart:
                self.plt.plot(Tw_conf, H, **format)
                self.drawlabel("isotwb", Tw_conf, H, value, txt)
            else:
                self.plt.plot(H, Tw_conf, **format)
                self.drawlabel("isotwb", H, Tw_conf, value, txt)

        # Isochor lines
        format = formatLine(self.Preferences, "Psychr", "isochor")
        for v, (Td, H) in list(data["v"].items()):
            value = SpecificVolume(v).config()
            Td_conf = [Temperature(Tdi).config() for Tdi in Td]
            txt = SpecificVolume.text()
            if chart:
                self.plt.plot(Td_conf, H, **format)
                self.drawlabel("isochor", Td_conf, H, value, txt)
            else:
                self.plt.plot(H, Td_conf, **format)
                self.drawlabel("isochor", H, Td_conf, value, txt)

        if self.plt.state:
            self.plt.createCrux(self.plt.state, chart)
        self.plt.draw()
        self.status.setText("%s %s" % (
            QtWidgets.QApplication.translate("pychemqt", "Using"),
            PsychroState().__class__.__name__[3:]))
Ejemplo n.º 2
0
    def plot(self):
        """Plot chart"""
        Preferences = ConfigParser()
        Preferences.read(config.conf_dir+"pychemqtrc")

        self.diagrama2D.axes2D.clear()
        self.diagrama2D.config()
        filename = config.conf_dir+"%s_%i.pkl" % (
            PsychroState().__class__.__name__, self.inputs.P.value)
        if os.path.isfile(filename):
            with open(filename, "rb") as archivo:
                data = pickle.load(archivo)
                self.status.setText(QtWidgets.QApplication.translate(
                    "pychemqt", "Loading cached data..."))
                QtWidgets.QApplication.processEvents()
        else:
            self.progressBar.setVisible(True)
            self.status.setText(QtWidgets.QApplication.translate(
                "pychemqt", "Calculating data, be patient..."))
            QtWidgets.QApplication.processEvents()
            data = PsychroState.calculatePlot(self)
            pickle.dump(data, open(filename, "wb"))
            self.progressBar.setVisible(False)
        self.status.setText(QtWidgets.QApplication.translate("pychemqt", "Plotting..."))
        QtWidgets.QApplication.processEvents()

        tmax = unidades.Temperature(Preferences.getfloat("Psychr", "isotdbEnd"))

        t = [unidades.Temperature(ti).config() for ti in data["t"]]
        Hs = data["Hs"]
        format = {}
        format["ls"] = Preferences.get("Psychr", "saturationlineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "saturationlineWidth")
        format["color"] = Preferences.get("Psychr", "saturationColor")
        format["marker"] = Preferences.get("Psychr", "saturationmarker")
        format["markersize"] = 3
        self.diagrama2D.plot(t, Hs, **format)

        format = {}
        format["ls"] = Preferences.get("Psychr", "isotdblineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isotdblineWidth")
        format["color"] = Preferences.get("Psychr", "isotdbColor")
        format["marker"] = Preferences.get("Psychr", "isotdbmarker")
        format["markersize"] = 3
        for i, T in enumerate(t):
            self.diagrama2D.plot([T, T], [0, Hs[i]], **format)

        H = data["H"]
        th = data["th"]
        format = {}
        format["ls"] = Preferences.get("Psychr", "isowlineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isowlineWidth")
        format["color"] = Preferences.get("Psychr", "isowColor")
        format["marker"] = Preferences.get("Psychr", "isowmarker")
        format["markersize"] = 3
        for i, H in enumerate(H):
            self.diagrama2D.plot([th[i], tmax.config()], [H, H], **format)

        format = {}
        format["ls"] = Preferences.get("Psychr", "isohrlineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isohrlineWidth")
        format["color"] = Preferences.get("Psychr", "isohrColor")
        format["marker"] = Preferences.get("Psychr", "isohrmarker")
        format["markersize"] = 3
        for Hr, H0 in list(data["Hr"].items()):
            self.diagrama2D.plot(t, H0, **format)
            self.drawlabel("isohr", Preferences, t, H0, Hr, "%")

        format = {}
        format["ls"] = Preferences.get("Psychr", "isotwblineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isotwblineWidth")
        format["color"] = Preferences.get("Psychr", "isotwbColor")
        format["marker"] = Preferences.get("Psychr", "isotwbmarker")
        format["markersize"] = 3
        for T, (H, Tw) in list(data["Twb"].items()):
            self.diagrama2D.plot(Tw, H, **format)
            value = unidades.Temperature(T).config()
            txt = unidades.Temperature.text()
            self.drawlabel("isotwb", Preferences, Tw, H, value, txt)

        format = {}
        format["ls"] = Preferences.get("Psychr", "isochorlineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isochorlineWidth")
        format["color"] = Preferences.get("Psychr", "isochorColor")
        format["marker"] = Preferences.get("Psychr", "isochormarker")
        format["markersize"] = 3
        for v, (Td, H) in list(data["v"].items()):
            self.diagrama2D.plot(Td, H, **format)
            value = unidades.SpecificVolume(v).config()
            txt = unidades.SpecificVolume.text()
            self.drawlabel("isochor", Preferences, Td, H, value, txt)

        self.diagrama2D.draw()
        self.status.setText(QtWidgets.QApplication.translate("pychemqt", "Using") +
                            " " + PsychroState().__class__.__name__[3:])
Ejemplo n.º 3
0
    def plot(self):
        """Plot chart"""
        Preferences = ConfigParser()
        Preferences.read(config.conf_dir + "pychemqtrc")

        self.diagrama2D.axes2D.clear()
        self.diagrama2D.config()
        filename = config.conf_dir + "%s_%i.pkl" % (
            PsychroState().__class__.__name__, self.inputs.P.value)
        if os.path.isfile(filename):
            with open(filename, "r") as archivo:
                data = cPickle.load(archivo)
                self.status.setText(
                    QtGui.QApplication.translate("pychemqt",
                                                 "Loading cached data..."))
                QtGui.QApplication.processEvents()
        else:
            self.progressBar.setVisible(True)
            self.status.setText(
                QtGui.QApplication.translate(
                    "pychemqt", "Calculating data, be patient..."))
            QtGui.QApplication.processEvents()
            data = PsychroState.calculatePlot(self)
            cPickle.dump(data, open(filename, "w"))
            self.progressBar.setVisible(False)
        self.status.setText(
            QtGui.QApplication.translate("pychemqt", "Plotting..."))
        QtGui.QApplication.processEvents()

        tmax = unidades.Temperature(Preferences.getfloat(
            "Psychr", "isotdbEnd"))

        t = [unidades.Temperature(ti).config() for ti in data["t"]]
        Hs = data["Hs"]
        format = {}
        format["ls"] = Preferences.get("Psychr", "saturationlineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "saturationlineWidth")
        format["color"] = Preferences.get("Psychr", "saturationColor")
        format["marker"] = Preferences.get("Psychr", "saturationmarker")
        format["markersize"] = 3
        self.diagrama2D.plot(t, Hs, **format)

        format = {}
        format["ls"] = Preferences.get("Psychr", "isotdblineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isotdblineWidth")
        format["color"] = Preferences.get("Psychr", "isotdbColor")
        format["marker"] = Preferences.get("Psychr", "isotdbmarker")
        format["markersize"] = 3
        for i, T in enumerate(t):
            self.diagrama2D.plot([T, T], [0, Hs[i]], **format)

        H = data["H"]
        th = data["th"]
        format = {}
        format["ls"] = Preferences.get("Psychr", "isowlineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isowlineWidth")
        format["color"] = Preferences.get("Psychr", "isowColor")
        format["marker"] = Preferences.get("Psychr", "isowmarker")
        format["markersize"] = 3
        for i, H in enumerate(H):
            self.diagrama2D.plot([th[i], tmax.config()], [H, H], **format)

        format = {}
        format["ls"] = Preferences.get("Psychr", "isohrlineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isohrlineWidth")
        format["color"] = Preferences.get("Psychr", "isohrColor")
        format["marker"] = Preferences.get("Psychr", "isohrmarker")
        format["markersize"] = 3
        for Hr, H0 in data["Hr"].iteritems():
            self.diagrama2D.plot(t, H0, **format)
            self.drawlabel("isohr", Preferences, t, H0, Hr, "%")

        format = {}
        format["ls"] = Preferences.get("Psychr", "isotwblineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isotwblineWidth")
        format["color"] = Preferences.get("Psychr", "isotwbColor")
        format["marker"] = Preferences.get("Psychr", "isotwbmarker")
        format["markersize"] = 3
        for T, (H, Tw) in data["Twb"].iteritems():
            self.diagrama2D.plot(Tw, H, **format)
            value = unidades.Temperature(T).config()
            txt = unidades.Temperature.text()
            self.drawlabel("isotwb", Preferences, Tw, H, value, txt)

        format = {}
        format["ls"] = Preferences.get("Psychr", "isochorlineStyle")
        format["lw"] = Preferences.getfloat("Psychr", "isochorlineWidth")
        format["color"] = Preferences.get("Psychr", "isochorColor")
        format["marker"] = Preferences.get("Psychr", "isochormarker")
        format["markersize"] = 3
        for v, (Td, H) in data["v"].iteritems():
            self.diagrama2D.plot(Td, H, **format)
            value = unidades.SpecificVolume(v).config()
            txt = unidades.SpecificVolume.text()
            self.drawlabel("isochor", Preferences, Td, H, value, txt)

        self.diagrama2D.draw()
        self.status.setText(
            QtGui.QApplication.translate("pychemqt", "Using") + " " +
            PsychroState().__class__.__name__[3:])
Ejemplo n.º 4
0
    def plot(self):
        """Plot chart"""
        self.plt.clearPointData()
        self.plt.ax.clear()
        chart = self.Preferences.getboolean("Psychr", "chart")
        self.plt.config(self.Preferences)
        filename = conf_dir+"%s_%i.pkl" % (
            PsychroState().__class__.__name__, self.inputs.P.value)
        if os.path.isfile(filename):
            with open(filename, "rb") as archivo:
                data = pickle.load(archivo)
                self.status.setText(QtWidgets.QApplication.translate(
                    "pychemqt", "Loading cached data..."))
                QtWidgets.QApplication.processEvents()
        else:
            self.progressBar.setVisible(True)
            self.status.setText(QtWidgets.QApplication.translate(
                "pychemqt", "Calculating data..."))
            QtWidgets.QApplication.processEvents()
            data = PsychroState.calculatePlot(self)
            pickle.dump(data, open(filename, "wb"))
            self.progressBar.setVisible(False)
        self.status.setText(
            QtWidgets.QApplication.translate("pychemqt", "Plotting..."))
        QtWidgets.QApplication.processEvents()

        # Saturation line
        t = [Temperature(ti).config() for ti in data["t"]]
        Hs = data["Hs"]
        format = formatLine(self.Preferences, "Psychr", "saturation")
        if chart:
            self.plt.plot(t, Hs, **format)
        else:
            self.plt.plot(Hs, t, **format)

        # Iso dew bulb temperaure lines, vertial lines in normal h-Tdb plot,
        # vertical in mollier diagram
        format = formatLine(self.Preferences, "Psychr", "isotdb")
        for i, T in enumerate(t):
            if chart:
                self.plt.plot([T, T], [0, Hs[i]], **format)
            else:
                self.plt.plot([0, Hs[i]], [T, T], **format)

        # Iso humidity lines, horizontal lines in normal h-Tdb plot, vertical
        # in mollier diagram
        H = data["H"]
        th = data["th"]
        tm = Temperature(self.Preferences.getfloat("Psychr", "isotdbEnd"))
        format = formatLine(self.Preferences, "Psychr", "isow")
        for i, H in enumerate(H):
            if chart:
                self.plt.plot([th[i], tm.config()], [H, H], **format)
            else:
                self.plt.plot([H, H], [th[i], tm.config()], **format)

        # Iso relative humidity lines
        format = formatLine(self.Preferences, "Psychr", "isohr")
        for Hr, H0 in list(data["Hr"].items()):
            if chart:
                self.plt.plot(t, H0, **format)
                self.drawlabel("isohr", t, H0, Hr, "%")
            else:
                self.plt.plot(H0, t, **format)
                self.drawlabel("isohr", H0, t, Hr, "%")

        # Iso wet bulb temperature lines
        format = formatLine(self.Preferences, "Psychr", "isotwb")
        for T, (H, Tw) in list(data["Twb"].items()):
            value = Temperature(T).config()
            txt = Temperature.text()
            if chart:
                self.plt.plot(Tw, H, **format)
                self.drawlabel("isotwb", Tw, H, value, txt)
            else:
                self.plt.plot(H, Tw, **format)
                self.drawlabel("isotwb", H, Tw, value, txt)

        # Isochor lines
        format = formatLine(self.Preferences, "Psychr", "isochor")
        for v, (Td, H) in list(data["v"].items()):
            value = SpecificVolume(v).config()
            txt = SpecificVolume.text()
            if chart:
                self.plt.plot(Td, H, **format)
                self.drawlabel("isochor", Td, H, value, txt)
            else:
                self.plt.plot(H, Td, **format)
                self.drawlabel("isochor", H, Td, value, txt)

        if self.plt.state:
            self.plt.createCrux(self.plt.state, chart)
        self.plt.draw()
        self.status.setText("%s %s" % (
            QtWidgets.QApplication.translate("pychemqt", "Using"),
            PsychroState().__class__.__name__[3:]))