Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update some bad field types noticed during metadata extractor tests #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions hsmodels/schemas/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ class Config:
title="Variable unit",
description="A string containing the units for the raster band variable",
)
no_data_value: str = Field(
no_data_value: float = Field(
default=None,
title="Nodata value",
description="A string containing the numeric nodata value for the raster band",
description="A float containing the numeric nodata value for the raster band",
)
maximum_value: str = Field(
maximum_value: float = Field(
default=None,
title="Maximum value",
description="A string containing the maximum numeric value for the raster band",
description="A float containing the maximum numeric value for the raster band",
)
comment: str = Field(
default=None, title="Comment", description="A string containing a comment about the raster band"
Expand All @@ -304,10 +304,10 @@ class Config:
title="Method",
description="A string containing a description of the method used to create the raster band data",
)
minimum_value: str = Field(
minimum_value: float = Field(
default=None,
title="Minimum value",
description="A string containing the minimum numerica value for the raster dataset",
description="A float containing the minimum numerica value for the raster dataset",
)


Expand All @@ -328,11 +328,10 @@ class Config:
)
# TODO: What is the "field_type_code"? It's not displayed on the resource landing page, but it's encoded in the
# aggregation metadata as an integer value.
field_type_code: str = Field(
field_type_code: int = Field(
default=None,
max_length=50,
title="Field type code",
description="A string value containing a code that indicates the field type",
description="An integer value containing a code that indicates the field type",
)
field_width: int = Field(
default=None, title="Field width", description="An integer value containing the width of the attribute field"
Expand Down Expand Up @@ -445,7 +444,7 @@ class Config:
# TODO: The NoData value for a variable in an ODM2 database is not always an integer.
# It could be a floating point value. We might want to change this to a string or a floating point value
# It is an integer in the HydroShare database, so will have to be updated there as well if changed
no_data_value: int = Field(title="NoData value", description="The NoData value for the variable")
no_data_value: float = Field(title="NoData value", description="The NoData value for the variable")
variable_definition: str = Field(
default=None,
max_length=255,
Expand Down Expand Up @@ -628,15 +627,18 @@ class Config:
description="A string containing the status of the time series result chosen from the ODM2 Status controlled vocabulary",
)
sample_medium: str = Field(
default=None,
max_length=255,
title="Sample medium",
description="A string containing the sample medium in which the time series result was measured chosen from the ODM2 Medium controlled vocabulary",
)
value_count: int = Field(
default=None,
title="Value count",
description="An integer value containing the number of data values contained within the time series result",
)
aggregation_statistic: str = Field(
default=None,
max_length=255,
title="Aggregation statistic",
description="A string containing the aggregation statistic associated with the values of the time series result chosen from the ODM2 Aggregation Statistic controlled vocabulary",
Expand All @@ -651,18 +653,22 @@ class Config:
description="A string containing a label for the time series result",
)
site: TimeSeriesSite = Field(
default=None,
title="Site",
description="An object containing metadata about the site at which the time series result was created",
)
variable: TimeSeriesVariable = Field(
title="Variablef",
default=None,
title="Variable",
description="An object containing metadata about the observed variable associated with the time series result values",
)
method: TimeSeriesMethod = Field(
default=None,
title="Method",
description="An object containing metadata about the method used to produce the time series result values",
)
processing_level: ProcessingLevel = Field(
default=None,
title="Processing level",
description="An object containing metadata about the processing level or level of quality control to which the time series result values have been subjected",
)
Expand Down
12 changes: 6 additions & 6 deletions tests/data/json/geographicfeature.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,39 @@
{
"field_name": "Id",
"field_type": "Integer64",
"field_type_code": "12",
"field_type_code": 12,
"field_width": 10
},
{
"field_name": "Shape_Area",
"field_type": "Real",
"field_type_code": "2",
"field_type_code": 2,
"field_width": 19,
"field_precision": 11
},
{
"field_name": "Area_km2",
"field_type": "Real",
"field_type_code": "2",
"field_type_code": 2,
"field_width": 19,
"field_precision": 11
},
{
"field_name": "OBJECTID",
"field_type": "Integer64",
"field_type_code": "12",
"field_type_code": 12,
"field_width": 10
},
{
"field_name": "gridcode",
"field_type": "Integer64",
"field_type_code": "12",
"field_type_code": 12,
"field_width": 10
},
{
"field_name": "Shape_Leng",
"field_type": "Real",
"field_type_code": "2",
"field_type_code": 2,
"field_width": 19,
"field_precision": 11
}
Expand Down
6 changes: 3 additions & 3 deletions tests/data/json/geographicraster.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"name": "Band_1",
"variable_name": "variablename",
"variable_unit": "variableunit",
"no_data_value": "-3.4028234663852886E+38",
"maximum_value": "6.9103932008822E-310",
"no_data_value": -3.4028234663852886E+38,
"maximum_value": 6.9103932008822E-310,
"comment": "comment",
"method": "method",
"minimum_value": "2.67393466E-316"
"minimum_value": 2.67393466E-316
},
"spatial_reference": {
"type": "box",
Expand Down
12 changes: 6 additions & 6 deletions tests/data/metadata/geographicfeature_meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<hsterms:fieldType>Real</hsterms:fieldType>
<hsterms:fieldName>Shape_Leng</hsterms:fieldName>
<hsterms:fieldWidth rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">19</hsterms:fieldWidth>
<hsterms:fieldTypeCode>2</hsterms:fieldTypeCode>
<hsterms:fieldTypeCode rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2</hsterms:fieldTypeCode>
<hsterms:fieldPrecision rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">11</hsterms:fieldPrecision>
</rdf:Description>
</hsterms:FieldInformation>
Expand All @@ -30,7 +30,7 @@
<dc:subject>fdas</dc:subject>
<hsterms:FieldInformation>
<rdf:Description>
<hsterms:fieldTypeCode>12</hsterms:fieldTypeCode>
<hsterms:fieldTypeCode rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">12</hsterms:fieldTypeCode>
<hsterms:fieldName>OBJECTID</hsterms:fieldName>
<hsterms:fieldType>Integer64</hsterms:fieldType>
<hsterms:fieldWidth rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">10</hsterms:fieldWidth>
Expand All @@ -52,7 +52,7 @@
<hsterms:FieldInformation>
<rdf:Description>
<hsterms:fieldName>Shape_Area</hsterms:fieldName>
<hsterms:fieldTypeCode>2</hsterms:fieldTypeCode>
<hsterms:fieldTypeCode rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2</hsterms:fieldTypeCode>
<hsterms:fieldWidth rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">19</hsterms:fieldWidth>
<hsterms:fieldType>Real</hsterms:fieldType>
<hsterms:fieldPrecision rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">11</hsterms:fieldPrecision>
Expand Down Expand Up @@ -95,15 +95,15 @@
<hsterms:FieldInformation>
<rdf:Description>
<hsterms:fieldType>Integer64</hsterms:fieldType>
<hsterms:fieldTypeCode>12</hsterms:fieldTypeCode>
<hsterms:fieldTypeCode rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">12</hsterms:fieldTypeCode>
<hsterms:fieldWidth rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">10</hsterms:fieldWidth>
<hsterms:fieldName>Id</hsterms:fieldName>
</rdf:Description>
</hsterms:FieldInformation>
<dc:subject>asdf</dc:subject>
<hsterms:FieldInformation>
<rdf:Description>
<hsterms:fieldTypeCode>2</hsterms:fieldTypeCode>
<hsterms:fieldTypeCode rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2</hsterms:fieldTypeCode>
<hsterms:fieldType>Real</hsterms:fieldType>
<hsterms:fieldWidth rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">19</hsterms:fieldWidth>
<hsterms:fieldPrecision rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">11</hsterms:fieldPrecision>
Expand All @@ -112,7 +112,7 @@
</hsterms:FieldInformation>
<hsterms:FieldInformation>
<rdf:Description>
<hsterms:fieldTypeCode>12</hsterms:fieldTypeCode>
<hsterms:fieldTypeCode rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">12</hsterms:fieldTypeCode>
<hsterms:fieldWidth rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">10</hsterms:fieldWidth>
<hsterms:fieldType>Integer64</hsterms:fieldType>
<hsterms:fieldName>gridcode</hsterms:fieldName>
Expand Down
6 changes: 3 additions & 3 deletions tests/data/metadata/geographicraster_meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
</dc:coverage>
<hsterms:BandInformation>
<rdf:Description>
<hsterms:minimumValue>2.67393466E-316</hsterms:minimumValue>
<hsterms:minimumValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.67393466E-316</hsterms:minimumValue>
<hsterms:variableUnit>variableunit</hsterms:variableUnit>
<hsterms:comment>comment</hsterms:comment>
<hsterms:maximumValue>6.9103932008822E-310</hsterms:maximumValue>
<hsterms:maximumValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">6.9103932008822E-310</hsterms:maximumValue>
<hsterms:variableName>variablename</hsterms:variableName>
<hsterms:name>Band_1</hsterms:name>
<hsterms:noDataValue>-3.4028234663852886E+38</hsterms:noDataValue>
<hsterms:noDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-3.4028234663852886E+38</hsterms:noDataValue>
<hsterms:method>method</hsterms:method>
</rdf:Description>
</hsterms:BandInformation>
Expand Down
14 changes: 7 additions & 7 deletions tests/data/metadata/timeseries_meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<hsterms:variable>
<rdf:Description>
<hsterms:VariableCode>USU36</hsterms:VariableCode>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">-9999</hsterms:NoDataValue>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-9999</hsterms:NoDataValue>
<hsterms:VariableName>Temperature</hsterms:VariableName>
<hsterms:VariableType>Water Quality</hsterms:VariableType>
<hsterms:Speciation>Not Applicable</hsterms:Speciation>
Expand Down Expand Up @@ -99,7 +99,7 @@
<hsterms:variable>
<rdf:Description>
<hsterms:VariableCode>USU36</hsterms:VariableCode>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">-9999</hsterms:NoDataValue>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-9999</hsterms:NoDataValue>
<hsterms:VariableName>Temperature</hsterms:VariableName>
<hsterms:VariableType>Water Quality</hsterms:VariableType>
<hsterms:Speciation>Not Applicable</hsterms:Speciation>
Expand Down Expand Up @@ -146,7 +146,7 @@
<hsterms:VariableType>Water Quality</hsterms:VariableType>
<hsterms:VariableName>Temperature</hsterms:VariableName>
<hsterms:VariableCode>USU36</hsterms:VariableCode>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">-9999</hsterms:NoDataValue>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-9999</hsterms:NoDataValue>
</rdf:Description>
</hsterms:variable>
<hsterms:SampleMedium>Surface Water</hsterms:SampleMedium>
Expand Down Expand Up @@ -178,7 +178,7 @@
<hsterms:VariableType>Water Quality</hsterms:VariableType>
<hsterms:Speciation>Not Applicable</hsterms:Speciation>
<hsterms:VariableCode>USU36</hsterms:VariableCode>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">-9999</hsterms:NoDataValue>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-9999</hsterms:NoDataValue>
<hsterms:VariableName>Temperature</hsterms:VariableName>
</rdf:Description>
</hsterms:variable>
Expand Down Expand Up @@ -250,7 +250,7 @@
<hsterms:Speciation>Not Applicable</hsterms:Speciation>
<hsterms:VariableType>Water Quality</hsterms:VariableType>
<hsterms:VariableCode>USU36</hsterms:VariableCode>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">-9999</hsterms:NoDataValue>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-9999</hsterms:NoDataValue>
<hsterms:VariableName>Temperature</hsterms:VariableName>
</rdf:Description>
</hsterms:variable>
Expand Down Expand Up @@ -330,7 +330,7 @@
<hsterms:variable>
<rdf:Description>
<hsterms:VariableCode>USU36</hsterms:VariableCode>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">-9999</hsterms:NoDataValue>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-9999</hsterms:NoDataValue>
<hsterms:VariableName>Temperature</hsterms:VariableName>
<hsterms:VariableType>Water Quality</hsterms:VariableType>
<hsterms:Speciation>Not Applicable</hsterms:Speciation>
Expand Down Expand Up @@ -383,7 +383,7 @@
<hsterms:Speciation>Not Applicable</hsterms:Speciation>
<hsterms:VariableType>Water Quality</hsterms:VariableType>
<hsterms:VariableCode>USU36</hsterms:VariableCode>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">-9999</hsterms:NoDataValue>
<hsterms:NoDataValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-9999</hsterms:NoDataValue>
<hsterms:VariableName>Temperature</hsterms:VariableName>
</rdf:Description>
</hsterms:variable>
Expand Down