Exemplo n.º 1
0
    def recalculate(self):
        longitude = self.left.ui.LongitudeLineEdit.value()  # lambda
        latitude = self.left.ui.latitudeLineEdit.value()    # Phi
        treeHeight = int(self.left.ui.treeHeightLineEdit.value())

        # Step 1: calculate sun set and sun rise
        dateTime = QDateTime(self.left.ui.dateEdit.date(), QTime(12,0), Qt.UTC)
        self.theSun.recalculate(dateTime, longitude, latitude, treeHeight)

        sunRise = QTime(int(self.theSun.Aufgang),  int(60.0*(self.theSun.Aufgang - int(self.theSun.Aufgang))))
        sunSet = QTime(int(self.theSun.Untergang), int(60.0*(self.theSun.Untergang - int(self.theSun.Untergang))))
        self.left.ui.sunriseLineEdit.setText(sunRise.toString(Qt.ISODate))
        self.left.ui.sunsetLineEdit.setText(sunSet.toString(Qt.ISODate))
        minuteStart = sunRise.msecsSinceStartOfDay() / 1000 / 60 
        minuteEnd = sunSet.msecsSinceStartOfDay() / 1000 / 60 
        self.left.ui.timeSlider.setMinimum(minuteStart)
        self.left.ui.timeSlider.setMaximum(minuteEnd)
        
        # Construct a time zone. NOTE: use IDs instead
        tzIdx = self.left.ui.timeZoneComboBox.currentIndex()
        timeZone = self.timeZones[tzIdx]
        dateTime = QDateTime(self.left.ui.dateEdit.date(), self.left.ui.timeEdit.time(), timeZone)

        self.theSun.recalculate(dateTime, longitude, latitude, treeHeight)
        self.left.ui.timeUTCLineEdit.setText(self.theSun.dateTimeUtc.toString(Qt.ISODate))
        self.left.ui.jDLineEdit.setText(str(self.theSun.JD))
        self.left.ui.timeVariableNLineEdit.setText(str(self.theSun.n))
        self.left.ui.LVariableLineEdit.setText(str(self.theSun.L))
        self.left.ui.meanAnomalyGLineEdit.setText(str(self.theSun.g))
        self.left.ui.eclipticLengthLineEdit.setText(str(self.theSun.Lambda))
        self.left.ui.eclipticSkewLineEdit.setText(u"{}\u00B0 / {} rad".format(self.theSun.epsilon, math.radians(self.theSun.epsilon)))
        self.left.ui.rightAscensionLineEdit.setText(u"{}\u00B0 / {} rad".format(self.theSun.alpha, math.radians(self.theSun.alpha)))
        self.left.ui.declinationLineEdit.setText(u"{}\u00B0 / {} rad".format(self.theSun.delta, math.radians(self.theSun.delta)))
        self.left.ui.jD_0LineEdit.setText(str(self.theSun.JD_0))
        self.left.ui.t_0LineEdit.setText(str(self.theSun.T_0))
        self.left.ui.sternzeitH_GLineEdit.setText(str(self.theSun.ThetaH_G))
        self.left.ui.greenwichStundenwinkelFP_GLineEdit.setText(str(self.theSun.Theta_G))
        self.left.ui.stundenwinkelFrHlingspunktLineEdit.setText(str(self.theSun.Theta))
        self.left.ui.stundenwinkelLineEdit.setText(str(self.theSun.tau))

        self.left.ui.azimutALineEdit.setText(u"{:.1f}\u00B0".format(self.theSun.azimut))
        self.left.ui.sunHeightHLineEdit.setText(u"{:.1f}\u00B0".format(math.degrees(self.theSun.sunHeight)))
        self.left.ui.shadowLengthLineEdit.setText("{:.1f} m".format(self.theSun.shadowLength))

        self.right.setAngle(self.theSun.azimut) # shadowAngle)
        self.right.setShadowLength(self.theSun.shadowLength)
 def changedTimeEnd(self, time: QTime):
     timeSeconds = time.msecsSinceStartOfDay() / 1e3
     self.ui.audioWidget.changeEndPos(timeSeconds)
     self.ui.timeStart.setMaximumTime(self.ui.timeEnd.time())
Exemplo n.º 3
0
    def recalculate(self):
        longitude = self.left.ui.LongitudeLineEdit.value()  # lambda
        latitude = self.left.ui.latitudeLineEdit.value()  # Phi
        treeHeight = int(self.left.ui.treeHeightLineEdit.value())

        # Step 1: calculate sun set and sun rise
        dateTime = QDateTime(self.left.ui.dateEdit.date(), QTime(12, 0),
                             Qt.UTC)
        self.theSun.recalculate(dateTime, longitude, latitude, treeHeight)

        sunRise = QTime(
            int(self.theSun.Aufgang),
            int(60.0 * (self.theSun.Aufgang - int(self.theSun.Aufgang))))
        sunSet = QTime(
            int(self.theSun.Untergang),
            int(60.0 * (self.theSun.Untergang - int(self.theSun.Untergang))))
        self.left.ui.sunriseLineEdit.setText(sunRise.toString(Qt.ISODate))
        self.left.ui.sunsetLineEdit.setText(sunSet.toString(Qt.ISODate))
        minuteStart = sunRise.msecsSinceStartOfDay() / 1000 / 60
        minuteEnd = sunSet.msecsSinceStartOfDay() / 1000 / 60
        self.left.ui.timeSlider.setMinimum(minuteStart)
        self.left.ui.timeSlider.setMaximum(minuteEnd)

        # Construct a time zone. NOTE: use IDs instead
        tzIdx = self.left.ui.timeZoneComboBox.currentIndex()
        timeZone = self.timeZones[tzIdx]
        dateTime = QDateTime(self.left.ui.dateEdit.date(),
                             self.left.ui.timeEdit.time(), timeZone)

        self.theSun.recalculate(dateTime, longitude, latitude, treeHeight)
        self.left.ui.timeUTCLineEdit.setText(
            self.theSun.dateTimeUtc.toString(Qt.ISODate))
        self.left.ui.jDLineEdit.setText(str(self.theSun.JD))
        self.left.ui.timeVariableNLineEdit.setText(str(self.theSun.n))
        self.left.ui.LVariableLineEdit.setText(str(self.theSun.L))
        self.left.ui.meanAnomalyGLineEdit.setText(str(self.theSun.g))
        self.left.ui.eclipticLengthLineEdit.setText(str(self.theSun.Lambda))
        self.left.ui.eclipticSkewLineEdit.setText(u"{}\u00B0 / {} rad".format(
            self.theSun.epsilon, math.radians(self.theSun.epsilon)))
        self.left.ui.rightAscensionLineEdit.setText(
            u"{}\u00B0 / {} rad".format(self.theSun.alpha,
                                        math.radians(self.theSun.alpha)))
        self.left.ui.declinationLineEdit.setText(u"{}\u00B0 / {} rad".format(
            self.theSun.delta, math.radians(self.theSun.delta)))
        self.left.ui.jD_0LineEdit.setText(str(self.theSun.JD_0))
        self.left.ui.t_0LineEdit.setText(str(self.theSun.T_0))
        self.left.ui.sternzeitH_GLineEdit.setText(str(self.theSun.ThetaH_G))
        self.left.ui.greenwichStundenwinkelFP_GLineEdit.setText(
            str(self.theSun.Theta_G))
        self.left.ui.stundenwinkelFrHlingspunktLineEdit.setText(
            str(self.theSun.Theta))
        self.left.ui.stundenwinkelLineEdit.setText(str(self.theSun.tau))

        self.left.ui.azimutALineEdit.setText(u"{:.1f}\u00B0".format(
            self.theSun.azimut))
        self.left.ui.sunHeightHLineEdit.setText(u"{:.1f}\u00B0".format(
            math.degrees(self.theSun.sunHeight)))
        self.left.ui.shadowLengthLineEdit.setText("{:.1f} m".format(
            self.theSun.shadowLength))

        self.right.setAngle(self.theSun.azimut)  # shadowAngle)
        self.right.setShadowLength(self.theSun.shadowLength)