예제 #1
0
def rtrace_with_pit_post_process(octree, sensor_grid, rad_params,
                                 rad_params_locked, metric, output, dry_run):
    """Run rtrace command with rcalc post-processing for point-in-time studies.

    \b
    Args:
        octree: Path to octree file.
        sensor_grid: Path to sensor grid file.
    """
    try:
        options = RtraceOptions()
        # parse input radiance parameters
        if rad_params:
            options.update_from_string(rad_params.strip())
        # overwrite input values with protected ones
        if rad_params_locked:
            options.update_from_string(rad_params_locked.strip())
        # overwrite the -I attribute depending on the metric to be calculated
        if metric in ('illuminance', 'irradiance'):
            options.I = True
        elif metric in ('luminance', 'radiance'):
            options.I = False
        else:
            raise ValueError('Metric "{}" is not recognized.'.format(metric))

        # create command.
        rtrace = Rtrace(options=options, octree=octree, sensors=sensor_grid)

        # add rcalc post-procing
        rcalc = Rcalc(output=output)
        rcalc.options.e = '$1=(0.265*$1+0.67*$2+0.065*$3)*179' if metric in \
            ('illuminance', 'luminance') else '$1=(0.265*$1+0.67*$2+0.065*$3)'
        rtrace.pipe_to = rcalc

        if dry_run:
            click.echo(rtrace)
        else:
            env = None
            if folders.env != {}:
                env = folders.env
            env = dict(os.environ, **env) if env else None
            rtrace.run(env=env)
    except Exception:
        _logger.exception('Failed to run point-in-time ray-tracing.')
        sys.exit(1)
    else:
        sys.exit(0)
예제 #2
0
def rtrace_with_df_post_process(octree, sensor_grid, rad_params,
                                rad_params_locked, sky_illum, output, dry_run):
    """Run rtrace command with rcalc post-processing for daylight factor studies.

    \b
    Args:
        octree: Path to octree file.
        sensor_grid: Path to sensor grid file.
    """
    try:
        options = RtraceOptions()
        # parse input radiance parameters
        if rad_params:
            options.update_from_string(rad_params.strip())
        # overwrite input values with protected ones
        if rad_params_locked:
            options.update_from_string(rad_params_locked.strip())

        # create command.
        rtrace = Rtrace(options=options, octree=octree, sensors=sensor_grid)

        # add rcalc post-procing
        rcalc = Rcalc(output=output)
        rcalc.options.e = '$1=(0.265*$1+0.67*$2+0.065*$3)*17900/{}'.format(
            sky_illum)
        rtrace.pipe_to = rcalc

        if dry_run:
            click.echo(rtrace)
        else:
            env = None
            if folders.env != {}:
                env = folders.env
            env = dict(os.environ, **env) if env else None
            rtrace.run(env=env)
    except Exception:
        _logger.exception('Failed to run daylight-factor ray-tracing.')
        sys.exit(1)
    else:
        sys.exit(0)
예제 #3
0
    rpict.options.vd = (0, 0, 1)
    rpict.options.vu = (0, 1, 0)
    rpict.options.vh = 180
    rpict.options.vv = 180

    pflip = Pflip(input=init_hdr, output=final_hdr)
    pflip.options.h = True

    # add the command to get the horizontal irradiance of the sky
    grid = SensorGrid.from_position_and_direction('up_sensor', [(0, 0, 0)],
                                                  [(0, 0, 1)])
    grid.to_file(sky_dir, 'up_sensor.pts')
    rtrace = Rtrace(octree=sky_oct, sensors='up_sensor.pts')
    rtrace.options.I = True
    rtrace.options.w = True
    rtrace.options.h = True
    rtrace.options.ab = 1
    rcalc = Rcalc(output=ghi_res)
    rcalc.options.e = '$1=(0.265*$1+0.67*$2+0.065*$3)'
    rtrace.pipe_to = rcalc

    # run the commands in series and load the global horizontal irradiance
    env = None
    if rad_folders.env != {}:
        env = rad_folders.env
    env = dict(os.environ, **env) if env else None
    for r_cmd in (oconv, rpict, pflip, rtrace):
        r_cmd.run(env, cwd=sky_dir)
    with open(full_ghi_res, 'r') as inf:
        ghi = inf.readlines()[0].strip()