OceanDataStore 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. OceanDataStore/__init__.py +21 -0
  2. OceanDataStore/catalog/__init__.py +12 -0
  3. OceanDataStore/catalog/oceandatacatalog.py +1242 -0
  4. OceanDataStore/catalog/stac/README.md +34 -0
  5. OceanDataStore/catalog/stac/__init__.py +30 -0
  6. OceanDataStore/catalog/stac/create_noc_stac.py +109 -0
  7. OceanDataStore/catalog/stac/npd_era5_collection.py +364 -0
  8. OceanDataStore/catalog/stac/npd_jra55_collection.py +196 -0
  9. OceanDataStore/catalog/stac/ods_obs_collection.py +534 -0
  10. OceanDataStore/catalog/stac/rapid_evo_collection.py +309 -0
  11. OceanDataStore/catalog/stac/template_collection.py +85 -0
  12. OceanDataStore/catalog/stac/utils.py +476 -0
  13. OceanDataStore/cli/__init__.py +34 -0
  14. OceanDataStore/cli/arg_parser.py +182 -0
  15. OceanDataStore/cli/cli.py +203 -0
  16. OceanDataStore/cli/exceptions.py +83 -0
  17. OceanDataStore/cli/icechunk.py +888 -0
  18. OceanDataStore/cli/logging.py +52 -0
  19. OceanDataStore/cli/object_store.py +293 -0
  20. OceanDataStore/cli/utils.py +275 -0
  21. OceanDataStore/cli/zarr.py +870 -0
  22. OceanDataStore/data/ARMOR3D/create_ARMOR3D_P1M-m_monthly_climatology.py +135 -0
  23. OceanDataStore/data/ARMOR3D/download_ARMOR3D_0.125def_P1M-m_1993_2024.py +33 -0
  24. OceanDataStore/data/ARMOR3D/run_create_ARMOR3D_P1M-m_monthly_climatology.slurm +32 -0
  25. OceanDataStore/data/ARMOR3D/run_send_ARMOR3D_P1M-m_climatology_to_os.slurm +32 -0
  26. OceanDataStore/data/ARMOR3D/run_send_ARMOR3D_P1M-m_monthly_to_os.slurm +32 -0
  27. OceanDataStore/data/ARMOR3D/run_update_ARMOR3D_P1m-m_monthly_to_os.slurm +32 -0
  28. OceanDataStore/data/ARMOR3D/send_ARMOR3D_P1m-m_monthly_climatology_to_os.py +99 -0
  29. OceanDataStore/data/ARMOR3D/send_ARMOR3D_P1m-m_monthly_to_os.py +147 -0
  30. OceanDataStore/data/ARMOR3D/update_ARMOR3D_P1m-m_monthly_to_os.py +143 -0
  31. OceanDataStore/data/EN.4.2.2/create_EN4.2.2_analysis_g10_climatology.py +162 -0
  32. OceanDataStore/data/EN.4.2.2/download_EN4.2.2_analysis_g10_data.sh +51 -0
  33. OceanDataStore/data/EN.4.2.2/run_send_EN4.2.2_analysis_g10_climatology_to_os.slurm +32 -0
  34. OceanDataStore/data/EN.4.2.2/run_send_EN4.2.2_analysis_g10_monthly_to_os.slurm +32 -0
  35. OceanDataStore/data/EN.4.2.2/run_update_EN4.2.2_analysis_g10_monthly_to_os.slurm +32 -0
  36. OceanDataStore/data/EN.4.2.2/send_EN4.2.2_analysis_g10_monthly_climatology_to_os.py +76 -0
  37. OceanDataStore/data/EN.4.2.2/send_EN4.2.2_analysis_g10_monthly_to_os.py +165 -0
  38. OceanDataStore/data/EN.4.2.2/update_EN4.2.2_analysis_g10_monthly_to_os.py +161 -0
  39. OceanDataStore/data/ERA5/create_ERA5_daily_climatology.py +110 -0
  40. OceanDataStore/data/ERA5/create_ERA5_daily_mean.py +69 -0
  41. OceanDataStore/data/ERA5/create_ERA5_monthly_mean.py +74 -0
  42. OceanDataStore/data/ERA5/run_create_ERA5_daily_climatology.slurm +54 -0
  43. OceanDataStore/data/ERA5/run_send_ERA5_daily_climatology_to_os.slurm +32 -0
  44. OceanDataStore/data/ERA5/run_send_ERA5_daily_to_os.slurm +32 -0
  45. OceanDataStore/data/ERA5/run_send_ERA5_monthly_to_os.slurm +32 -0
  46. OceanDataStore/data/ERA5/run_update_ERA5_daily_to_os.slurm +32 -0
  47. OceanDataStore/data/ERA5/run_update_ERA5_monthly_to_os.slurm +32 -0
  48. OceanDataStore/data/ERA5/send_ERA5_daily_climatology_to_os.py +159 -0
  49. OceanDataStore/data/ERA5/send_ERA5_daily_to_os.py +141 -0
  50. OceanDataStore/data/ERA5/send_ERA5_monthly_to_os.py +173 -0
  51. OceanDataStore/data/ERA5/update_ERA5_daily_to_os.py +141 -0
  52. OceanDataStore/data/ERA5/update_ERA5_monthly_to_os.py +169 -0
  53. OceanDataStore/data/HadISST/download_HadISST1_data.sh +43 -0
  54. OceanDataStore/data/HadISST/run_send_HadISST1_monthly_to_os.slurm +32 -0
  55. OceanDataStore/data/HadISST/send_HadISST1_monthly_to_os.py +133 -0
  56. OceanDataStore/data/NSIDC/download_NSIDC_monthly_1979_2025_data.sh +54 -0
  57. OceanDataStore/data/NSIDC/process_NSIDC_SSI_Antarctic_data.py +130 -0
  58. OceanDataStore/data/NSIDC/process_NSIDC_SSI_Arctic_data.py +129 -0
  59. OceanDataStore/data/NSIDC/run_send_NSIDC_v4.0_to_OS.slurm +32 -0
  60. OceanDataStore/data/NSIDC/send_NSIDC_SII_v4.0_to_os.py +140 -0
  61. OceanDataStore/data/OISST/create_OISSTv2_daily_climatology.py +83 -0
  62. OceanDataStore/data/OISST/download_oisstv2_data.sh +43 -0
  63. OceanDataStore/data/OISST/run_create_OISSTv2_daily_climatology.slurm +44 -0
  64. OceanDataStore/data/OISST/run_send_OISSTv2_daily_climatology_to_os.slurm +32 -0
  65. OceanDataStore/data/OISST/run_send_OISSTv2_daily_to_os.slurm +32 -0
  66. OceanDataStore/data/OISST/run_send_OISSTv2_monthly_climatology_to_os.slurm +32 -0
  67. OceanDataStore/data/OISST/run_send_OISSTv2_monthly_to_os.slurm +32 -0
  68. OceanDataStore/data/OISST/run_update_OISSTv2_daily_to_os.slurm +32 -0
  69. OceanDataStore/data/OISST/send_OISSTv2_daily_climatology_to_os.py +154 -0
  70. OceanDataStore/data/OISST/send_OISSTv2_daily_ltm_climatology_to_os.py +151 -0
  71. OceanDataStore/data/OISST/send_OISSTv2_daily_to_os.py +142 -0
  72. OceanDataStore/data/OISST/send_OISSTv2_monthly_climatology_to_os.py +150 -0
  73. OceanDataStore/data/OISST/send_OISSTv2_monthly_to_os.py +145 -0
  74. OceanDataStore/data/OISST/update_OISSTv2_daily_to_os.py +142 -0
  75. OceanDataStore/data/OSTIA/create_OSTIA_daily_climatology.py +120 -0
  76. OceanDataStore/data/OSTIA/download_OSTIA_NRT.py +42 -0
  77. OceanDataStore/data/OSTIA/download_OSTIA_REP_1981_2025.py +42 -0
  78. OceanDataStore/data/OSTIA/run_create_OSTIA_daily_climatology.slurm +54 -0
  79. OceanDataStore/data/OSTIA/run_send_OSTIA_daily_climatology_to_os.slurm +32 -0
  80. OceanDataStore/data/OSTIA/run_send_OSTIA_nrt_daily_to_os.slurm +32 -0
  81. OceanDataStore/data/OSTIA/run_send_OSTIA_rep_daily_to_os.slurm +32 -0
  82. OceanDataStore/data/OSTIA/run_update_OSTIA_daily_to_os.slurm +33 -0
  83. OceanDataStore/data/OSTIA/send_OSTIA_daily_climatology_to_os.py +194 -0
  84. OceanDataStore/data/OSTIA/send_OSTIA_nrt_daily_to_os.py +141 -0
  85. OceanDataStore/data/OSTIA/send_OSTIA_rep_daily_to_os.py +145 -0
  86. OceanDataStore/data/OSTIA/update_OSTIA_copernicus_nrt_daily_to_os.py +144 -0
  87. OceanDataStore/data/OSTIA/update_OSTIA_nrt_daily_to_os.py +137 -0
  88. OceanDataStore/data/WOA23/download_WOA23_climatology.sh +41 -0
  89. OceanDataStore/data/WOA23/run_send_WOA23_annual_climatology_to_os.slurm +32 -0
  90. OceanDataStore/data/WOA23/run_send_WOA23_monthly_climatology_to_os.slurm +32 -0
  91. OceanDataStore/data/WOA23/send_WOA23_annual_climatology_to_os.py +263 -0
  92. OceanDataStore/data/WOA23/send_WOA23_monthly_climatology_to_os.py +292 -0
  93. OceanDataStore/data/update_icechunk_repo_attrs.py +76 -0
  94. OceanDataStore/data/update_noc_npd_era5v1_attrs.py +172 -0
  95. OceanDataStore/data/utils.py +506 -0
  96. OceanDataStore/zarr.py +993 -0
  97. oceandatastore-0.3.0.dist-info/METADATA +184 -0
  98. oceandatastore-0.3.0.dist-info/RECORD +104 -0
  99. oceandatastore-0.3.0.dist-info/WHEEL +5 -0
  100. oceandatastore-0.3.0.dist-info/entry_points.txt +2 -0
  101. oceandatastore-0.3.0.dist-info/licenses/LICENSE +201 -0
  102. oceandatastore-0.3.0.dist-info/scm_file_list.json +154 -0
  103. oceandatastore-0.3.0.dist-info/scm_version.json +8 -0
  104. oceandatastore-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,309 @@
1
+ """
2
+ rapid_evolution_collection.py
3
+
4
+ Description:
5
+ Function to create the National Oceanography Centre (NOC)
6
+ Rapid Evolution Spatio-Temporal Access Catalog Collection.
7
+
8
+ Authors:
9
+ - Ollie Tooth (oliver.tooth@noc.ac.uk)
10
+ """
11
+ # -- Import Python Modules -- #
12
+ import logging
13
+ import pystac
14
+ import datetime
15
+ import xarray as xr
16
+ from tqdm import tqdm
17
+ from OceanDataStore.cli.object_store import ObjectStoreS3
18
+
19
+ from OceanDataStore.catalog.stac.utils import create_item_with_zarr_asset
20
+
21
+ def create_rapid_evo_collection(
22
+ credentials_json: str
23
+ ) -> pystac.Collection:
24
+ """
25
+ Create the NOC Rapid Evolution STAC Collection.
26
+
27
+ Parameters:
28
+ ----------
29
+ credentials_json : str
30
+ Path to the JSON file containing the credentials for the S3 object store.
31
+
32
+ Returns:
33
+ -------
34
+ rapid_evo_collection : pystac.Collection
35
+ NOC Rapid Evolution STAC Collection.
36
+ """
37
+ # -- Initialise Object Store -- #
38
+ obj_store = ObjectStoreS3(anon=False,
39
+ asynchronous=False,
40
+ store_credentials_json=credentials_json
41
+ )
42
+
43
+ # Define list of variable Zarr stores to exclude from the STAC item creation:
44
+ exclude_vars = ['depthu_bounds', 'depthv_bounds', 'depthw_bounds', 'deptht_bounds', 'time_counter_bounds', 'time_centered_bounds']
45
+
46
+ # -- Define NOC Rapid Evolution Collection -- #
47
+ # Define the spatial extent for the collection:
48
+ spatial_extent = pystac.SpatialExtent(bboxes=[[-180.0, -90.0, 0, 180.0, 90.0, 6000]])
49
+
50
+ # Define the current temporal extent for the collection:
51
+ collection_interval = sorted([datetime.datetime(year=1976, month=1, day=1), datetime.datetime(year=2024, month=12, day=31)])
52
+ temporal_extent = pystac.TemporalExtent(intervals=[collection_interval])
53
+
54
+ # Define the RAPID-Evolution Collection:
55
+ rapid_evo_collection = pystac.Collection(
56
+ id="noc-rapid-evolution",
57
+ title="NOC RAPID-Evolution Collection",
58
+ description="**About:**\n\nCollection of nested ocean model simulations produced by the National Oceanography Centre (NOC) as part of the CCROC RAPID-Evolution project delivered through a partnership between UK (National Oceanography Centre, Met Office) and US (University of Miami and NOAA's AOML).\n\n**More Information:**\n - [RAPID-Evolution](https://rapid.ac.uk/rapid-evolution)",
59
+ extent=pystac.Extent(spatial=spatial_extent, temporal=temporal_extent),
60
+ # Open Government License (OGL) - UK version 3.0 - http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/
61
+ license="OGL-UK-3.0",
62
+ extra_fields=dict(contact="Adam Blaker (atb299@noc.ac.uk)", project="RAPID-Evolution", status="complete", last_data_update="2025-05-30"),
63
+ keywords=["NOC", "Rapid Evolution", "hindcast", "global", "nested", "model", "ocean", "sea-ice"],
64
+ providers=[
65
+ pystac.Provider(
66
+ name="National Oceanography Centre (NOC)",
67
+ description="National Oceanography Centre (United Kingdom) - Ocean Modelling Group.",
68
+ roles=[pystac.ProviderRole.PRODUCER, pystac.ProviderRole.LICENSOR],
69
+ url="https://rapid.ac.uk/rapid-evolution"
70
+ ),
71
+ pystac.Provider(
72
+ name="JASMIN",
73
+ description="JASMIN Environmental Data Analysis Facility (United Kingdom).",
74
+ roles=[pystac.ProviderRole.HOST],
75
+ url="https://jasmin.ac.uk"
76
+ )
77
+ ],
78
+ )
79
+
80
+ logging.info(f"Completed: Created STAC Collection: {rapid_evo_collection}")
81
+
82
+ # -- Define NOC RAPID-Evolution Model Configuration Catalogs -- #
83
+ r_evo_eorca025 = pystac.Catalog(
84
+ id="r_evo_eorca025",
85
+ title="eORCA025 RAPID-Evolution global parent domain Catalog",
86
+ description="Catalog of eORCA025 JRA55-do global parent domain outputs from the RAPID-Evolution ocean physics simulation performed by the National Oceanography Centre."
87
+ )
88
+
89
+ logging.info(f"Completed: Created STAC Catalog: {r_evo_eorca025}")
90
+
91
+ r_evo_rapid12 = pystac.Catalog(
92
+ id="r_evo_rapid12",
93
+ title="RAPID12 RAPID-Evolution nested child domain Catalog",
94
+ description="Catalog of RAPID12 JRA55-do nested child domain outputs from the RAPID-Evolution ocean physics simulation performed by the National Oceanography Centre.",
95
+ )
96
+
97
+ logging.info(f"Completed: Created STAC Catalog: {r_evo_rapid12}")
98
+
99
+ r_evo_rapid36 = pystac.Catalog(
100
+ id="r_evo_rapid36",
101
+ title="RAPID36 RAPID-Evolution nested grandchild domain Catalog",
102
+ description="Catalog of RAPID36 JRA55-do nested grandchild domain outputs from the RAPID-Evolution ocean physics simulation performed by the National Oceanography Centre.",
103
+ )
104
+
105
+ logging.info(f"Completed: Created STAC Catalog: {r_evo_rapid36}")
106
+
107
+ # -- Add Items to NOC RAPID-Evolution eORCA025 global parent Sub-Catalog -- #
108
+ # Define url for eORCA025 RAPID-Evolution data:
109
+ endpoint_url="https://rapidevolution-o.s3-ext.jc.rl.ac.uk"
110
+
111
+ for prefix in ["T1m", "U1m", "V1m", "W1m", "S1m", "eORCA025_domain_cfg"]:
112
+ # Create item with asset for each eORCA025 global parent RAPID-Evolution prefix:
113
+ if 'domain' in prefix:
114
+ operation = "None None"
115
+ bucket="rapid-evolution-ancillaries"
116
+
117
+ # Open domain_cfg dataset from Zarr store:
118
+ ds = xr.open_zarr(f"{endpoint_url}/{bucket}/{prefix}", consolidated=True)
119
+ item = create_item_with_zarr_asset(
120
+ id="noc-rapid-evolution/r_evo_eorca025/domain_cfg",
121
+ ds=ds,
122
+ bucket=bucket,
123
+ platform="gn",
124
+ prefix=prefix,
125
+ title=f"RAPID-Evolution eORCA025 {prefix}",
126
+ horizontal_grid_resolution="1/4 degree",
127
+ start_date="1976-01-01",
128
+ end_date="2023-12-31",
129
+ collection="noc-rapid-evolution",
130
+ operation=operation,
131
+ endpoint_url=endpoint_url,
132
+ zarr_format=3,
133
+ )
134
+ # Add item to the eORCA025 RAPID-Evolution global parent domain native model grid catalog:
135
+ r_evo_eorca025.add_item(item)
136
+
137
+ else:
138
+ bucket="r-evo1-eorca025-rapid12-rapid36"
139
+ prefix = f"eORCA025/{prefix}"
140
+
141
+ if '1y' in prefix:
142
+ operation = "annual mean"
143
+ elif '1m' in prefix:
144
+ operation = "monthly mean"
145
+
146
+ # Get variable Zarr stores from JASMIN object store:
147
+ var_stores = [path.split("/")[-1] for path in obj_store.ls(f"{bucket}/{prefix}") if path.split("/")[-1] not in exclude_vars]
148
+
149
+ # Create STAC Item for each variable Zarr store:
150
+ logging.info(f"In Progress: Adding {prefix} Items...")
151
+ for var in tqdm(var_stores):
152
+ # Open dataset from Zarr store:
153
+ ds = xr.open_zarr(f"{endpoint_url}/{bucket}/{prefix}/{var}", consolidated=True)
154
+ item = create_item_with_zarr_asset(
155
+ id=f"noc-rapid-evolution/r_evo_eorca025/{prefix}/{var}",
156
+ ds=ds,
157
+ bucket=bucket,
158
+ platform="gn",
159
+ prefix=f"{prefix}/{var}",
160
+ title=f"RAPID-Evolution eORCA025 {prefix}/{var}",
161
+ horizontal_grid_resolution="1/4 degree",
162
+ start_date="1976-01-01",
163
+ end_date="2023-12-31",
164
+ collection="noc-rapid-evolution",
165
+ operation=operation,
166
+ endpoint_url=endpoint_url,
167
+ zarr_format=3,
168
+ )
169
+ # Add item to the eORCA025 RAPID-Evolution global parent domain native model grid catalog:
170
+ r_evo_eorca025.add_item(item)
171
+
172
+ logging.info(f"Completed: Added Items to STAC Catalog: {r_evo_eorca025}")
173
+
174
+ # -- Add Items to NOC RAPID-Evolution RAPID12 nested child domain Sub-Catalog -- #
175
+ for prefix in ["T1m", "U1m", "V1m", "W1m", "S1m", "eORCA025_RAPID12_domain_cfg"]:
176
+ # Create item with asset for each RAPID12 nested child domain prefix:
177
+ if 'domain' in prefix:
178
+ operation = "None None"
179
+ bucket="rapid-evolution-ancillaries"
180
+
181
+ # Open domain_cfg dataset from Zarr store:
182
+ ds = xr.open_zarr(f"{endpoint_url}/{bucket}/{prefix}", consolidated=True)
183
+ item = create_item_with_zarr_asset(
184
+ id="noc-rapid-evolution/r_evo_rapid12/domain_cfg",
185
+ ds=ds,
186
+ bucket=bucket,
187
+ platform="gn",
188
+ prefix=prefix,
189
+ title=f"RAPID-Evolution RAPID12 {prefix}",
190
+ horizontal_grid_resolution="1/12 degree",
191
+ start_date="1976-01-01",
192
+ end_date="2023-12-31",
193
+ bbox=(-100.143814, 6.0719233, -1.8753614, 42.41955),
194
+ collection="noc-rapid-evolution",
195
+ operation=operation,
196
+ endpoint_url=endpoint_url,
197
+ zarr_format=3,
198
+ )
199
+ # Add item to the RAPID12 RAPID-Evolution nested child domain native model grid catalog:
200
+ r_evo_rapid12.add_item(item)
201
+
202
+ else:
203
+ bucket="r-evo1-eorca025-rapid12-rapid36"
204
+ prefix = f"RAPID12/{prefix}"
205
+ if '1y' in prefix:
206
+ operation = "annual mean"
207
+ elif '1m' in prefix:
208
+ operation = "monthly mean"
209
+
210
+ # Get variable Zarr stores from JASMIN object store:
211
+ var_stores = [path.split("/")[-1] for path in obj_store.ls(f"{bucket}/{prefix}") if path.split("/")[-1] not in exclude_vars]
212
+
213
+ # Create STAC Item for each variable Zarr store:
214
+ logging.info(f"In Progress: Adding {prefix} Items...")
215
+ for var in tqdm(var_stores):
216
+ # Open dataset from Zarr store:
217
+ ds = xr.open_zarr(f"{endpoint_url}/{bucket}/{prefix}/{var}", consolidated=True)
218
+ item = create_item_with_zarr_asset(
219
+ id=f"noc-rapid-evolution/r_evo_rapid12/{prefix}/{var}",
220
+ ds=ds,
221
+ bucket=bucket,
222
+ platform="gn",
223
+ prefix=f"{prefix}/{var}",
224
+ title=f"RAPID-Evolution RAPID12 {prefix}/{var}",
225
+ horizontal_grid_resolution="1/12 degree",
226
+ start_date="1976-01-01",
227
+ end_date="2023-12-31",
228
+ bbox=(-100.143814, 6.0719233, -1.8753614, 42.41955),
229
+ collection="noc-rapid-evolution",
230
+ operation=operation,
231
+ endpoint_url=endpoint_url,
232
+ zarr_format=3,
233
+ )
234
+ # Add item to the RAPID12 RAPID-Evolution nested child domain native model grid catalog:
235
+ r_evo_rapid12.add_item(item)
236
+
237
+ logging.info(f"Completed: Added Items to STAC Catalog: {r_evo_rapid12}")
238
+
239
+ # -- Add Items to NOC RAPID-Evolution RAPID36 nested grandchild domain Sub-Catalog -- #
240
+ for prefix in ["T1m", "U1m", "V1m", "W1m", "S1m", "eORCA025_RAPID36_domain_cfg"]:
241
+ # Create item with asset for each RAPID36 nested grandchild domain prefix:
242
+ if 'domain' in prefix:
243
+ operation = "None None"
244
+ bucket="rapid-evolution-ancillaries"
245
+
246
+ # Open domain_cfg dataset from Zarr store:
247
+ ds = xr.open_zarr(f"{endpoint_url}/{bucket}/{prefix}", consolidated=True)
248
+ item = create_item_with_zarr_asset(
249
+ id="noc-rapid-evolution/r_evo_rapid36/domain_cfg",
250
+ ds=ds,
251
+ bucket=bucket,
252
+ platform="gn",
253
+ prefix=prefix,
254
+ title=f"RAPID-Evolution RAPID36 {prefix}",
255
+ horizontal_grid_resolution="1/36 degree",
256
+ start_date="1976-01-01",
257
+ end_date="2023-12-31",
258
+ bbox=(-98.530975, 17.34014, -8.879465, 30.447763),
259
+ collection="noc-rapid-evolution",
260
+ operation=operation,
261
+ endpoint_url=endpoint_url,
262
+ zarr_format=3,
263
+ )
264
+ # Add item to the RAPID36 RAPID-Evolution nested grandchild domain native model grid catalog:
265
+ r_evo_rapid36.add_item(item)
266
+
267
+ else:
268
+ bucket="r-evo1-eorca025-rapid12-rapid36"
269
+ prefix = f"RAPID36/{prefix}"
270
+ if '1y' in prefix:
271
+ operation = "annual mean"
272
+ elif '1m' in prefix:
273
+ operation = "monthly mean"
274
+
275
+ # Get variable Zarr stores from JASMIN object store:
276
+ var_stores = [path.split("/")[-1] for path in obj_store.ls(f"{bucket}/{prefix}") if path.split("/")[-1] not in exclude_vars]
277
+
278
+ # Create STAC Item for each variable Zarr store:
279
+ logging.info(f"In Progress: Adding {prefix} Items...")
280
+ for var in tqdm(var_stores):
281
+ # Open dataset from Zarr store:
282
+ ds = xr.open_zarr(f"{endpoint_url}/{bucket}/{prefix}/{var}", consolidated=True)
283
+ item = create_item_with_zarr_asset(
284
+ id=f"noc-rapid-evolution/r_evo_rapid36/{prefix}/{var}",
285
+ ds=ds,
286
+ bucket=bucket,
287
+ platform="gn",
288
+ horizontal_grid_resolution="1/36 degree",
289
+ start_date="1976-01-01",
290
+ end_date="2023-12-31",
291
+ prefix=f"{prefix}/{var}",
292
+ bbox=(-98.530975, 17.34014, -8.879465, 30.447763),
293
+ collection="noc-rapid-evolution",
294
+ title=f"RAPID-Evolution RAPID36 {prefix}/{var}",
295
+ operation=operation,
296
+ endpoint_url=endpoint_url,
297
+ zarr_format=3,
298
+ )
299
+ # Add item to the RAPID36 RAPID-Evolution nested grandchild domain native model grid catalog:
300
+ r_evo_rapid36.add_item(item)
301
+
302
+ logging.info(f"Completed: Added Items to STAC Catalog: {r_evo_rapid36}")
303
+
304
+ # -- Add Nested Catalogs to NOC RAPID-Evolution Collection -- #
305
+ rapid_evo_collection.add_child(r_evo_eorca025)
306
+ rapid_evo_collection.add_child(r_evo_rapid12)
307
+ rapid_evo_collection.add_child(r_evo_rapid36)
308
+
309
+ return rapid_evo_collection
@@ -0,0 +1,85 @@
1
+ """
2
+ template_collections.py
3
+
4
+ Description:
5
+ Template Function to create Spatio-Temporal Access Catalog Collections
6
+ for ocean observation datasets.
7
+
8
+ Authors:
9
+ - Ollie Tooth (oliver.tooth@noc.ac.uk)
10
+ """
11
+ # -- Import Python Modules -- #
12
+ import logging
13
+ import pystac
14
+ import datetime
15
+
16
+ from OceanDataStore.catalog.stac.utils import open_icechunk_store, create_item_with_icechunk_asset
17
+
18
+
19
+ def create_example_collection() -> pystac.Collection:
20
+ """
21
+ Create an example STAC Collection from an Icechunk repository
22
+ stored in the JASMIN cloud object store.
23
+
24
+ Returns:
25
+ -------
26
+ example_collection : pystac.Collection
27
+ Example STAC Collection.
28
+
29
+ """
30
+ # ==== Define Example Collection ==== #
31
+ # Define the spatial extent for the collection - this is the maximum extent of all datasets in the collection:
32
+ spatial_extent = pystac.SpatialExtent(bboxes=[[-180.0, -90.0, 180.0, 90.0]])
33
+
34
+ # Define the current temporal extent for the collection - this is the maximum temporal extent of all datasets in the collection:
35
+ collection_interval = sorted([datetime.datetime(year=1975, month=1, day=1), datetime.datetime(year=2026, month=6, day=1)])
36
+ temporal_extent = pystac.TemporalExtent(intervals=[collection_interval])
37
+
38
+ # Define PySTAC Collection:
39
+ example_collection = pystac.Collection(
40
+ id="example",
41
+ title="Example STAC Collection",
42
+ description="**About:**\n\nExample STAC Collection from an Icechunk repository.\n\n**More Information:**\n - [Source](https://link-to-source.com)",
43
+ extent=pystac.Extent(spatial=spatial_extent, temporal=temporal_extent),
44
+ license="License String", # For example, UK Open Government License v3.0
45
+ extra_fields=dict(contact="Name (email)", project="project_name", status="ongoing / completed", update_frequency="monthly/quarterly/annually", last_data_update="YYYY-MM-DD"),
46
+ keywords=["SOURCE", "global / arctic / antarctic", "model / observation", "temperature / salinity / sea ice concentration"],
47
+ providers=[
48
+ pystac.Provider(
49
+ name="National Oceanography Centre",
50
+ description="National Oceanography Centre (NOC), United Kingdom.",
51
+ roles=[pystac.ProviderRole.PRODUCER, pystac.ProviderRole.LICENSOR],
52
+ url="https://www.noc.ac.uk"
53
+ ),
54
+ pystac.Provider(
55
+ name="JASMIN",
56
+ description="JASMIN Environmental Data Analysis Facility (United Kingdom).",
57
+ roles=[pystac.ProviderRole.HOST],
58
+ url="https://jasmin.ac.uk"
59
+ )
60
+ ],
61
+ )
62
+
63
+ logging.info(f"Completed: Created STAC Collection with ID: {example_collection.id}")
64
+
65
+ # -- Add Items to Example STAC Collection -- #
66
+ bucket = "bucket_name"
67
+ for prefix in ["example_dataset_1", "example_dataset_2"]:
68
+ # Open dataset from Icechunk repository:
69
+ ds = open_icechunk_store(bucket=bucket, prefix=prefix, branch="branch_name")
70
+
71
+ item = create_item_with_icechunk_asset(
72
+ ds=ds,
73
+ id=f"{bucket}/{prefix}",
74
+ bucket=bucket,
75
+ prefix=prefix,
76
+ start_date="YYYY-MM-DD",
77
+ end_date="YYYY-MM-DD",
78
+ collection=bucket,
79
+ )
80
+ # Add Item to the Example STAC Collection:
81
+ example_collection.add_item(item)
82
+
83
+ logging.info(f"Completed: Added Items to STAC Collection with ID: {example_collection.id}")
84
+
85
+ return example_collection