Skip to content

Commit

Permalink
Merge pull request #421 from euroargodev/420-unknown-profiler
Browse files Browse the repository at this point in the history
Fix unknown profiler error from Ref table 8
  • Loading branch information
gmaze authored Dec 16, 2024
2 parents e9ec8d1 + 44429e8 commit 3581d91
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 69 deletions.
30 changes: 22 additions & 8 deletions argopy/related/utils.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
import importlib
import os
import json
import logging
from . import ArgoNVSReferenceTables


path2assets = importlib.util.find_spec('argopy.static.assets').submodule_search_locations[0]
log = logging.getLogger("argopy.related.utils")
path2assets = importlib.util.find_spec(
"argopy.static.assets"
).submodule_search_locations[0]


def load_dict(ptype):
if ptype == "profilers":
try:
nvs = ArgoNVSReferenceTables(cache=True)
profilers = {}
for row in nvs.tbl(8).iterrows():
profilers.update({int(row[1]['altLabel']): row[1]['prefLabel']})
for irow, row in nvs.tbl(8).iterrows():
profilers.update({int(row['id'].split("/")[-2]): row["prefLabel"]})
profilers = dict(sorted(profilers.items()))
return profilers
except Exception:
with open(os.path.join(path2assets, "profilers.json"), "rb") as f:
loaded_dict = json.load(f)['data']['profilers']
return loaded_dict
jsdata = json.load(f)
log.debug(
"Failed to load the ArgoNVSReferenceTables R08 for profiler types, fall back on static assets last updated on %s"
% jsdata["last_update"]
)
return jsdata["data"]["profilers"]
elif ptype == "institutions":
try:
nvs = ArgoNVSReferenceTables(cache=True)
institutions = {}
for row in nvs.tbl(4).iterrows():
institutions.update({row[1]['altLabel']: row[1]['prefLabel']})
institutions.update({row[1]["altLabel"]: row[1]["prefLabel"]})
institutions = dict(sorted(institutions.items()))
return institutions
except Exception:
with open(os.path.join(path2assets, "institutions.json"), "rb") as f:
loaded_dict = json.load(f)['data']['institutions']
return loaded_dict
jsdata = json.load(f)
log.debug(
"Failed to load the ArgoNVSReferenceTables R04 for institutions name, fall back on static assets last updated on %s"
% jsdata["last_update"]
)
return jsdata["data"]["institutions"]
else:
raise ValueError("Invalid dictionary name")

Expand Down
40 changes: 20 additions & 20 deletions argopy/static/assets/institutions.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"name": "institutions",
"long_name": "Institution names from Argo reference table 4",
"last_update": "2024-10-16T08:36:35.323003+00:00",
"last_update": "2024-12-16T09:16:41.313125+00:00",
"data": {
"institutions": {
"PL": "IOPAN, Institute of Oceanology Polish Academy of Science",
"NA": "NAVO, USA",
"JA": "JMA, Japan",
"RU": "Russia",
"UW": "University of Washington, USA",
"AO": "AOML, USA",
"BO": "BODC, United Kingdom",
"SP": "Spain",
"VL": "Far Eastern Regional Hydrometeorological Research Institute of Vladivostock, Russia",
"KO": "KORDI, Korea",
"CI": "Institute of Ocean Sciences, Canada",
"CS": "CSIRO, Australia",
"GE": "BSH, Germany",
"GT": "GTS : used for data coming from WMO GTS network",
"HZ": "CSIO, China Second Institute of Oceanography",
"IF": "Ifremer, France",
"IN": "INCOIS, India",
"JA": "JMA, Japan",
"JM": "Jamstec, Japan",
"AO": "AOML, USA",
"KM": "KMA, Korea",
"GT": "GTS : used for data coming from WMO GTS network",
"KO": "KORDI, Korea",
"LV": "Laboratoire Oc\u00e9anographique de Villefranche, Sorbonne University",
"MB": "MBARI, USA",
"ME": "MEDS, Canada",
"NA": "NAVO, USA",
"NM": "NMDIS, China",
"LV": "Laboratoire Oc\u00e9anographique de Villefranche, Sorbonne University",
"IF": "Ifremer, France",
"HZ": "CSIO, China Second Institute of Oceanography",
"PL": "IOPAN, Institute of Oceanology Polish Academy of Science",
"PM": "PMEL, USA",
"WH": "Woods Hole Oceanographic Institution, USA",
"GE": "BSH, Germany",
"IN": "INCOIS, India",
"RU": "Russia",
"SI": "SIO, Scripps, USA",
"CI": "Institute of Ocean Sciences, Canada",
"CS": "CSIRO, Australia",
"ME": "MEDS, Canada"
"SP": "Spain",
"UW": "University of Washington, USA",
"VL": "Far Eastern Regional Hydrometeorological Research Institute of Vladivostock, Russia",
"WH": "Woods Hole Oceanographic Institution, USA"
}
}
}
83 changes: 44 additions & 39 deletions argopy/static/assets/profilers.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,65 @@
{
"name": "profilers",
"long_name": "Profiler codes and description from Argo reference table 8",
"last_update": "2024-10-16T08:36:35.759259+00:00",
"last_update": "2024-12-16T09:16:11.170268+00:00",
"data": {
"profilers": {
"841": "PROVOR float with SBE conductivity sensor",
"838": "ARVOR-D deep float with SBE conductivity sensor",
"831": "PALACE float",
"887": "SOLO_BGC_MRV, RBR",
"880": "S2A float with RBR conductivity sensor",
"877": "APEX float with RBR conductivity sensor",
"881": "HM4000",
"851": "SOLO float with SBE conductivity sensor",
"847": "Teledyne Webb Research float with FSI conductivity sensor",
"848": "APEX-EM float with SBE conductivity sensor",
"834": "PROVOR V SBE",
"835": "PROVOR IV",
"837": "ARVOR-C float with SBE conductivity sensor",
"883": "APEX_D deep float with RBR conductivity sensor",
"879": "SOLO-II with RBR conductivity sensor",
"885": "SOLO_BGC, RBR",
"859": "NEMO float with no conductivity",
"861": "NEMO float with FSI conductivity sensor",
"858": "NINJA float with TSK conductivity sensor",
"836": "PROVOR III",
"837": "ARVOR-C float with SBE conductivity sensor",
"838": "ARVOR-D deep float with SBE conductivity sensor",
"839": "PROVOR-II float with SBE conductivity sensor",
"840": "PROVOR float with no conductivity sensor",
"841": "PROVOR float with SBE conductivity sensor",
"842": "PROVOR float with FSI conductivity sensor",
"843": "POPS ice platform using PROVOR float with SBE conductivity sensor",
"878": "ARVOR float with RBR conductivity sensor",
"889": "PROVOR_V - Jumbo, RBR",
"888": "PROVOR_V - Jumbo, SBE",
"834": "PROVOR V SBE",
"863": "Navis-A float with SBE conductivity sensor",
"844": "ARVOR float with SBE conductivity sensor",
"886": "SOLO_BGC_MRV, SBE",
"853": "SOLO-II float with SBE conductivity sensor",
"864": "NINJA-D deep float with SBE conductivity sensor",
"842": "PROVOR float with FSI conductivity sensor",
"845": "Teledyne Webb Research float with no conductivity sensor",
"890": "PROVOR_III - Jumbo, SBE",
"875": "ALTO float with RBR conductivity sensor",
"846": "Teledyne Webb Research float with SBE conductivity sensor",
"847": "Teledyne Webb Research float with FSI conductivity sensor",
"848": "APEX-EM float with SBE conductivity sensor",
"849": "APEX-D deep float with SBE conductivity sensor",
"850": "SOLO float with no conductivity sensor",
"851": "SOLO float with SBE conductivity sensor",
"852": "SOLO float with FSI conductivity sensor",
"853": "SOLO-II float with SBE conductivity sensor",
"854": "S2A float with SBE conductivity sensor",
"855": "NINJA float with no conductivity sensor",
"856": "NINJA float with SBE conductivity sensor",
"884": "SOLO_BGC, SBE",
"857": "NINJA float with FSI conductivity sensor",
"858": "NINJA float with TSK conductivity sensor",
"859": "NEMO float with no conductivity",
"860": "NEMO float with SBE conductivity sensor",
"861": "NEMO float with FSI conductivity sensor",
"862": "SOLO-D deep float with SBE conductivity sensor",
"854": "S2A float with SBE conductivity sensor",
"840": "PROVOR float with no conductivity sensor",
"863": "Navis-A float with SBE conductivity sensor",
"864": "NINJA-D deep float with SBE conductivity sensor",
"865": "NOVA float with SBE conductivity sensor",
"869": "NAVIS_EBR",
"870": "HM2000",
"871": "COPEX",
"872": "S2X",
"846": "Teledyne Webb Research float with SBE conductivity sensor",
"891": "PROVOR_III - Jumbo, RBR",
"850": "SOLO float with no conductivity sensor",
"839": "PROVOR-II float with SBE conductivity sensor",
"873": "ALTO",
"874": "SOLO_D_MRV",
"875": "ALTO float with RBR conductivity sensor",
"876": "ALTO float with SBE conductivity sensor",
"877": "APEX float with RBR conductivity sensor",
"878": "ARVOR float with RBR conductivity sensor",
"879": "SOLO-II with RBR conductivity sensor",
"880": "S2A float with RBR conductivity sensor",
"881": "HM4000",
"882": "XUANWU",
"857": "NINJA float with FSI conductivity sensor",
"860": "NEMO float with SBE conductivity sensor",
"849": "APEX-D deep float with SBE conductivity sensor",
"855": "NINJA float with no conductivity sensor"
"883": "APEX_D deep float with RBR conductivity sensor",
"884": "SOLO_BGC, SBE",
"885": "SOLO_BGC, RBR",
"886": "SOLO_BGC_MRV, SBE",
"887": "SOLO_BGC_MRV, RBR",
"888": "PROVOR_V - Jumbo, SBE",
"889": "PROVOR_V - Jumbo, RBR",
"890": "PROVOR_III - Jumbo, SBE",
"891": "PROVOR_III - Jumbo, RBR"
}
}
}
2 changes: 0 additions & 2 deletions argopy/stores/argo_index_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,6 @@ def get_filename(s, index):
df["dac"] = df["file"].apply(lambda x: x.split("/")[0])

profiler_dictionnary = load_dict("profilers")
profiler_dictionnary["?"] = "?"

def ev(x):
try:
return int(x)
Expand Down
2 changes: 2 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Coming up next
Internals
^^^^^^^^^

- Fix bug raised when the Argo reference table 8 return by the NVS server has a missing altLabel. ID of platform types are now extracted from the NVS url ID property. :issue:`420`, (:pr:`421`) by |gmaze|.

- When argopy is sending a http request to a data server, add a custom http header ``Argopy-Version`` to ease server log analysis. (:pr:`407`) by |gmaze|.

- New :meth:`ArgoIndex.copy` method (:pr:`418`) by |gmaze|. This copy allows for a:
Expand Down

0 comments on commit 3581d91

Please sign in to comment.