Skip to content

Commit cf6960a

Browse files
authored
Merge pull request #33 from DataIntegrationGroup/pre-production
Pre production
2 parents 4012bea + e50dce7 commit cf6960a

6 files changed

Lines changed: 41 additions & 23 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Data comes from the following sources. We are continuously adding new sources as
2424
- Available data: `water quality`
2525
- [City of Albuquerque (CABQ)](https://st2.newmexicowaterdata.org/FROST-Server/v1.1/Locations?$filter=properties/agency%20eq%20%27CABQ%27)
2626
- Available data: `water levels`
27-
- Note: the elevation data is the top of casing, not ground surface elevation
2827
- [Elephant Butte Irrigation District (EBID)](https://st2.newmexicowaterdata.org/FROST-Server/v1.1/Locations?$filter=properties/agency%20eq%20%27EBID%27)
2928
- Available data: `water levels`
3029
- [New Mexico Bureau of Geology and Mineral Resources (NMBGMR) Aquifer Mapping Program (AMP)](https://waterdata.nmt.edu/)
@@ -124,7 +123,7 @@ A log of the inputs and processes, called `die.log`, is also saved to the output
124123
| most_recent_value | value of the most recent record | float | Y |
125124
| most_recent_units | units of the most recent record | string | Y |
126125

127-
<sup>* elevation at top of casing for CABQ</sup>
126+
<sup>*CABQ elevation is calculated as [elevation at top of casing] - [stickup height]; if stickup height < 0 the measuring point is assumed to be beneath the ground surface</sup>
128127

129128
#### Sites Table
130129

@@ -145,7 +144,7 @@ A log of the inputs and processes, called `die.log`, is also saved to the output
145144
| aquifer | aquifer from which the well draws water | string | N |
146145
| well_depth | depth of well | float | N |
147146

148-
<sup>** elevation at top of casing for CABQ</sup>
147+
<sup>**CABQ elevation is calculated as [elevation at top of casing] - [stickup height]; if stickup height < 0 the measuring point is assumed to be beneath the ground surface</sup>
149148

150149
#### Time Series Table(s)
151150

backend/connectors/nmbgmr/source.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,18 @@ def get_records(self):
8484
sites = self._execute_json_request(
8585
_make_url("locations"), params, tag="features", timeout=30
8686
)
87-
return sites
87+
for site in sites:
88+
print(f"Obtaining well data for {site['properties']['point_id']}")
89+
well_data = self._execute_json_request(
90+
_make_url("wells"),
91+
params={"pointid": site["properties"]["point_id"]},
92+
tag="",
93+
)
94+
site["properties"]["formation"] = well_data["formation"]
95+
site["properties"]["well_depth"] = well_data["well_depth_ftbgs"]
96+
site["properties"]["well_depth_units"] = FEET
8897

89-
# loop through the responses and add well information for each location
90-
# this may be slow because of the number of sites that need to be queried
91-
# but it is necessary to get the well information. With further
92-
# development, this could be faster if one can batch the requests
93-
# to /wells
94-
# for site in sites:
95-
# well_info = self._execute_json_request(
96-
# _make_url("/wells"),
97-
# params={"pointid": site["properties"]["point_id"]},
98-
# tag="",
99-
# )
100-
# site["properties"]["formation"] = well_info["formation"]
101-
# site["properties"]["well_depth"] = well_info["well_depth_ftbgs"]
102-
# site["properties"]["well_depth_units"] = "ft"
98+
return sites
10399

104100

105101
class NMBGMRAnalyteSource(BaseAnalyteSource):

backend/connectors/nmbgmr/transformer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def _transform(self, record):
3838
"vertical_datum": props["altitude_datum"],
3939
"usgs_site_id": props["site_id"],
4040
"alternate_site_id": props["alternate_site_id"],
41-
# "formation": props["formation"],
42-
# "well_depth": props["well_depth"]["value"],
43-
# "well_depth_units": props["well_depth"]["units"],
41+
"formation": props["formation"],
42+
"well_depth": props["well_depth"],
43+
"well_depth_units": props["well_depth_units"],
4444
}
4545
return rec
4646

backend/connectors/st2/transformer.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414
# limitations under the License.
1515
# ===============================================================================
1616
import pprint
17+
import sys
1718

1819
from backend.connectors.st_connector import STSiteTransformer
1920
from backend.record import SiteRecord, WaterLevelRecord
20-
from backend.transformer import BaseTransformer, WaterLevelTransformer, SiteTransformer
21+
from backend.transformer import (
22+
BaseTransformer,
23+
WaterLevelTransformer,
24+
SiteTransformer,
25+
convert_units,
26+
)
2127

2228

2329
class PVACDSiteTransformer(STSiteTransformer):
@@ -58,6 +64,19 @@ class EBIDSiteTransformer(STSiteTransformer):
5864
class CABQSiteTransformer(STSiteTransformer):
5965
source_id = "ST2/CABQ"
6066

67+
def _transform_elevation(self, elevation, record):
68+
if elevation:
69+
try:
70+
thing = record.things._entities[0]
71+
stickup_height_ft = thing._properties["stickup_height"]["value"]
72+
stickup_height_m, conversion_factor, warning_msg = convert_units(
73+
stickup_height_ft, "ft", "m", "stickup_height", "stickup_height"
74+
)
75+
elevation = elevation - stickup_height_m
76+
except KeyError:
77+
self.config.warn(f"No stickup_height for {record.id}")
78+
return elevation
79+
6180

6281
# class ST2WaterLevelTransformer(WaterLevelTransformer):
6382
# source_tag = "ST2"

backend/connectors/st_connector.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ class STSiteTransformer(SiteTransformer):
148148
source_id: str
149149
check_contained = False # API returns only records within the bounds
150150

151+
def _transform_elevation(self, elevation, record):
152+
return elevation
153+
151154
def _transform_hook(self, rec):
152155
return rec
153156

@@ -166,6 +169,7 @@ def _transform(self, record):
166169
ele = None
167170
if len(coordinates) == 3:
168171
ele = coordinates[2]
172+
ele = self._transform_elevation(ele, record)
169173

170174
rec = {
171175
"source": self.source_id,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
setup(
2323
name="nmuwd",
24-
version="0.5.2",
24+
version="0.6.0",
2525
author="Jake Ross",
2626
description="New Mexico Water Data Integration Engine",
2727
long_description=long_description,

0 commit comments

Comments
 (0)