Skip to content

Commit

Permalink
Merge pull request #104 from slacgismo/dev
Browse files Browse the repository at this point in the history
New development work
  • Loading branch information
bmeyers authored Sep 26, 2023
2 parents ccfc528 + 8c66bab commit 14af303
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 112 deletions.
10 changes: 4 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ matplotlib
seaborn
requests
pvlib
cvxpy>=1.1.0
cvxpy>=1.3.2
cmake
pykml
haversine
boto3
sig-decomp
# I suggest using the MOSEK convex solver with cvxpy, if possible. For additional information about setting up MOSEK,
# see here: https://docs.mosek.com/8.1/pythonapi/install-interface.html. A license is required to use this software.
# Academic license info: https://www.mosek.com/products/academic-licenses/
# Trial commercial license info: https://www.mosek.com/products/trial/
Mosek
osqp
clarabel
qss
26 changes: 13 additions & 13 deletions solardatatools/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def run_pipeline(
daytime_threshold=0.005,
units="W",
solver="QSS",
solver_convex="OSQP",
solver_convex="CLARABEL",
reset=True,
):
if solver == "MOSEK":
Expand Down Expand Up @@ -469,7 +469,9 @@ def run_pipeline(
)

# Update daytime detection based on cleaned up data
self.daytime_analysis.calculate_times(self.filled_data_matrix, solver=solver_convex)
self.daytime_analysis.calculate_times(
self.filled_data_matrix, solver=solver_convex
)
self.boolean_masks.daytime = self.daytime_analysis.sunup_mask_estimated
######################################################################
# Process Extra columns
Expand Down Expand Up @@ -891,7 +893,7 @@ def capacity_clustering(
self.filled_data_matrix,
filter=self.daily_flags.no_errors,
quantile=1.00,
w1=40e-6, # scaled weights for QSS
w1=40e-6, # scaled weights for QSS
w2=6561e-6,
solver=solver,
)
Expand All @@ -918,7 +920,7 @@ def capacity_clustering(
gridspec_kw={"height_ratios": [4, 1]},
)
ax[0].plot(xs, s1, label="capacity change detector")
ax[0].plot(xs, s1+s2+s3, label="signal model")
ax[0].plot(xs, s1 + s2 + s3, label="signal model")
ax[0].plot(xs, metric, alpha=0.3, label="measured signal")
ax[0].legend()
ax[0].set_title("Detection of system capacity changes")
Expand All @@ -929,7 +931,7 @@ def capacity_clustering(
else:
fig, ax = plt.subplots(nrows=1, figsize=figsize)
ax.plot(xs, s1, label="capacity change detector")
ax.plot(xs, s1+s2+s3, label="signal model")
ax.plot(xs, s1 + s2 + s3, label="signal model")
ax.plot(xs, metric, alpha=0.3, label="measured signal")
ax.legend()
ax.set_title("Detection of system capacity changes")
Expand All @@ -947,8 +949,8 @@ def auto_fix_time_shifts(
solver=None,
):
def max_min_scale(signal):
maximum = np.nanquantile(signal, .95)
minimum = np.nanquantile(signal, .05)
maximum = np.nanquantile(signal, 0.95)
minimum = np.nanquantile(signal, 0.05)
return (signal - minimum) / (maximum - minimum), minimum, maximum

def rescale_signal(signal, minimum, maximum):
Expand Down Expand Up @@ -979,7 +981,7 @@ def rescale_signal(signal, minimum, maximum):
threshold=threshold,
periodic_detector=periodic_detector,
solver=solver,
sum_card=False
sum_card=False,
)

if solver == "QSS":
Expand All @@ -994,7 +996,7 @@ def rescale_signal(signal, minimum, maximum):
threshold=threshold,
periodic_detector=periodic_detector,
solver=solver,
sum_card=True
sum_card=True,
)
else:
# If solver is QSS, run with nonconvex formulation again
Expand All @@ -1008,14 +1010,12 @@ def rescale_signal(signal, minimum, maximum):
threshold=threshold,
periodic_detector=periodic_detector,
solver=solver,
sum_card=True
sum_card=True,
)

# Scale data back
self.filled_data_matrix = rescale_signal(
self.time_shift_analysis.corrected_data,
min_metric,
max_metric
self.time_shift_analysis.corrected_data, min_metric, max_metric
)
if len(self.time_shift_analysis.index_set) == 0:
self.time_shifts = False
Expand Down
Loading

0 comments on commit 14af303

Please sign in to comment.