def setUp(self):
     """Set up the test case by initiating the class."""
     # create a sky to be able to initiate gridbased module
     sky = radSky(1000)
     points = [(0,0,0),(1,1,0),(3,2,0)]
     analysis_grid = AnalysisGrid.from_points_and_vectors(points)
     self.rp = GridBased(sky, analysis_grids = [analysis_grid])
예제 #2
0
def run_from_json(recipe, folder, name):
    """Create a python recipe from json object and run the analysis."""
    if recipe["id"] == 0:
        rec = SolarAccessGridBased.fromJson(recipe)
    elif recipe["id"] == 1:
        rec = GridBased.fromJson(recipe)
    else:
        raise ValueError(
            "Invalid id input {}. "
            "Currently only the id of [0] SolarAccess and [1] pointintime are supported!"
            .format(recipe['id']))

    # generate bat file
    bat = rec.write(folder, name)
    # Convert bat to sh
    sh = bat_to_sh(bat)

    # import pdb; pdb.set_trace()
    # start to run the subprocess
    if os.name == 'nt':
        success = rec.run(bat)
    else:
        success = rec.run(sh)

    # run post-processing code
    if success:
        return (True, [r.toJson() for r in rec.results()])
    else:
        return (False, ())
class GridbasedTestCase(unittest.TestCase):
    """Test for (honeybee/radiance/recipe/gridbased.py)."""

    # preparing to test
    def setUp(self):
        """Set up the test case by initiating the class."""
        # create a sky to be able to initiate gridbased module
        sky = radSky(1000)
        self.rp = GridBased(sky, point_groups=[0, 0, 0])

    # ending the test
    def tearDown(self):
        """Cleaning up after the test."""
        pass

    # test default values
    def test_default_values(self):
        """Make sure default values are set correctly."""
        self.assertEqual(self.rp.simulation_type, 0,
                         "Default simulation type is changed from 0!")
        # more tests here

    # test for assertion and exceptions
    def test_assertions_exceptions(self):
        """Make sure the class catches wrong inputs, etc."""
        # results should not be available before the analysis is ran
        self.assertRaises(
            AssertionError, self.rp.results,
            "Results should not be available unless the analysis is executed!"
        )
        # more tests here

    # test for specific cases
    def test_single_point_input(self):
        """A single point should be converted to a single test group."""
        self.rp.updatepoint_groups([0, 0, 0])
        self.assertEqual(self.rp.num_of_point_groups, 1,
                         "Failed to convert single test point to a group!")
class GridbasedTestCase(unittest.TestCase):
    """Test for (honeybee/radiance/recipe/gridbased.py)."""

    # preparing to test
    def setUp(self):
        """Set up the test case by initiating the class."""
        # create a sky to be able to initiate gridbased module
        sky = radSky(1000)
        points = [(0,0,0),(1,1,0),(3,2,0)]
        analysis_grid = AnalysisGrid.from_points_and_vectors(points)
        self.rp = GridBased(sky, analysis_grids = [analysis_grid])

    # ending the test
    def tearDown(self):
        """Cleaning up after the test."""
        pass

    # test default values
    def test_default_values(self):
        """Make sure default values are set correctly."""
        assert self.rp.simulation_type == 0, \
                         "Default simulation type is changed from 0!"
        # more tests here

    # test for assertion and exceptions
    def test_assertions_exceptions(self):
        """Make sure the class catches wrong inputs, etc."""
        # results should not be available before the analysis is ran
        with pytest.raises(
            TypeError):
            self.rp.results("Results should not be available unless the analysis is executed!")
        # more tests here

    # test for specific cases
    def test_single_point_input(self):
        """A single point should be converted to a single test group."""
        pass
예제 #5
0
class GridbasedTestCase(unittest.TestCase):
    """Test for (honeybee/radiance/recipe/gridbased.py)."""

    # preparing to test
    def setUp(self):
        """Set up the test case by initiating the class."""
        # create a sky to be able to initiate gridbased module
        sky = radSky(1000)
        self.rp = GridBased(sky, pointGroups=[0, 0, 0])

    # ending the test
    def tearDown(self):
        """Cleaning up after the test."""
        pass

    # test default values
    def test_default_values(self):
        """Make sure default values are set correctly."""
        self.assertEqual(self.rp.simulationType, 0,
                         "Default simulation type is changed from 0!")
        # more tests here

    # test for assertion and exceptions
    def test_assertions_exceptions(self):
        """Make sure the class catches wrong inputs, etc."""
        # results should not be available before the analysis is ran
        self.assertRaises(
            AssertionError, self.rp.results,
            "Results should not be available unless the analysis is executed!")
        # more tests here

    # test for specific cases
    def test_single_point_input(self):
        """A single point should be converted to a single test group."""
        self.rp.updatePointGroups([0, 0, 0])
        self.assertEqual(self.rp.numOfPointGroups, 1,
                         "Failed to convert single test point to a group!")
def run_from_json(recipe, folder, name):
    """Create a python recipe from json object and run the analysis."""
    if recipe["type"] == "gridbased":
        if recipe["id"] == "solar_access":
            rec = SolarAccessGridBased.from_json(recipe)
        elif recipe["id"] == "point_in_time":
            rec = PITGridBased.from_json(recipe)
        elif recipe["id"] == "daylight_factor":
            rec = DFGridBased.from_json(recipe)
        elif recipe["id"] == "annual":
            raise NotImplementedError(
                "Annual recipe is not supported use daylightcoeff recipe instead."
            )
        elif recipe["id"] == "daylight_coeff":
            rec = DCGridBased.from_json(recipe)
        else:
            raise NotImplementedError(
                "{} {} recipe is not supported yet.".format(
                    recipe['type'], recipe['id']))
    else:
        raise NotImplementedError("{} {} recipe is not supported yet.".format(
            recipe['type'], recipe['id']))

    # generate bat file
    bat = rec.write(folder, name)
    # Convert bat to sh
    sh = bat_to_sh(bat)

    # start to run the subprocess
    if os.name == 'nt':
        success = rec.run(bat)
    else:
        success = rec.run(sh)

    # run post-processing code
    if success:
        return (True, [r.to_json() for r in rec.results()])
    else:
        return (False, ())
예제 #7
0
 def setUp(self):
     """Set up the test case by initiating the class."""
     # create a sky to be able to initiate gridbased module
     sky = radSky(1000)
     self.rp = GridBased(sky, pointGroups=[0, 0, 0])
-

    Args:
        _sky: A radiance sky. Find honeybee skies under 02::Daylight::Light Sources.
        _analysis_grids: A list of analysis grids.
        _analysis_type_: Analysis type. [0] illuminance(lux), [1] radiation (kwh),
            [2] luminance (Candela).
        _radiance_par_: Radiance parameters for Grid-based analysis. Find Radiance
            parameters node under 03::Daylight::Recipes.
    Returns:
        analysis_recipe: Grid-based analysis recipe. Connect this recipe to
            Run Radiance Analysis to run a grid-based analysis.
"""

ghenv.Component.Name = "HoneybeePlus_Grid-Based Recipe"
ghenv.Component.NickName = 'gridBasedRecipe'
ghenv.Component.Message = 'VER 0.0.05\nOCT_22_2018'
ghenv.Component.Category = "HoneybeePlus"
ghenv.Component.SubCategory = '03 :: Daylight :: Recipe'
ghenv.Component.AdditionalHelpFromDocStrings = "2"

try:
    from honeybee.radiance.recipe.pointintime.gridbased import GridBased
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))


if _sky and _analysis_grids and _analysis_grids[0] is not None:
    # set a sunlight hours analysis recipe together if there are points
    analysis_recipe = GridBased(_sky, _analysis_grids, _analysis_type_,
                               _radiance_par_)
# assign inputs
_sky, _analysisGrids, _analysisType_, _radiancePar_ = IN
analysisRecipe = None

#import honeybee
#reload(honeybee.radiance.recipe.pointintime.gridbased)
try:
    from honeybee.radiance.recipe.pointintime.gridbased import GridBased
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

if _sky and _analysisGrids:

    # set a sunlight hours analysis recipe together if there are points
    analysisRecipe = GridBased(_sky, _analysisGrids, _analysisType_,
                               _radiancePar_)

# assign outputs to OUT
OUT = (analysisRecipe, )
예제 #10
0
# add fenestration
#  # add a window to the back wall
room.add_fenestration_surface(wall_name='back',
                              width=2,
                              height=2,
                              sill_height=0.7)

# add another window with custom material. This time to the right wall
glass_60 = Glass.by_single_trans_value('tvis_0.6', 0.6)
room.add_fenestration_surface('right', 4, 1.5, 1.2, radiance_material=glass_60)

# run a grid-based analysis for this room
# generate the sky
sky = CertainIlluminanceLevel(illuminance_value=2000)

# Swap this and try and get from open_mesh
# generate grid of test points
test_points = room.generate_test_points(grid_size=0.5, height=0.75)

# put the recipe together
rp = GridBased(sky=sky,
               point_groups=(test_points, ),
               simulation_type=0,
               hb_objects=(room, ))

# write and run the analysis
rp.write_to_file(target_folder=r'c:\ladybug', project_name='room')
rp.run(debug=False)

results = rp.results()
 def setUp(self):
     """Set up the test case by initiating the class."""
     # create a sky to be able to initiate gridbased module
     sky = radSky(1000)
     self.rp = GridBased(sky, point_groups=[0, 0, 0])