@@ -65,7 +65,7 @@ public class SpectraRatioInversionCalculator {
65
65
66
66
private static final int PARAM_COUNT = 2 ;
67
67
68
- private final double DEFAULT_MOMENT_ERROR = 1.0 ;
68
+ private double momentErrorRange ;
69
69
private final double DEFAULT_LOW_MOMENT = 1.0 ;
70
70
private final double DEFAULT_HIGH_MOMENT = 25.0 ;
71
71
private final double testMomentIncrement = 0.25 ;
@@ -79,11 +79,12 @@ public class SpectraRatioInversionCalculator {
79
79
private MdacCalculator mdacCalculator ;
80
80
81
81
public SpectraRatioInversionCalculator (MdacCalculatorService mdacService , MdacParametersFI mdacFiEntry , MdacParametersPS psRows , MeasuredMwsService fitMwService ,
82
- ReferenceMwParametersService refMwService ) {
82
+ ReferenceMwParametersService refMwService , double momentErrorRange ) {
83
83
this .fitMwService = fitMwService ;
84
84
this .refMwService = refMwService ;
85
85
//We just want the K constant for the given MDAC model so no need for a real moment here
86
86
this .mdacCalculator = mdacService .getMdacCalculator (psRows , mdacFiEntry , DEFAULT_HIGH_MOMENT );
87
+ this .momentErrorRange = momentErrorRange ;
87
88
}
88
89
89
90
public Map <EventPair , List <MomentCornerEstimate >> gridSearchPerPair (Map <EventPair , Map <Station , Map <FrequencyBand , SpectraRatioPairDetails >>> ratioData ) {
@@ -115,6 +116,8 @@ public Map<EventPair, List<MomentCornerEstimate>> gridSearchPerPair(Map<EventPai
115
116
116
117
if (lowTestMomentEventA == null ) {
117
118
lowTestMomentEventA = DEFAULT_LOW_MOMENT ;
119
+ }
120
+ if (highTestMomentEventA == null ) {
118
121
highTestMomentEventA = DEFAULT_HIGH_MOMENT ;
119
122
}
120
123
@@ -131,6 +134,8 @@ public Map<EventPair, List<MomentCornerEstimate>> gridSearchPerPair(Map<EventPai
131
134
132
135
if (lowTestMomentEventB == null ) {
133
136
lowTestMomentEventB = DEFAULT_LOW_MOMENT ;
137
+ }
138
+ if (highTestMomentEventB == null ) {
134
139
highTestMomentEventB = DEFAULT_HIGH_MOMENT ;
135
140
}
136
141
@@ -168,6 +173,7 @@ public Map<EventPair, List<MomentCornerEstimate>> gridSearchPerPair(Map<EventPai
168
173
});
169
174
170
175
return estimatedMomentCorners ;
176
+
171
177
}
172
178
173
179
public Map <EventPair , SpectraRatioPairInversionResult > cmaesRegressionPerPair (Map <EventPair , Map <Station , Map <FrequencyBand , SpectraRatioPairDetails >>> ratioData ) {
@@ -187,31 +193,35 @@ public Map<EventPair, SpectraRatioPairInversionResult> cmaesRegressionPerPair(Ma
187
193
ReferenceMwParameters refMoment = refMwService .findByEventId (eventPair .getY ().getEventId ());
188
194
189
195
if (fitMoment != null ) {
190
- lowTestMomentEventA = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) - DEFAULT_MOMENT_ERROR ;
191
- highTestMomentEventA = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) + DEFAULT_MOMENT_ERROR ;
196
+ lowTestMomentEventA = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) - momentErrorRange ;
197
+ highTestMomentEventA = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) + momentErrorRange ;
192
198
} else if (refMoment != null ) {
193
- lowTestMomentEventA = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) - DEFAULT_MOMENT_ERROR ;
194
- highTestMomentEventA = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) + DEFAULT_MOMENT_ERROR ;
199
+ lowTestMomentEventA = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) - momentErrorRange ;
200
+ highTestMomentEventA = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) + momentErrorRange ;
195
201
}
196
202
197
203
if (lowTestMomentEventA == null ) {
198
204
lowTestMomentEventA = DEFAULT_LOW_MOMENT ;
205
+ }
206
+ if (highTestMomentEventA == null ) {
199
207
highTestMomentEventA = DEFAULT_HIGH_MOMENT ;
200
208
}
201
209
202
210
fitMoment = fitMwService .findByEventId (eventPair .getX ().getEventId ());
203
211
refMoment = refMwService .findByEventId (eventPair .getX ().getEventId ());
204
212
205
213
if (fitMoment != null ) {
206
- lowTestMomentEventB = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) - DEFAULT_MOMENT_ERROR ;
207
- highTestMomentEventB = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) + DEFAULT_MOMENT_ERROR ;
214
+ lowTestMomentEventB = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) - momentErrorRange ;
215
+ highTestMomentEventB = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) + momentErrorRange ;
208
216
} else if (refMoment != null ) {
209
- lowTestMomentEventB = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) - DEFAULT_MOMENT_ERROR ;
210
- highTestMomentEventB = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) + DEFAULT_MOMENT_ERROR ;
217
+ lowTestMomentEventB = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) - momentErrorRange ;
218
+ highTestMomentEventB = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) + momentErrorRange ;
211
219
}
212
220
213
221
if (lowTestMomentEventB == null ) {
214
222
lowTestMomentEventB = DEFAULT_LOW_MOMENT ;
223
+ }
224
+ if (highTestMomentEventB == null ) {
215
225
highTestMomentEventB = DEFAULT_HIGH_MOMENT ;
216
226
}
217
227
@@ -352,31 +362,35 @@ public Map<EventPair, SpectraRatioPairInversionResultJoint> cmaesRegressionJoint
352
362
ReferenceMwParameters refMoment = refMwService .findByEventId (eventPair .getY ().getEventId ());
353
363
354
364
if (fitMoment != null ) {
355
- lowTestMomentEventA = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) - DEFAULT_MOMENT_ERROR ;
356
- highTestMomentEventA = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) + DEFAULT_MOMENT_ERROR ;
365
+ lowTestMomentEventA = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) - momentErrorRange ;
366
+ highTestMomentEventA = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) + momentErrorRange ;
357
367
} else if (refMoment != null ) {
358
- lowTestMomentEventA = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) - DEFAULT_MOMENT_ERROR ;
359
- highTestMomentEventA = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) + DEFAULT_MOMENT_ERROR ;
368
+ lowTestMomentEventA = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) - momentErrorRange ;
369
+ highTestMomentEventA = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) + momentErrorRange ;
360
370
}
361
371
362
372
if (lowTestMomentEventA == null ) {
363
373
lowTestMomentEventA = DEFAULT_LOW_MOMENT ;
374
+ }
375
+ if (highTestMomentEventA == null ) {
364
376
highTestMomentEventA = DEFAULT_HIGH_MOMENT ;
365
377
}
366
378
367
379
fitMoment = fitMwService .findByEventId (eventPair .getX ().getEventId ());
368
380
refMoment = refMwService .findByEventId (eventPair .getX ().getEventId ());
369
381
370
382
if (fitMoment != null ) {
371
- lowTestMomentEventB = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) - DEFAULT_MOMENT_ERROR ;
372
- highTestMomentEventB = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) + DEFAULT_MOMENT_ERROR ;
383
+ lowTestMomentEventB = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) - momentErrorRange ;
384
+ highTestMomentEventB = MdacCalculator .mwToLogM0 (fitMoment .getMw ()) + momentErrorRange ;
373
385
} else if (refMoment != null ) {
374
- lowTestMomentEventB = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) - DEFAULT_MOMENT_ERROR ;
375
- highTestMomentEventB = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) + DEFAULT_MOMENT_ERROR ;
386
+ lowTestMomentEventB = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) - momentErrorRange ;
387
+ highTestMomentEventB = MdacCalculator .mwToLogM0 (refMoment .getRefMw ()) + momentErrorRange ;
376
388
}
377
389
378
390
if (lowTestMomentEventB == null ) {
379
391
lowTestMomentEventB = DEFAULT_LOW_MOMENT ;
392
+ }
393
+ if (highTestMomentEventB == null ) {
380
394
highTestMomentEventB = DEFAULT_HIGH_MOMENT ;
381
395
}
382
396
0 commit comments