Skip to content

Commit

Permalink
two major changes to time shift detection algorithm: (1) override QSS…
Browse files Browse the repository at this point in the history
… solver to use CLARABEL with the iteratively reweighted problem otherwise stick with MOSEK and (2) default behavior is now to round the estimated corrections to the nearest hour
  • Loading branch information
bmeyers committed Mar 21, 2024
1 parent 41d1c54 commit a9dba82
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion solardatatools/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def run_pipeline(
zero_night=True,
interp_day=True,
fix_shifts=False,
round_shifts_to_hour=True,
density_lower_threshold=0.6,
density_upper_threshold=1.05,
linearity_threshold=0.1,
Expand Down Expand Up @@ -448,6 +449,7 @@ def run_pipeline(
if fix_shifts:
try:
self.auto_fix_time_shifts(
round_shifts_to_hour=round_shifts_to_hour,
w1=w1,
w2=w2,
estimator=solar_noon_estimator,
Expand All @@ -461,6 +463,7 @@ def run_pipeline(
print("Invoking periodic timeshift detector.")
old_analysis = self.time_shift_analysis
self.auto_fix_time_shifts(
round_shifts_to_hour=round_shifts_to_hour,
w1=w1,
w2=w2,
estimator=solar_noon_estimator,
Expand Down Expand Up @@ -1114,6 +1117,7 @@ def capacity_clustering(

def auto_fix_time_shifts(
self,
round_shifts_to_hour=True,
w1=5,
w2=1e5,
estimator="com",
Expand All @@ -1137,7 +1141,11 @@ def rescale_signal(signal, minimum, maximum):
use_ixs = self.daily_flags.clear
else:
use_ixs = self.daily_flags.no_errors

### NEW 3/20/24: overwrite use of qss on this function. Forcing CLARABEL here uses the old-style
# iteratively reweighted model, rather than the nonconvex piecewise constant model. In testing,
# the older model (which is not technically covered by the monograph) seems to work better.
if solver != "MOSEK":
solver = "CLARABEL"
########## Updates to timeshift algorithm, 6/2023 ##########
# If running with any solver other than QSS: solve convex problem
# If running with QSS without a set w1: run w1 meta-opt with convex problem,
Expand All @@ -1155,6 +1163,7 @@ def rescale_signal(signal, minimum, maximum):
periodic_detector=periodic_detector,
solver=solver,
sum_card=False,
round_shifts_to_hour=round_shifts_to_hour,
)

if solver == "QSS":
Expand All @@ -1170,6 +1179,7 @@ def rescale_signal(signal, minimum, maximum):
periodic_detector=periodic_detector,
solver=solver,
sum_card=True,
round_shifts_to_hour=round_shifts_to_hour,
)
else:
# If solver is QSS, run with nonconvex formulation again
Expand All @@ -1184,6 +1194,7 @@ def rescale_signal(signal, minimum, maximum):
periodic_detector=periodic_detector,
solver=solver,
sum_card=True,
round_shifts_to_hour=round_shifts_to_hour,
)

# Scale data back
Expand Down

0 comments on commit a9dba82

Please sign in to comment.