argopy.reference.vocabulary.ArgoReferenceTable#
- class ArgoReferenceTable(identifier: str | None = None, *args, **kwargs)[source]#
A class to work with an Argo reference table, i.e. a NVS “vocabulary”
An Argo reference table is a NVS “vocabulary”, aka a SKOS “collection”.
For instance, the vocabulary for “Argo sensor models”, corresponds to the Argo reference table 27 (“R27”) and is used to document possible values of the “SENSOR_MODEL” parameter in netcdf files. All possible values for this parameter are instances of
ArgoReferenceValue.Note
# Deprecated API: ArgoNVSReferenceTables.tbl(‘R25’)
# New API, but not backward compatible (new column names): ArgoReferenceTable(‘R25’).to_dataframe()
Examples
Creation and Attributes#from argopy import ArgoReferenceTable # Use an Argo parameter name, documented by one of the Argo reference tables: art = ArgoReferenceTable('SENSOR') # or a reference table identifier: art = ArgoReferenceTable('R25') # or a URN: art = ArgoReferenceTable.from_urn('SDN:R25::CTD_TEMP') # All possible attributes are listed in: art.attrs # Reference Table attributes: art.parameter # Name of the netcdf dataset parameter filled with values from this table art.identifier # Reference Table ID art.description # [nvs['@graph']['@type']=='skos:Collection']["dc:description"] art.uri # [nvs['@graph']['@type']=='skos:Collection']["@id"] art.version # [nvs['@graph']['@type']=='skos:Collection']['owl:versionInfo'] art.date # [nvs['@graph']['@type']=='skos:Collection']['dc:date'] # Raw NVS json data: art.nvs
Indexing and values#from argopy import ArgoReferenceTable art = ArgoReferenceTable('SENSOR') # Values (or concept) within this reference table: len(art) # Number of reference values art.keys() # List of reference values name art.values() # List of :class:`ArgoReferenceValue` # Check for values: 'CTD_TEMP_CNDC' in art # Return True # Index by value key, like a simple dictionary: art['CTD_TEMP_CNDC'] # Return a :class:`ArgoReferenceValue` instance # Allows to iterate over all values/concepts: for concept in art: print(concept.name, concept.urn)
Export methods#from argopy import ArgoReferenceTable art = ArgoReferenceTable('SENSOR') # Export table attributes to a dictionary (rq: this is not to export values): art.to_dict() art.to_dict(keys=['parameter', 'date', 'uri']) # Select Table attributes to export in dictionary keys # Export table values to a pd.DataFrame: art.to_dataframe() art.to_dataframe(columns=['name', 'deprecated']) # Select value attributes to export in columns # Export table values to a dictionary, use pd.DataFrame: art.to_dataframe(columns=['name', 'deprecated']).to_dict(orient='records')
Search the table## Search methods (return a list of :class:`ArgoReferenceValue` with match): # Any of the :class:`ArgoReferenceValue` attribute can be searched art.search(name='RAMSES') # Search in values name art.search(definition='imaging') # Search in values definition art.search(long_name='TriOS') # Search in values long name # Possible change to output format: art.search(deprecated=True, output='df') # To a :class:`pd.DataFrame`
Methods
__init__([identifier])from_urn(urn)keys()search(**kwargs)Search in table list of
ArgoReferenceValueattributesto_dataframe([columns])Export all reference values attributes to a
pd.DataFrameto_dict([keys])Export reference table attributes to a dictionary
valid_identifier()values()Attributes
identifierparameterlong_namedescriptionversiondateuriTwo methods: 1- From the skos:Collection list of members: >>> values = [m['@id'].split("/")[-2] for m in Collection['skos:member']] 2- From skos:Concept in the @graph: >>> values = [c['skos:altLabel'] for c in [item for item in self['@graph'] if item['@type'] == 'skos:Concept']] We stick to Collection for consistency with other attributes gathering
nvsattrsPublic attributes