openclimatefix / openclimatefix/ocf-data-sampler

refactor nwp handling in pvnet.py

Open
#29 2 comments 0 reactions 1 assignee View on GitHub

@AUdaltsova is already working on this.

Since Aug 30, 2024.

ocf-internal
Dominant language
Python
Stars
20
Forks
43
PR merge metrics
No merged PRs in 30d

Description

Detailed Description

Several functions in pvnet.py (find_valid_t0_times, slice_datasets_by_time, process_and_combine_datasets) have to unpack nested nwp sources when iterating through datasets and include preparation of specific parameters needed for nwp-specific functions. It might be better to take all of this out into separate functions and keep nwp datasets un-nested for this bit of code, to allow the functions to cleanly and homogeneously iterate over the sources

Context

Currently these three functions are a bit bulky and feel like they are doing a lot of stuff, this will compartmentalize them more.

Possible Implementation

something vaguely like this:

def is_nwp(key):
  split_key = key.split()
  return split_key[0] == "nwp"

def return_spacial_slice(da, config, key):
  if is_nwp(key):
    return spacial_slice_nwp(da, config, **get_additional_nwp_kwargs(da, config))
  else:
    return spacial_slice(da, config)

for key, dataset in datasets_dict.items():
  config = config.key
  slice = return_spacial_slice(dataset, config, key)
  slices.append(slice)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.