2020_DATA_HOME = os .environ .get ("PARCELS_EXAMPLE_DATA" )
2121if _DATA_HOME is None :
2222 _DATA_HOME = pooch .os_cache ("parcels" )
23+ _DATA_HOME = Path (_DATA_HOME )
2324
2425# See instructions at https://github.com/Parcels-code/parcels-data for adding new datasets
25- _POOCH_REGISTRY_FILES : list [str ] = (
26+ _ODIE_REGISTRY_FILES : list [str ] = (
2627 # These datasets are from v3 and before of Parcels, where we just used netcdf files
2728 [
2829 "data/MovingEddies_data/moving_eddiesP.nc" ,
104105 # ...
105106)
106107
107- _POOCH_REGISTRY = {k : None for k in _POOCH_REGISTRY_FILES }
108-
109-
110108_ODIE = pooch .create (
111109 path = _DATA_HOME ,
112110 base_url = _DATA_URL ,
113- registry = _POOCH_REGISTRY ,
111+ registry = { k : None for k in _ODIE_REGISTRY_FILES } ,
114112)
115113
116114
@@ -120,13 +118,13 @@ def open_dataset(self) -> xr.Dataset: ...
120118
121119
122120class _V3Dataset (_ParcelsDataset ):
123- def __init__ (self , path_relative_to_root : str , pre_decode_cf_callable = None ):
124- self .path_relative_to_root = path_relative_to_root # glob is allowed
121+ def __init__ (self , pup : pooch . Pooch , path_relative_to_pup : str , pre_decode_cf_callable = None ):
122+ self .path_relative_to_root = path_relative_to_pup # glob is allowed
125123
126124 # Function to apply to the dataset before the decoding the CF variables
127- self .pup = _ODIE
125+ self .pup = pup
128126 self .pre_decode_cf_callable : None | Callable [[xr .Dataset ], xr .Dataset ] = pre_decode_cf_callable
129- self .v3_dataset_name = path_relative_to_root .split ("/" )[0 ]
127+ self .v3_dataset_name = path_relative_to_pup .split ("/" )[0 ]
130128
131129 def open_dataset (self ) -> xr .Dataset :
132130 self .download_relevant_files ()
@@ -154,9 +152,9 @@ def download_relevant_files(self) -> None:
154152
155153
156154class _ZarrZipDataset (_ParcelsDataset ):
157- def __init__ (self , path_relative_to_root ):
158- self .pup = _ODIE
159- self .path_relative_to_root = path_relative_to_root
155+ def __init__ (self , pup , path_relative_to_pup ):
156+ self .pup = pup
157+ self .path_relative_to_root = path_relative_to_pup
160158
161159 def open_dataset (self ) -> xr .Dataset :
162160 self .pup .fetch (self .path_relative_to_root )
@@ -190,35 +188,35 @@ class _Purpose(enum.Enum):
190188# The first here is a human readable key used to open datasets, with an object to open the datasets
191189# fmt: off
192190_DATASET_KEYS_AND_CONFIGS : dict [str , tuple [_V3Dataset , _Purpose ]] = dict ([
193- ("MovingEddies_data/P" , (_V3Dataset ("data/MovingEddies_data/moving_eddiesP.nc" ), _Purpose .TUTORIAL )),
194- ("MovingEddies_data/U" , (_V3Dataset ("data/MovingEddies_data/moving_eddiesU.nc" ), _Purpose .TUTORIAL )),
195- ("MovingEddies_data/V" , (_V3Dataset ("data/MovingEddies_data/moving_eddiesV.nc" ), _Purpose .TUTORIAL )),
196- ("MITgcm_example_data/mitgcm_UV_surface_zonally_reentrant" , (_V3Dataset ("data/MITgcm_example_data/mitgcm_UV_surface_zonally_reentrant.nc" ), _Purpose .TUTORIAL )),
197- ("OFAM_example_data/U" , (_V3Dataset ("data/OFAM_example_data/OFAM_simple_U.nc" ), _Purpose .TUTORIAL )),
198- ("OFAM_example_data/V" , (_V3Dataset ("data/OFAM_example_data/OFAM_simple_V.nc" ), _Purpose .TUTORIAL )),
199- ("Peninsula_data/U" , (_V3Dataset ("data/Peninsula_data/peninsulaU.nc" ), _Purpose .TUTORIAL )),
200- ("Peninsula_data/V" , (_V3Dataset ("data/Peninsula_data/peninsulaV.nc" ), _Purpose .TUTORIAL )),
201- ("Peninsula_data/P" , (_V3Dataset ("data/Peninsula_data/peninsulaP.nc" ), _Purpose .TUTORIAL )),
202- ("Peninsula_data/T" , (_V3Dataset ("data/Peninsula_data/peninsulaT.nc" ), _Purpose .TUTORIAL )),
203- ("GlobCurrent_example_data/data" , (_V3Dataset ("data/GlobCurrent_example_data/*000000-GLOBCURRENT-L4-CUReul_hs-ALT_SUM-v02.0-fv01.0.nc" , pre_decode_cf_callable = patch_dataset_v4_compat ), _Purpose .TUTORIAL )),
204- ("CopernicusMarine_data_for_Argo_tutorial/data" , (_V3Dataset ("data/CopernicusMarine_data_for_Argo_tutorial/cmems_mod_glo_phy-*.nc" ), _Purpose .TUTORIAL )),
205- ("DecayingMovingEddy_data/U" , (_V3Dataset ("data/DecayingMovingEddy_data/decaying_moving_eddyU.nc" ), _Purpose .TUTORIAL )),
206- ("DecayingMovingEddy_data/V" , (_V3Dataset ("data/DecayingMovingEddy_data/decaying_moving_eddyV.nc" ), _Purpose .TUTORIAL )),
207- ("FESOM_periodic_channel/fesom_channel" , (_V3Dataset ("data/FESOM_periodic_channel/fesom_channel.nc" ), _Purpose .TUTORIAL )),
208- ("FESOM_periodic_channel/u.fesom_channel" , (_V3Dataset ("data/FESOM_periodic_channel/u.fesom_channel.nc" ), _Purpose .TUTORIAL )),
209- ("FESOM_periodic_channel/v.fesom_channel" , (_V3Dataset ("data/FESOM_periodic_channel/v.fesom_channel.nc" ), _Purpose .TUTORIAL )),
210- ("FESOM_periodic_channel/w.fesom_channel" , (_V3Dataset ("data/FESOM_periodic_channel/w.fesom_channel.nc" ), _Purpose .TUTORIAL )),
211- ("NemoCurvilinear_data_zonal/U" , (_V3Dataset ("data/NemoCurvilinear_data/U_purely_zonal-ORCA025_grid_U.nc4" ), _Purpose .TUTORIAL )),
212- ("NemoCurvilinear_data_zonal/V" , (_V3Dataset ("data/NemoCurvilinear_data/V_purely_zonal-ORCA025_grid_V.nc4" ), _Purpose .TUTORIAL )),
213- ("NemoCurvilinear_data_zonal/mesh_mask" , (_V3Dataset ("data/NemoCurvilinear_data/mesh_mask.nc4" , _preprocess_drop_time_from_mesh2 ), _Purpose .TUTORIAL )),
214- ("NemoNorthSeaORCA025-N006_data/U" , (_V3Dataset ("data/NemoNorthSeaORCA025-N006_data/ORCA025-N06_200001*05U.nc" ), _Purpose .TUTORIAL )),
215- ("NemoNorthSeaORCA025-N006_data/V" , (_V3Dataset ("data/NemoNorthSeaORCA025-N006_data/ORCA025-N06_200001*05V.nc" ), _Purpose .TUTORIAL )),
216- ("NemoNorthSeaORCA025-N006_data/W" , (_V3Dataset ("data/NemoNorthSeaORCA025-N006_data/ORCA025-N06_200001*05W.nc" ), _Purpose .TUTORIAL )),
217- ("NemoNorthSeaORCA025-N006_data/mesh_mask" , (_V3Dataset ("data/NemoNorthSeaORCA025-N006_data/coordinates.nc" , _preprocess_drop_time_from_mesh1 ), _Purpose .TUTORIAL )),
191+ ("MovingEddies_data/P" , (_V3Dataset (_ODIE , "data/MovingEddies_data/moving_eddiesP.nc" ), _Purpose .TUTORIAL )),
192+ ("MovingEddies_data/U" , (_V3Dataset (_ODIE , "data/MovingEddies_data/moving_eddiesU.nc" ), _Purpose .TUTORIAL )),
193+ ("MovingEddies_data/V" , (_V3Dataset (_ODIE , "data/MovingEddies_data/moving_eddiesV.nc" ), _Purpose .TUTORIAL )),
194+ ("MITgcm_example_data/mitgcm_UV_surface_zonally_reentrant" , (_V3Dataset (_ODIE , "data/MITgcm_example_data/mitgcm_UV_surface_zonally_reentrant.nc" ), _Purpose .TUTORIAL )),
195+ ("OFAM_example_data/U" , (_V3Dataset (_ODIE , "data/OFAM_example_data/OFAM_simple_U.nc" ), _Purpose .TUTORIAL )),
196+ ("OFAM_example_data/V" , (_V3Dataset (_ODIE , "data/OFAM_example_data/OFAM_simple_V.nc" ), _Purpose .TUTORIAL )),
197+ ("Peninsula_data/U" , (_V3Dataset (_ODIE , "data/Peninsula_data/peninsulaU.nc" ), _Purpose .TUTORIAL )),
198+ ("Peninsula_data/V" , (_V3Dataset (_ODIE , "data/Peninsula_data/peninsulaV.nc" ), _Purpose .TUTORIAL )),
199+ ("Peninsula_data/P" , (_V3Dataset (_ODIE , "data/Peninsula_data/peninsulaP.nc" ), _Purpose .TUTORIAL )),
200+ ("Peninsula_data/T" , (_V3Dataset (_ODIE , "data/Peninsula_data/peninsulaT.nc" ), _Purpose .TUTORIAL )),
201+ ("GlobCurrent_example_data/data" , (_V3Dataset (_ODIE , "data/GlobCurrent_example_data/*000000-GLOBCURRENT-L4-CUReul_hs-ALT_SUM-v02.0-fv01.0.nc" , pre_decode_cf_callable = patch_dataset_v4_compat ), _Purpose .TUTORIAL )),
202+ ("CopernicusMarine_data_for_Argo_tutorial/data" , (_V3Dataset (_ODIE , "data/CopernicusMarine_data_for_Argo_tutorial/cmems_mod_glo_phy-*.nc" ), _Purpose .TUTORIAL )),
203+ ("DecayingMovingEddy_data/U" , (_V3Dataset (_ODIE , "data/DecayingMovingEddy_data/decaying_moving_eddyU.nc" ), _Purpose .TUTORIAL )),
204+ ("DecayingMovingEddy_data/V" , (_V3Dataset (_ODIE , "data/DecayingMovingEddy_data/decaying_moving_eddyV.nc" ), _Purpose .TUTORIAL )),
205+ ("FESOM_periodic_channel/fesom_channel" , (_V3Dataset (_ODIE , "data/FESOM_periodic_channel/fesom_channel.nc" ), _Purpose .TUTORIAL )),
206+ ("FESOM_periodic_channel/u.fesom_channel" , (_V3Dataset (_ODIE , "data/FESOM_periodic_channel/u.fesom_channel.nc" ), _Purpose .TUTORIAL )),
207+ ("FESOM_periodic_channel/v.fesom_channel" , (_V3Dataset (_ODIE , "data/FESOM_periodic_channel/v.fesom_channel.nc" ), _Purpose .TUTORIAL )),
208+ ("FESOM_periodic_channel/w.fesom_channel" , (_V3Dataset (_ODIE , "data/FESOM_periodic_channel/w.fesom_channel.nc" ), _Purpose .TUTORIAL )),
209+ ("NemoCurvilinear_data_zonal/U" , (_V3Dataset (_ODIE , "data/NemoCurvilinear_data/U_purely_zonal-ORCA025_grid_U.nc4" ), _Purpose .TUTORIAL )),
210+ ("NemoCurvilinear_data_zonal/V" , (_V3Dataset (_ODIE , "data/NemoCurvilinear_data/V_purely_zonal-ORCA025_grid_V.nc4" ), _Purpose .TUTORIAL )),
211+ ("NemoCurvilinear_data_zonal/mesh_mask" , (_V3Dataset (_ODIE , "data/NemoCurvilinear_data/mesh_mask.nc4" , _preprocess_drop_time_from_mesh2 ), _Purpose .TUTORIAL )),
212+ ("NemoNorthSeaORCA025-N006_data/U" , (_V3Dataset (_ODIE , "data/NemoNorthSeaORCA025-N006_data/ORCA025-N06_200001*05U.nc" ), _Purpose .TUTORIAL )),
213+ ("NemoNorthSeaORCA025-N006_data/V" , (_V3Dataset (_ODIE , "data/NemoNorthSeaORCA025-N006_data/ORCA025-N06_200001*05V.nc" ), _Purpose .TUTORIAL )),
214+ ("NemoNorthSeaORCA025-N006_data/W" , (_V3Dataset (_ODIE , "data/NemoNorthSeaORCA025-N006_data/ORCA025-N06_200001*05W.nc" ), _Purpose .TUTORIAL )),
215+ ("NemoNorthSeaORCA025-N006_data/mesh_mask" , (_V3Dataset (_ODIE , "data/NemoNorthSeaORCA025-N006_data/coordinates.nc" , _preprocess_drop_time_from_mesh1 ), _Purpose .TUTORIAL )),
218216 # "POPSouthernOcean_data/t.x1_SAMOC_flux.16900*.nc", # TODO v4: In v3 but should not be in v4 https://github.com/Parcels-code/Parcels/issues/2571#issuecomment-4214476973
219- ("SWASH_data/data" , (_V3Dataset ("data/SWASH_data/field_00655*.nc" ), _Purpose .TUTORIAL )),
220- ("WOA_data/data" , (_V3Dataset ("data/WOA_data/woa18_decav_t*_04.nc" , _preprocess_set_cf_calendar_360_day ), _Purpose .TUTORIAL )),
221- ("CROCOidealized_data/data" , (_V3Dataset ("data/CROCOidealized_data/CROCO_idealized.nc" ), _Purpose .TUTORIAL )),
217+ ("SWASH_data/data" , (_V3Dataset (_ODIE , "data/SWASH_data/field_00655*.nc" ), _Purpose .TUTORIAL )),
218+ ("WOA_data/data" , (_V3Dataset (_ODIE , "data/WOA_data/woa18_decav_t*_04.nc" , _preprocess_set_cf_calendar_360_day ), _Purpose .TUTORIAL )),
219+ ("CROCOidealized_data/data" , (_V3Dataset (_ODIE , "data/CROCOidealized_data/CROCO_idealized.nc" ), _Purpose .TUTORIAL )),
222220])
223221# fmt: on
224222
0 commit comments