1+ # -*- coding: utf-8 -*-
2+ """
3+ Created on Tue Jun 17 09:03:21 2025
4+
5+ @author: smunger
6+
7+ # Interior water levels at Clifton Court reported by SCADA in units of feet NAVD88.,
8+ # These were adjusted to NAVD88 by adding the NGVD29 to NAVD88 conversion of 2.56 ft
9+ # Following the calibration adjustment from survey dated of 4/15/2024
10+ # 0.27 ft is subtracted from the upstream gage (2.57ft-0.27ft)
11+ # 0.22 ft is added to the downstream gage (2.57ft+0.22ft)
12+ # convert to PST
13+
14+ """
15+ import pandas as pd
16+ import matplotlib .pyplot as plt
17+
18+ path_fn = r'\\nasbdo\Modeling_Data\clifton_court\ccf_water_levels_wonderware_2020_2024.csv'
19+
20+
21+ def to_pst (ts ):
22+ """ Convert to PST
23+
24+ Parameters
25+ ----------
26+ infile : str
27+ path to the Wonderware file
28+ """
29+ pst = 'ETC/GMT+8'
30+ pdt = 'US/Pacific'
31+
32+
33+ ts .index = ts .index .tz_localize (pdt , nonexistent = 'shift_forward' ,ambiguous = "infer" ).tz_convert (pst )
34+ ts .index = ts .index .floor ("1min" )
35+ ts = ts [~ ts .index .duplicated (keep = "first" )]
36+ ts .index = ts .index .tz_localize (None )
37+ return ts
38+
39+
40+
41+ ts_raw = pd .read_csv (path_fn ,index_col = 0 ,parse_dates = [0 ],na_values = ["(null)" ])
42+ ts = to_pst (ts_raw )
43+ ts .columns = ["ccf_up" ,"ccf_down" ]
44+
45+ # make datum and instrument correction
46+ ts ['ccf_up' ] = ts ['ccf_up' ]+ 2.57 - 0.27
47+ ts ['ccf_down' ] = ts ['ccf_down' ]+ 2.57 + 0.22
48+
49+ # Remove outliers -- pretty agressively.
50+ ts ['ccf_up' ] = ts ['ccf_up' ].mask ((ts .ccf_up > 8.5 ) | (ts .ccf_up < - 0.5 ))
51+ ts ['ccf_down' ] = ts ['ccf_down' ].mask ((ts .ccf_down > 4.5 ) | (ts .ccf_down < 0 ))
52+
53+ ts .to_csv ("dwr_ccf_waterlevels_NAVD88_2020_2024.csv" )
54+ ts .plot ()
55+ plt .show ()
0 commit comments