Exemple #1
0
def rfluxmtx_command_with_postprocess(
        octree, sensor_grid, sky_dome, sky_mtx, sensor_count, rad_params,
        rad_params_locked, output, conversion, output_format, dry_run
):
    """Run rfluxmtx command and pass the results to rmtxop.

    octree: Path to octree file.

    sensor-grid: Path to sensor grid file.

    sky-dome: Path to sky dome for coefficient calculation.

    sky-mtx: Path to sky matrix.

    """
    try:
        options = RfluxmtxOptions()
        # parse input radiance parameters
        if rad_params.strip():
            options.update_from_string(rad_params.strip())
        # overwrite input values with protected ones
        if rad_params_locked.strip():
            options.update_from_string(rad_params_locked.strip())

        if not sensor_count:
            raise ValueError('Number of sensors in senor grid must be provided!')

        options.update_from_string('-aa 0.0 -faf -y {}'.format(sensor_count))

        # create command.
        cmd_template = 'rfluxmtx {rad_params} - {sky_dome} -i {octree} < ' \
            '{sensors} | rmtxop -f{output_format} - {sky_mtx}'

        if conversion and conversion.strip():
            cmd_template = cmd_template + ' -c %s' % conversion

        if output:
            cmd_template = cmd_template + ' > {output}'.format(output=output)

        cmd = cmd_template.format(
            rad_params=options.to_radiance(), sky_dome=sky_dome, octree=octree,
            sensors=sensor_grid, output_format=output_format, sky_mtx=sky_mtx
        )

        if dry_run:
            click.echo(cmd)
        else:
            run_command(cmd, env=folders.env)
    except Exception:
        _logger.exception('Failed to run rfluxmtx command.')
        sys.exit(1)
    else:
        sys.exit(0)
def test_protected_assignment():
    options = RfluxmtxOptions()
    with pytest.raises(exceptions.ProtectedOptionError):
        options.f = 'bins.cal'
    with pytest.raises(exceptions.ProtectedOptionError):
        options.e = '2*$1=$2'
    with pytest.raises(exceptions.ProtectedOptionError):
        options.m = 'modifier'
    with pytest.raises(exceptions.ProtectedOptionError):
        options.m = None
        options.M = './suns.mod'
def test_reassignment():
    options = RfluxmtxOptions()
    options.v = True
    assert options.v == True
    assert options.to_radiance() == '-v'
    # remove assigned values
    options.v = None
    assert options.v == None
    assert options.to_radiance() == ''
def test_default():
    options = RfluxmtxOptions()
    assert options.to_radiance() == ''
def test_assignment():
    options = RfluxmtxOptions()
    options.v = True
    assert options.v == True
    assert options.to_radiance() == '-v'
    'point-in-time-image': 'rpict',
    'rpict': 'rpict',
    '2': 'rfluxmtx',
    'annual': 'rfluxmtx',
    'rfluxmtx': 'rfluxmtx',
}

DETAIL_LEVELS = {'0': 0, 'low': 0, '1': 1, 'medium': 1, '2': 2, 'high': 2}

if all_required_inputs(ghenv.Component):
    # process the recipe type and level of detail
    _detail_level_ = DETAIL_LEVELS[_detail_level_.lower()] \
        if _detail_level_ is not None else 0
    command_name = RECIPE_TYPES[_recipe_type.lower()]
    if command_name == 'rtrace':
        option_dict = RTRACE
        option_obj = RtraceOptions()
    elif command_name == 'rpict':
        option_dict = RPICT
        option_obj = RpictOptions()
    elif command_name == 'rfluxmtx':
        option_dict = RFLUXMTX
        option_obj = RfluxmtxOptions()

    # assign the defualts to the object and output the string
    for opt_name, opt_val in option_dict.items():
        setattr(option_obj, opt_name, opt_val[_detail_level_])
    if additional_par_:
        option_obj.update_from_string(additional_par_)
    rad_par = option_obj.to_radiance()