NREL / reV

Renewable Energy Potential (reV) Model
https://nrel.github.io/reV/
BSD 3-Clause "New" or "Revised" License
107 stars 24 forks source link

Regional Aggregation in Rep-profiles. #412

Closed WilliamsTravis closed 1 year ago

WilliamsTravis commented 1 year ago

Bug Description reV-rep-profiles will not aggregate regionally. It will only aggregate individual supply curve points. There does not appear to be a test for aggregating by region (only by sc point), but using the sample datasets built in test_rep_profiles.py and adding a regional argument to reg_cols the routine fails silently, returning the same number of profiles as there are supply curve points. When running on a full dataset, however, the run fails with the traceback below (this happens because of repeated resource gids from multiple sc points). So, it appears that the regional rep-profile functionality isn't linked to the aggregation functionality yet and it fails in at least one place anyways.

Full Traceback

"""
Traceback (most recent call last):
  File "/shared-projects/rev/modulefiles/alternate_envs/devruns/lib/python3.9/concurrent/futures/process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/vast/shared-projects/rev/modulefiles/alternate_repos/reV/reV/rep_profiles/rep_profiles.py", line 559, in get_region_rep_profile
    return r.rep_profiles, r.i_reps, r.rep_gen_gids, r.rep_res_gids
  File "/vast/shared-projects/rev/modulefiles/alternate_repos/reV/reV/rep_profiles/rep_profiles.py", line 478, in rep_profiles
    self._run_rep_methods()
  File "/vast/shared-projects/rev/modulefiles/alternate_repos/reV/reV/rep_profiles/rep_profiles.py", line 467, in _run_rep_methods
    raise DataShapeError(e)
reV.utilities.exceptions.DataShapeError: Weights column "gid_counts" resulted in 34 weight scalars which doesnt match gid column which yields profiles with shape (8760, 11).
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/shared-projects/rev/modulefiles/alternate_envs/devruns/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/shared-projects/rev/modulefiles/alternate_envs/devruns/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/vast/shared-projects/rev/modulefiles/alternate_repos/reV/reV/rep_profiles/cli_rep_profiles.py", line 381, in <module>
    main(obj={})
  File "/home/sthomson/.local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/sthomson/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/sthomson/.local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/sthomson/.local/lib/python3.9/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
  File "/home/sthomson/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/sthomson/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/sthomson/.local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/vast/shared-projects/rev/modulefiles/alternate_repos/reV/reV/rep_profiles/cli_rep_profiles.py", line 228, in direct
    RepProfiles.run(gen_fpath, rev_summary, reg_cols, cf_dset=cf_dset,
  File "/vast/shared-projects/rev/modulefiles/alternate_repos/reV/reV/rep_profiles/rep_profiles.py", line 1191, in run
    rp._run(fout=fout, save_rev_summary=save_rev_summary,
  File "/vast/shared-projects/rev/modulefiles/alternate_repos/reV/reV/rep_profiles/rep_profiles.py", line 1120, in _run
    self._run_parallel(max_workers=max_workers)
  File "/vast/shared-projects/rev/modulefiles/alternate_repos/reV/reV/rep_profiles/rep_profiles.py", line 1077, in _run_parallel
    profiles, _, ggids, rgids = future.result()
  File "/shared-projects/rev/modulefiles/alternate_envs/devruns/lib/python3.9/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/shared-projects/rev/modulefiles/alternate_envs/devruns/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
reV.utilities.exceptions.DataShapeError: Weights column "gid_counts" resulted in 34 weight scalars which doesnt match gid column which yields profiles with shape (8760, 11).

To Reproduce Steps to reproduce the problem behavior

  1. When configuring the reV-rep-profiles CLI, enter a reg_cols argument other than sc_gid or sc_point_gid.
  2. Set aggregate_profiles to True (in RepProfiles.run, I believe this is done by setting err_method to None)
  3. Run job.

Expected behavior We get one spatially weighted average time series for each region represented by the reg_cols entry.

Charge code The budget for the project I was working on when I found this is rather tight, so I will do this manually for now (i.e., not urgent).

ppinchuk commented 1 year ago

Fixed in #415