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
Next Next commit
changed i_t_chunk arg -> temporal_id which makes a lot more sense
  • Loading branch information
grantbuster committed Sep 15, 2022
commit d973a75ea81b60719fb70627f62ef173ca134b48
19 changes: 9 additions & 10 deletions sup3r/solar/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import glob
import json
import os
import pandas as pd
import numpy as np
import logging
from scipy.spatial import KDTree
Expand Down Expand Up @@ -550,7 +549,7 @@ def run_temporal_chunk(cls, fp_pattern, nsrdb_fp,
fp_out_suffix='irradiance', tz=-6, agg_factor=1,
nn_threshold=0.5, cloud_threshold=0.99,
features=('ghi', 'dni', 'dhi'),
i_t_chunk=None):
temporal_id=None):
"""Run the solar module on all spatial chunks for a single temporal
chunk corresponding to the fp_pattern. This typically gets run from the
CLI.
Expand Down Expand Up @@ -593,22 +592,22 @@ def run_temporal_chunk(cls, fp_pattern, nsrdb_fp,
features : list | tuple
List of features to write to disk. These have to be attributes of
the Solar class (ghi, dni, dhi).
i_t_chunk : int | None
Index of the sorted list of unique temporal indices to run (parsed
from the files matching fp_pattern). This input typically gets set
from the CLI. If None, this will run all temporal indices.
temporal_id : str | None
One of the unique zero-padded temporal id's from the file chunks
that match fp_pattern. This input typically gets set from the CLI.
If None, this will run all temporal indices.
"""

temp = cls.get_sup3r_fps(fp_pattern, ignore=f'_{fp_out_suffix}.h5')
fp_sets, t_slices, temporal_ids, spatial_ids, target_fps = temp

if i_t_chunk is not None:
if temporal_id is not None:
fp_sets = [fp_set for i, fp_set in enumerate(fp_sets)
if temporal_ids[i] == temporal_ids[i_t_chunk]]
if temporal_ids[i] == temporal_id]
t_slices = [t_slice for i, t_slice in enumerate(t_slices)
if temporal_ids[i] == temporal_ids[i_t_chunk]]
if temporal_ids[i] == temporal_id]
target_fps = [target_fp for i, target_fp in enumerate(target_fps)
if temporal_ids[i] == temporal_ids[i_t_chunk]]
if temporal_ids[i] == temporal_id]

zip_iter = zip(fp_sets, t_slices, target_fps)
for i, (fp_set, t_slice, fp_target) in enumerate(zip_iter):
Expand Down
4 changes: 2 additions & 2 deletions sup3r/solar/solar_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def from_config(ctx, config_file, verbose):
'on. Submitting to {} nodes based on the number of temporal '
'chunks'.format(len(fp_sets), len(set(temporal_ids))))

for i_node, _ in enumerate(temporal_ids):
for i_node, temporal_id in enumerate(sorted(set(temporal_ids))):
node_config = copy.deepcopy(config)
node_config['log_file'] = (
log_pattern if log_pattern is None
Expand All @@ -86,7 +86,7 @@ def from_config(ctx, config_file, verbose):
ctx.obj['NAME'] = name
node_config['job_name'] = name

node_config['i_t_chunk'] = i_node
node_config['temporal_id'] = temporal_id
cmd = Solar.get_node_cmd(node_config)

cmd_log = '\n\t'.join(cmd.split('\n'))
Expand Down
12 changes: 7 additions & 5 deletions tests/test_solar_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def make_cs_ratio_files(td, low_res_times, low_res_lat_lon):
"""
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):
Expand All @@ -60,7 +61,7 @@ def make_cs_ratio_files(td, low_res_times, low_res_lat_lon):
[timestamp],
out_file, max_workers=1,
meta_data=GAN_META)
return fps
return fps, fp_pattern


def test_solar_module(plot=False):
Expand All @@ -71,13 +72,14 @@ 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_cs_ratio_files(td, LOW_RES_TIMES, LOW_RES_LAT_LON)

with Resource(fps[1]) as res:
meta_base = res.meta
attrs_base = res.global_attrs

with Solar(fps, NSRDB_FP, t_slice=t_slice, nn_threshold=0.4) as solar:
with Solar(fps, NSRDB_FP, t_slice=t_slice,
nn_threshold=0.4) as solar:
ghi = solar.ghi
dni = solar.dni
dhi = solar.dhi
Expand Down Expand Up @@ -168,8 +170,8 @@ 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 = make_cs_ratio_files(td, LOW_RES_TIMES, LOW_RES_LAT_LON)
fp_pattern = os.path.join(td, 'chunks/sup3r*.h5')
fps, fp_pattern = make_cs_ratio_files(td, LOW_RES_TIMES,
LOW_RES_LAT_LON)
config = {'fp_pattern': fp_pattern,
'nsrdb_fp': NSRDB_FP,
'log_level': 'DEBUG',
Expand Down