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

refactor nwp handling in pvnet.py #29

Open
AUdaltsova opened this issue Aug 15, 2024 · 0 comments
Open

refactor nwp handling in pvnet.py #29

AUdaltsova opened this issue Aug 15, 2024 · 0 comments
Assignees

Comments

@AUdaltsova
Copy link
Contributor

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 untested 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)
@AUdaltsova AUdaltsova added the enhancement New feature or request label Aug 15, 2024
@AUdaltsova AUdaltsova self-assigned this Aug 30, 2024
@peterdudfield peterdudfield removed the enhancement New feature or request label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants