Skip to content
Closed
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
49 changes: 25 additions & 24 deletions core/lexicon.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{"name": "field_contact_role", "description": null},
{"name": "geochronology", "description": null},
{"name": "horizontal_datum", "description": null},
{"name": "level_status", "description": null},
{"name": "activity_status", "description": null},
{"name": "measurement_method", "description": null},
{"name": "monitoring_status", "description": null},
{"name": "observed_property", "description": null},
Expand Down Expand Up @@ -284,29 +284,30 @@
{"categories": ["thing_type"], "term": "perennial stream", "definition": "that has a continuous flow of water throughout the year, even during drier periods."},
{"categories": ["thing_type"], "term": "ephemeral stream", "definition": "a stream that flows only briefly during and after precipitation events"},
{"categories": ["thing_type"], "term": "meteorological station", "definition": "a station that measures the weather conditions at a particular location"},
{"categories": ["level_status"], "term": "Water level affected by atmospheric pressure", "definition": "Water level affected by atmospheric pressure"},
{"categories": ["level_status"], "term": "Water level was frozen (no level recorded).", "definition": "Water level was frozen (no level recorded)."},
{"categories": ["level_status"], "term": "Site was dry", "definition": "Site was dry"},
{"categories": ["level_status"], "term": "Site was flowing recently.", "definition": "Site was flowing recently."},
{"categories": ["level_status"], "term": "Site was flowing. Water level or head couldn't be measured w/out additional equipment.", "definition": "Site was flowing. Water level or head couldn't be measured w/out additional equipment."},
{"categories": ["level_status"], "term": "Nearby site that taps the same aquifer was flowing.", "definition": "Nearby site that taps the same aquifer was flowing."},
{"categories": ["level_status"], "term": "Nearby site that taps the same aquifer had been flowing recently.", "definition": "Nearby site that taps the same aquifer had been flowing recently."},
{"categories": ["level_status"], "term": "Recharge water was being injected into the aquifer at this site.", "definition": "Recharge water was being injected into the aquifer at this site."},
{"categories": ["level_status"], "term": "Recharge water was being injected into nearby site that taps the same aquifer.", "definition": "Recharge water was being injected into nearby site that taps the same aquifer."},
{"categories": ["level_status"], "term": "Water was cascading down the inside of the well.", "definition": "Water was cascading down the inside of the well."},
{"categories": ["level_status"], "term": "Water level was affected by brackish or saline water.", "definition": "Water level was affected by brackish or saline water."},
{"categories": ["level_status"], "term": "Well was not in hydraulic contact w/formation (from source other than defined in USGS C714 or C93).", "definition": "Well was not in hydraulic contact w/formation (from source other than defined in USGS C714 or C93)."},
{"categories": ["level_status"], "term": "Measurement was discontinued (no level recorded).", "definition": "Measurement was discontinued (no level recorded)."},
{"categories": ["level_status"], "term": "Obstruction was encountered in the well (no level recorded)", "definition": "Obstruction was encountered in the well (no level recorded)"},
{"categories": ["level_status"], "term": "Site was being pumped", "definition": "Site was being pumped"},
{"categories": ["level_status"], "term": "Site was pumped recently", "definition": "Site was pumped recently"},
{"categories": ["level_status"], "term": "Nearby site that taps the same aquifer was being pumped", "definition": "Nearby site that taps the same aquifer was being pumped"},
{"categories": ["level_status"], "term": "Nearby site that taps the same aquifer was pumped recently", "definition": "Nearby site that taps the same aquifer was pumped recently"},
{"categories": ["level_status"], "term": "Foreign substance present on the water surface", "definition": "Foreign substance present on the water surface"},
{"categories": ["level_status"], "term": "Well was destroyed (no subsequent water levels should be recorded)", "definition": "Well was destroyed (no subsequent water levels should be recorded)"},
{"categories": ["level_status"], "term": "Water level affected by stage in nearby surface-water site", "definition": "Water level affected by stage in nearby surface-water site"},
{"categories": ["level_status"], "term": "Other conditions exist that would affect the level (remarks)", "definition": "Other conditions exist that would affect the level (remarks)"},
{"categories": ["level_status"], "term": "Water level not affected by status", "definition": "Water level not affected by status"},
{"categories": ["activity_status"], "term": "Water level affected by atmospheric pressure", "definition": "Water level affected by atmospheric pressure"},
{"categories": ["activity_status"], "term": "Water level was frozen (no level recorded).", "definition": "Water level was frozen (no level recorded)."},
{"categories": ["activity_status"], "term": "Site was dry", "definition": "Site was dry"},
{"categories": ["activity_status"], "term": "Site was flowing recently.", "definition": "Site was flowing recently."},
{"categories": ["activity_status"], "term": "Site was flowing. Water level or head couldn't be measured w/out additional equipment.", "definition": "Site was flowing. Water level or head couldn't be measured w/out additional equipment."},
{"categories": ["activity_status"], "term": "Nearby site that taps the same aquifer was flowing.", "definition": "Nearby site that taps the same aquifer was flowing."},
{"categories": ["activity_status"], "term": "Nearby site that taps the same aquifer had been flowing recently.", "definition": "Nearby site that taps the same aquifer had been flowing recently."},
{"categories": ["activity_status"], "term": "Recharge water was being injected into the aquifer at this site.", "definition": "Recharge water was being injected into the aquifer at this site."},
{"categories": ["activity_status"], "term": "Recharge water was being injected into nearby site that taps the same aquifer.", "definition": "Recharge water was being injected into nearby site that taps the same aquifer."},
{"categories": ["activity_status"], "term": "Water was cascading down the inside of the well.", "definition": "Water was cascading down the inside of the well."},
{"categories": ["activity_status"], "term": "Water level was affected by brackish or saline water.", "definition": "Water level was affected by brackish or saline water."},
{"categories": ["activity_status"], "term": "Well was not in hydraulic contact w/formation (from source other than defined in USGS C714 or C93).", "definition": "Well was not in hydraulic contact w/formation (from source other than defined in USGS C714 or C93)."},
{"categories": ["activity_status"], "term": "Measurement was discontinued (no level recorded).", "definition": "Measurement was discontinued (no level recorded)."},
{"categories": ["activity_status"], "term": "Obstruction was encountered in the well (no level recorded)", "definition": "Obstruction was encountered in the well (no level recorded)"},
{"categories": ["activity_status"], "term": "Site was being pumped", "definition": "Site was being pumped"},
{"categories": ["activity_status"], "term": "Site was pumped recently", "definition": "Site was pumped recently"},
{"categories": ["activity_status"], "term": "Nearby site that taps the same aquifer was being pumped", "definition": "Nearby site that taps the same aquifer was being pumped"},
{"categories": ["activity_status"], "term": "Nearby site that taps the same aquifer was pumped recently", "definition": "Nearby site that taps the same aquifer was pumped recently"},
{"categories": ["activity_status"], "term": "Foreign substance present on the water surface", "definition": "Foreign substance present on the water surface"},
{"categories": ["activity_status"], "term": "Well was destroyed (no subsequent water levels should be recorded)", "definition": "Well was destroyed (no subsequent water levels should be recorded)"},
{"categories": ["activity_status"], "term": "Water level affected by stage in nearby surface-water site", "definition": "Water level affected by stage in nearby surface-water site"},
{"categories": ["activity_status"], "term": "Other conditions exist that would affect the level (remarks)", "definition": "Other conditions exist that would affect the level (remarks)"},
{"categories": ["activity_status"], "term": "Water level not affected by status", "definition": "Water level not affected by status"},
{"categories": ["activity_status"], "term": "Sample not affected by status", "definition": "Sample not affected by status"},
{"categories": ["status"], "term": "Abandoned", "definition": "Abandoned"},
{"categories": ["status"], "term": "Active, pumping well", "definition": "Active, pumping well"},
{"categories": ["status"], "term": "Destroyed, exists but not usable", "definition": "Destroyed, exists but not usable"},
Expand Down
4 changes: 4 additions & 0 deletions db/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class FieldActivity(Base, AutoBaseMixin, ReleaseMixin):
nullable=False,
comment="The type of activity performed during the field event (e.g., 'groundwater level', 'water chemistry', 'geothermal').",
)
activity_status: Mapped[str] = lexicon_term(
nullable=False,
comment="The status of the activity, whether normal or impacted by external factors like roving bovine, dry well, or equipment failure.",
)
notes: Mapped[str] = mapped_column(
nullable=True,
comment="Notes or comments about the field activity.",
Expand Down
5 changes: 2 additions & 3 deletions db/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class Observation(Base, AutoBaseMixin, ReleaseMixin):
)
observed_property: Mapped[str] = lexicon_term(nullable=False)
value: Mapped[float] = mapped_column(
nullable=True,
nullable=False,
comment="The value of the observation. If a value could not be retrieved then an observation could not be made. The reason for the missing value should be documented in the correct table, like field_activity.",
Comment on lines +59 to +60

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking more about lab data and value being nullable or not, I think it SHOULD be nullable. It's very common for labs to analyze samples, but the chemical is not present at a high enough concentration to be quantified. In these situations, the value is null, but there are lab qualifiers and reporting limits to provide further context.

I agree NULL values can be a pain to work with sometimes, but no result is a result and the Observation table has additional fields to explain why.

)
unit: Mapped[str] = lexicon_term(nullable=False)

Expand All @@ -67,8 +68,6 @@ class Observation(Base, AutoBaseMixin, ReleaseMixin):
info={"unit": "ft"},
)

level_status: Mapped[str] = lexicon_term(nullable=True)

# geothermal
observation_depth: Mapped[float] = mapped_column(
nullable=True,
Expand Down
1 change: 1 addition & 0 deletions schemas/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class FieldActivityResponse(BaseResponseModel):
field_event_id: int
activity_type: str
activity_status: str


class FieldEventResponse(BaseResponseModel):
Expand Down
3 changes: 0 additions & 3 deletions schemas/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class CreateBaseObservation(BaseCreateModel, ValidateObservation):

class CreateGroundwaterLevelObservation(CreateBaseObservation):
measuring_point_height: float
level_status: str


class CreateWaterChemistryObservation(CreateBaseObservation):
Expand All @@ -94,7 +93,6 @@ class UpdateBaseObservation(BaseUpdateModel, ValidateObservation):

class UpdateGroundwaterLevelObservation(UpdateBaseObservation):
measuring_point_height: float | None = None
level_status: str | None = None


class UpdateWaterChemistryObservation(UpdateBaseObservation):
Expand All @@ -119,7 +117,6 @@ class BaseObservationResponse(BaseResponseModel):
class GroundwaterLevelObservationResponse(BaseObservationResponse):
depth_to_water_bgs: float | None
measuring_point_height: float | None
level_status: str | None

@model_validator(mode="before")
def calculate_depth_to_water_bgs(self: Self) -> Self:
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ def groundwater_level_field_activity(field_event):
field_activity = FieldActivity(
field_event_id=field_event.id,
activity_type="groundwater level",
activity_status="Water level not affected by status",
notes="field activity fixture notes",
release_status="draft",
)
Expand All @@ -525,6 +526,7 @@ def water_chemistry_field_activity(field_event):
field_activity = FieldActivity(
field_event_id=field_event.id,
activity_type="water chemistry",
activity_status="Sample not affected by status",
notes="field activity fixture notes",
release_status="draft",
)
Expand Down Expand Up @@ -610,7 +612,6 @@ def groundwater_level_observation(sensor, groundwater_level_sample):
value=10.0,
unit="ft",
measuring_point_height=5.0,
level_status="Water level not affected by status",
)
session.add(observation)
session.commit()
Expand Down
10 changes: 0 additions & 10 deletions tests/test_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def test_add_groundwater_level_observation(groundwater_level_sample, sensor):
"measuring_point_height": 53,
"sample_id": groundwater_level_sample.id,
"sensor_id": sensor.id,
"level_status": "Water level not affected by status",
"observed_property": "groundwater level",
"unit": "ft",
}
Expand All @@ -96,7 +95,6 @@ def test_add_groundwater_level_observation(groundwater_level_sample, sensor):
assert data["value"] == payload["value"]
assert data["measuring_point_height"] == payload["measuring_point_height"]
assert data["sensor_id"] == payload["sensor_id"]
assert data["level_status"] == payload["level_status"]
assert data["observed_property"] == payload["observed_property"]
assert (
data["depth_to_water_bgs"]
Expand Down Expand Up @@ -343,9 +341,6 @@ def test_get_groundwater_level_observations(groundwater_level_observation):
data["items"][0]["release_status"]
== groundwater_level_observation.release_status
)
assert (
data["items"][0]["level_status"] == groundwater_level_observation.level_status
)
assert data["items"][0]["value"] == groundwater_level_observation.value
assert data["items"][0]["unit"] == groundwater_level_observation.unit
assert (
Expand All @@ -357,9 +352,6 @@ def test_get_groundwater_level_observations(groundwater_level_observation):
data["items"][0]["measuring_point_height"]
== groundwater_level_observation.measuring_point_height
)
assert (
data["items"][0]["level_status"] == groundwater_level_observation.level_status
)


def test_get_groundwater_level_observation_by_id(groundwater_level_observation):
Expand All @@ -384,7 +376,6 @@ def test_get_groundwater_level_observation_by_id(groundwater_level_observation):
== groundwater_level_observation.observed_property[colon_index + 1 :]
)
assert data["release_status"] == groundwater_level_observation.release_status
assert data["level_status"] == groundwater_level_observation.level_status
assert data["value"] == groundwater_level_observation.value
assert data["unit"] == groundwater_level_observation.unit
assert (
Expand All @@ -396,7 +387,6 @@ def test_get_groundwater_level_observation_by_id(groundwater_level_observation):
data["measuring_point_height"]
== groundwater_level_observation.measuring_point_height
)
assert data["level_status"] == groundwater_level_observation.level_status


def test_get_groundwater_level_observation_by_id_404_not_found(
Expand Down
Loading