Skip to content

Commit d792e97

Browse files
author
kmilner
committed
bugfix
1 parent a95cb92 commit d792e97

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/scratch/kevin/simulators/slipRateVar/SingleLocSlipRateVarPlot.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,26 @@ public static void main(String[] args) throws IOException {
8787
List<PlotCurveCharacterstics> chars = new ArrayList<>();
8888

8989
int prevIndex = 0;
90+
double prevLastSlip = 0d;
9091
for (double startTime=firstEventTime; startTime+windowSize<lastEventTime; startTime+=windowSize) {
9192
double endTime = startTime + windowSize;
9293
DiscretizedFunc subFunc = new ArbitrarilyDiscretizedFunc();
93-
double slipAtStart = 0d;
94+
double slipAtStart = prevLastSlip;
9495
for (int i=prevIndex; i<cumulativeSlipFunc.size(); i++) {
9596
double time = cumulativeSlipFunc.getX(i);
9697
if (time < startTime)
9798
continue;
9899
if (time > endTime)
99100
break;
100101
prevIndex = i;
101-
if (slipAtStart==0 && startTime > firstEventTime)
102-
slipAtStart = cumulativeSlipFunc.getY(i-1);
103-
double slip = cumulativeSlipFunc.getY(i) - slipAtStart;
102+
double slip = cumulativeSlipFunc.getY(i);
103+
prevLastSlip = slip;
104+
double relSlip = slip - slipAtStart;
104105
double relTime = time - startTime;
105106
Preconditions.checkState(relTime >= 0d);
106-
subFunc.set(relTime, slip);
107+
subFunc.set(relTime, relSlip);
107108
}
109+
subFunc.set(0d, slipAtStart);
108110
funcs.add(subFunc);
109111
chars.add(new PlotCurveCharacterstics(PlotLineType.SOLID, 1f, Color.GRAY));
110112
}
@@ -116,7 +118,7 @@ public static void main(String[] args) throws IOException {
116118
funcs.add(oneToOne);
117119
chars.add(new PlotCurveCharacterstics(PlotLineType.DASHED, 1f, Color.BLACK));
118120

119-
PlotSpec spec = new PlotSpec(funcs, chars, middle.getParentSectionName(), "Windowed Time (years)", "Cumulative Slip (mm/yr)");
121+
PlotSpec spec = new PlotSpec(funcs, chars, middle.getParentSectionName(), "Windowed Time (years)", "Cumulative Slip (m)");
120122

121123
HeadlessGraphPanel gp = PlotUtils.initHeadless();
122124

0 commit comments

Comments
 (0)