Skip to content

Commit 8edde46

Browse files
committed
🐛 Nest IceNetSIC downloads under the dataset name to avoid overwriting data when multiple datasets use the same year
1 parent 588c4d8 commit 8edde46

7 files changed

Lines changed: 12 additions & 9 deletions

ice_station_zebra/config/datasets/nbsamp_sicnorth_osisaf_25k_2003_2003_24h_v1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ nbsamp-sicnorth-osisaf-25k-2003-2003-24h-v1:
1616

1717
input:
1818
netcdf:
19-
path: ${base_path}/data/preprocessing/${...preprocessor.type}/data/osisaf/${...preprocessor.hemisphere}/siconca/2003.nc
19+
path: ${base_path}/data/preprocessing/${...name}/${...preprocessor.type}/data/osisaf/${...preprocessor.hemisphere}/siconca/2003.nc

ice_station_zebra/config/datasets/nbsamp_sicnorth_osisaf_25k_2010_2010_24h_v1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ nbsamp-sicnorth-osisaf-25k-2010-2010-24h-v1:
1616

1717
input:
1818
netcdf:
19-
path: ${base_path}/data/preprocessing/${...preprocessor.type}/data/osisaf/${...preprocessor.hemisphere}/siconca/2010.nc
19+
path: ${base_path}/data/preprocessing/${...name}/${...preprocessor.type}/data/osisaf/${...preprocessor.hemisphere}/siconca/2010.nc

ice_station_zebra/config/datasets/nbsamp_sicnorth_osisaf_25k_2018_2018_24h_v1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ nbsamp-sicnorth-osisaf-25k-2018-2018-24h-v1:
1616

1717
input:
1818
netcdf:
19-
path: ${base_path}/data/preprocessing/${...preprocessor.type}/data/osisaf/${...preprocessor.hemisphere}/siconca/2018.nc
19+
path: ${base_path}/data/preprocessing/${...name}/${...preprocessor.type}/data/osisaf/${...preprocessor.hemisphere}/siconca/2018.nc

ice_station_zebra/config/datasets/nbsamp_weathersouth_era5_0p5_2020_2020_24h_v1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ nbsamp-weathersouth-era5-0p5-2020-2020-24h-v1:
1313
input:
1414
anemoi-dataset:
1515
join:
16-
- dataset: ${base_path}/data/anemoi/samp-era5-0p5-2020-2020-24h-v1-01-04-south.zarr
16+
- dataset: ${base_path}/data/anemoi/samp-weathersouth-era5-0p5-2020-2020-24h-v1.zarr
1717
select: [ 2t, z_250, z_500 , 10u, 10v, cos_julian_day, sin_julian_day ]

ice_station_zebra/config/datasets/samp_sicsouth_osisaf_25k_2020_2020_24h_v1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ samp-sicsouth-osisaf-25k-2020-2020-24h-v1:
1616

1717
input:
1818
netcdf:
19-
path: ${base_path}/data/preprocessing/${...preprocessor.type}/data/osisaf/${...preprocessor.hemisphere}/siconca/2020.nc
19+
path: ${base_path}/data/preprocessing/${...name}/${...preprocessor.type}/data/osisaf/${...preprocessor.hemisphere}/siconca/2020.nc

ice_station_zebra/data_processors/preprocessors/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
from collections.abc import ABC, abstractmethod
12
from pathlib import Path
23

34
from omegaconf import DictConfig
45

56

6-
class IPreprocessor:
7+
class IPreprocessor(ABC):
78
def __init__(self, config: DictConfig) -> None:
89
"""Initialise the IPreprocessor base class."""
9-
self.name = str(config.get("preprocessor", {}).get("type", "None"))
10+
self.cls_name = str(config.get("preprocessor", {}).get("type", "None"))
11+
self.dataset_name = str(config.get("name", "None"))
1012

13+
@abstractmethod
1114
def download(self, preprocessor_path: Path) -> None:
1215
"""Download data to the specified preprocessor path."""
1316

ice_station_zebra/data_processors/preprocessors/icenet_sic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def is_south(self) -> bool:
3030
def download(self, preprocessor_path: Path) -> None:
3131
"""Download data to the specified preprocessor path."""
3232
# Change to the output directory before downloading
33-
icenet_path = preprocessor_path / self.name
33+
icenet_path = preprocessor_path / self.dataset_name / self.cls_name
3434
icenet_path.mkdir(parents=True, exist_ok=True)
3535
current_directory = Path.cwd()
3636
os.chdir(icenet_path)
@@ -41,7 +41,7 @@ def download(self, preprocessor_path: Path) -> None:
4141
logger.info("Generating polar masks for %s.", mask_year)
4242
masks.generate(year=mask_year)
4343

44-
logger.info("Downloading sea ice concentration data.")
44+
logger.info("Downloading sea ice concentration data to %s.", icenet_path)
4545
sic = SICDownloader(
4646
dates=[
4747
pd.to_datetime(date).date() for date in self.date_range

0 commit comments

Comments
 (0)