Skip to content

Commit 6f2b2a3

Browse files
authored
Merge pull request #34 from DataIntegrationGroup/dev/jab
2 parents e50dce7 + 3e1a211 commit 6f2b2a3

7 files changed

Lines changed: 111 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## Unrelease
8+
9+
10+
## 0.7.0
11+
12+
### Added
13+
14+
- CHANGELOG.md to document changes to the DIE
15+
- ppb to mg/L unit conversion
16+
17+
### Changed
18+
19+
- Report analyte sources as `False` if source does not have measurements for those analytes
20+
- e.g. BoR has analyte measurements, but does not have `carbonate` measurements, so if the user invokes `die weave carbonate ...` Config will print to the command line `user_source_bor: False` even if the user does not specify `--no-bor`
21+
22+
### Fixed
23+
24+
- Decreased NMBGMR chunk size from 100 to 10 to prevent ReadTimeoutErrors from occurring while gathering water level data
25+
26+
## 0.6.0 - 2025-02-14
27+
28+
### Added
29+
30+
- CABQ water level data
31+
- EBID water level data
32+
- `source_parameter_name`, `source_parameter_units`, and `conversion_factor` to all time series tables
33+
- `well_depth`, `well_depth_units`, and `formation` back to NMBGMR summary and site tables
34+
- UNIT_CONVERSIONS.md to document unit conversions done by the DIE

README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,19 @@ where `{parameter}` is the name of the parameter whose data is to be retrieved,
5454

5555

5656
#### Available Parameters
57-
The following parameters are currently available for retrieval:
58-
- waterlevels
59-
- arsenic
60-
- bicarbonate
61-
- calcium
62-
- carbonate
63-
- chloride
64-
- fluoride
65-
- magnesium
66-
- nitrate
67-
- ph
68-
- potassium
69-
- silica
70-
- sodium
71-
- sulfate
72-
- tds
73-
- uranium
57+
| | waterlevels | arsenic | bicarbonate | calcium | carbonate | chloride | fluoride | magnesium | nitrate | ph | potassium | silica | sodium | sulfate | tds | uranium |
58+
| -------------------------- | ----------- | ------- | ----------- | ------- | --------- | -------- | -------- | --------- | ------- | --- | --------- | ------ | ------ | ------- | --- | ------- |
59+
| **bernco** | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
60+
| **bor** | - | X | - | X | - | X | X | X | X | X | X | X | X | X | X | X |
61+
| **cabq** | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
62+
| **ebid** | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
63+
| **nmbgmr-amp** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
64+
| **nmed-dwb** | - | X | X | X | - | X | X | X | X | X | X | X | X | X | X | X |
65+
| **nmose-isc-seven-rivers** | X | - | X | X | - | X | X | X | X | X | X | X | X | X | X | - |
66+
| **nmose-roswell** | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
67+
| **nwis** | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
68+
| **pvacd** | X | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
69+
| **wqp** | - | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
7470

7571
### Output
7672
The `--output` option is required and used to set the output type:

backend/connectors/nmbgmr/source.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _make_url(endpoint):
5252

5353
class NMBGMRSiteSource(BaseSiteSource):
5454
transformer_klass = NMBGMRSiteTransformer
55-
chunk_size = 100
55+
chunk_size = 10
5656
bounding_polygon = NM_STATE_BOUNDING_POLYGON
5757

5858
def __repr__(self):
@@ -94,6 +94,9 @@ def get_records(self):
9494
site["properties"]["formation"] = well_data["formation"]
9595
site["properties"]["well_depth"] = well_data["well_depth_ftbgs"]
9696
site["properties"]["well_depth_units"] = FEET
97+
# site["properties"]["formation"] = None
98+
# site["properties"]["well_depth"] = None
99+
# site["properties"]["well_depth_units"] = FEET
97100

98101
return sites
99102

backend/constants.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
# ===============================================================================
1616

17-
TDS = "tds"
17+
WATERLEVELS = "waterlevels"
1818
ARSENIC = "arsenic"
1919
BICARBONATE = "bicarbonate"
2020
CALCIUM = "calcium"
@@ -23,20 +23,19 @@
2323
FLUORIDE = "fluoride"
2424
MAGNESIUM = "magnesium"
2525
NITRATE = "nitrate"
26+
PH = "ph"
2627
POTASSIUM = "potassium"
2728
SILICA = "silica"
2829
SODIUM = "sodium"
2930
SULFATE = "sulfate"
31+
TDS = "tds"
3032
URANIUM = "uranium"
31-
WATERLEVELS = "waterlevels"
32-
33-
34-
PH = "ph"
3533

3634

3735
MILLIGRAMS_PER_LITER = "mg/L"
3836
MICROGRAMS_PER_LITER = "ug/L"
3937
PARTS_PER_MILLION = "ppm"
38+
PARTS_PER_BILLION = "ppb"
4039
TONS_PER_ACRE_FOOT = "tons/ac ft"
4140
FEET = "ft"
4241
METERS = "m"
@@ -65,13 +64,13 @@
6564
FLUORIDE,
6665
MAGNESIUM,
6766
NITRATE,
67+
PH,
6868
POTASSIUM,
6969
SILICA,
7070
SODIUM,
7171
SULFATE,
7272
TDS,
7373
URANIUM,
74-
PH,
7574
]
7675
)
7776

backend/transformer.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from backend.constants import (
2424
MILLIGRAMS_PER_LITER,
2525
PARTS_PER_MILLION,
26+
PARTS_PER_BILLION,
2627
FEET,
2728
METERS,
2829
TONS_PER_ACRE_FOOT,
@@ -181,6 +182,7 @@ def convert_units(
181182
mgl = MILLIGRAMS_PER_LITER.lower()
182183
ugl = MICROGRAMS_PER_LITER.lower()
183184
ppm = PARTS_PER_MILLION.lower()
185+
ppb = PARTS_PER_BILLION.lower()
184186
tpaf = TONS_PER_ACRE_FOOT.lower()
185187
ft = FEET.lower()
186188
m = METERS.lower()
@@ -210,7 +212,7 @@ def convert_units(
210212
conversion_factor = 0.004427
211213
elif input_units == "pci/l":
212214
conversion_factor = 0.00149
213-
elif input_units == ugl:
215+
elif input_units in (ugl, ppb):
214216
conversion_factor = 0.001
215217
elif input_units == tpaf:
216218
conversion_factor = 735.47
@@ -239,7 +241,7 @@ def convert_units(
239241
return input_value, conversion_factor, warning
240242

241243

242-
def standardize_datetime(dt):
244+
def standardize_datetime(dt, record_id):
243245
if isinstance(dt, tuple):
244246
dt = [di for di in dt if di is not None]
245247
dt = " ".join(dt)
@@ -274,7 +276,7 @@ def standardize_datetime(dt):
274276
except ValueError as e:
275277
pass
276278
else:
277-
raise ValueError(f"Failed to parse datetime {dt}")
279+
raise ValueError(f"Failed to parse datetime {dt} for {record_id}")
278280

279281
if fmt == "%Y-%m-%d":
280282
return dt.strftime("%Y-%m-%d"), ""
@@ -405,13 +407,13 @@ def do_transform(
405407
# standardize datetime
406408
dt = record.get(DT_MEASURED)
407409
if dt:
408-
d, t = standardize_datetime(dt)
410+
d, t = standardize_datetime(dt, record["id"])
409411
record["date_measured"] = d
410412
record["time_measured"] = t
411413
else:
412414
mrd = record.get("most_recent_datetime")
413415
if mrd:
414-
d, t = standardize_datetime(mrd)
416+
d, t = standardize_datetime(mrd, record["id"])
415417
record["date_measured"] = d
416418
record["time_measured"] = t
417419

@@ -661,7 +663,7 @@ def _transform(self, record, site_record):
661663
rec = {}
662664

663665
if self.config.output_summary:
664-
self._transform_most_recents(record)
666+
self._transform_most_recents(record, site_record.id)
665667

666668
parameter, units = self._get_parameter_name_and_units()
667669
rec.update(
@@ -693,9 +695,9 @@ def _transform(self, record, site_record):
693695
rec.update(source_id)
694696
return rec
695697

696-
def _transform_most_recents(self, record):
698+
def _transform_most_recents(self, record, site_id):
697699
# convert most_recents
698-
dt, tt = standardize_datetime(record["most_recent_datetime"])
700+
dt, tt = standardize_datetime(record["most_recent_datetime"], site_id)
699701
record["most_recent_date"] = dt
700702
record["most_recent_time"] = tt
701703
parameter_name, unit = self._get_parameter_name_and_units()

frontend/cli.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def weave(
255255
config.output_timeseries_separated = timeseries_separated
256256

257257
# sources
258-
if parameter.lower() == "waterlevels":
258+
if parameter == "waterlevels":
259259
config.use_source_bernco = no_bernco
260260
config.use_source_cabq = no_cabq
261261
config.use_source_ebid = no_ebid
@@ -268,7 +268,49 @@ def weave(
268268
config.use_source_bor = False
269269
config.use_source_nmed_dwb = False
270270
config.use_source_wqp = False
271-
else:
271+
272+
elif parameter == "carbonate":
273+
config.use_source_nmbgmr_amp = no_nmbgmr_amp
274+
config.use_source_wqp = no_wqp
275+
276+
config.use_source_bor = False
277+
config.use_source_bernco = False
278+
config.use_source_cabq = False
279+
config.use_source_ebid = False
280+
config.use_source_nmed_dwb = False
281+
config.use_source_nmose_isc_seven_rivers = False
282+
config.use_source_nmose_roswell = False
283+
config.use_source_nwis = False
284+
config.use_source_pvacd = False
285+
286+
elif parameter in ["arsenic", "uranium"]:
287+
config.use_source_bor = no_bor
288+
config.use_source_nmbgmr_amp = no_nmbgmr_amp
289+
config.use_source_nmed_dwb = no_nmed_dwb
290+
config.use_source_wqp = no_wqp
291+
292+
config.use_source_bernco = False
293+
config.use_source_cabq = False
294+
config.use_source_ebid = False
295+
config.use_source_nmose_isc_seven_rivers = False
296+
config.use_source_nmose_roswell = False
297+
config.use_source_nwis = False
298+
config.use_source_pvacd = False
299+
300+
elif parameter in [
301+
"bicarbonate",
302+
"calcium",
303+
"chloride",
304+
"fluoride",
305+
"magnesium",
306+
"nitrate",
307+
"ph",
308+
"potassium",
309+
"silica",
310+
"sodium",
311+
"sulfate",
312+
"tds",
313+
]:
272314
config.use_source_bor = no_bor
273315
config.use_source_nmbgmr_amp = no_nmbgmr_amp
274316
config.use_source_nmed_dwb = no_nmed_dwb

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.6.0",
24+
version="0.7.0",
2525
author="Jake Ross",
2626
description="New Mexico Water Data Integration Engine",
2727
long_description=long_description,

0 commit comments

Comments
 (0)