Beispiel #1
0
    def fromJson(cls, locJson):
        """Create sky form json.
        {
          "location": {}, // honeybee (or actually ladybug location schema)
          "day": 1, // an integer between 1-31
          "month": 1, // an integer between 1-12
          "hour": 12.0, // a float number between 0-23
          "north": 0, // degree for north if not Y axis
          "sky_type": 0 // A number between 0-5 --  0: sunny sky
        }

        location schema
        {
          "city": "",
          "latitude": 0,
          "longitude": 0,
          "time_zone": 0,
          "elevation": 0
        }
        """
        data = locJson
        location = Location.fromJson(data["location"])
        return cls(location, month=data["month"],
                   day=data["day"], hour=data["hour"], north=data["north"],
                   skyType=data["sky_type"])
    def fromJson(cls, recJson):
        """Create the solar access recipe from json.
            {
              "id": 0, // do NOT overwrite this id
              "location": null, // a honeybee location - see below
              "hoys": [], // list of hours of the year
              "surfaces": [], // list of honeybee surfaces
              "analysis_grids": [] // list of analysis grids
              "sun_vectors": [] // list of sun vectors if location is not provided
            }
        """
        hoys = recJson["hoys"]
        if 'sun_vectors' not in recJson or not recJson['sun_vectors']:
            loc = Location.fromJson(recJson['location'])
            sp = Sunpath.fromLocation(loc)
            suns = (sp.calculateSunFromHOY(HOY) for HOY in hoys)
            sunVectors = tuple(s.sunVector for s in suns if s.isDuringDay)
        else:
            sunVectors = recJson['sun_vectors']

        analysisGrids = \
            tuple(AnalysisGrid.fromJson(ag) for ag in recJson["analysis_grids"])
        hbObjects = tuple(HBSurface.fromJson(srf) for srf in recJson["surfaces"])
        return cls(sunVectors, hoys, analysisGrids, 1, hbObjects)