From 43a88f454a76bd9586d24cffb1de60ba92955287 Mon Sep 17 00:00:00 2001 From: pkdash Date: Tue, 26 Mar 2024 23:03:28 -0400 Subject: [PATCH] [#8] adding missingValue to netcdf variable adapter --- hsextract/adapters/hydroshare.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hsextract/adapters/hydroshare.py b/hsextract/adapters/hydroshare.py index 074f9af..c618bd1 100644 --- a/hsextract/adapters/hydroshare.py +++ b/hsextract/adapters/hydroshare.py @@ -299,6 +299,7 @@ class Variable(BaseModel): type: str shape: str method: Optional[str] + missing_value: Optional[str] def to_aggregation_variable(self): _property_value = schema.PropertyValue.construct() @@ -307,10 +308,18 @@ def to_aggregation_variable(self): _property_value.description = self.descriptive_name _property_value.measurementTechnique = self.method # creating a nested PropertyValue object to account for the shape field of the extracted variable metadata - _property_value.value = schema.PropertyValue.construct() - _property_value.value.name = "shape" - _property_value.value.unitCode = self.type - _property_value.value.value = self.shape + shape = schema.PropertyValue.construct() + shape.name = "shape" + shape.unitCode = self.type + shape.value = self.shape + if self.missing_value: + missing_value = schema.PropertyValue.construct() + missing_value.name = "missingValue" + missing_value.value = self.missing_value + _property_value.value = [shape, missing_value] + else: + _property_value.value = [shape] + return _property_value