Qualifications

Qualifications are used to modify and hence create new standard names:

import ssnolib

There are two type of Qualification classes:

  • Qualification: Normal qualification adding a phrase to the standard name

  • VectorQualification: Adding a phrase to a standard name which must be a vector!

Let’s start with a “normal” Qualification, like adding an information about the medium to a variable.

Assume the scalar standard name “density”. We would like to allow adding “air” or “water” to standard names but no other:

medium = ssnolib.Qualification(
    name="medium",
    description=["medium of a quantity@en", "Medium der Größe@en"],
    hasValidValues=["air", "water"],
    before=ssnolib.SSNO.AnyStandardName
)

Add this qualification to the standard name table:

snt = ssnolib.StandardNameTable(standard_names=[ssnolib.ScalarStandardName(standard_name="density", description="", unit="kg/m^3")])
snt.hasModifier = [medium,]
snt.get_qualification_rule_as_string()
'[medium] standard_name'

Let’s verify the obvious case:

snt.verify_name("density")
True

The prefix “air” should be possible, too:

snt.verify_name("air_density")
False

“oil” is an invalid medium:

snt.verify_name("oil_density")
False

Now towards vector qualifications: Let’s add “velocity” as a vector quantity to the core list of standard names:

snt.add_new_standard_name(
    ssnolib.VectorStandardName(
        standard_name="velocity",
        description="A velocity vector quantity",
        unit="m/s"
    ),
    verify=False
)
VectorStandardName(id=_:Nf265417081134e37ada17ef7c39baa92, description=A velocity vector quantity, standardName=velocity, unit=http://qudt.org/vocab/unit/M-PER-SEC)
component = ssnolib.VectorQualification(name="component", description="component of a vector@en", hasValidValues=["x", "y", "z"],
                                        before=ssnolib.SSNO.AnyStandardName)
snt.hasModifier = [component,]
snt.get_qualification_rule_as_string()
'[component] standard_name'
snt.verify_name("x_velocity")
False
snt.verify_name("u_velocity")
False
snt.verify_name("velocity")
True
print(component.serialize("ttl"))
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix m4i: <http://w3id.org/nfdi4ing/metadata4ing#> .
@prefix schema: <https://schema.org/> .
@prefix ssno: <https://matthiasprobst.github.io/ssno#> .

[] a ssno:VectorQualification ;
    dcterms:description "component of a vector"@en ;
    ssno:before ssno:AnyStandardName ;
    ssno:hasValidValues [ a m4i:TextVariable ;
            m4i:hasStringValue "x" ;
            m4i:hasVariableDescription "No description available." ],
        [ a m4i:TextVariable ;
            m4i:hasStringValue "z" ;
            m4i:hasVariableDescription "No description available." ],
        [ a m4i:TextVariable ;
            m4i:hasStringValue "y" ;
            m4i:hasVariableDescription "No description available." ] ;
    schema:name "component" .