diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index bbcee5ad..82d69493 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -22,8 +22,7 @@ jobs: - name: ๐ฆ Install dependencies run: | python -m pip install --upgrade pip - pip install pytest pytest-mock - pip install git+https://github.com/NOC-MSM/OceanDataStore.git + pip install -e .[tests] - name: ๐งช Run Pytest run: | diff --git a/OceanDataStore/catalog/__init__.py b/OceanDataStore/catalog/__init__.py index 0db5e707..f7d4a298 100644 --- a/OceanDataStore/catalog/__init__.py +++ b/OceanDataStore/catalog/__init__.py @@ -7,6 +7,6 @@ __author__ = "Ollie Tooth, Joao Morado, Tobias Ferreira" __credits__ = "National Oceanography Centre (NOC), Southampton, UK" -from OceanDataStore.catalog.oceandatacatalog import OceanDataCatalog +from OceanDataStore.catalog.oceandatacatalog import OceanDataCatalog, CatalogSummary -__all__ = ("OceanDataCatalog",) \ No newline at end of file +__all__ = ("OceanDataCatalog", "CatalogSummary",) diff --git a/OceanDataStore/catalog/oceandatacatalog.py b/OceanDataStore/catalog/oceandatacatalog.py index 1336356b..659b412d 100644 --- a/OceanDataStore/catalog/oceandatacatalog.py +++ b/OceanDataStore/catalog/oceandatacatalog.py @@ -1,5 +1,5 @@ """ -data_catalog.py +oceandatacatalog.py Description: This module defines the OceanDataCatalog() class which is a @@ -16,6 +16,193 @@ import icechunk import xarray as xr +# -- NOC brand CSS -- # +_NOC_CSS = """ + +""" + +# -- Define CatalogSummary() class -- # +class CatalogSummary: + """ + Container for OceanDataCatalog summary. + + Parameters + ---------- + num_collections : int + The number of collections in the catalog. + num_items : int + The number of items in the catalog. + other_info : dict + Any other relevant summary information about the catalog. + """ + def __init__(self, + display_text: str | None = None, + display_html: str | None = None, + ): + self.display_text = display_text + self.display_html = display_html + + def __repr__(self): + """ + Plain text representation of the CatalogSummary. + """ + return self.display_text + + def _repr_html_(self): + """ + HTML representation of the CatalogSummary. + """ + return self.display_html + # -- Define OceanDataCatalog() class -- # class OceanDataCatalog: """ @@ -56,6 +243,54 @@ def __init__(self, # Define the Collection and Items attributes: self.Collection = None self.Items = None + # Cache the catalog name for display: + self._catalog_name = catalog_name + + def __repr__(self) -> str: + """ + Plain text representation of the OceanDataCatalog. + """ + n_collections = len(self.available_collections) + col_name = self.Collection.id if self.Collection else "โ" + n_items = len(self.Items) if self.Items is not None else "โ" + return ( + f"OceanDataCatalog\n" + f" Catalog: {self._catalog_name}\n" + f" URL: {self._stac_url}\n" + f" Collections: {n_collections} available\n" + f" Collection: {col_name}\n" + f" Search: {n_items} items" + ) + + + def _repr_html_(self) -> str: + """ + HTML representation of the OceanDataCatalog. + """ + n_collections = len(self.available_collections) + col_name = self.Collection.id if self.Collection else "none selected" + n_items = ( + f"{len(self.Items)} items" + if self.Items is not None + else "no search yet" + ) + return ( + f"{_NOC_CSS}" + f"
| Item ID | Title | Platform | " + f"Start Date | End Date | Variables | " + f"
|---|
| Collection ID | Title | Description | " + f"From | To | " + f"
|---|
| Title | Description |
|---|---|
| {title_val} | {desc_val.replace('**', '')} |
| Property | Value |
|---|
| Key | Media Type | Endpoint | Bucket | Prefix | " + f"
|---|
{access_str}"
+ f" "
+ f"| Item ID | Title | Platform | Start Date | End Date | Variables |
|---|---|---|---|---|---|
| noc-npd-era5/npd-eorca1-era5v1/r1i1c1f1/gn/T1y | T1y Icechunk repository | gn | 1976-01-01T00:00:00Z | 2025-07-31T00:00:00Z | 74 variablesempmr e3t hfempds hfds fsitherm hflx_rnf hfns hfrainds hfls ficeberg friver berg_latent_heat_flux mlotst hfss hfto hfsr hfevapds deptht_bounds mlotstmax evs mlotstsq ocontempdiff osaltpmdiff osaltdiff mlotstmin ocontempmint rlntds ocontempadvect osalttend rsdo prsn osaltadvect ocontemptend pbo sbt_con snow_ai_cea sbs_abs rsntds sfdsi so_abs ocontemppmdiff sohfcisf somixhgt sos_abs sosafldo soicecov somint_abs sohflisf rsdoabsorb snowpre strd_atf_li sowaflup sowflisf strd_bbl_li thetao_con somxl010 time_centered_bounds strd_evd_li somxzint1 ttrd_evd_li ttrd_atf_li sowindsp time_counter_bounds tos_con tossq_con tnpeo ttrd_bbl_li sossq_abs ttrd_qns_li zossq vohflisf zos vowflisf vohfcisf |
| noc-npd-era5/npd-eorca1-era5v1/r1i1c1f1/gn/T1m | T1m Icechunk repository | gn | 1976-01-01T00:00:00Z | 2025-07-31T00:00:00Z | 74 variablesberg_latent_heat_flux deptht_bounds ficeberg fsitherm e3t evs empmr friver hfds hfevapds hfrainds hfsr hfempds hflx_rnf hfls hfns mlotst mlotstmin mlotstsq mlotstmax hfto hfss ocontemptend osaltadvect osaltdiff ocontempdiff ocontempmint osaltpmdiff ocontempadvect ocontemppmdiff rlntds rsdo rsdoabsorb osalttend pbo prsn rsntds sbs_abs sbt_con snow_ai_cea sohfcisf soicecov snowpre sohflisf so_abs somxl010 somint_abs sosafldo sos_abs sossq_abs strd_bbl_li strd_atf_li strd_evd_li sowaflup sowindsp sowflisf somixhgt somxzint1 sfdsi thetao_con tossq_con tnpeo tos_con time_centered_bounds zossq time_counter_bounds ttrd_bbl_li vowflisf zos ttrd_evd_li ttrd_atf_li vohfcisf ttrd_qns_li vohflisf |
| noc-npd-era5/npd-eorca025-era5v1/r1i1c1f1/gn/T1y_3d | T1y_3d Icechunk repository | gn | 1976-01-01T00:00:00Z | 2025-07-31T00:00:00Z | 51 variableshfls evs friver empmr hfempds berg_latent_heat_flux ficeberg hfevapds fsitherm hfds hflx_rnf hfns hfss mlotstmax mlotstsq hfto hfsr hfrainds mlotstmin mlotst prsn sbt_con sbs_abs pbo ocontempmint rlntds rsntds snow_ai_cea sohfcisf somint_abs somixhgt soicecov sfdsi sowflisf somxl010 somxzint1 sohflisf sossq_abs sowaflup time_centered_bounds snowpre time_counter_bounds sos_abs tnpeo sosafldo sowindsp tossq_con zos tos_con ttrd_qns_li zossq |
| noc-npd-era5/npd-eorca025-era5v1/r1i1c1f1/gn/T1m_3d | T1m_3d Icechunk repository | gn | 1976-01-01T00:00:00Z | 2025-07-31T00:00:00Z | 51 variablesevs empmr ficeberg fsitherm hfds hfls berg_latent_heat_flux hfevapds hfempds friver hflx_rnf hfsr mlotst hfss hfrainds hfto hfns mlotstsq mlotstmax pbo rlntds ocontempmint prsn rsntds mlotstmin sbs_abs sbt_con snowpre sohfcisf somixhgt soicecov snow_ai_cea sfdsi somint_abs sohflisf somxl010 sosafldo sos_abs sossq_abs sowaflup time_counter_bounds somxzint1 sowindsp time_centered_bounds tos_con ttrd_qns_li tossq_con zos sowflisf zossq tnpeo |
| noc-npd-era5/npd-eorca025-era5v1/r1i1c1f1/gn/T5d_3d | T5d_3d Icechunk repository | gn | 1976-01-01T00:00:00Z | 2025-07-31T00:00:00Z | 50 variableshfls evs empmr fsitherm berg_latent_heat_flux hfds hfevapds hfss friver hfrainds ficeberg hfto hfempds hfns hfsr mlotst hflx_rnf rlntds ocontempmint mlotstmax mlotstmin rsntds sbs_abs snow_ai_cea sbt_con sfdsi snowpre sohfcisf mlotstsq prsn pbo somixhgt sowaflup somint_abs sowindsp sosafldo sohflisf soicecov sowflisf somxl010 time_centered_bounds tossq_con sossq_abs tos_con somxzint1 time_counter_bounds tnpeo sos_abs zos zossq |
| noc-npd-era5/npd-eorca12-era5v1/r1i1c1f1/gn/T1y_3d | T1y_3d Icechunk repository | gn | 1976-01-01T00:00:00Z | 2025-06-30T00:00:00Z | 50 variablesberg_latent_heat_flux ficeberg friver hfds empmr fsitherm hfls evs hfevapds hfempds hfns mlotstmax hfsr mlotstsq hfto hflx_rnf mlotst mlotstmin hfrainds pbo sbt_con rlntds ocontempmint hfss sbs_abs sohflisf prsn rsntds sohfcisf snow_ai_cea sfdsi sos_abs somxzint1 soicecov sossq_abs sosafldo somixhgt time_centered_bounds sowflisf sowaflup somxl010 snowpre somint_abs sowindsp time_counter_bounds tos_con tnpeo zossq zos tossq_con |
| noc-npd-era5/npd-eorca12-era5v1/r1i1c1f1/gn/T1m_3d | T1m_3d Icechunk repository | gn | 1976-01-01T00:00:00Z | 2025-06-30T00:00:00Z | 50 variablesberg_latent_heat_flux hfevapds friver ficeberg evs hfls hfempds empmr fsitherm mlotstmax hfsr hflx_rnf hfss hfto mlotst mlotstmin hfrainds hfns hfds ocontempmint sbt_con mlotstsq rlntds pbo rsntds prsn sfdsi sohflisf somint_abs sbs_abs snowpre sohfcisf somxl010 snow_ai_cea soicecov somixhgt sos_abs sossq_abs sowindsp time_centered_bounds sosafldo tnpeo somxzint1 sowflisf time_counter_bounds tos_con sowaflup tossq_con zos zossq |
| noc-npd-era5/npd-eorca12-era5v1/r1i1c1f1/gn/T5d_3d | T5d_3d Icechunk repository | gn | 1990-01-01T00:00:00Z | 2025-06-30T00:00:00Z | 50 variablesberg_latent_heat_flux hfds hfevapds hflx_rnf fsitherm hfempds friver empmr evs ficeberg hfls hfns mlotstsq hfto mlotst mlotstmin mlotstmax hfsr hfss hfrainds pbo prsn rsntds sbt_con sfdsi sbs_abs ocontempmint rlntds snow_ai_cea sohfcisf somixhgt somint_abs somxl010 soicecov sohflisf snowpre sosafldo sowaflup sowindsp time_centered_bounds somxzint1 sowflisf sossq_abs sos_abs time_counter_bounds tos_con zos tnpeo tossq_con zossq |
| Title | Description |
|---|---|
| T1y Icechunk repository | Annual mean global ocean physics outputs defined at NEMO model T-points.\n", + "\n", + " |
catalog.open_dataset(id='noc-npd-era5/npd-eorca1-era5v1/r1i1c1f1/gn/T1y') | Property | Value |
|---|---|
| variant | r1i1c1f1 |
| variables | 74 itemsempmr e3t hfempds hfds fsitherm hflx_rnf hfns hfrainds hfls ficeberg friver berg_latent_heat_flux mlotst hfss hfto hfsr hfevapds deptht_bounds mlotstmax evs mlotstsq ocontempdiff osaltpmdiff osaltdiff mlotstmin ocontempmint rlntds ocontempadvect osalttend rsdo prsn osaltadvect ocontemptend pbo sbt_con snow_ai_cea sbs_abs rsntds sfdsi so_abs ocontemppmdiff sohfcisf somixhgt sos_abs sosafldo soicecov somint_abs sohflisf rsdoabsorb snowpre strd_atf_li sowaflup sowflisf strd_bbl_li thetao_con somxl010 time_centered_bounds strd_evd_li somxzint1 ttrd_evd_li ttrd_atf_li sowindsp time_counter_bounds tos_con tossq_con tnpeo ttrd_bbl_li sossq_abs ttrd_qns_li zossq vohflisf zos vowflisf vohfcisf |
| variable_standard_names | 74 itemswater_flux_out_of_sea_ice_and_sea_water cell_thickness ocean_surface_downward_heat_flux_from_E-P ocean_surface_downward_total_heat_flux fsitherm temperature_flux_due_to_runoff_expressed_as_heat_flux_into_sea_water surface_net_downward_non_solar_heat_flux temperature_flux_due_to_rain_expressed_as_heat_flux_into_sea_water ocean_surface_downward_latent_heat_flux water_flux_into_sea_water_from_icebergs water_flux_into_sea_water_from_rivers latent_heat_flux_from_icebergs ocean_mixed_layer_thickness_defined_by_sigma_theta ocean_surface_downward_sensible_heat_flux surface_net_downward_total_heat_flux surface_net_downward_solar_heat_flux temperature_flux_due_to_evaporation_expressed_as_heat_flux_out_of_sea_water deptht_bounds ocean_mixed_layer_thickness_defined_by_sigma_theta water_evaporation_flux square_of_ocean_mixed_layer_thickness_defined_by_sigma_theta ocontempdiff osaltpmdiff osaltdiff ocean_mixed_layer_thickness_defined_by_sigma_theta integral_wrt_depth_of_product_of_density_and_conservative_temperature ocean_surface_net_downward_longwave_heat_flux ocontempadvect osalttend downwelling_shortwave_flux_in_sea_water snowfall_flux osaltadvect ocontemptend sea_water_pressure_at_sea_floor sbt_con snowfall_flux sbs_abs ocean_surface_net_downward_shortwave_heat_flux downward_sea_ice_basal_salt_flux sea_water_absolute_salinity ocontemppmdiff ocean_mixed_layer_thickness_defined_by_vertical_tracer_diffusivity sea_surface_salinity salt_flux_into_sea_water sea_ice_area_fraction integral_wrt_depth_of_product_of_density_and_absolute_salinity rsdoabsorb snowfall_flux strd_atf_li water_flux_out_of_sea_ice_and_sea_water strd_bbl_li sea_water_conservative_temperature ocean_mixed_layer_thickness_defined_by_sigma_theta time_centered_bounds strd_evd_li ocean_mixed_layer_thickness_defined_by_sigma_theta ttrd_evd_li ttrd_atf_li wind_speed time_counter_bounds sea_surface_temperature square_of_sea_surface_temperature tnpeo ttrd_bbl_li square_of_sea_surface_Salinity ttrd_qns_li square_of_sea_surface_height_above_geoid sea_surface_height_above_geoid |
| dimensions | 5 itemstime_counter y x deptht axis_nbounds |
| operation | mean |
| operation_frequency | annual |
| ocean_component | NEMO v4.2.2 |
| sea_ice_component | SI3 v4.0 |
| biogeochemistry_component | โ |
| atmosphere_component | โ |
| status | ongoing |
| update_frequency | quarterly |
| latest_data_update | 2026-03-22T21:41:49.874907 |
| Key | Media Type | Endpoint | Bucket | Prefix |
|---|---|---|---|---|
| T1y | application/vnd.zarr+icechunk | https://noc-msm-o.s3-ext.jc.rl.ac.uk | npd-eorca1-era5v1 | T1y |