-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ec1d37
commit 943f559
Showing
5 changed files
with
134 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/local/notebook_steps/retrieve_and_process_neem_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
""" | ||
Retrieve and extract NEEM data notebook steps | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from collections.abc import Iterable | ||
from pathlib import Path | ||
from typing import TYPE_CHECKING | ||
|
||
from pydoit_nb.checklist import get_checklist_file | ||
from pydoit_nb.config_handling import get_config_for_step_id | ||
from pydoit_nb.notebook import ConfiguredNotebook, UnconfiguredNotebook | ||
from pydoit_nb.notebook_step import UnconfiguredNotebookBasedStep | ||
|
||
if TYPE_CHECKING: | ||
from ..config.base import Config, ConfigBundle | ||
|
||
|
||
def configure_notebooks( | ||
unconfigured_notebooks: Iterable[UnconfiguredNotebook], | ||
config_bundle: ConfigBundle, | ||
step_name: str, | ||
step_config_id: str, | ||
) -> list[ConfiguredNotebook]: | ||
""" | ||
Configure notebooks | ||
Parameters | ||
---------- | ||
unconfigured_notebooks | ||
Unconfigured notebooks | ||
config_bundle | ||
Configuration bundle from which to take configuration values | ||
step_name | ||
Name of the step | ||
step_config_id | ||
Step config ID to use when configuring the notebook | ||
Returns | ||
------- | ||
Configured notebooks | ||
""" | ||
uc_nbs_dict = {nb.notebook_path: nb for nb in unconfigured_notebooks} | ||
|
||
config = config_bundle.config_hydrated | ||
|
||
config_step = get_config_for_step_id( | ||
config=config, step=step_name, step_config_id=step_config_id | ||
) | ||
|
||
configured_notebooks = [ | ||
ConfiguredNotebook( | ||
unconfigured_notebook=uc_nbs_dict[ | ||
Path("006y_process-neem-data") / "0060_download-neem" | ||
], | ||
configuration=( | ||
config_step.merged_ice_core_data, | ||
config_step.station_data, | ||
), | ||
dependencies=(), | ||
targets=( | ||
config_step.merged_ice_core_data_processed_data_file, | ||
get_checklist_file(config_step.raw_dir), | ||
), | ||
config_file=config_bundle.config_hydrated_path, | ||
step_config_id=step_config_id, | ||
), | ||
ConfiguredNotebook( | ||
unconfigured_notebook=uc_nbs_dict[ | ||
Path("006y_process-neem-data") / "0061_process-neem" | ||
], | ||
configuration=(), | ||
dependencies=(get_checklist_file(config_step.raw_dir),), | ||
targets=(config_step.processed_data_with_loc_file,), | ||
config_file=config_bundle.config_hydrated_path, | ||
step_config_id=step_config_id, | ||
), | ||
] | ||
|
||
return configured_notebooks | ||
|
||
|
||
step: UnconfiguredNotebookBasedStep[ | ||
Config, ConfigBundle | ||
] = UnconfiguredNotebookBasedStep( | ||
step_name="retrieve_and_process_neem_data", | ||
unconfigured_notebooks=[ | ||
UnconfiguredNotebook( | ||
notebook_path=Path("006y_process-neem-data") / "0060_download-neem", | ||
raw_notebook_ext=".py", | ||
summary="process NEEM data - download", | ||
doc="Download NEEM data", | ||
), | ||
UnconfiguredNotebook( | ||
notebook_path=Path("006y_process-neem-data") / "0061_process-neem", | ||
raw_notebook_ext=".py", | ||
summary="process NEEM data - process", | ||
doc="Process NEEM data into a single file with monthly information etc.", | ||
), | ||
], | ||
configure_notebooks=configure_notebooks, | ||
) |