Skip to content

Commit 09c94c7

Browse files
committed
feat: added additional thing_types, PS, ES, M
1 parent dae3738 commit 09c94c7

2 files changed

Lines changed: 51 additions & 9 deletions

File tree

core/lexicon.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
{"category": "thing_type", "term": "water well", "definition": "a hole drill into the ground to access groundwater"},
3333
{"category": "thing_type", "term": "spring", "definition": "a natural discharge of groundwater at the surface"},
34+
{"category": "thing_type", "term": "perennial stream", "definition": "that has a continuous flow of water throughout the year, even during drier periods."},
35+
{"category": "thing_type", "term": "ephemeral stream", "definition": "a stream that flows only briefly during and after precipitation events"},
36+
{"category": "thing_type", "term": "meteorological station", "definition": "a station that measures the weather conditions at a particular location"},
3437

3538
{"category": "level_status", "term": "dry", "definition": "well is dry"},
3639
{"category": "level_status", "term": "normal", "definition": "normal well water level status"},

transfers/transfer2.py

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ def transfer_water_levels(session):
200200

201201
ADDED = []
202202

203-
204-
def transfer_springs(session, limit=None):
203+
def transfer_thing(session, site_type, make_payload, limit=None):
205204
ldf = pd.read_csv("./data/location.csv")
206-
ldf = ldf[ldf["SiteType"] == "SP"]
205+
ldf = ldf[ldf["SiteType"] == site_type]
207206
ldf = ldf[ldf["Easting"].notna() & ldf["Northing"].notna()]
208207
n = len(ldf)
209208
start_time = time.time()
@@ -223,11 +222,7 @@ def transfer_springs(session, limit=None):
223222

224223
spring = add_thing(
225224
session,
226-
{
227-
"name": row.PointID,
228-
"thing_type": "spring",
229-
"release_status": "public" if row.PublicRelease else "private",
230-
},
225+
make_payload(row),
231226
)
232227
assoc = LocationThingAssociation()
233228

@@ -236,6 +231,47 @@ def transfer_springs(session, limit=None):
236231
session.add(assoc)
237232

238233

234+
def transfer_springs(session, limit=None):
235+
def make_payload(row):
236+
return {
237+
"name": row.PointID,
238+
"thing_type": "spring",
239+
"release_status": "public" if row.PublicRelease else "private",
240+
}
241+
242+
transfer_thing(session, "SP", make_payload, limit)
243+
244+
245+
def transfer_perennial_stream(session, limit=None):
246+
def make_payload(row):
247+
return {
248+
"name": row.PointID,
249+
"thing_type": "perennial stream",
250+
"release_status": "public" if row.PublicRelease else "private",
251+
}
252+
transfer_thing(session, "PS", make_payload, limit)
253+
254+
255+
def transfer_ephemeral_stream(session, limit=None):
256+
def make_payload(row):
257+
return {
258+
"name": row.PointID,
259+
"thing_type": "ephemeral stream",
260+
"release_status": "public" if row.PublicRelease else "private",
261+
}
262+
transfer_thing(session, "ES", make_payload, limit)
263+
264+
265+
def transfer_met(session, limit=None):
266+
def make_payload(row):
267+
return {
268+
"name": row.PointID,
269+
"thing_type": "meteorological station",
270+
"release_status": "public" if row.PublicRelease else "private",
271+
}
272+
transfer_thing(session, "M", make_payload, limit)
273+
274+
239275
def transfer_wells(session, limit=None):
240276
wdf = pd.read_csv("./data/welldata.csv")
241277
ldf = pd.read_csv("./data/location.csv")
@@ -356,7 +392,10 @@ def transfer_wellscreens(session, limit=None):
356392
with session_ctx() as sess:
357393
transfer_wells(sess, 1000)
358394
transfer_springs(sess, limit=1000)
395+
transfer_perennial_stream(sess)
396+
transfer_ephemeral_stream(sess)
397+
transfer_met(sess)
359398
# transfer_wellscreens(sess)
360-
transfer_water_levels(sess)
399+
# transfer_water_levels(sess)
361400

362401
# ============= EOF =============================================

0 commit comments

Comments
 (0)