def main(config):
    """
    This function makes the calculation of solar insolation in X sensor points for every building in the zone
    of interest. the number of sensor points depends on the size of the grid selected in the SETTINGS.py file and
    are generated automatically.

    :param config: Configuration object with the settings (genera and radiation-daysim)
    :type config: cea.config.Configuartion
    :return:
    """

    #  reference case need to be provided here
    locator = cea.inputlocator.InputLocator(scenario=config.scenario)
    #  the selected buildings are the ones for which the individual radiation script is run for
    #  this is only activated when in default.config, run_all_buildings is set as 'False'
    settings = config.radiation_daysim

    # BUGFIX for PyCharm: the PATH variable might not include the daysim-bin-directory, so we add it here
    os.environ[
        "PATH"] = settings.daysim_bin_directory + os.pathsep + os.environ[
            "PATH"]

    print("verifying geometry files")
    print(locator.get_zone_geometry())
    verify_input_geometry_zone(gpdf.from_file(locator.get_zone_geometry()))
    verify_input_geometry_district(
        gpdf.from_file(locator.get_district_geometry()))

    # import material properties of buildings
    building_surface_properties = reader_surface_properties(
        locator=locator, input_shp=locator.get_building_architecture())
    print("creating 3D geometry and surfaces")
    # create geometrical faces of terrain and buildingsL
    elevation, geometry_terrain, geometry_3D_zone, geometry_3D_surroundings = geometry_generator.geometry_main(
        locator, config)

    print("Sending the scene: geometry and materials to daysim")
    # send materials
    daysim_mat = locator.get_temporary_file('default_materials.rad')
    rad = py2radiance.Rad(daysim_mat, locator.get_temporary_folder())
    print("\tradiation_main: rad.base_file_path: {}".format(
        rad.base_file_path))
    print("\tradiation_main: rad.data_folder_path: {}".format(
        rad.data_folder_path))
    print("\tradiation_main: rad.command_file: {}".format(rad.command_file))
    add_rad_mat(daysim_mat, building_surface_properties)
    # send terrain
    terrain2radiance(rad, geometry_terrain)
    # send buildings
    buildings2radiance(rad, building_surface_properties, geometry_3D_zone,
                       geometry_3D_surroundings)
    # create scene out of all this
    rad.create_rad_input_file()
    print("\tradiation_main: rad.rad_file_path: {}".format(rad.rad_file_path))

    time1 = time.time()
    radiation_singleprocessing(rad, geometry_3D_zone, locator, settings)

    print("Daysim simulation finished in %.2f mins" %
          ((time.time() - time1) / 60.0))
Exemple #2
0
def radiation_daysim_main(weatherfile_path, locator, zone_shp, district_shp,
                          input_terrain_raster, architecture_dbf):
    """
    This function makes the calculation of solar insolation in X sensor points for every building in the zone
    of interest. the number of sensor points depends on the size of the grid selected in the SETTINGS.py file and
    are generated automatically.

    :param weatherfile_path:
    :param locator:
    :param zone_shp:
    :param district_shp:
    :param input_terrain_raster:
    :param architecture_dbf:
    :return:
    """

    # import material properties of buildings
    building_surface_properties = reader_surface_properties(
        locator=locator, input_shp=locator.get_building_architecture())

    print "creating 3D geometry and surfaces"
    # create geometrical faces of terrain and buildings
    simplification_params = settings.SIMPLIFICATION_PARAMS
    geometry_terrain, geometry_3D_zone, geometry_3D_surroundings = geometry_generator.geometry_main(
        zone_shp, district_shp, input_terrain_raster, architecture_dbf,
        simplification_params)

    print "Sending the scene: geometry and materials to daysim"
    # send materials
    daysim_mat = locator.get_temporary_file('default_materials.rad')
    rad = py2radiance.Rad(daysim_mat, locator.get_temporary_folder())
    add_rad_mat(daysim_mat, building_surface_properties)
    # send terrain
    terrain2radiance(rad, geometry_terrain)
    # send buildings
    buildings2radiance(rad, building_surface_properties, geometry_3D_zone,
                       geometry_3D_surroundings)
    # create scene out of all this
    rad.create_rad_input_file()

    time1 = time.time()
    if settings.SIMUL_PARAMS['multiprocessing']:
        radiation_multiprocessing(rad, geometry_3D_zone, locator,
                                  weatherfile_path)
    else:
        radiation_singleprocessing(rad, geometry_3D_zone, locator,
                                   weatherfile_path)

    print "Daysim simulation finished in ", (time.time() -
                                             time1) / 60.0, " mins"
Exemple #3
0
def main(config):
    """
    This function makes the calculation of solar insolation in X sensor points for every building in the zone
    of interest. the number of sensor points depends on the size of the grid selected in the SETTINGS.py file and
    are generated automatically.

    :param config: Configuration object with the settings (genera and radiation-daysim)
    :type config: cea.config.Configuartion
    :return:
    """

    #  reference case need to be provided here
    locator = cea.inputlocator.InputLocator(scenario=config.scenario)

    #  the selected buildings are the ones for which the individual radiation script is run for
    #  this is only activated when in default.config, run_all_buildings is set as 'False'

    settings = config.radiation_daysim
    region = config.region
    # import material properties of buildings
    building_surface_properties = reader_surface_properties(
        locator=locator,
        input_shp=locator.get_building_architecture(),
        region=region)

    print "creating 3D geometry and surfaces"
    # create geometrical faces of terrain and buildingsL
    elevation, geometry_terrain, geometry_3D_zone, geometry_3D_surroundings = geometry_generator.geometry_main(
        locator, settings)

    print "Sending the scene: geometry and materials to daysim"
    # send materials
    daysim_mat = locator.get_temporary_file('default_materials.rad')
    rad = py2radiance.Rad(daysim_mat, locator.get_temporary_folder())
    add_rad_mat(daysim_mat, building_surface_properties)
    # send terrain
    terrain2radiance(rad, geometry_terrain)
    # send buildings
    buildings2radiance(rad, building_surface_properties, geometry_3D_zone,
                       geometry_3D_surroundings)
    # create scene out of all this
    rad.create_rad_input_file()

    time1 = time.time()
    radiation_singleprocessing(rad, geometry_3D_zone, locator, config.weather,
                               settings)

    print("Daysim simulation finished in %.2f mins" %
          ((time.time() - time1) / 60.0))
Exemple #4
0
def main(config):
    """
    This function makes the calculation of solar insolation in X sensor points for every building in the zone
    of interest. The number of sensor points depends on the size of the grid selected in the config file and
    are generated automatically.

    :param config: Configuration object with the settings (genera and radiation)
    :type config: cea.config.Configuartion
    :return:
    """

    #  reference case need to be provided here
    locator = cea.inputlocator.InputLocator(scenario=config.scenario)
    #  the selected buildings are the ones for which the individual radiation script is run for
    #  this is only activated when in default.config, run_all_buildings is set as 'False'

    # BUGFIX for #2447 (make sure the Daysim binaries are there before starting the simulation)
    daysim_bin_path, daysim_lib_path = check_daysim_bin_directory(config.radiation.daysim_bin_directory,
                                                                  config.radiation.use_latest_daysim_binaries)
    print('Using Daysim binaries from path: {}'.format(daysim_bin_path))
    # Save daysim path to config
    config.radiation.daysim_bin_directory = daysim_bin_path

    # BUGFIX for PyCharm: the PATH variable might not include the daysim-bin-directory, so we add it here
    os.environ["PATH"] = "{bin}{pathsep}{path}".format(bin=config.radiation.daysim_bin_directory, pathsep=os.pathsep,
                                                       path=os.environ["PATH"])
    os.environ["RAYPATH"] = daysim_lib_path

    if not "PROJ_LIB" in os.environ:
        os.environ["PROJ_LIB"] = os.path.join(os.path.dirname(sys.executable), "Library", "share")
    if not "GDAL_DATA" in os.environ:
        os.environ["GDAL_DATA"] = os.path.join(os.path.dirname(sys.executable), "Library", "share", "gdal")

    print("verifying geometry files")
    print(locator.get_zone_geometry())
    verify_input_geometry_zone(gpdf.from_file(locator.get_zone_geometry()))
    verify_input_geometry_surroundings(gpdf.from_file(locator.get_surroundings_geometry()))

    # import material properties of buildings
    print("getting geometry materials")
    building_surface_properties = reader_surface_properties(locator=locator,
                                                            input_shp=locator.get_building_architecture())
    building_surface_properties.to_csv(locator.get_radiation_materials())
    print("creating 3D geometry and surfaces")
    # create geometrical faces of terrain and buildingsL
    elevation, geometry_terrain, geometry_3D_zone, geometry_3D_surroundings = geometry_generator.geometry_main(locator,
                                                                                                               config)

    print("Sending the scene: geometry and materials to daysim")
    # send materials
    daysim_mat = locator.get_temporary_file('default_materials.rad')
    rad = CEARad(daysim_mat, locator.get_temporary_folder(), debug=config.debug)
    print("\tradiation_main: rad.base_file_path: {}".format(rad.base_file_path))
    print("\tradiation_main: rad.data_folder_path: {}".format(rad.data_folder_path))
    print("\tradiation_main: rad.command_file: {}".format(rad.command_file))
    add_rad_mat(daysim_mat, building_surface_properties)
    # send terrain
    terrain_to_radiance(rad, geometry_terrain)
    # send buildings
    buildings_to_radiance(rad, building_surface_properties, geometry_3D_zone, geometry_3D_surroundings)
    # create scene out of all this
    rad.create_rad_input_file()
    print("\tradiation_main: rad.rad_file_path: {}".format(rad.rad_file_path))

    time1 = time.time()
    radiation_singleprocessing(rad, geometry_3D_zone, locator, config.radiation)

    print("Daysim simulation finished in %.2f mins" % ((time.time() - time1) / 60.0))
Exemple #5
0
def main(config):
    """
    This function makes the calculation of solar insolation in X sensor points for every building in the zone
    of interest. The number of sensor points depends on the size of the grid selected in the config file and
    are generated automatically.

    :param config: Configuration object with the settings (genera and radiation)
    :type config: cea.config.Configuartion
    :return:
    """

    #  reference case need to be provided here
    locator = cea.inputlocator.InputLocator(scenario=config.scenario)
    #  the selected buildings are the ones for which the individual radiation script is run for
    #  this is only activated when in default.config, run_all_buildings is set as 'False'

    # BUGFIX for #2447 (make sure the Daysim binaries are there before starting the simulation)
    daysim_bin_path, daysim_lib_path = check_daysim_bin_directory(
        config.radiation.daysim_bin_directory,
        config.radiation.use_latest_daysim_binaries)
    print('Using Daysim binaries from path: {}'.format(daysim_bin_path))
    print('Using Daysim data from path: {}'.format(daysim_lib_path))
    # Save daysim path to config
    config.radiation.daysim_bin_directory = daysim_bin_path

    # BUGFIX for PyCharm: the PATH variable might not include the daysim-bin-directory, so we add it here
    os.environ["PATH"] = "{bin}{pathsep}{path}".format(
        bin=config.radiation.daysim_bin_directory,
        pathsep=os.pathsep,
        path=os.environ["PATH"])
    os.environ["RAYPATH"] = daysim_lib_path

    if not "PROJ_LIB" in os.environ:
        os.environ["PROJ_LIB"] = os.path.join(os.path.dirname(sys.executable),
                                              "Library", "share")
    if not "GDAL_DATA" in os.environ:
        os.environ["GDAL_DATA"] = os.path.join(os.path.dirname(sys.executable),
                                               "Library", "share", "gdal")

    print("verifying geometry files")
    zone_path = locator.get_zone_geometry()
    surroundings_path = locator.get_surroundings_geometry()
    print("zone: {zone_path}\nsurroundings: {surroundings_path}".format(
        zone_path=zone_path, surroundings_path=surroundings_path))
    verify_input_geometry_zone(gpdf.from_file(zone_path))
    verify_input_geometry_surroundings(gpdf.from_file(surroundings_path))

    # import material properties of buildings
    print("Getting geometry materials")
    building_surface_properties = reader_surface_properties(locator)
    building_surface_properties.to_csv(locator.get_radiation_materials())

    print("Creating 3D geometry and surfaces")
    geometry_pickle_dir = os.path.join(
        locator.get_temporary_folder(),
        "{}_radiation_geometry_pickle".format(config.scenario_name))
    print("Saving geometry pickle files in: {}".format(geometry_pickle_dir))
    # create geometrical faces of terrain and buildings
    geometry_terrain, zone_building_names, surroundings_building_names = geometry_generator.geometry_main(
        locator, config, geometry_pickle_dir)

    # daysim_bin_directory might contain two paths (e.g. "C:\Daysim\bin;C:\Daysim\lib") - in which case, only
    # use the "bin" folder
    bin_directory = [
        d for d in config.radiation.daysim_bin_directory.split(";")
        if not d.endswith("lib")
    ][0]
    daysim_staging_location = os.path.join(locator.get_temporary_folder(),
                                           'cea_radiation')
    cea_daysim = CEADaySim(daysim_staging_location, bin_directory)

    # create radiance input files
    print("Creating radiance material file")
    cea_daysim.create_radiance_material(building_surface_properties)
    print("Creating radiance geometry file")
    cea_daysim.create_radiance_geometry(geometry_terrain,
                                        building_surface_properties,
                                        zone_building_names,
                                        surroundings_building_names,
                                        geometry_pickle_dir)

    print("Converting files for DAYSIM")
    weather_file = locator.get_weather_file()
    print('Transforming weather files to daysim format')
    cea_daysim.execute_epw2wea(weather_file)
    print('Transforming radiance files to daysim format')
    cea_daysim.execute_radfiles2daysim()

    time1 = time.time()
    radiation_singleprocessing(cea_daysim,
                               zone_building_names,
                               locator,
                               config.radiation,
                               geometry_pickle_dir,
                               num_processes=config.get_number_of_processes())

    print("Daysim simulation finished in %.2f mins" %
          ((time.time() - time1) / 60.0))