Exemplo n.º 1
0
class SimulateIdf(Function):
    """Simulate an IDF file in EnergyPlus."""

    idf = Inputs.file(description='Path to a simulate-able IDF file.',
                      path='model.idf',
                      extensions=['idf'])

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

    @command
    def simulate_model(self):
        return 'honeybee-energy simulate idf model.idf weather.epw --folder output'

    sql = Outputs.file(
        description='The result SQL file output by the simulation.',
        path='output/eplusout.sql')

    zsz = Outputs.file(
        description=
        'The result CSV with the zone loads over the design day output '
        'by the simulation.',
        path='output/epluszsz.csv',
        optional=True)

    html = Outputs.file(
        description='The result HTML page with summary reports output by the '
        'simulation.',
        path='output/eplustbl.htm')

    err = Outputs.file(
        description='The error report output by the simulation.',
        path='output/eplusout.err')
Exemplo n.º 2
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')
class ModelToOsm(Function):
    """Translate a Model JSON file into an OpenStudio Model and corresponding IDF."""

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

    sim_par = Inputs.file(
        description='SimulationParameter JSON that describes the settings for the '
        'simulation.', path='sim-par.json', extensions=['json']
    )

    @command
    def model_to_osm(self):
        return 'honeybee-energy translate model-to-osm model.json ' \
            '--sim-par-json sim-par.json --folder output ' \
            '--log-file output/output_paths.json'

    osm = Outputs.file(
        description='The OpenStudio model file.', path='output/run/in.osm'
    )

    idf = Outputs.file(
        description='The IDF file.', path='output/run/in.idf'
    )
class ResultCsvQueryable(Function):
    """Get a CSV of energy simulation results as an easily query-able SQLite table."""

    result_sql = Inputs.file(
        description='A SQLite file that was generated by EnergyPlus.',
        path='result.sql',
        extensions=['sql', 'db', 'sqlite'])

    model = Inputs.file(
        description=
        'Honeybee model in JSON format that will be matched to results '
        'in the result sql and used to account for triangulated sub-faces, room '
        'multipliers, and any area normalization of results.',
        path='model.json',
        extensions=['hbjson', 'json'])

    output_name = Inputs.str(
        description=
        'An EnergyPlus output name to be retrieved from the result-sql. '
        '(eg. Zone Operative Temperature). This can also be a JSON array of names '
        'formatted with [] brackets.')

    run_period = Inputs.str(
        description='The name of the run period from which the CSV data will be '
        'selected. (eg. BOSTON LOGAN INTL ARPT ANN CLG .4% CONDNS DB=>MWB).')

    units = Inputs.str(
        description='A switch to indicate whether the data in the resulting CSV '
        'should be in SI or IP units. Valid values are "si" and "ip".',
        default='si',
        spec={
            'type': 'string',
            'enum': ['si', 'ip']
        })

    normalization = Inputs.str(
        description=
        'A switch to indicate whether the data in the resulting CSV should '
        'be normalized by floor area (in the case of Zone/System data) or surface '
        'area (in the case of Surface data). This has no effect if the requested '
        'data is not normalizable. Valid values are "normalize" and "no-normalize".',
        default='normalize',
        spec={
            'type': 'string',
            'enum': ['normalize', 'no-normalize']
        })

    @command
    def result_csv_queryable(self):
        return 'honeybee-energy result output-csv-queryable result.sql model.json ' \
            '"{{inputs.run-period}}" "{{inputs.output_name}}" --{{inputs.units}} ' \
            '--{{inputs.normalization}} --folder output --log-file output/col_names.json'

    column_names = Outputs.file(
        description='A list of DataCollection JSONs that match the requested '
        'output name.',
        path='output.json')
class DaylightContribution(Function):
    """
    Calculate daylight contribution for a grid of sensors from a series of modifiers
    using rcontrib command.
    """

    radiance_parameters = Inputs.str(
        description='Radiance parameters. -I and -aa 0 are already included in '
        'the command.',
        default='')

    fixed_radiance_parameters = Inputs.str(
        description='Radiance parameters. -I and -aa 0 are already included in '
        'the command.',
        default='-aa 0')

    calculate_values = Inputs.str(
        description='A switch to indicate if the values should be multiplied. '
        'Otherwise the contribution is calculated as a coefficient. Default is set to '
        'value. Use coeff for contribution',
        default='value',
        spec={
            'type': 'string',
            'enum': ['value', 'coeff']
        })

    sensor_count = Inputs.int(
        description='Number of maximum sensors in each generated grid.',
        spec={
            'type': 'integer',
            'minimum': 1
        })

    modifiers = Inputs.file(
        description=
        'Path to modifiers file. In most cases modifiers are sun modifiers.',
        path='suns.mod')

    sensor_grid = Inputs.file(description='Path to sensor grid files.',
                              path='grid.pts',
                              extensions=['pts'])

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

    @command
    def run_daylight_coeff(self):
        return 'honeybee-radiance dc scontrib scene.oct grid.pts suns.mod ' \
            '--{{self.calculate_values}} --sensor-count {{self.sensor_count}} ' \
            '--rad-params "{{self.radiance_parameters}}" --rad-params-locked ' \
            '"{{self.fixed_radiance_parameters}}" --output results.ill'

    result_file = Outputs.file(description='Output result file.',
                               path='results.ill')
Exemplo n.º 6
0
class Tcp(Function):
    """Compute Thermal Comfort Petcent (TCP) from thermal condition CSV map."""

    condition_csv = Inputs.file(
        description=
        'A CSV file of thermal conditions output by a thermal mapping '
        'function.',
        path='condition.csv',
        extensions=['csv', 'cond'])

    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'])

    occ_schedule_json = Inputs.file(
        description='An occupancy schedule JSON output by the honeybee-energy '
        'model-occ-schedules function.',
        path='occ_schedule.json',
        extensions=['json'])

    schedule = Inputs.file(
        description=
        'An optional path to a CSV file to specify the relevant times '
        'during which comfort should be evaluated. If specified, this will override '
        'the occ-schedule-json for both indoor and outdoor conditions. Values '
        'should be 0-1 separated by new line.',
        path='schedule.txt',
        optional=True)

    @command
    def compute_tcp(self):
        return 'ladybug-comfort map tcp condition.csv enclosure_info.json ' \
            '--schedule schedule.txt --occ-schedule-json occ_schedule.json ' \
            '--folder output'

    tcp = Outputs.file(
        description='A CSV that contains the Thermal Comfort Percent (TCP) for '
        'each sensor.',
        path='output/tcp.csv')

    hsp = Outputs.file(
        description='A CSV that contains the Heat Sensation Percent (HSP) for '
        'each sensor.',
        path='output/hsp.csv')

    csp = Outputs.file(
        description='A CSV that contains the Cold Sensation Percent (CSP) for '
        'each sensor.',
        path='output/csp.csv')
Exemplo n.º 7
0
class AirMap(Function):
    """Get CSV files with maps of air temperatures or humidity from EnergyPlus results.
    """

    result_sql = Inputs.file(
        description=
        'A SQLite file that was generated by EnergyPlus and contains '
        'hourly or sub-hourly thermal comfort results.',
        path='result.sql',
        extensions=['sql', 'db', 'sqlite'],
        optional=True)

    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'])

    epw = Inputs.file(
        description='Weather file used to estimate conditions for any outdoor '
        'sensors.',
        path='weather.epw',
        extensions=['epw'])

    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='')

    metric = Inputs.str(
        description=
        'A switch to note whether the the output matrix should be with '
        'relative humidity or air temperature values.',
        default='air-temperature',
        spec={
            'type': 'string',
            'enum': ['air-temperature', 'relative-humidity']
        })

    @command
    def run_air_map(self):
        return 'ladybug-comfort map air result.sql enclosure_info.json weather.epw ' \
            '--run-period "{{self.run_period}}" --{{self.metric}} ' \
            '--output-file air.csv'

    air_map = Outputs.file(
        description=
        'CSV file containing a map of air temperatures or humidity.',
        path='air.csv')
Exemplo n.º 8
0
class LongwaveMrtMap(Function):
    """Get CSV files with maps of longwave MRT from Radiance and EnergyPlus results."""

    result_sql = Inputs.file(
        description=
        'A SQLite file that was generated by EnergyPlus and contains '
        'hourly or sub-hourly thermal comfort results.',
        path='result.sql',
        extensions=['sql', 'db', 'sqlite'],
        optional=True)

    view_factors = Inputs.file(
        description=
        'A CSV of spherical view factors to the surfaces in the result-sql.',
        path='view_factors.csv',
        extensions=['csv'])

    modifiers = Inputs.file(
        description=
        'Path to a modifiers file that aligns with the view-factors.',
        path='view_factors.mod',
        extensions=['mod', 'txt'])

    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'])

    epw = Inputs.file(
        description='Weather file used to estimate conditions for any outdoor '
        'sensors.',
        path='weather.epw',
        extensions=['epw'])

    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 run_longwave_map(self):
        return 'ladybug-comfort map longwave-mrt result.sql view_factors.csv ' \
            'view_factors.mod enclosure_info.json weather.epw ' \
            '--run-period "{{self.run_period}}" --output-file longwave.csv'

    longwave_mrt_map = Outputs.file(
        description='CSV file containing a map of longwave MRT.',
        path='longwave.csv')
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'
    )
Exemplo n.º 10
0
class AddRemoveSkyMatrix(Function):
    """Remove direct sky from total sky and add direct sun."""

    total_sky_matrix = Inputs.file(
        description='Path to matrix for total sky contribution.',
        path='sky.ill',
        extensions=['ill', 'dc'])

    direct_sky_matrix = Inputs.file(
        description='Path to matrix for direct sky contribution.',
        path='sky_dir.ill',
        extensions=['ill', 'dc'])

    sunlight_matrix = Inputs.file(
        description='Path to matrix for direct sunlight contribution.',
        path='sun.ill',
        extensions=['ill', 'dc'])

    conversion = Inputs.str(
        description=
        'Conversion as a string which will be passed to rmtxop -c option.',
        default=' ')

    output_format = Inputs.str(
        default='a',
        description='Output file format. a for ASCII, d for double, f for '
        'float and c for RGBE color.',
        spec={
            'type': 'string',
            'enum': ['a', 'd', 'f', 'c']
        })

    header = Inputs.str(
        default='remove',
        description=
        'An input to indicate if header should be kept or removed from the'
        'output matrix.',
        spec={
            'type': 'string',
            'enum': ['keep', 'remove']
        })

    @command
    def create_matrix(self):
        return 'honeybee-radiance mtxop operate-three sky.ill sky_dir.ill sun.ill ' \
            '--operator-one "-" --operator-two "+" --{{self.header}}-header ' \
            '--conversion "{{self.conversion}}" --output-mtx final.ill ' \
            '--output-format {{self.output_format}}'

    results_file = Outputs.file(description='Radiance matrix file.',
                                path='final.ill')
class RayTracingPointInTime(Function):
    """Run ray-tracing and post-process the results for a point-in-time simulation."""

    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='illuminance',
        spec={
            'type': 'string',
            'enum': ['illuminance', 'irradiance', 'luminance', 'radiance']
        })

    fixed_radiance_parameters = Inputs.str(
        description=
        'Parameters that are meant to be fixed for a given recipe and '
        'should not be overwritten by radiance_parameters input.',
        default='-h')

    grid = Inputs.file(description='Input sensor grid.', path='grid.pts')

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

    bsdf_folder = Inputs.folder(
        description='Folder containing any BSDF files needed for ray tracing.',
        path='model/bsdf',
        optional=True)

    @command
    def ray_tracing(self):
        return 'honeybee-radiance raytrace point-in-time scene.oct grid.pts ' \
            '--rad-params "{{self.radiance_parameters}}" --rad-params-locked ' \
            '"{{self.fixed_radiance_parameters}}" --metric {{self.metric}} ' \
            '--output grid.res'

    result = Outputs.file(
        description=
        'Point-in-time result file. The result for each sensor is in a '
        'new line of the file. Values are in standard SI units of the input '
        'metric (lux, W/m2, cd/m2, W/m2-sr).',
        path='grid.res')
Exemplo n.º 12
0
class CreateLeedSkies(Function):
    """Generate two climate-based lear skies for LEED v4.1 Daylight Option 2."""

    wea = Inputs.file(
        description=
        'Path to a Typical Meteorological Year (TMY) .wea file. The file '
        'must be annual with a timestep of 1 for a non-leap year.',
        extensions=['wea'],
        path='sky.wea')

    north = Inputs.int(
        description='An angle for north direction. Default is 0.',
        default=0,
        spec={
            'type': 'integer',
            'maximum': 360,
            'minimum': 0
        })

    @command
    def create_leed_skies(self):
        return 'honeybee-radiance sky leed-illuminance sky.wea ' \
            '--north {{self.north}} --folder output --log-file output/sky_info.json'

    sky_list = Outputs.list(
        description='A JSON array containing the information about the two '
        'generated sky files.',
        path='output/sky_info.json')

    output_folder = Outputs.folder(
        description='Output folder with the generated sky files.',
        path='output')
Exemplo n.º 13
0
class CreateSunMatrix(Function):
    """Generate a Radiance sun matrix (AKA sun-path)."""

    north = Inputs.int(
        description='An angle for north direction. Default is 0.',
        default=0,
        spec={
            'type': 'integer',
            'maximum': 360,
            'minimum': 0
        })

    wea = Inputs.file(description='Path to a wea file.',
                      extensions=['wea'],
                      path='sky.wea')

    output_type = Inputs.int(
        description='Output type. 0 is for visible and 1 is for solar.',
        default=0,
        spec={
            'type': 'integer',
            'maximum': 1,
            'minimum': 0
        })

    @command
    def generate_sun_matrix(self):
        return 'gendaymtx -n -D sunpath.mtx -M suns.mod -O{{self.output_type}} ' \
            '-r {{self.north}} -v sky.wea'

    sunpath = Outputs.file(description='Output sunpath matrix.',
                           path='sunpath.mtx')

    sun_modifiers = Outputs.file(
        description='List of sun modifiers in sunpath.', path='suns.mod')
Exemplo n.º 14
0
class CreateRadianceFolder(Function):
    """Create a Radiance folder from a HBJSON input file.

    This function creates the folder but doesn't expose information for sensor grids
    and views.
    """

    input_model = Inputs.file(description='Path to input HBJSON file.',
                              path='model.hbjson')

    grid_filter = Inputs.str(
        description=
        'Text for a grid identifer or a pattern to filter the sensor grids '
        'of the model that are simulated. For instance, first_floor_* will simulate '
        'only the sensor grids that have an identifier that starts with '
        'first_floor_. By default, all grids in the model will be simulated.',
        default='*')

    view_filter = Inputs.str(
        description='Text for a view identifer or a pattern to filter the views '
        'of the model that are simulated. For instance, first_floor_* will simulate '
        'only the views that have an identifier that starts with first_floor_. By '
        'default, all views in the model will be simulated.',
        default='*')

    @command
    def hbjson_to_rad_folder(self):
        return 'honeybee-radiance translate model-to-rad-folder model.hbjson ' \
            '--grid "{{self.grid_filter}}" --view "{{self.view_filter}}"'

    model_folder = Outputs.folder(description='Radiance folder.', path='model')
Exemplo n.º 15
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')
Exemplo n.º 16
0
class WeaToConstant(Function):
    """Convert a Wea file to have a constant value for each datetime.

    This is useful in workflows where hourly irradiance values are inconsequential
    to the analysis and one is only using the Wea as a format to pass location
    and datetime information (eg. for direct sun hours).
    """

    wea = Inputs.file(
        description='Wea file with irradiance values to be set to constant.',
        path='weather.wea',
        extensions=['wea'])

    value = Inputs.int(
        description=
        'The direct and diffuse irradiance value that will be written '
        'in for all datetimes of the Wea.',
        default=1000)

    @command
    def wea_to_constant(self):
        return 'ladybug translate wea-to-constant weather.wea ' \
            '--value {{self.value}} --output-file constant.wea'

    constant_wea = Outputs.file(
        description=
        'A wea file with constant irradiance values for each datetime.',
        path='constant.wea')
Exemplo n.º 17
0
class EpwToWea(Function):
    """Translate an .epw file to a .wea file."""

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

    period = Inputs.str(
        description=
        'An AnalysisPeriod string to filter the datetimes in the resulting '
        'Wea (eg. "6/21 to 9/21 between 8 and 16 @1"). Note that the timestep '
        'of the analysis period should match the input timestep and a * must be at '
        'the end of the string if the input epw is for a leap year. If None, '
        'the Wea will be annual.',
        default='')

    timestep = Inputs.int(
        description=
        'An integer to set the number of time steps per hour. Default is 1 '
        'for one value per hour. Note that this input will only do a linear '
        'interpolation over the data in the epw file.',
        default=1)

    @command
    def epw_to_wea(self):
        return 'ladybug translate epw-to-wea weather.epw ' \
            '--analysis-period "{{self.period}}" --timestep {{self.timestep}} ' \
            '--output-file weather.wea'

    wea = Outputs.file(description='A wea file generated from the input epw.',
                       path='weather.wea')
Exemplo n.º 18
0
class CreateRadiantEnclosureInfo(Function):
    """Create JSONs with radiant enclosure information from a HBJSON input file.

    This enclosure info is intended to be consumed by thermal mapping functions.
    """

    model = Inputs.file(description='Path to input HBJSON file.',
                        path='model.hbjson')

    @command
    def hbjson_to_radiant_enclosure_info(self):
        return 'honeybee-radiance translate model-radiant-enclosure-info model.hbjson ' \
            '--folder output --log-file enclosure_list.json'

    enclosure_list = Outputs.dict(
        description=
        'A list of dictionaries that include information about generated '
        'radiant enclosure files.',
        path='enclosure_list.json')

    enclosure_list_file = Outputs.file(
        description=
        'A JSON file that includes information about generated radiant '
        'enclosure files.',
        path='enclosure_list.json')

    output_folder = Outputs.folder(
        description=
        'Output folder with the enclosure info JSONs for each grid.',
        path='output')
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'
    )
Exemplo n.º 20
0
class CreateRadianceFolderView(Function):
    """Create a Radiance folder from a HBJSON input file."""

    input_model = Inputs.file(description='Path to input HBJSON file.',
                              path='model.hbjson')

    view_filter = Inputs.str(
        description='Text for a view identifer or a pattern to filter the views '
        'of the model that are simulated. For instance, first_floor_* will simulate '
        'only the views that have an identifier that starts with first_floor_. By '
        'default, all views in the model will be simulated.',
        default='*')

    @command
    def hbjson_to_rad_folder(self):
        return 'honeybee-radiance translate model-to-rad-folder model.hbjson ' \
            '--view "{{self.view_filter}}" --view-check'

    model_folder = Outputs.folder(description='Radiance folder.', path='model')

    views = Outputs.list(description='Views information.',
                         path='model/view/_info.json')

    views_file = Outputs.file(description='Views information JSON file.',
                              path='model/view/_info.json')
Exemplo n.º 21
0
class CreateSkyMatrix(Function):
    """Generate a sun-up sky matrix."""

    north = Inputs.int(
        description='An angle for north direction. Default is 0.',
        default=0,
        spec={
            'type': 'integer',
            'maximum': 360,
            'minimum': 0
        })

    sky_component = Inputs.str(
        description='A switch for generating sun-only using -d or exclude sun '
        'contribution using -s. The default is an empty string for including both.',
        default=' ',
        spec={
            'type': 'string',
            'enum': ['-s', '-d', ' ']
        })

    wea = Inputs.file(description='Path to a wea file.',
                      extensions=['wea'],
                      path='sky.wea')

    @command
    def generate_sky_matrix(self):
        return 'gendaymtx -u -O0 -r {{self.north}} -v {{self.sky_component}} sky.wea > sky.mtx'

    sky_matrix = Outputs.file(description='Output Sky matrix', path='sky.mtx')
Exemplo n.º 22
0
class SplitGrid(Function):
    """Split a single sensor grid file into multiple smaller grids."""

    sensor_count = Inputs.int(
        description='Number of maximum sensors in each generated grid.',
        spec={
            'type': 'integer',
            'minimum': 1
        })

    input_grid = Inputs.file(description='Input grid file.', path='grid.pts')

    @command
    def split_grid(self):
        return 'honeybee-radiance grid split grid.pts ' \
            '{{self.sensor_count}} --folder output --log-file output/grids_info.json'

    grids_list = Outputs.list(
        description=
        'A JSON array that includes information about generated sensor '
        'grids.',
        path='output/grids_info.json')

    output_folder = Outputs.folder(
        description='Output folder with new sensor grids.', path='output')
Exemplo n.º 23
0
class AdjustSkyForMetric(Function):
    """Adjust a sky file to ensure it is suitable for a given metric.

    Specifcally, this ensures that skies being created with gendaylit have a -O
    option that aligns with visible vs. solar energy.
    """

    sky = Inputs.file(
        description='Path to a .sky file to be adjusted based on the metric.',
        path='input.sky')

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

    @command
    def adjust_sky_for_metric(self):
        return 'honeybee-radiance sky adjust-for-metric {{self.sky}} ' \
            '--metric {{self.metric}}'

    adjusted_sky = Outputs.file(description='Adjusted sky file.',
                                path='{{self.metric}}.sky')
class WindowsByRatio(Function):
    """Add windows to all outdoor walls of a model given a ratio."""

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

    ratio = Inputs.str(
        description=
        'A number between 0 and 1 (but not perfectly equal to 1) for the '
        'desired ratio between window area and wall area. If multiple values are '
        'input here (each separated by a space), different WindowParameters will be '
        'assigned based on cardinal direction, starting with north and moving '
        'clockwise.',
        default='0.4')

    @command
    def windows_by_ratio(self):
        return 'dragonfly edit windows-by-ratio model.dfjson {{self.ratio}} ' \
            '--output-file new_model.dfjson'

    new_model = Outputs.file(
        description='Dragonfly Model JSON with window parameters set based on '
        'the input ratio.',
        path='new_model.dfjson')
Exemplo n.º 25
0
class DaylightCoefficient(Function):
    """Calculate daylight coefficient for a grid of sensors from a sky matrix."""

    radiance_parameters = Inputs.str(
        description=
        'Radiance parameters. -I, -c 1 and -aa 0 are already included in '
        'the command.',
        default='')

    fixed_radiance_parameters = Inputs.str(
        description=
        'Radiance parameters. -I, -c 1 and -aa 0 are already included in '
        'the command.',
        default='-aa 0')

    sensor_count = Inputs.int(
        description='Number of maximum sensors in each generated grid.',
        spec={
            'type': 'integer',
            'minimum': 1
        })

    sky_matrix = Inputs.file(description='Path to a sky matrix.',
                             path='sky.mtx',
                             extensions=['mtx', 'smx'])

    sky_dome = Inputs.file(description='Path to a sky dome.', path='sky.dome')

    sensor_grid = Inputs.file(description='Path to sensor grid files.',
                              path='grid.pts',
                              extensions=['pts'])

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

    @command
    def run_daylight_coeff(self):
        return 'honeybee-radiance dc scoeff scene.oct grid.pts sky.dome sky.mtx ' \
            '--sensor-count {{self.sensor_count}} --output results.ill --rad-params ' \
            '"{{self.radiance_parameters}}" --rad-params-locked '\
            '"{{self.fixed_radiance_parameters}}"'

    result_file = Outputs.file(description='Output result file.',
                               path='results.ill')
Exemplo n.º 26
0
class AnnualDaylightMetrics(Function):
    """Calculate annual daylight metrics for annual daylight simulation."""

    folder = Inputs.folder(
        description='This folder is an output folder of annual daylight recipe. Folder '
        'should include grids_info.json and sun-up-hours.txt. The command uses the list '
        'in grids_info.json to find the result files for each sensor grid.',
        path='raw_results'
    )

    schedule = Inputs.file(
        description='Path to an annual schedule file. Values should be 0-1 separated '
        'by new line. If not provided an 8-5 annual schedule will be created.',
        path='schedule.txt', optional=True
    )

    thresholds = Inputs.str(
        description='A string to change the threshold for daylight autonomy and useful '
        'daylight illuminance. Valid keys are -t for daylight autonomy threshold, -lt '
        'for the lower threshold for useful daylight illuminance and -ut for the upper '
        'threshold. The defult is -t 300 -lt 100 -ut 3000. The order of the keys is not '
        'important and you can include one or all of them. For instance if you only '
        'want to change the upper threshold to 2000 lux you should use -ut 2000 as '
        'the input.', default='-t 300 -lt 100 -ut 3000'
    )

    @command
    def calculate_annual_metrics(self):
        return 'honeybee-radiance post-process annual-daylight raw_results ' \
            '--schedule schedule.txt {{self.thresholds}} --sub_folder ../metrics'

    # outputs
    annual_metrics = Outputs.folder(
        description='Annual metrics folder. This folder includes all the other '
        'subfolders which are also exposed as separate outputs.', path='metrics'
    )

    daylight_autonomy = Outputs.folder(
        description='Daylight autonomy results.', path='metrics/da'
    )

    continuous_daylight_autonomy = Outputs.folder(
        description='Continuous daylight autonomy results.', path='metrics/cda'
    )

    useful_daylight_illuminance_lower = Outputs.folder(
        description='Lower useful daylight illuminance results.',
        path='metrics/udi_lower'
    )

    useful_daylight_illuminance = Outputs.folder(
        description='Useful daylight illuminance results.', path='metrics/udi'
    )

    useful_daylight_illuminance_upper = Outputs.folder(
        description='Upper useful daylight illuminance results.',
        path='metrics/udi_upper'
    )
Exemplo n.º 27
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')
Exemplo n.º 28
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')
class RayTracingDaylightFactor(Function):
    """Run ray-tracing and post-process the results for a daylight factor simulation."""

    radiance_parameters = Inputs.str(
        description=
        'Radiance parameters to be exposed within recipes. -I and -h are '
        'usually already included in the fixed_radiance_parameters.',
        default='-ab 2')

    sky_illum = Inputs.int(
        description='Sky illuminance level for the sky included in octree.',
        default=100000)

    fixed_radiance_parameters = Inputs.str(
        description=
        'Parameters that are meant to be fixed for a given recipe and '
        'should not be overwritten by radiance_parameters input.',
        default='-I -h')

    grid = Inputs.file(description='Input sensor grid.', path='grid.pts')

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

    bsdf_folder = Inputs.folder(
        description='Folder containing any BSDF files needed for ray tracing.',
        path='model/bsdf',
        optional=True)

    @command
    def ray_tracing(self):
        return 'honeybee-radiance raytrace daylight-factor scene.oct grid.pts ' \
            '--rad-params "{{self.radiance_parameters}}" --rad-params-locked ' \
            '"{{self.fixed_radiance_parameters}}" --sky-illum {{self.sky_illum}} ' \
            '--output grid.res'

    result = Outputs.file(
        description=
        'Daylight factor results file. The results for each sensor is in a '
        'new line.',
        path='grid.res')
Exemplo n.º 30
0
class CreateOctreeWithSky(CreateOctree):
    """Generate an octree from a Radiance folder and a sky!"""

    # inputs
    sky = Inputs.file(description='Path to sky file.', path='sky.sky')

    @command
    def create_octree(self):
        return 'honeybee-radiance octree from-folder model --output scene.oct ' \
            '--{{self.include_aperture}}-aperture --{{self.black_out}} ' \
            '--add-before sky.sky'