Skip to content

Commit 3989376

Browse files
committed
updated Merger to use mask1D and remove its own filters
added StaIndexFilter and StaConfFilter renamed methods in IndexMask
1 parent 42af587 commit 3989376

13 files changed

Lines changed: 223 additions & 164 deletions

File tree

src/main/java/fr/jmmc/oitools/OIFitsProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private static void merge(final String[] args) throws FitsException, IOException
233233
selector.setNightID(Integer.valueOf(night));
234234
}
235235
if (baselines != null) {
236-
selector.addFilter(Selector.FILTER_BASELINE, parseStrings(baselines));
236+
selector.addFilter(Selector.FILTER_STAINDEX, parseStrings(baselines));
237237
}
238238
if (mjds != null) {
239239
selector.addFilter(Selector.FILTER_MJD, parseRanges(mjds));
@@ -416,7 +416,7 @@ public static String generateCLIargs(final Selector selector) {
416416
return ((selector.getTargetUID() != null) ? OIFitsProcessor.OPTION_TARGET + " " + selector.getTargetUID() + " " : "")
417417
+ ((selector.getInsModeUID() != null) ? OIFitsProcessor.OPTION_INSNAME + " " + selector.getInsModeUID() + " " : "")
418418
+ ((selector.getNightID() != null) ? OIFitsProcessor.OPTION_NIGHT + " " + selector.getNightID() + " " : "")
419-
+ ((selector.hasFilter(Selector.FILTER_BASELINE)) ? OIFitsProcessor.OPTION_BASELINES + " " + dumpStrings(selector.getFilter(Selector.FILTER_BASELINE)) + " " : "")
419+
+ ((selector.hasFilter(Selector.FILTER_STAINDEX)) ? OIFitsProcessor.OPTION_BASELINES + " " + dumpStrings(selector.getFilter(Selector.FILTER_STAINDEX)) + " " : "")
420420
+ ((selector.hasFilter(Selector.FILTER_MJD)) ? OIFitsProcessor.OPTION_MJD_RANGES + " " + dumpRanges(selector.getFilter(Selector.FILTER_MJD)) + " " : "")
421421
+ ((selector.hasFilter(Selector.FILTER_EFFWAVE)) ? OIFitsProcessor.OPTION_WL_RANGES + " " + dumpRanges(selector.getFilter(Selector.FILTER_EFFWAVE)) + " " : "");
422422
}

src/main/java/fr/jmmc/oitools/model/IndexMask.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private IndexMask(final BitSet bitSet, final int nbRows, final int nbCols) {
7474
* @param rowIndex Must be >= 0 and < nbRows
7575
* @return true to accept; false to reject
7676
*/
77-
public boolean isRow(final int rowIndex) {
77+
public boolean accept(final int rowIndex) {
7878
if (vect1D) {
7979
return bitSet.get(rowIndex);
8080
}
@@ -87,7 +87,7 @@ public boolean isRow(final int rowIndex) {
8787
* @param rowIndex Must be >= 0 and < nbRows
8888
* @param value true to accept; false to reject
8989
*/
90-
public void setRow(final int rowIndex, final boolean value) {
90+
public void setAccept(final int rowIndex, final boolean value) {
9191
// shortcut for 1D masks
9292
if (vect1D) {
9393
bitSet.set(rowIndex, value);
@@ -103,7 +103,7 @@ public void setRow(final int rowIndex, final boolean value) {
103103
* @param colIndex Must be >= 0 and < nbCols
104104
* @return true if cell equals @param value. cell [rowIndex, colIndex]
105105
*/
106-
public boolean isCell(final int rowIndex, final int colIndex) {
106+
public boolean accept(final int rowIndex, final int colIndex) {
107107
if (!vect1D) {
108108
return bitSet.get(getBitIndex(rowIndex, colIndex));
109109
}
@@ -117,7 +117,7 @@ public boolean isCell(final int rowIndex, final int colIndex) {
117117
* @param colIndex Must be >= 0 and < nbCols
118118
* @param value false to mask
119119
*/
120-
public void setCell(final int rowIndex, final int colIndex, final boolean value) {
120+
public void setAccept(final int rowIndex, final int colIndex, final boolean value) {
121121
if (!vect1D) {
122122
bitSet.set(getBitIndex(rowIndex, colIndex), value);
123123
}
@@ -132,14 +132,6 @@ public int cardinality() {
132132
return this.bitSet.cardinality();
133133
}
134134

135-
public boolean isMaskEmpty() {
136-
return cardinality() == 0;
137-
}
138-
139-
public boolean isMaskFull() {
140-
return cardinality() == (nbRows * nbCols);
141-
}
142-
143135
public boolean isFull() {
144136
return (this == FULL);
145137
}

src/main/java/fr/jmmc/oitools/model/OIData.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434
import fr.jmmc.oitools.model.range.Range;
3535
import fr.jmmc.oitools.util.MathUtils;
3636
import java.util.Arrays;
37-
import java.util.LinkedHashMap;
3837
import java.util.LinkedHashSet;
39-
import java.util.Map;
38+
import java.util.List;
4039
import java.util.Set;
4140
import java.util.logging.Level;
4241

@@ -940,6 +939,24 @@ public int getDistinctStaConfCount() {
940939
return distinctStaConf.size();
941940
}
942941

942+
/**
943+
* Find the StaConfs instances corresponding to the selected StaNames (using getRealStaNames)
944+
* @param selectedStaNames selected StaNames to match
945+
* @param staIndexMatching set to store StaIndexes instances
946+
*/
947+
public void getMatchingStaConfs(final List<String> selectedStaNames,
948+
final Set<short[]> staIndexMatching) {
949+
staIndexMatching.clear();
950+
951+
for (final short[] staIndexes : getDistinctStaConf()) {
952+
final String staNames = getStaNames(staIndexes); // cached
953+
954+
if (selectedStaNames.contains(staNames)) {
955+
staIndexMatching.add(staIndexes);
956+
}
957+
}
958+
}
959+
943960
/**
944961
* Return the wavelenth range
945962
* @return wavelenth range

src/main/java/fr/jmmc/oitools/model/OIFitsCollection.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import fr.jmmc.oitools.processing.NightIdFilter;
2929
import fr.jmmc.oitools.processing.Selector;
3030
import fr.jmmc.oitools.processing.SelectorResult;
31+
import fr.jmmc.oitools.processing.StaConfFilter;
32+
import fr.jmmc.oitools.processing.StaIndexFilter;
3133
import fr.jmmc.oitools.processing.TargetUIDFilter;
3234
import fr.jmmc.oitools.util.GranuleComparator;
3335
import fr.jmmc.oitools.util.OIFitsFileComparator;
@@ -441,6 +443,14 @@ public SelectorResult findOIData(final Selector selector, final SelectorResult i
441443
// table refs: see OIData filtering below
442444

443445
// generic filters:
446+
if (selector.hasFilter(Selector.FILTER_STAINDEX)) {
447+
filtersData1D.add(new StaIndexFilter(getUsedStaNamesMap(),
448+
selector.getFilter(Selector.FILTER_STAINDEX)));
449+
}
450+
if (selector.hasFilter(Selector.FILTER_STACONF)) {
451+
filtersData1D.add(new StaConfFilter(
452+
selector.getFilter(Selector.FILTER_STACONF)));
453+
}
444454
if (selector.hasFilter(Selector.FILTER_MJD)) {
445455
filtersData1D.add(new Double1DFilter(Selector.FILTER_MJD,
446456
selector.getFilter(Selector.FILTER_MJD)));
@@ -554,7 +564,7 @@ private void filterOIData(final SelectorResult result, final Granule g, final OI
554564
return;
555565
}
556566
if (logger.isLoggable(Level.FINE)) {
557-
logger.log(Level.FINE, "wlen filters: {0}", result.getFiltersOIWavelength());
567+
logger.log(Level.FINE, "wlen filters: {0}", result.getFiltersUsed());
558568
logger.log(Level.FINE, "wlenMask: {0}", maskWavelength);
559569
}
560570
result.putWavelengthMask(oiWavelength, maskWavelength);
@@ -577,7 +587,7 @@ private void filterOIData(final SelectorResult result, final Granule g, final OI
577587
return;
578588
}
579589
if (logger.isLoggable(Level.FINE)) {
580-
logger.log(Level.FINE, "oidata filters: {0}", result.getFiltersOIData());
590+
logger.log(Level.FINE, "oidata filters: {0}", result.getFiltersUsed());
581591
logger.log(Level.FINE, "maskRows: {0}", maskRows);
582592
}
583593
result.putDataMask1D(oiData, maskRows);
@@ -643,7 +653,7 @@ private IndexMask computeMask1D(final List<FitsTableFilter<?>> filters,
643653
}
644654
// update mask:
645655
if (match) {
646-
maskRows.setRow(i, true);
656+
maskRows.setAccept(i, true);
647657
} else {
648658
// data row does not correspond to selected wavelength ranges
649659
filterRows = true;
@@ -719,8 +729,8 @@ private List<Granule> findGranules(final Selector selector) {
719729
final Granule pattern = new Granule(target, insMode, nightId);
720730

721731
// Baselines criteria:
722-
if (selector.hasFilter(Selector.FILTER_BASELINE)) {
723-
pattern.getDistinctStaNames().addAll(selector.getFilter(Selector.FILTER_BASELINE));
732+
if (selector.hasFilter(Selector.FILTER_STAINDEX)) {
733+
pattern.getDistinctStaNames().addAll(selector.getFilter(Selector.FILTER_STAINDEX));
724734
}
725735

726736
// MJD & Wavelength ranges criteria:
@@ -770,7 +780,8 @@ private List<Granule> findGranules(final Selector selector) {
770780

771781
private static boolean isCustomFilter(final String name) {
772782
switch (name) {
773-
case Selector.FILTER_BASELINE:
783+
case Selector.FILTER_STAINDEX:
784+
case Selector.FILTER_STACONF:
774785
case Selector.FILTER_MJD:
775786
return true;
776787
default:

src/main/java/fr/jmmc/oitools/processing/Double1DFilter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public FilterState prepare(final FitsTable fitsTable) {
4545
}
4646
logger.log(Level.FINE, "prepare: matching ranges: {0}", rangeMatchings);
4747

48-
final boolean checkRows = !Range.matchFully(rangeMatchings, tableRange);
49-
50-
if (checkRows) {
48+
if (!Range.matchFully(rangeMatchings, tableRange)) {
5149
// resolve column once
5250
tableColumn1D = fitsTable.getColumnAsDouble(columnName);
5351

0 commit comments

Comments
 (0)