-
Notifications
You must be signed in to change notification settings - Fork 145
CMORizer ESACCI-PERMAFROST #3545
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
Open
axel-lauer
wants to merge
18
commits into
main
Choose a base branch
from
cmorize_esacci_permafrost
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0fab902
first draft ESACCI-PERMAFROST downloader
axel-lauer 9e0be9d
snapshot 2024-02-28
axel-lauer 680c617
working version of ESACCI-PERMAFROST downloader
axel-lauer 127c924
some pylint fixes
axel-lauer ada5ae3
snapshot 2024-02-29
axel-lauer 2230739
added cmor_config/ESACCI-PERMAFROST.yml
axel-lauer b7d412e
snapshot 2024-03-01
axel-lauer 81b99c6
first working version
axel-lauer 5487cb4
cleaned up code a bit
axel-lauer 7682235
Merge branch 'main' into cmorize_esacci_permafrost
axel-lauer 21708d6
snapshot 2024-06-21
axel-lauer f913206
merged with main
axel-lauer b0ebee8
snapshot 2025-05-07
axel-lauer ba1359e
updated recipe_check_obs.yml
axel-lauer ae463f4
Merge branch 'main' into cmorize_esacci_permafrost
axel-lauer b174566
updated input.rst
axel-lauer 133cd2e
small formatting updates
axel-lauer 52c7782
format updates
axel-lauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
esmvaltool/cmorizers/data/cmor_config/ESACCI-PERMAFROST.yml
This file contains hidden or 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,29 @@ | ||
| --- | ||
| # Common global attributes for CMORizer output | ||
| attributes: | ||
| dataset_id: ESACCI-PERMAFROST | ||
| version: 'v3.0' | ||
| tier: 2 | ||
| modeling_realm: sat | ||
| project_id: OBS6 | ||
| source: 'ftp://anon-ftp.ceda.ac.uk/neodc/esacci/permafrost' | ||
| reference: "esacci-permafrost" | ||
| comment: "" | ||
|
|
||
| # Variables to CMORize | ||
| variables: | ||
| alt: | ||
| mip: Lyr | ||
| raw: ALT | ||
| file: 'ESACCI-PERMAFROST-L4-ALT-*-AREA4_PP-{year}-fv03.0.nc' | ||
| weights_dir: '/work/bd0854/b380103/esacci-permafrost-weights' | ||
| gtd: | ||
| mip: Lyr | ||
| raw: [GST, T1m, T2m, T5m, T10m] | ||
| file: 'ESACCI-PERMAFROST-L4-GTD-*-AREA4_PP-{year}-fv03.0.nc' | ||
| weights_dir: '/work/bd0854/b380103/esacci-permafrost-weights' | ||
| pfr: | ||
| mip: Lyr | ||
| raw: PFR | ||
| file: 'ESACCI-PERMAFROST-L4-PFR-*-AREA4_PP-{year}-fv03.0.nc' | ||
| weights_dir: '/work/bd0854/b380103/esacci-permafrost-weights' |
This file contains hidden or 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
75 changes: 75 additions & 0 deletions
75
esmvaltool/cmorizers/data/downloaders/datasets/esacci_permafrost.py
This file contains hidden or 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,75 @@ | ||
| """Script to download ESACCI-PERMAFROST.""" | ||
|
|
||
| import logging | ||
| from datetime import datetime | ||
|
|
||
| from dateutil import relativedelta | ||
|
|
||
| from esmvaltool.cmorizers.data.downloaders.ftp import CCIDownloader | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def download_dataset( | ||
| config: dict, | ||
| dataset: str, | ||
| dataset_info: dict, | ||
| start_date: datetime, | ||
| end_date: datetime, | ||
| overwrite: bool, | ||
| ) -> None: | ||
| """Download dataset. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| config : dict | ||
| ESMValTool's user configuration | ||
| dataset : str | ||
| Name of the dataset | ||
| dataset_info : dict | ||
| Dataset information from the datasets.yml file | ||
| start_date : datetime | ||
| Start of the interval to download | ||
| end_date : datetime | ||
| End of the interval to download | ||
| overwrite : bool | ||
| Overwrite already downloaded files | ||
| """ | ||
| if start_date is None: | ||
| start_date = datetime(1997, 1, 1, tzinfo=datetime.timezone.utc) | ||
| if end_date is None: | ||
| end_date = datetime(2019, 12, 31, tzinfo=datetime.timezone.utc) | ||
|
|
||
| downloader = CCIDownloader( | ||
| config=config, | ||
| dataset=dataset, | ||
| dataset_info=dataset_info, | ||
| overwrite=overwrite, | ||
| ) | ||
|
|
||
| downloader.connect() | ||
|
|
||
| version = "v03.0" | ||
|
|
||
| ccivars = [ | ||
| "active_layer_thickness", | ||
| "ground_temperature", | ||
| "permafrost_extent", | ||
| ] | ||
|
|
||
| # download active layer thickness | ||
| loop_date = start_date | ||
| while loop_date <= end_date: | ||
| for var in ccivars: | ||
| pathname = f"{var}/L4/area4/pp/{version}/" | ||
| fname = f"ESACCI-PERMAFROST-L4-*-{loop_date.year}-f{version}.nc" | ||
| if downloader.file_exists(fname, pathname): | ||
| downloader.download_files(fname, pathname) | ||
| else: | ||
| logger.info( | ||
| "%d: no data for %s %s", | ||
| loop_date.year, | ||
| var, | ||
| version, | ||
| ) | ||
| loop_date += relativedelta.relativedelta(years=1) | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives me the following error message:
AttributeError: type object 'datetime.datetime' has no attribute 'timezone'. Did you mean: 'astimezone'?It worked when I added
from datetime import timezoneand replaceddatetime.timezonewithtimezone.