Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gb/solar module #92

Merged
merged 23 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3967370
started test setup for solar module
grantbuster Sep 13, 2022
14a2dd6
added two weeks of cleasky data for nsrdb solar tests
grantbuster Sep 13, 2022
624224c
added farms requirement for solar module
grantbuster Sep 13, 2022
d46f7b1
added basic solar module that will take clearsky ratio GAN outputs an…
grantbuster Sep 13, 2022
7b1ad5e
added solar irrad output handling
grantbuster Sep 13, 2022
69e1431
more tests
grantbuster Sep 13, 2022
d0b57e0
added get_node_cmd for solar module
grantbuster Sep 13, 2022
15d06ca
added solar file parser with test
grantbuster Sep 13, 2022
3569890
added cli
grantbuster Sep 13, 2022
62ff8aa
finished solar cli with tests
grantbuster Sep 13, 2022
88b2597
fixed up tests
grantbuster Sep 13, 2022
d9b96fe
added solar cli to the main cli and pipeline
grantbuster Sep 13, 2022
b23230e
moved i_t_chunks to optional arg and enabled the solar class method e…
grantbuster Sep 13, 2022
d306db3
fixed node count logic
grantbuster Sep 13, 2022
5e92b11
fixed a stupid assumption that the nsrdb time index would always have…
grantbuster Sep 13, 2022
d973a75
changed i_t_chunk arg -> temporal_id which makes a lot more sense
grantbuster Sep 14, 2022
d785fc1
logging updates
grantbuster Sep 14, 2022
883a77f
linter fixes
grantbuster Sep 14, 2022
2fb8630
added new rex version requirement for sup3r solar multitimeresource i…
grantbuster Sep 14, 2022
0476f26
added the option for the user to specify qa datsets with mapping from…
grantbuster Sep 14, 2022
b99c42a
fixed qa features as list
grantbuster Sep 14, 2022
2833f0f
CC-based clearsky ratio should be set with ceiling not scaled to the …
grantbuster Sep 15, 2022
ca33492
moved solar test utilities
grantbuster Sep 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
moved solar test utilities
  • Loading branch information
grantbuster committed Sep 16, 2022
commit ca334922433d4e183434742c7bf5f8b8d9b502cc
46 changes: 46 additions & 0 deletions sup3r/utilities/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,52 @@ def make_fake_h5_chunks(td):
return out


def make_fake_cs_ratio_files(td, low_res_times, low_res_lat_lon, gan_meta):
"""Make a set of dummy clearsky ratio files that match the GAN fwp outputs

Parameters
----------
td : tempfile.TemporaryDirectory
Test TemporaryDirectory
low_res_times :
List of times for low res input data. If there is only a single low
res timestep, it is assumed the data is daily.
low_res_lat_lon
Array of lat/lon for input data.
(spatial_1, spatial_2, 2)
Last dimension has ordering (lat, lon)
gan_meta : dict
Meta data for model to write to file.

Returns
-------
fps : list
List of clearsky ratio .h5 chunked files.
fp_pattern : str
Glob pattern*string to find fps
"""
fps = []
chunk_dir = os.path.join(td, 'chunks/')
fp_pattern = os.path.join(chunk_dir, 'sup3r_chunk_*.h5')
os.makedirs(chunk_dir)

for idt, timestamp in enumerate(low_res_times):
fn = ('sup3r_chunk_{}_{}.h5'
.format(str(idt).zfill(6), str(0).zfill(6)))
out_file = os.path.join(chunk_dir, fn)
fps.append(out_file)

cs_ratio = np.random.uniform(0, 1, (20, 20, 1, 1))
cs_ratio = np.repeat(cs_ratio, 24, axis=2)

OutputHandlerH5.write_output(cs_ratio, ['clearsky_ratio'],
low_res_lat_lon,
[timestamp],
out_file, max_workers=1,
meta_data=gan_meta)
return fps, fp_pattern


def tke_spectrum(u, v):
"""Longitudinal Turbulent Kinetic Energy Spectrum. Gives the portion of
kinetic energy associated with each longitudinal wavenumber.
Expand Down
35 changes: 6 additions & 29 deletions tests/test_solar_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from sup3r import TEST_DATA_DIR
from sup3r.solar import Solar
from sup3r.postprocessing.file_handling import OutputHandlerH5
from sup3r.utilities.utilities import pd_date_range
from sup3r.utilities.test_utils import make_fake_cs_ratio_files
from sup3r.solar.solar_cli import from_config as solar_main


Expand All @@ -39,31 +39,6 @@ def runner():
return CliRunner()


def make_cs_ratio_files(td, low_res_times, low_res_lat_lon):
"""Make a set of dummy clearsky ratio files that match the GAN fwp outputs
"""
fps = []
chunk_dir = os.path.join(td, 'chunks/')
fp_pattern = os.path.join(chunk_dir, 'sup3r_chunk_*.h5')
os.makedirs(chunk_dir)

for idt, timestamp in enumerate(low_res_times):
fn = ('sup3r_chunk_{}_{}.h5'
.format(str(idt).zfill(6), str(0).zfill(6)))
out_file = os.path.join(chunk_dir, fn)
fps.append(out_file)

cs_ratio = np.random.uniform(0, 1, (20, 20, 1, 1))
cs_ratio = np.repeat(cs_ratio, 24, axis=2)

OutputHandlerH5.write_output(cs_ratio, ['clearsky_ratio'],
low_res_lat_lon,
[timestamp],
out_file, max_workers=1,
meta_data=GAN_META)
return fps, fp_pattern


def test_solar_module(plot=False):
"""Test the solar module operating on a set of SolarMultiStepGan chunked
outputs"""
Expand All @@ -72,7 +47,8 @@ def test_solar_module(plot=False):

with tempfile.TemporaryDirectory() as td:

fps, _ = make_cs_ratio_files(td, LOW_RES_TIMES, LOW_RES_LAT_LON)
fps, _ = make_fake_cs_ratio_files(td, LOW_RES_TIMES, LOW_RES_LAT_LON,
gan_meta=GAN_META)

with Resource(fps[1]) as res:
meta_base = res.meta
Expand Down Expand Up @@ -170,8 +146,9 @@ def test_solar_cli(runner):
"""Test the solar CLI. This test is here and not in the test_cli.py file
because it uses some common test utilities stored here."""
with tempfile.TemporaryDirectory() as td:
fps, fp_pattern = make_cs_ratio_files(td, LOW_RES_TIMES,
LOW_RES_LAT_LON)
fps, fp_pattern = make_fake_cs_ratio_files(td, LOW_RES_TIMES,
LOW_RES_LAT_LON,
gan_meta=GAN_META)
config = {'fp_pattern': fp_pattern,
'nsrdb_fp': NSRDB_FP,
'log_level': 'DEBUG',
Expand Down