def test_wind_icing_losses(i): """Test wind icing losses.""" pc = Gen.get_pc(REV2_POINTS, None, SAM_FILE, 'windpower', sites_per_worker=3, res_file=RES_FILE) pc.project_points.sam_configs[SAM_FILE]['en_icing_cutoff'] = 1 pc.project_points.sam_configs[SAM_FILE]['icing_cutoff_temp'] = \ ICING_BASELINE[i]['temp'] pc.project_points.sam_configs[SAM_FILE]['icing_cutoff_rh'] = \ ICING_BASELINE[i]['rh'] gen = Gen.reV_run('windpower', pc, SAM_FILE, RES_FILE, max_workers=1, sites_per_worker=3, fout=None) gen_outs = list(gen.out['cf_mean']) assert np.allclose(gen_outs, ICING_BASELINE[i]['output'], rtol=RTOL, atol=ATOL)
def test_wind_low_temp_cutoff(i): """Test wind low temperature cutoff.""" pc = Gen.get_pc(REV2_POINTS, None, SAM_FILE, 'windpower', sites_per_worker=3, res_file=RES_FILE) pc.project_points.sam_configs[SAM_FILE]['en_low_temp_cutoff'] = 1 pc.project_points.sam_configs[SAM_FILE]['low_temp_cutoff'] = \ LOW_TEMP_BASELINE[i]['temp'] gen = Gen.reV_run('windpower', pc, SAM_FILE, RES_FILE, max_workers=1, sites_per_worker=3, fout=None) gen_outs = list(gen.out['cf_mean']) assert np.allclose(gen_outs, LOW_TEMP_BASELINE[i]['output'], rtol=RTOL, atol=ATOL)
def get_pc(points, points_range, sam_files, cf_file, sites_per_worker=None, append=False): """ Get a PointsControl instance. Parameters ---------- points : slice | list | str | reV.config.project_points.PointsControl Slice specifying project points, or string pointing to a project points csv, or a fully instantiated PointsControl object. points_range : list | None Optional two-entry list specifying the index range of the sites to analyze. To be taken from the reV.config.PointsControl.split_range property. sam_files : dict | str | list | SAMConfig SAM input configuration ID(s) and file path(s). Keys are the SAM config ID(s), top level value is the SAM path. Can also be a single config file str. If it's a list, it is mapped to the sorted list of unique configs requested by points csv. Can also be a pre loaded SAMConfig object. cf_file : str reV generation capacity factor output file with path. sites_per_worker : int Number of sites to run in series on a worker. None defaults to the resource file chunk size. append : bool Flag to append econ datasets to source cf_file. This has priority over the fout and dirout inputs. Returns ------- pc : reV.config.project_points.PointsControl PointsControl object instance. """ pc = Gen.get_pc(points, points_range, sam_files, 'econ', sites_per_worker=sites_per_worker, res_file=cf_file) if append: pc = Econ._econ_append_pc(pc.project_points, cf_file, sites_per_worker=sites_per_worker) return pc
def test_curtailment_res_mean(year): """Run Wind generation and ensure that the cf_profile is zero when curtailment is expected. Note that the probability of curtailment must be 1 for this to succeed. """ res_file = os.path.join(TESTDATADIR, 'wtk/ri_100_wtk_{}.h5'.format(year)) sam_files = os.path.join(TESTDATADIR, 'SAM/wind_gen_standard_losses_0.json') curtailment = os.path.join(TESTDATADIR, 'config/', 'curtailment.json') points = slice(0, 100) output_request = ('cf_mean', 'ws_mean') pc = Gen.get_pc(points, None, sam_files, 'windpower', sites_per_worker=50, res_file=res_file, curtailment=curtailment) resources = RevPySam.get_sam_res(res_file, pc.project_points, pc.project_points.tech, output_request) truth = resources['mean_windspeed'] # run reV 2.0 generation gen = Gen.reV_run('windpower', points, sam_files, res_file, fout=None, output_request=output_request, curtailment=curtailment, max_workers=1, sites_per_worker=50, scale_outputs=True) test = gen.out['ws_mean'] assert np.allclose(truth, test, rtol=0.001)
def test_wind_generic_losses(loss): """Test varying wind turbine losses""" pc = Gen.get_pc(REV2_POINTS, None, SAM_FILE, 'windpower', sites_per_worker=3, res_file=RES_FILE) del pc.project_points.sam_configs[SAM_FILE]['wind_farm_losses_percent'] pc.project_points.sam_configs[SAM_FILE]['turb_generic_loss'] = loss gen = Gen.reV_run('windpower', pc, SAM_FILE, RES_FILE, max_workers=1, sites_per_worker=3, fout=None) gen_outs = list(gen.out['cf_mean']) assert np.allclose(gen_outs, LOSS_BASELINE[loss], rtol=RTOL, atol=ATOL)
def run(cls, gen_fpath, offshore_fpath, points, sam_files, fpath_out=None, max_workers=None, offshore_gid_adder=1e7, small_farm_limit=7, farm_gid_label='wfarm_id', sub_dir='chunk_files'): """Run the offshore aggregation methods. Parameters ---------- gen_fpath : str Full filepath to reV gen h5 output file. offshore_fpath : str Full filepath to offshore wind farm data file. points : slice | list | str | reV.config.project_points.PointsControl Slice specifying project points, or string pointing to a project points csv, or a fully instantiated PointsControl object. sam_files : dict | str | list Dict contains SAM input configuration ID(s) and file path(s). Keys are the SAM config ID(s), top level value is the SAM path. Can also be a single config file str. If it's a list, it is mapped to the sorted list of unique configs requested by points csv. fpath_out : str | NoneType Optional output filepath. max_workers : int | None Number of workers for process pool executor. 1 will run in serial. offshore_gid_adder : int | float The offshore Supply Curve gids will be set equal to the respective resource gids plus this number. small_farm_limit : int Wind farms with less than this number of neighboring resource pixels will not be included in the output. Default is 7 based on median number of farm resource neighbors in a small test case. farm_gid_label : str Label in offshore_fpath for the wind farm gid unique identifier. sub_dir : str | None Sub directory name to move chunks to. None to not move files. Returns ------- offshore : Offshore Offshore aggregation object. """ points_range = None pc = Gen.get_pc(points, points_range, sam_files, 'windpower', sites_per_worker=100) offshore = cls(gen_fpath, offshore_fpath, pc.project_points, offshore_gid_adder=offshore_gid_adder, small_farm_limit=small_farm_limit, farm_gid_label=farm_gid_label, max_workers=max_workers) if any(offshore.offshore_gids): offshore._run() if fpath_out is not None: offshore.save_output(fpath_out) offshore.move_input_file(sub_dir) logger.info('Offshore wind gen/econ module complete!') return offshore