Exemplo n.º 1
0
    def test_import_stat(self):
        """Test to compare import from stat with its json version."""
        stat_path = './tests/stat/chicago.stat'
        wea_from_stat = Wea.from_stat_file(stat_path)

        wea_json = wea_from_stat.to_json()
        wea_from_json = Wea.from_json(wea_json)
        assert wea_from_json.direct_normal_radiation.values == \
            wea_from_stat.direct_normal_radiation.values
        assert wea_from_json.diffuse_horizontal_radiation.values == \
            wea_from_stat.diffuse_horizontal_radiation.values
Exemplo n.º 2
0
    def test_import_epw(self):
        """Test to compare import from epw with its json version."""
        epw_path = './tests/epw/chicago.epw'

        wea_from_epw = Wea.from_epw_file(epw_path)

        wea_json = wea_from_epw.to_json()
        wea_from_json = Wea.from_json(wea_json)
        assert wea_from_json.direct_normal_radiation.values == \
            wea_from_epw.direct_normal_radiation.values
        assert wea_from_json.diffuse_horizontal_radiation.values == \
            wea_from_epw.diffuse_horizontal_radiation.values
Exemplo n.º 3
0
 def from_json(cls, rec_json):
     """Create sky from json file
         {
         "wea": {}, // ladybug wea schema
         "sky_density": int, // [1] Tregenza Sky, [2] Reinhart Sky, etc. (Default: 1)
         "north": float, // Angle in degrees between 0-360 to indicate North
         "hoys": [], // List of hours for generating the sky
         "mode": int, // Sky mode, integer between 0 and 2
         "suffix": string //Suffix for sky matrix
         }
     """
     wea = Wea.from_json(rec_json["wea"])
     return cls(wea, rec_json["sky_density"], rec_json["north"], \
             rec_json["hoys"], rec_json["mode"], rec_json["suffix"])
Exemplo n.º 4
0
 def from_json(cls, rec_json):
     """Create sky from json file
         {
         "wea": {}, // ladybug wea schema
         "sky_density": int, // [1] Tregenza Sky, [2] Reinhart Sky, etc. (Default: 1)
         "north": float, // Angle in degrees between 0-360 to indicate North
         "hoys": [], // List of hours for generating the sky
         "mode": int, // Sky mode, integer between 0 and 2
         "suffix": string //Suffix for sky matrix
         }
     """
     wea = Wea.from_json(rec_json["wea"])
     return cls(wea, rec_json["sky_density"], rec_json["north"], \
             rec_json["hoys"], rec_json["mode"], rec_json["suffix"])
Exemplo n.º 5
0
    def test_json_methods(self):
        """Test JSON serialization methods"""
        epw_path = './tests/epw/chicago.epw'
        wea = Wea.from_epw_file(epw_path)

        assert wea.to_json() == Wea.from_json(wea.to_json()).to_json()