Skip to content

Commit

Permalink
Update downloader, add North Hemisphere
Browse files Browse the repository at this point in the history
  • Loading branch information
rbeucher committed Jan 24, 2025
1 parent 425e233 commit 295027c
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 11 deletions.
8 changes: 8 additions & 0 deletions esmvaltool/cmorizers/data/datasets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,14 @@ datasets:
info: |
Download monthly data.
Login required for download, and also requires citation only to use
NSIDC-G02202-nh:
tier: 3
source: https://polarwatch.noaa.gov/erddap/griddap/nsidcG02202v4shmday
last_access: 2025-01-24
info: |
Download monthly data.
Login required for download, and also requires citation only to use
OceanSODA-ETHZ:
tier: 2
Expand Down
76 changes: 76 additions & 0 deletions esmvaltool/cmorizers/data/downloaders/datasets/nsidc_g02202_nh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""Script to download NSIDC-G02202-nh."""
import logging
from datetime import datetime
from dateutil import relativedelta

from esmvaltool.cmorizers.data.downloaders.wget import WGetDownloader

logger = logging.getLogger(__name__)


def download_dataset(config, dataset, dataset_info, start_date, end_date,
overwrite):
"""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(1979, 1, 1)
if end_date is None:
end_date = datetime(2024, 6, 1)

loop_date = start_date

downloader = WGetDownloader(
config=config,
dataset=dataset,
dataset_info=dataset_info,
overwrite=overwrite,
)

# need area file
area_dat = ('ftp://sidads.colorado.edu/DATASETS/seaice'
'/polar-stereo/tools/psn25area_v3.dat')
downloader.download_folder(area_dat, [])

anc_path = ('https://noaadata.apps.nsidc.org/NOAA/G02202_V5/'
'ancillary/G02202-ancillary-psn25-v05r00.nc')
downloader.download_folder(anc_path, [])

base_path = ('https://noaadata.apps.nsidc.org/NOAA/G02202_V5/north/monthly'
'/sic_psn25_{year}{month:02d}_{other}_v05r00.nc')

datels = [datetime(1978, 11, 1), datetime(1987, 7, 30),
datetime(1991, 12, 30), datetime(1995, 9, 30),
datetime(2007, 12, 30), end_date]
suffls = ['n07', 'F08', 'F11', 'F13', 'F17']
isuf = 0
suffix = suffls[isuf]
# initialize suffix if dates start higher than initial
while loop_date >= datels[isuf]:
suffix = suffls[isuf]
isuf += 1

while loop_date <= end_date:

if loop_date > datels[isuf]:
suffix = suffls[isuf]
isuf += 1

downloader.download_folder(
base_path.format(year=loop_date.year, month=loop_date.month,
other=suffix), [])
loop_date += relativedelta.relativedelta(months=1)
18 changes: 7 additions & 11 deletions esmvaltool/cmorizers/data/downloaders/datasets/nsidc_g02202_sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def download_dataset(config, dataset, dataset_info, start_date, end_date,
if start_date is None:
start_date = datetime(1979, 1, 1)
if end_date is None:
end_date = datetime(2023, 1, 1)
end_date = datetime(2024, 6, 1)

loop_date = start_date

Expand All @@ -47,20 +47,17 @@ def download_dataset(config, dataset, dataset_info, start_date, end_date,
'/polar-stereo/tools/pss25area_v3.dat')
downloader.download_folder(area_dat, [])

anc_path = ('https://noaadata.apps.nsidc.org/NOAA/G02202_V4/'
'ancillary/G02202-cdr-ancillary-sh.nc')
anc_path = ('https://noaadata.apps.nsidc.org/NOAA/G02202_V5/'
'ancillary/G02202-ancillary-pss25-v05r00.nc')
downloader.download_folder(anc_path, [])

base_path = ('https://noaadata.apps.nsidc.org/NOAA/G02202_V4/south/monthly'
'/seaice_conc_monthly_sh_{year}{month:02d}_{other}_v04r00.nc')
base_path = ('https://noaadata.apps.nsidc.org/NOAA/G02202_V5/south/monthly'
'/sic_pss25_{year}{month:02d}_{other}_v05r00.nc')

# regex for n07 changes to f08.. file names
# bins #{'197811':'n07','198708':'f08',
# '199201':'f11','199510':'f13', '200801':'f17'}
datels = [datetime(1978, 11, 1), datetime(1987, 7, 30),
datetime(1991, 12, 30), datetime(1995, 9, 30),
datetime(2007, 12, 30), end_date]
suffls = ['n07', 'f08', 'f11', 'f13', 'f17']
suffls = ['n07', 'F08', 'F11', 'F13', 'F17']
isuf = 0
suffix = suffls[isuf]
# initialize suffix if dates start higher than initial
Expand All @@ -77,5 +74,4 @@ def download_dataset(config, dataset, dataset_info, start_date, end_date,
downloader.download_folder(
base_path.format(year=loop_date.year, month=loop_date.month,
other=suffix), [])
loop_date += relativedelta.relativedelta(months=1)
# check loop_date is => next bin
loop_date += relativedelta.relativedelta(months=1)

0 comments on commit 295027c

Please sign in to comment.