Skip to content

Commit 155151d

Browse files
authored
Merge pull request #559 from AAVSO/558-wwz-statistic-goes-to-zero-in-the-presence-of-gaps
558 wwz statistic goes to zero in the presence of gaps
2 parents c97a026 + 73d8f1f commit 155151d

15 files changed

Lines changed: 2091 additions & 1636 deletions

src/org/aavso/tools/vstar/plugin/period/impl/WeightedWaveletZTransformPluginBase.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.aavso.tools.vstar.plugin.period.PeriodAnalysisPluginBase;
2424
import org.aavso.tools.vstar.ui.dialog.ITextComponent;
2525
import org.aavso.tools.vstar.ui.dialog.DoubleField;
26+
import org.aavso.tools.vstar.ui.dialog.IntegerField;
2627
import org.aavso.tools.vstar.ui.mediator.Mediator;
2728
import org.aavso.tools.vstar.util.locale.LocaleProps;
2829
import org.aavso.tools.vstar.util.period.wwz.WeightedWaveletZTransform;
@@ -37,9 +38,11 @@ abstract public class WeightedWaveletZTransformPluginBase extends
3738

3839
protected Double currDecay;
3940
protected Double currTimeDivisions;
41+
protected Integer currThreadCount;
4042

4143
protected DoubleField decayField;
4244
protected DoubleField timeDivisionsField;
45+
protected IntegerField threadCountField;
4346

4447
/**
4548
* Constructor
@@ -67,6 +70,14 @@ protected List<ITextComponent<?>> createNumberFields(DoubleField... moreFields)
6770
currTimeDivisions);
6871
fields.add(timeDivisionsField);
6972

73+
int recommendedThreads = WeightedWaveletZTransform.getRecommendedThreadCount();
74+
if (currThreadCount == null || currThreadCount > recommendedThreads) {
75+
currThreadCount = recommendedThreads;
76+
}
77+
threadCountField = new IntegerField(LocaleProps.get("WWZ_PARAMETERS_THREADS"),
78+
1, recommendedThreads, currThreadCount);
79+
fields.add(threadCountField);
80+
7081
return fields;
7182
}
7283

@@ -85,13 +96,16 @@ public String getGroup() {
8596
public void reset() {
8697
currDecay = 0.001;
8798
currTimeDivisions = 50.0;
99+
currThreadCount = WeightedWaveletZTransform.getRecommendedThreadCount();
88100
}
89101

90102
/**
91103
* @see org.aavso.tools.vstar.plugin.period.PeriodAnalysisPluginBase#interrupt()
92104
*/
93105
@Override
94106
public void interrupt() {
95-
wwt.interrupt();
107+
if (wwt != null) {
108+
wwt.interrupt();
109+
}
96110
}
97111
}

src/org/aavso/tools/vstar/plugin/period/impl/WeightedWaveletZTransformWithFrequencyRangePlugin.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,30 @@ public void executeAlgorithm(List<ValidObservation> obs)
8181

8282
if (!paramDialog.isCancelled()) {
8383
double minFreq, maxFreq, deltaFreq, decay, timeDivisions;
84+
int threadCount;
8485

8586
currMinFreq = minFreq = minFreqField.getValue();
8687
currMaxFreq = maxFreq = maxFreqField.getValue();
8788
currDeltaFreq = deltaFreq = deltaFreqField.getValue();
8889
currDecay = decay = decayField.getValue();
8990
currTimeDivisions = timeDivisions = timeDivisionsField.getValue();
91+
Integer threadCountValue = threadCountField.getValue();
92+
if (threadCountValue == null) {
93+
threadCountValue = WeightedWaveletZTransform.getRecommendedThreadCount();
94+
}
95+
currThreadCount = threadCount = threadCountValue;
9096

9197
// TODO: ask about number of frequencies > 1000 via dialog?
9298

9399
wwt = new WeightedWaveletZTransform(obs, decay, timeDivisions);
100+
wwt.setThreadCount(threadCount);
94101
wwt.make_freqs_from_freq_range(Math.min(minFreq, maxFreq), Math
95102
.max(minFreq, maxFreq), deltaFreq);
96103
wwt.execute();
104+
if (wwt.isCancelled()) {
105+
throw new CancellationException("WWZ "
106+
+ LocaleProps.get("CANCELLED"));
107+
}
97108
} else {
98109
throw new CancellationException("WWZ "
99110
+ LocaleProps.get("CANCELLED"));

src/org/aavso/tools/vstar/plugin/period/impl/WeightedWaveletZTransformWithPeriodRangePlugin.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,30 @@ public void executeAlgorithm(List<ValidObservation> obs)
7878

7979
if (!paramDialog.isCancelled()) {
8080
double minPeriod, maxPeriod, deltaPeriod, decay, timeDivisions;
81+
int threadCount;
8182

8283
currMinPeriod = minPeriod = minPeriodField.getValue();
8384
currMaxPeriod = maxPeriod = maxPeriodField.getValue();
8485
currDeltaPeriod = deltaPeriod = deltaPeriodField.getValue();
8586
currDecay = decay = decayField.getValue();
8687
currTimeDivisions = timeDivisions = timeDivisionsField.getValue();
88+
Integer threadCountValue = threadCountField.getValue();
89+
if (threadCountValue == null) {
90+
threadCountValue = WeightedWaveletZTransform.getRecommendedThreadCount();
91+
}
92+
currThreadCount = threadCount = threadCountValue;
8793

8894
// TODO: ask about number of periods > 1000 via dialog?
8995

9096
wwt = new WeightedWaveletZTransform(obs, decay, timeDivisions);
97+
wwt.setThreadCount(threadCount);
9198
wwt.make_freqs_from_period_range(Math.min(minPeriod, maxPeriod),
9299
Math.max(minPeriod, maxPeriod), deltaPeriod);
93100
wwt.execute();
101+
if (wwt.isCancelled()) {
102+
throw new CancellationException("WWZ "
103+
+ LocaleProps.get("CANCELLED"));
104+
}
94105
} else {
95106
throw new CancellationException("WWZ "
96107
+ LocaleProps.get("CANCELLED"));

src/org/aavso/tools/vstar/ui/resources/locale/strings.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ WWZ_PARAMETERS_FREQUENCY_STEP=Frequency Step
183183
WWZ_PARAMETERS_PERIOD_STEP=Period Step
184184
WWZ_PARAMETERS_DECAY=Decay
185185
WWZ_PARAMETERS_TIME_DIVISIONS=Time Divisions
186+
WWZ_PARAMETERS_THREADS=Threads
186187

187188
// WWZ result dialog
188189
WWZ_RESULTS=WWZ Results

src/org/aavso/tools/vstar/ui/resources/locale/strings_es.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,4 @@ EPOCH=\u00E9poca
294294
VERSUS=vs
295295
MAXIMAL=maximal
296296
CONTOUR=contorno
297+
WWZ_PARAMETERS_THREADS=Hilos

src/org/aavso/tools/vstar/ui/resources/locale/strings_fr.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,5 @@ PERIOD=p\u00E9riode
294294
EPOCH=\u00E9poque
295295
VERSUS=vs
296296
MAXIMAL=maximal
297-
CONTOUR=courbe
297+
CONTOUR=courbe
298+
WWZ_PARAMETERS_THREADS=threads

0 commit comments

Comments
 (0)