コード例 #1
0
    def calculateAnalemmaCurves(self):
        """Calculate analemma curves for an annual sunpath.

        After calculating the curves check 'dailyCurves' property for curves.
        """
        day = 21
        # point and plane for triming the curves
        pt = Point.ByCoordinates(0, 0, -10 + self.basePoint.Z)
        plane = Plane.ByOriginNormal(self.basePoint, Vector.ZAxis())

        for hour in range(0, 24):
            anySunUpHour = False
            anySunDownHour = False
            monthlySunPositions = []
            for month in range(1, 13):
                sun = self.calculateSunPosition(month, day, hour=hour)
                if sun.isDuringDay:
                    anySunUpHour = True
                else:
                    anySunDownHour = True

                monthlySunPositions.append(sun.position)

            # all night hour
            if not anySunUpHour:
                continue

            # create the curve
            analemmaCurve = NurbsCurve.ByPoints(monthlySunPositions, True)

            if anySunDownHour + anySunUpHour == 2:
                # some of the hours are up hours and some are down
                # trim the curve
                curves = Geometry.Trim(analemmaCurve, plane, pt)
                # Dynamo trim doesn't work as expected
                # or I don't know how it is supposed to work so I check the curves
                selectedCurves = []
                for curve in curves:
                    # find mid point
                    midPar = (curve.EndParameter() +
                              curve.StartParameter()) / 2
                    midPt = curve.PointAtParameter(midPar)
                    if midPt.Z >= self.basePoint.Z:
                        selectedCurves.append(curve)
                    else:
                        curve.Dispose()

                if len(selectedCurves) == 1:
                    analemmaCurve = selectedCurves[0]
                else:
                    try:
                        # join curves
                        analemmaCurve = selectedCurves[0].Join(
                            selectedCurves[1:])
                    except StandardError:
                        analemmaCurve = selectedCurves

            go.disposeGeometries(monthlySunPositions)

            self.__analemmaCurves.append(analemmaCurve)
コード例 #2
0
    def calculateAnalemmaCurves(self):
        """Calculate analemma curves for an annual sunpath
            After calculating the curves check 'dailyCurves' property for curve geometries
        """
        day = 21
        # point and plane for triming the curves
        pt = Point.ByCoordinates(0, 0, -10 + self.basePoint.Z)
        plane = Plane.ByOriginNormal(self.basePoint, Vector.ZAxis())

        for hour in range(1, 25):
            anySunUpHour = False
            anySunDownHour = False
            monthlySunPositions = []
            for month in range(1,13):
                sun = self.calculateSunPosition(month, day, hour = hour)
                if sun.isDuringDay:
                    anySunUpHour = True
                else:
                    anySunDownHour = True

                monthlySunPositions.append(sun.position)

            # all night hour
            if not anySunUpHour: continue
            # create the curve
            analemmaCurve = NurbsCurve.ByPoints(monthlySunPositions, True)

            if anySunDownHour + anySunUpHour == 2:
                # some of the hours are up hours and some are down
                # trim the curve
                curves = Geometry.Trim(analemmaCurve, plane, pt)
                # Dynamo trim doesn't work as expected
                # or I don't know how it is supposed to work so I check the curves
                selectedCurves = []
                for curve in curves:
                    # find mid point
                    midPar = (curve.EndParameter() + curve.StartParameter())/2
                    midPt = curve.PointAtParameter(midPar)
                    if midPt.Z >= self.basePoint.Z:
                        selectedCurves.append(curve)
                    else:
                        curve.Dispose()

                if len(selectedCurves)==1:
                    analemmaCurve = selectedCurves[0]
                else:
                    try:
                        # join curves
                        analemmaCurve = selectedCurves[0].Join(selectedCurves[1:])
                    except StandardError:
                        analemmaCurve = selectedCurves

            go.disposeGeometries(monthlySunPositions)

            self.__analemmaCurves.append(analemmaCurve)
コード例 #3
0
    def calculateDailyCurve(self, month, day = 21, isSolarTime = False):
        """Calculate daily curve the day
            After calculating the curves check 'dailyCurves' property for curve geometries
        """
        # calculate sunrise, noon and sunset
        datetimesDictionary = self.calculateSunriseSunset(month, day = day, depression = 0, isSolarTime = isSolarTime)

        datetimes = [
                    datetimesDictionary['sunrise'], \
                    datetimesDictionary['noon'], \
                    datetimesDictionary['sunset']
                    ]

        dailySunPositions = []
        for datetime in datetimes:
            sun = self.calculateSunPositionFromDateTime(datetime, isSolarTime = False)
            dailySunPositions.append(sun.position)

        dailyCurve = Arc.ByThreePoints(*dailySunPositions)
        self.__dailyCurves.append(dailyCurve)
        go.disposeGeometries(dailySunPositions)