Skip to content

Commit 13d4ab7

Browse files
update description for application of transformations
1 parent 3bb7319 commit 13d4ab7

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ authors:
66
orcid: "https://orcid.org/0000-0001-8729-0482"
77
title: "ssnolib (1.5.1.2)"
88
version: 1.5.1.2
9-
doi: 10.5281/zenodo.todo
9+
doi: 10.5281/zenodo.15457925
1010
date-released: 2025-05-18
1111
url: "https://github.com/matthiasprobst/ssnolib"

ssnolib/ssno/standard_name_table.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,24 +578,24 @@ def _get_by_transformation(self, standard_name: str) -> Union[StandardName, None
578578
descriptions = []
579579
for m in matches:
580580
if isinstance(m, StandardName):
581-
descriptions.append(m.description.strip("."))
581+
descriptions.append(f"{m.standardName}: {m.description.strip('.')}.")
582582
else:
583-
descriptions.append(m.hasVariableDescription.strip("."))
584-
match_descriptions = ". ".join(descriptions)
583+
descriptions.append(f"{m.hasStringValue}: {m.hasVariableDescription.strip('.')}.")
584+
match_descriptions = " ".join(descriptions)
585585
matches_standard_names = [m for m in matches if isinstance(m, StandardName)]
586586
combined_description = " and ".join([f"'{m.standardName}'" for m in matches_standard_names])
587587
if len(matches) == 1:
588-
new_description = f"Derived Standard Name using transformation '{found_transformation.name}' ({found_transformation.description}) from standard name {combined_description}."
588+
new_description = f"Derived standard name using transformation '{found_transformation.name}' ({found_transformation.description}) applied to {combined_description}."
589589
else:
590-
new_description = f"Derived Standard Name using transformation '{found_transformation.name}' ({found_transformation.description}) from standard names {combined_description}."
590+
new_description = f"Derived standard name using transformation '{found_transformation.name}' ({found_transformation.description}) applied to {combined_description}."
591591
if self.id.endswith("/"):
592592
new_sn_id = self.id + "derived_standard_name/" + standard_name
593593
else:
594594
new_sn_id = self.id + "/derived_standard_name/" + standard_name
595595
valid_standard_name = StandardName(id=new_sn_id,
596596
standardName=standard_name,
597597
unit=alter_unit(matches_standard_names, found_transformation),
598-
description=new_description + " " + match_descriptions + ".")
598+
description=new_description.strip(".") + ". " + match_descriptions)
599599

600600
_cache_valid_standard_name(self, valid_standard_name)
601601
return valid_standard_name

tests/test_ssno_table.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ def test_from_jsonld_file(self):
300300
self.assertFalse(snt.verify_name("u_velocity"))
301301
self.assertTrue(snt.verify_name("x_air_density"))
302302
sn = snt.get_standard_name("x_velocity")
303-
self.assertEqual("velocity: The velocity vector of an object or fluid. x: No description available.", sn.description)
303+
self.assertEqual("velocity: The velocity vector of an object or fluid. x: No description available.",
304+
sn.description)
304305
self.assertEqual('http://qudt.org/vocab/unit/M-PER-SEC', sn.unit)
305306
self.assertEqual("x_velocity", sn.standardName)
306307

@@ -566,7 +567,8 @@ def test_cf_qualifications(self):
566567
name="component",
567568
description='The direction of the spatial component of a vector is indicated by one of the words upward, downward, northward, southward, eastward, westward, x, y. The last two indicate directions along the horizontal grid being used when they are not true longitude and latitude (if there is a rotated pole, for instance). If the standard name indicates a tensor quantity, two of these direction words may be included, applying to two of the spatial dimensions Z Y X, in that order. If only one component is indicated for a tensor, it means the flux in the indicated direction of the magnitude of the vector quantity in the plane of the other two spatial dimensions. The names of vertical components of radiative fluxes are prefixed with net_, thus: net_downward and net_upward. This treatment is not applied for any kinds of flux other than radiative. Radiative fluxes from above and below are often measured and calculated separately, the "net" being the difference. Within the atmosphere, radiation from below (not net) is indicated by a prefix of upwelling, and from above with downwelling. For the top of the atmosphere, the prefixes incoming and outgoing are used instead.,',
568569
hasValidValues=["upward", "downward", "northward", "southward", "eastward", "westward",
569-
TextVariable(hasStringValue="x", hasVariableDescription="The x-component of the vector."), "y"]
570+
TextVariable(hasStringValue="x", hasVariableDescription="The x-component of the vector."),
571+
"y"]
570572
)
571573
at_surface = ssnolib.Qualification(
572574
name="surface",
@@ -923,7 +925,7 @@ def test_transformation_with_domain_concept_set(self):
923925
hasValidValues=[
924926
TextVariable(
925927
has_string_value="fan",
926-
has_variable_description="my fan"),
928+
has_variable_description="The investigated fan."),
927929
TextVariable(
928930
has_string_value="orifice plate",
929931
has_variable_description="orifice plate to measure volume flow rate"
@@ -933,8 +935,9 @@ def test_transformation_with_domain_concept_set(self):
933935
id=f"https://example.org/transformation/difference_of_X_across_device",
934936
name="difference_of_X_across_DEVICE",
935937
altersUnit="[X]",
936-
hasCharacter=[Character(character="X", associatedWith=SSNO.AnyStandardName),
937-
Character(character="DEVICE", associatedWith=devices), ],
938+
hasCharacter=[
939+
Character(character="X", associatedWith=SSNO.AnyStandardName),
940+
Character(character="DEVICE", associatedWith=devices), ],
938941
description="Difference of a quantity across a device."
939942
)
940943
test_snt = StandardNameTable(title="Test SNT")
@@ -948,6 +951,10 @@ def test_transformation_with_domain_concept_set(self):
948951
# self.assertEqual("http://qudt.org/vocab/unit/M-PER-SEC", vel.unit)
949952
vel_across_fan = test_snt.get_standard_name("difference_of_velocity_across_fan")
950953
self.assertEqual("difference_of_velocity_across_fan", vel_across_fan.standardName)
954+
self.assertEqual(
955+
"Derived standard name using transformation 'difference_of_X_across_DEVICE' (Difference of a quantity across a device.) applied to 'velocity'. velocity: velocity. fan: The investigated fan.",
956+
vel_across_fan.description
957+
)
951958
self.assertEqual("http://qudt.org/vocab/unit/M-PER-SEC", vel_across_fan.unit)
952959

953960
# test parsing domain concept set
@@ -959,7 +966,6 @@ def test_transformation_with_domain_concept_set(self):
959966

960967
pathlib.Path('snt_with_domain_concept.jsonld').unlink(missing_ok=True)
961968

962-
963969
def test_get_transformed_standard_name(self):
964970
snt = StandardNameTable(name="Fluid SNT")
965971
velocity = StandardName(standardName="velocity", description="velocity", unit="m/s")

0 commit comments

Comments
 (0)