コード例 #1
0
class Count(Function):
    """Count values in a row that meet a certain criteria."""

    # inputs
    input_mtx = Inputs.file(
        description='Input Radiance matrix in ASCII format', path='input.mtx')

    minimum = Inputs.float(
        description='Minimum range for the values that should be counted.',
        default=-1 * 10**100)

    maximum = Inputs.float(
        description='Maximum range for the values that should be counted.',
        default=10**100)

    include_min = Inputs.str(
        description=
        'A flag to include the minimum threshold itself. By default the '
        'threshold value will be included.',
        default='include',
        spec={
            'type': 'string',
            'enum': ['include', 'exclude']
        })

    include_max = Inputs.str(
        description=
        'A flag to include the maximum threshold itself. By default the '
        'threshold value will be included.',
        default='include',
        spec={
            'type': 'string',
            'enum': ['include', 'exclude']
        })

    reverse = Inputs.str(
        description=
        'A flag to reverse the selection logic. This is useful for cases '
        'that you want to all the values outside a certain range. By default the input '
        'logic will be used as is.',
        default='comply',
        spec={
            'type': 'string',
            'enum': ['comply', 'reverse']
        })

    @command
    def count_values(self):
        return 'honeybee-radiance post-process count input.mtx ' \
            '--output counter.mtx --maximum {{self.maximum}} ' \
            '--minimum {{self.minimum}} --{{self.reverse}} ' \
            '--{{self.include_min}}-min --{{self.include_max}}-max'

    # outputs
    output_mtx = Outputs.file(description='Newly created binary matrix.',
                              path='counter.mtx')
コード例 #2
0
class ConvertToBinary(Function):
    """Convert a Radiance matrix to a new matrix with 0-1 values."""

    # inputs
    input_mtx = Inputs.file(
        description='Input Radiance matrix in ASCII format', path='input.mtx')

    minimum = Inputs.float(
        description='Minimum range for the values that will be converted to 1.',
        default=-1 * 10**100)

    maximum = Inputs.float(
        description='Maximum range for the values that will be converted to 1.',
        default=10**100)

    include_min = Inputs.str(
        description=
        'A flag to include the minimum threshold itself. By default the '
        'threshold value will be included.',
        default='include',
        spec={
            'type': 'string',
            'enum': ['include', 'exclude']
        })

    include_max = Inputs.str(
        description=
        'A flag to include the maximum threshold itself. By default the '
        'threshold value will be included.',
        default='include',
        spec={
            'type': 'string',
            'enum': ['include', 'exclude']
        })

    reverse = Inputs.str(
        description=
        'A flag to reverse the selection logic. This is useful for cases '
        'that you want to all the values outside a certain range to be converted to 1. '
        'By default the input logic will be used as is.',
        default='comply',
        spec={
            'type': 'string',
            'enum': ['comply', 'reverse']
        })

    @command
    def convert_to_zero_one(self):
        return 'honeybee-radiance post-process convert-to-binary input.mtx ' \
            '--output binary.mtx --maximum {{self.maximum}} ' \
            '--minimum {{self.minimum}} --{{self.reverse}} ' \
            '--{{self.include_min}}-min --{{self.include_max}}-max'

    # outputs
    output_mtx = Outputs.file(description='Newly created binary matrix.',
                              path='binary.mtx')
コード例 #3
0
class ModelOccSchedules(Function):
    """Translate a Model's occupancy schedules into a JSON of 0/1 values.

    This JSON is useful in workflows that compute thermal comfort percent,
    daylight autonomy, etc.
    """

    model = Inputs.file(
        description='Honeybee model in JSON format.', path='model.json',
        extensions=['hbjson', 'json']
    )

    period = Inputs.str(
        description='An AnalysisPeriod string to dictate the start and end of the '
        'exported occupancy values (eg. "6/21 to 9/21 between 0 and 23 @1"). Note '
        'that the timestep of the period will determine the timestep of output '
        'values. If unspecified, the values will be annual.', default=''
    )

    threshold = Inputs.float(
        description='A number between 0 and 1 for the threshold at and above which '
        'a schedule value is considered occupied.', default=0.1,
        spec={'type': 'number', 'maximum': 1, 'minimum': 0}
    )

    @command
    def export_model_occ_schedules(self):
        return 'honeybee-energy translate model-occ-schedules model.json ' \
            '--threshold {{self.threshold}} --period "{{self.period}}" ' \
            '--output-file occ_schedules.json'

    occ_schedule_json = Outputs.file(
        description='An occupancy schedule JSON that is useful in workflows like '
        'thermal comfort percent, daylight autonomy, etc.', path='occ_schedules.json'
    )
コード例 #4
0
class MergeImages(Function):
    """Merge several .HDR image files with similar starting name into one."""

    folder = Inputs.folder(
        description='Target folder with the input .HDR image files.',
        path='input_folder')

    name = Inputs.str(description='Base name for files to be merged.',
                      default='view')

    extension = Inputs.str(
        description='File extension including the . before the extension '
        '(e.g. .HDR, .pic, .unf)',
        default='.unf')

    scale_factor = Inputs.float(
        description='A number that will be used to scale the dimensions of the '
        'output image as it is filtered for anti-aliasing.',
        default=1)

    @command
    def merge_files(self):
        return 'honeybee-radiance view merge input_folder view ' \
            '{{self.extension}} --scale-factor {{self.scale_factor}} ' \
            '--name {{self.name}}'

    result_image = Outputs.file(description='Output combined image file.',
                                path='{{self.name}}.HDR')
コード例 #5
0
class RayTracingPicture(Function):
    """Run ray-tracing with rpict command for an input octree and a view file.."""

    view = Inputs.file(description='Input view file.', path='view.vf')

    scene_file = Inputs.file(
        description='Path to an octree file to describe the scene.',
        path='scene.oct')

    radiance_parameters = Inputs.str(
        description='Radiance parameters to be exposed within recipes. -h is '
        'usually already included in the fixed_radiance_parameters and -I will '
        'be overwritten based on the input metric.',
        default='-ab 2')

    metric = Inputs.str(
        description=
        'Text for the type of metric to be output from the calculation. '
        'Choose from: illuminance, irradiance, luminance, radiance.',
        default='luminance',
        spec={
            'type': 'string',
            'enum': ['illuminance', 'irradiance', 'luminance', 'radiance']
        })

    resolution = Inputs.int(
        description=
        'An integer for the maximum dimension of the image in pixels '
        '(either width or height depending on the input view angle and type).',
        spec={
            'type': 'integer',
            'minimum': 1
        },
        default=512)

    scale_factor = Inputs.float(
        description=
        'A number that will be multiplied by the input resolution to '
        'scale the dimensions of the output image. This is useful in workflows if '
        'one plans to re-scale the image after the ray tracing calculation to '
        'improve anti-aliasing.',
        default=1)

    ambient_cache = Inputs.file(
        description='Path to the ambient cache if an overture calculation was '
        'specified. If unspecified, no ambient cache will be used.',
        path='view.amb',
        optional=True)

    @command
    def ray_tracing(self):
        return 'honeybee-radiance rpict rpict scene.oct view.vf ' \
            '--rad-params "{{self.radiance_parameters}}" --metric {{self.metric}} ' \
            '--resolution {{self.resolution}} --scale-factor {{self.scale_factor}} ' \
            '--output view.HDR'

    result_image = Outputs.file(
        description='Path to the High Dynamic Range (HDR) image file of the '
        'input view.',
        path='view.HDR')
コード例 #6
0
class SumRow(Function):
    """Postprocess a Radiance matrix and add all the numbers in each row.

    This function is useful for translating Radiance results to outputs like radiation
    to total radiation. Input matrix must be in ASCII format. The header in the input
    file will be ignored.
    """

    # inputs
    input_mtx = Inputs.file(
        description='Input Radiance matrix in ASCII format', path='input.mtx')

    divisor = Inputs.float(
        description=
        'An optional number, that the summed row will be divided by. '
        'For example, this can be a timestep, which can be used to ensure that a '
        'summed row of irradiance yields cumulative radiation over the entire '
        'time period of the matrix.',
        default=1)

    @command
    def sum_mtx_row(self):
        return 'honeybee-radiance post-process sum-row input.mtx ' \
            '--divisor {{self.divisor}} --output sum.mtx'

    # outputs
    output_mtx = Outputs.file(description='Newly created sum matrix.',
                              path='sum.mtx')
コード例 #7
0
class GenSkyWithCertainIllum(Function):
    """Generates a sky with certain illuminance level."""

    illuminance = Inputs.float(default=100000,
                               description='Sky illuminance level.')

    @command
    def gen_overcast_sky(self):
        return 'honeybee-radiance sky illuminance {{self.illuminance}} --name overcast.sky'

    sky = Outputs.file(description='Generated sky file.', path='overcast.sky')
コード例 #8
0
class AirSpeedJson(Function):
    """Get a JSON of air speeds that can be used as input for the mtx functions."""

    epw = Inputs.file(
        description='Weather file used to obtain prevailing temperatures.',
        path='weather.epw', extensions=['epw']
    )

    enclosure_info = Inputs.file(
        description='A JSON file containing information about the radiant '
        'enclosure that sensor points belong to.', path='enclosure_info.json',
        extensions=['json']
    )

    multiply_by = Inputs.float(
        description='A number to denote a factor that EPW wind speeds should be '
        'multipled by in order to represent air speeds at ground level.', default=0.5
    )

    indoor_air_speed = Inputs.file(
        description='The path to a CSV file containing a single number for air speed '
        'in m/s or multiple numbers (with one value per row) that align with the '
        'length of the run-period. This will be used for all '
        'indoor comfort evaluation.', path='in_speed.txt', optional=True
    )

    outdoor_air_speed = Inputs.file(
        description='The path to a CSV file containing a single number for air speed '
        'in m/s or multiple numbers (with one value per row) that align with the '
        'length of the run-period. If None, the resulting air speed JSON will use '
        'the EPW wind speed times the multiply-by value.',
        path='out_speed.txt', optional=True
    )

    run_period = Inputs.str(
        description='An AnalysisPeriod string to set the start and end dates of the '
        'analysis (eg. "6/21 to 9/21 between 8 and 16 @1"). If unspecified, results '
        'will be annual.', default=''
    )

    @command
    def get_air_speed_json(self):
        return 'ladybug-comfort epw air-speed-json weather.epw enclosure_info.json ' \
            '--multiply-by {{self.multiply_by}} --indoor-air-speed in_speed.txt ' \
            '--outdoor-air-speed out_speed.txt --run-period "{{self.run_period}}" ' \
            '--output-file air_speed.json'

    air_speeds = Outputs.file(
        description='A JSON of air speeds that can be used as input for the mtx '
        'functions.', path='air_speed.json'
    )
コード例 #9
0
class EpwToDdy(Function):
    """Translate an .epw file to a .ddy file."""

    epw = Inputs.file(description='Weather file.',
                      path='weather.epw',
                      extensions=['epw'])

    percentile = Inputs.float(
        description=
        'A number between 0 and 50 for the percentile difference from '
        'the most extreme conditions within the EPW to be used for the design day. '
        'Typical values are 0.4 and 1.0.',
        default=0.4)

    @command
    def epw_to_ddy(self):
        return 'ladybug translate epw-to-ddy weather.epw ' \
            '--percentile {{self.percentile}} --output-file weather.ddy'

    ddy = Outputs.file(description='A ddy file generated from the input epw.',
                       path='weather.ddy')
コード例 #10
0
class ModelModifiersFromConstructions(Function):
    """Assign honeybee Radiance modifiers based on energy construction properties.

    This includes matching properties for reflectance, absorptance and transmission.
    Furthermore, any dynamic window constructions can be translated to dynamic
    Radiance groups and shade transmittance schedules will be translated to
    dynamic shade groups.
    """

    model = Inputs.file(description='Honeybee model in JSON format.',
                        path='model.hbjson',
                        extensions=['hbjson', 'json'])

    use_visible = Inputs.str(
        description=
        'A switch to indicate whether the assigned radiance modifiers '
        'should follow the solar properties of the constructions or the visible '
        'properties.',
        default='solar',
        spec={
            'type': 'string',
            'enum': ['solar', 'visible']
        })

    dynamic_behavior = Inputs.str(
        description='A switch to note whether dynamic window constructions and '
        'window constructions with blinds/shades should be translated to dynamic '
        'aperture groups or just the static (bare) construction should be used.',
        default='dynamic',
        spec={
            'type': 'string',
            'enum': ['dynamic', 'static']
        })

    dynamic_shade = Inputs.str(
        description=
        'A switch to note whether dynamic shade transmittance schedules '
        'should be translated to dynamic shade groups or just a static, fully-opaque '
        'construction should be used.',
        default='dynamic',
        spec={
            'type': 'string',
            'enum': ['dynamic', 'static']
        })

    exterior_offset = Inputs.float(
        description=
        'A number for the distance at which the exterior Room faces should '
        'be offset in meters. This is used to account for the fact that the exterior '
        'material layer of the construction usually needs a different modifier '
        'from the interior. If set to 0, no offset will occur and all assigned '
        'modifiers will be interior.',
        default=0)

    @command
    def model_modifiers_from_constructions(self):
        return 'honeybee-energy edit modifiers-from-constructions model.hbjson ' \
            '--{{self.use_visible}} --{{self.dynamic_behavior}}-groups ' \
            '--{{self.dynamic_shade}}-groups ' \
            '--exterior-offset {{self.exterior_offset}} --output-file new_model.hbjson'

    new_model = Outputs.file(
        description=
        'Model JSON with its Radiance modifiers assigned based on its '
        'energy constructions.',
        path='new_model.hbjson')
コード例 #11
0
class Hvac2004(Function):
    """Convert a Model's HVAC to conform to ASHRAE 90.1-2004 appendix G.

    This includes the selection of the correct Appendix G template HVAC based on
    the inputs and the application of this HVAC to all conditioned spaces in
    the model.
    """

    model = Inputs.file(
        description='Honeybee model in JSON format.', path='model.hbjson',
        extensions=['hbjson', 'json']
    )

    climate_zone = Inputs.str(
        description='Text indicating the ASHRAE climate zone. This can be a single '
        'integer (in which case it is interpreted as A) or it can include the '
        'A, B, or C qualifier (eg. 3C).',
        spec={
            'type': 'string',
            'enum': [
                '1', '2', '3', '4', '5', '6', '7', '8',
                '1A', '2A', '3A', '4A', '5A', '6A', '7A', '8A',
                '1B', '2B', '3B', '4B', '5B', '6B', '7B', '8B',
                '3C', '4C', '5C'
            ]
        }
    )

    is_residential = Inputs.str(
        description='A switch to note whether the model represents a residential '
        'or nonresidential building.', default='nonresidential',
        spec={'type': 'string', 'enum': ['nonresidential', 'residential']}
    )

    energy_source = Inputs.str(
        description='A switch to note whether the available energy source is '
        'fossil fuel based or all-electric.', default='fuel',
        spec={'type': 'string', 'enum': ['fuel', 'electric']}
    )

    floor_area = Inputs.float(
        description='A number for the floor area of the building that the model '
        'is a part of in m2. If 0, the model floor area will be used.', default=0
    )

    story_count = Inputs.int(
        description='An integer for the number of stories of the building that the '
        'model is a part of. If None, the model stories will be used.', default=0,
        spec={'type': 'integer', 'minimum': 0}
    )

    @command
    def hvac_2004(self):
        return 'honeybee-energy baseline hvac-2004 model.hbjson {{self.climate_zone}} ' \
            '--{{self.is_residential}} --{{self.energy_source}} ' \
            '--story-count {{self.story_count}} --floor-area {{self.floor_area}} ' \
            '--output-file new_model.hbjson'

    new_model = Outputs.file(
        description='Model JSON with its properties edited to conform to ASHRAE '
        '90.1 appendix G.', path='new_model.hbjson'
    )