Exemple #1
0
def test_proj_points_split(start, interval):
    """Test the split operation of project points."""
    res_file = os.path.join(TESTDATADIR, 'wtk/ri_100_wtk_2012.h5')
    sam_files = os.path.join(TESTDATADIR,
                             'SAM/wind_gen_standard_losses_0.json')
    pp = ProjectPoints(slice(start, 100, interval), sam_files, 'windpower',
                       res_file=res_file)

    iter_interval = 5
    for i0 in range(0, len(pp), iter_interval):
        i1 = i0 + iter_interval
        if i1 > len(pp):
            break

        pp_0 = ProjectPoints.split(i0, i1, pp)

        msg = 'ProjectPoints split did not function correctly!'
        assert pp_0.sites == pp.sites[i0:i1], msg
        assert all(pp_0.df == pp.df.iloc[i0:i1]), msg
Exemple #2
0
def test_sam_config_kw_replace():
    """Test that the SAM config with old keys from pysam v1 gets updated on
    the fly and gets propogated to downstream splits."""

    fpp = os.path.join(TESTDATADIR, 'project_points/pp_offshore.csv')
    sam_files = {'onshore': os.path.join(
                 TESTDATADIR, 'SAM/wind_gen_standard_losses_0.json'),
                 'offshore': os.path.join(
                 TESTDATADIR, 'SAM/wind_gen_standard_losses_1.json')}
    res_file = os.path.join(TESTDATADIR, 'wtk/ri_100_wtk_2012.h5')
    pp = ProjectPoints(fpp, sam_files, 'windpower')
    pc = PointsControl(pp, sites_per_split=100)

    gen = Gen(pc, res_file)
    config_on = gen.project_points.sam_configs['onshore']
    config_of = gen.project_points.sam_configs['offshore']
    assert 'turb_generic_loss' in config_on
    assert 'turb_generic_loss' in config_of

    pp_split = ProjectPoints.split(0, 10000, gen.project_points)
    config_on = pp_split.sam_configs['onshore']
    config_of = pp_split.sam_configs['offshore']
    assert 'turb_generic_loss' in config_on
    assert 'turb_generic_loss' in config_of

    pc_split = PointsControl.split(0, 10000, gen.project_points)
    config_on = pc_split.project_points.sam_configs['onshore']
    config_of = pc_split.project_points.sam_configs['offshore']
    assert 'turb_generic_loss' in config_on
    assert 'turb_generic_loss' in config_of

    for ipc in pc_split:
        if 'onshore' in ipc.project_points.sam_configs:
            config = ipc.project_points.sam_configs['onshore']
            assert 'turb_generic_loss' in config

        if 'offshore' in ipc.project_points.sam_configs:
            config = ipc.project_points.sam_configs['offshore']
            assert 'turb_generic_loss' in config