Skip to content

Commit 69f5728

Browse files
committed
new BaseSelectorResult to get selected granule on targetUID filter only
used to get distinct StaNames and StaConfs Fixed StaIndexFilter to use real StaNames (distinct in all OIFits collection) code formatting
1 parent 2f66361 commit 69f5728

27 files changed

Lines changed: 798 additions & 311 deletions

rules/DataModel.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ li {
6666
}
6767

6868
.myhide {
69-
display:none;
69+
display:none;
7070
}
7171

7272
.oitable {

src/main/java/fr/jmmc/jmcs/util/StringUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ public static String removeAccents(final String value) {
123123
}
124124

125125
/* --- common white space helper methods -------------------------------- */
126-
127126
/**
128127
* Trim and remove redundant white space characters
129128
* @param value input value
@@ -150,7 +149,7 @@ public static String removeWhiteSpaces(final String value) {
150149
public static String removeUnderscores(final String value) {
151150
return PATTERN_UNDERSCORE.matcher(value).replaceAll(STRING_EMPTY);
152151
}
153-
152+
154153
/**
155154
* Remove redundant white space characters
156155
* @param value input value

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,7 @@ NS_MODEL_T3PHIERR D(NWAVE) Model of the error in triple-product phase in degrees
472472

473473
/** Resolution value */
474474
public final static String VALUE_RESOLUTION = "RESOLUTION";
475+
476+
/** StaNames separator '-' */
477+
public final static char STA_NAME_SEPARATOR = '-';
475478
}

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

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -493,28 +493,30 @@ public static String generateCLIargs(final Selector selector) {
493493
}
494494
/* no way to define selector.tables via CLI */
495495

496-
if (selector.hasFilter(Selector.FILTER_MJD)) {
497-
dumpRangeFilter(sb, selector.getFilterValues(Selector.FILTER_MJD));
498-
}
496+
if (selector.hasFilters()) {
497+
if (selector.hasFilter(Selector.FILTER_MJD)) {
498+
dumpRangeFilter(sb, selector.getFilterValues(Selector.FILTER_MJD));
499+
}
499500

500-
if (selector.hasFilter(Selector.FILTER_STAINDEX)) {
501-
dumpStringFilter(sb, selector.getFilterValues(Selector.FILTER_STAINDEX));
502-
}
503-
if (selector.hasFilter(Selector.FILTER_STACONF)) {
504-
dumpStringFilter(sb, selector.getFilterValues(Selector.FILTER_STACONF));
505-
}
501+
if (selector.hasFilter(Selector.FILTER_STAINDEX)) {
502+
dumpStringFilter(sb, selector.getFilterValues(Selector.FILTER_STAINDEX));
503+
}
504+
if (selector.hasFilter(Selector.FILTER_STACONF)) {
505+
dumpStringFilter(sb, selector.getFilterValues(Selector.FILTER_STACONF));
506+
}
506507

507-
if (selector.hasFilter(Selector.FILTER_EFFWAVE)) {
508-
dumpRangeFilter(sb, selector.getFilterValues(Selector.FILTER_EFFWAVE));
509-
}
510-
if (selector.hasFilter(Selector.FILTER_EFFBAND)) {
511-
dumpRangeFilter(sb, selector.getFilterValues(Selector.FILTER_EFFBAND));
512-
}
508+
if (selector.hasFilter(Selector.FILTER_EFFWAVE)) {
509+
dumpRangeFilter(sb, selector.getFilterValues(Selector.FILTER_EFFWAVE));
510+
}
511+
if (selector.hasFilter(Selector.FILTER_EFFBAND)) {
512+
dumpRangeFilter(sb, selector.getFilterValues(Selector.FILTER_EFFBAND));
513+
}
513514

514-
// convert generic filters from selector.filters:
515-
for (Map.Entry<String, FilterValues<?>> e : selector.getFiltersMap().entrySet()) {
516-
if (!Selector.isCustomFilter(e.getKey())) {
517-
dumpRangeFilter(sb, e.getValue());
515+
// convert generic filters from selector.filters:
516+
for (Map.Entry<String, FilterValues<?>> e : selector.getFiltersMap().entrySet()) {
517+
if (!Selector.isCustomFilter(e.getKey())) {
518+
dumpRangeFilter(sb, e.getValue());
519+
}
518520
}
519521
}
520522
return sb.toString();

src/main/java/fr/jmmc/oitools/image/FitsImageHDU.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class FitsImageHDU extends FitsHDU {
6868
* reference pixels, rotation angle, pixels values.
6969
*/
7070
public final static Matcher<FitsImageHDU> MATCHER = new Matcher<FitsImageHDU>() {
71-
71+
7272
/**
7373
* decide equivalence between two FitsImageHDU
7474
* @param src FitsImageHDU to compare with other (optional)

src/main/java/fr/jmmc/oitools/image/FitsUnit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static FitsUnit getAngleDegUnit(final double angle) {
109109
}
110110
return FitsUnit.ANGLE_MILLI_ARCSEC;
111111
}
112-
112+
113113
/* members */
114114
/** string representation separated by '|' */
115115
private final String representation;

src/main/java/fr/jmmc/oitools/image/ImageOiInputParam.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ public void checkSyntax(final OIFitsChecker checker) {
263263
String useVIS = getUseVis();
264264
if ((useVIS != null) && (useVIS.length() == 1)) {
265265
setUseVis("T".equals(useVIS) ? ImageOiInputParam.USE_ALL : ImageOiInputParam.USE_NONE);
266-
logger.log(Level.INFO, "Fixed {0} = ''{1}''",
266+
logger.log(Level.INFO, "Fixed {0} = ''{1}''",
267267
new Object[]{ImageOiConstants.KEYWORD_USE_VIS, getUseVis()});
268268
}
269269
String useT3 = getUseT3();
270270
if ((useT3 != null) && (useT3.length() == 1)) {
271271
setUseT3("T".equals(useT3) ? ImageOiInputParam.USE_ALL : ImageOiInputParam.USE_NONE);
272-
logger.log(Level.INFO, "Fixed {0} = ''{1}''",
272+
logger.log(Level.INFO, "Fixed {0} = ''{1}''",
273273
new Object[]{ImageOiConstants.KEYWORD_USE_T3, getUseT3()});
274274
}
275275

src/main/java/fr/jmmc/oitools/meta/CellMeta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public final Types getDataType() {
221221
public final Class<?> getBaseClass() {
222222
return Types.getBaseClass(getDataType());
223223
}
224-
224+
225225
/**
226226
* Get type.
227227
*

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public void visit(final OIFitsFile oiFitsFile) {
104104
if (isLogDebug) {
105105
logger.log(Level.FINE, "process: OIFitsFile[{0}] usedStaNamesMap: {1}",
106106
new Object[]{oiFitsFile.getAbsoluteFilePath(), oiFitsFile.getUsedStaNamesMap().entrySet()});
107+
logger.log(Level.FINE, "process: OIFitsFile[{0}] sortedStaNamesMap: {1}",
108+
new Object[]{oiFitsFile.getAbsoluteFilePath(), oiFitsFile.getSortedStaNamesMap()});
107109
logger.log(Level.FINE, "process: OIFitsFile[{0}] granules: {1}",
108110
new Object[]{oiFitsFile.getAbsoluteFilePath(), oiFitsFile.getDistinctGranules().keySet()});
109111
}
@@ -184,6 +186,8 @@ private void process(final OIData oiData) {
184186
final short[][] staIndexes = oiData.getStaIndex();
185187
// Get MJD column:
186188
final double[] mjds = oiData.getMJD();
189+
// Derived StaConf column:
190+
final short[][] staConfs = (oiData.getDistinctStaConfCount()) != 0 ? oiData.getStaConf() : null;
187191

188192
// note: if no OITarget table then the target will be Target.UNDEFINED
189193
final Map<Short, Target> targetIdToTarget = (oiTarget != null) ? oiTarget.getTargetIdToTarget() : null;
@@ -236,22 +240,19 @@ private void process(final OIData oiData) {
236240
// Get corresponding StaName:
237241
String staNames = null;
238242
if (staIndexes != null) {
239-
final short[] staIndex = staIndexes[i];
240-
241243
// resolve sorted StaNames (reference) to get its orientation:
242-
final StaNamesDir sortedStaNamesDir = oiData.getSortedStaNamesDir(staIndex);
244+
final StaNamesDir sortedStaNamesDir = oiData.getSortedStaNamesDir(staIndexes[i]);
243245

244246
if (sortedStaNamesDir != null) {
245247
// find the previous (real) baseline corresponding to the sorted StaNames (stable):
246-
final StaNamesDir refStaNamesDir = usedStaNamesMap.get(sortedStaNamesDir.getStaNames());
247-
248-
if (refStaNamesDir == null) {
249-
logger.log(Level.WARNING, "bad usedStaNamesMap: missing {0}", sortedStaNamesDir.getStaNames());
250-
} else {
251-
staNames = refStaNamesDir.getStaNames();
252-
}
248+
staNames = OIAbstractData.getRealStaNames(usedStaNamesMap, sortedStaNamesDir.getStaNames(), null);
253249
}
254250
}
251+
// Get corresponding StaConf:
252+
String staConf = null;
253+
if (staConfs != null) {
254+
staConf = oiData.getStaNames(staConfs[i]); // staConf computed before
255+
}
255256

256257
// Get MJD value:
257258
final double mjd = mjds[i];
@@ -268,7 +269,11 @@ private void process(final OIData oiData) {
268269

269270
// Update distinct StaNames on shared granule:
270271
if (staNames != null) {
271-
granule.getDistinctStaNames().add(staNames);
272+
granule.getDistinctStaNames().add(staNames); // real staNames present in OIFitsFile
273+
}
274+
// Update distinct StaConfs on shared granule:
275+
if (staConf != null) {
276+
granule.getDistinctStaConfs().add(staConf);
272277
}
273278

274279
// Update MJD Ranges on shared granule:
@@ -461,6 +466,7 @@ private void processStaIndex(final OIData oiData) {
461466

462467
// Fill used staNames to StaNamesDir (reference StaNames / orientation):
463468
final Map<String, StaNamesDir> usedStaNamesMap = oiData.getOIFitsFile().getUsedStaNamesMap();
469+
final Map<String, String> sortedStaNamesMap = oiData.getOIFitsFile().getSortedStaNamesMap();
464470

465471
// 2nd step: fill mapping:
466472
if (staLen >= 2) {
@@ -499,7 +505,6 @@ private void processStaIndex(final OIData oiData) {
499505
}
500506

501507
final StaNamesDir sortedStaNamesDir = new StaNamesDir(sortedStaNames, orientation);
502-
503508
staIndexesToSortedStaNamesDir.put(staIndex, sortedStaNamesDir);
504509

505510
// global level (OIFits):
@@ -509,6 +514,7 @@ private void processStaIndex(final OIData oiData) {
509514
// store this (real) baseline corresponding to the sorted StaNames (stable) with the reference orientation flag:
510515
usedStaNamesMap.put(sortedStaNames, new StaNamesDir(staNames, sortedStaNamesDir.isOrientation()));
511516
}
517+
sortedStaNamesMap.put(staNames, sortedStaNames);
512518
}
513519
} else {
514520
// 1T (OI_FLUX):
@@ -518,6 +524,7 @@ private void processStaIndex(final OIData oiData) {
518524

519525
staIndexesToSortedStaNamesDir.put(staIndex, sortedStaNamesDir);
520526
usedStaNamesMap.put(staNames, sortedStaNamesDir);
527+
sortedStaNamesMap.put(staNames, staNames);
521528
}
522529
}
523530
}

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

Lines changed: 71 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
import fr.jmmc.oitools.model.range.Range;
2323
import fr.jmmc.oitools.util.GranuleComparator;
24+
import fr.jmmc.oitools.util.StationNamesComparator;
2425
import java.util.ArrayList;
2526
import java.util.Collection;
2627
import java.util.Collections;
2728
import java.util.HashSet;
2829
import java.util.LinkedHashSet;
29-
import java.util.List;
3030
import java.util.Set;
3131
import java.util.logging.Logger;
3232

@@ -44,15 +44,21 @@ public enum GranuleField {
4444
TARGET, INS_MODE, NIGHT;
4545
}
4646

47+
public enum GranuleExtraField {
48+
DISTINCT_STA_NAMES, DISTINCT_STA_CONFS;
49+
}
50+
4751
/* members */
4852
private Target target;
4953
private InstrumentMode insMode;
5054
private NightId night;
5155
/* extra information (filters) */
52-
/** Set of distinct staNames */
53-
private Set<String> distinctStaNames = null;
5456
/** MJD range */
5557
private Range mjdRange = null;
58+
/** Set of distinct staNames */
59+
private Set<String> distinctStaNames = null;
60+
/** Set of distinct staConfs */
61+
private Set<String> distinctStaConfs = null;
5662

5763
public Granule() {
5864
this(null, null, null);
@@ -80,7 +86,7 @@ public NightId getNight() {
8086
return night;
8187
}
8288

83-
public Object getField(GranuleField field) {
89+
public Object getField(final GranuleField field) {
8490
switch (field) {
8591
case TARGET:
8692
return getTarget();
@@ -93,6 +99,17 @@ public Object getField(GranuleField field) {
9399
}
94100
}
95101

102+
public Set<String> getField(final GranuleExtraField field) {
103+
switch (field) {
104+
case DISTINCT_STA_NAMES:
105+
return getDistinctStaNames();
106+
case DISTINCT_STA_CONFS:
107+
return getDistinctStaConfs();
108+
default:
109+
return null;
110+
}
111+
}
112+
96113
@Override
97114
public int hashCode() {
98115
int hash = 7;
@@ -131,15 +148,8 @@ public boolean isEmpty() {
131148
}
132149

133150
/* extra information for specific filters (distinct staNames, mjd range) */
134-
public boolean hasDistinctStaNames() {
135-
return (distinctStaNames != null) && !distinctStaNames.isEmpty();
136-
}
137-
138-
public Set<String> getDistinctStaNames() {
139-
if (distinctStaNames == null) {
140-
distinctStaNames = new LinkedHashSet<String>();
141-
}
142-
return distinctStaNames;
151+
public Range getWavelengthRange() {
152+
return (getInsMode() != null) ? getInsMode().getWavelengthRange() : null;
143153
}
144154

145155
public boolean hasMjdRange() {
@@ -153,7 +163,7 @@ public Range getMjdRange() {
153163
return mjdRange;
154164
}
155165

156-
public void updateMjdRange(final double mjd) {
166+
void updateMjdRange(final double mjd) {
157167
final Range r = getMjdRange();
158168
if (mjd < r.getMin()) {
159169
r.setMin(mjd);
@@ -163,31 +173,71 @@ public void updateMjdRange(final double mjd) {
163173
}
164174
}
165175

166-
public void updateMjdRange(final Range other) {
176+
void updateMjdRange(final Range other) {
167177
updateMjdRange(other.getMin());
168178
updateMjdRange(other.getMax());
169179
}
170180

181+
public boolean hasDistinctStaNames() {
182+
return (distinctStaNames != null) && !distinctStaNames.isEmpty();
183+
}
184+
185+
public Set<String> getDistinctStaNames() {
186+
if (distinctStaNames == null) {
187+
distinctStaNames = new LinkedHashSet<String>();
188+
}
189+
return distinctStaNames;
190+
}
191+
192+
public boolean hasDistinctStaConfs() {
193+
return (distinctStaConfs != null) && !distinctStaConfs.isEmpty();
194+
}
195+
196+
public Set<String> getDistinctStaConfs() {
197+
if (distinctStaConfs == null) {
198+
distinctStaConfs = new LinkedHashSet<String>();
199+
}
200+
return distinctStaConfs;
201+
}
202+
171203
@Override
172204
public String toString() {
173205
return "Granule{" + "target=" + target + ", insMode=" + insMode
174206
+ ", night=" + night + ", mjdRange=" + mjdRange
175207
+ ", distinctStaNames=" + distinctStaNames
208+
+ ", distinctStaConfs=" + distinctStaConfs
176209
+ '}';
177210
}
178211

179-
public static <K> Set<K> getDistinctGranuleField(final Collection<Granule> granules, final GranuleField field) {
212+
public static <K> HashSet<K> getDistinctGranuleField(final Collection<Granule> granules, final GranuleField field) {
180213
final HashSet<K> values = new HashSet<K>();
181214
for (Granule g : granules) {
182215
values.add((K) g.getField(field));
183216
}
184217
return values;
185218
}
186219

187-
public static <K> List<K> getSortedDistinctGranuleField(final Collection<Granule> granules, final GranuleField field) {
188-
final Set<K> values = getDistinctGranuleField(granules, field);
189-
final ArrayList<K> sorted = new ArrayList<K>(values);
190-
Collections.sort(sorted, GranuleComparator.getComparator(field));
191-
return sorted;
220+
public static <K> ArrayList<K> getSortedDistinctGranuleField(final Collection<Granule> granules, final GranuleField field) {
221+
final HashSet<K> values = getDistinctGranuleField(granules, field);
222+
final ArrayList<K> sortedList = new ArrayList<K>(values);
223+
Collections.sort(sortedList, GranuleComparator.getComparator(field));
224+
return sortedList;
192225
}
226+
227+
public static HashSet<String> getDistinctGranuleField(final Collection<Granule> granules, final GranuleExtraField field) {
228+
final HashSet<String> values = new HashSet<String>();
229+
for (Granule g : granules) {
230+
final Set<String> set = g.getField(field);
231+
values.addAll(g.getField(field));
232+
}
233+
return values;
234+
}
235+
236+
public static ArrayList<String> getSortedDistinctGranuleField(final Collection<Granule> granules, final GranuleExtraField field) {
237+
final HashSet<String> values = getDistinctGranuleField(granules, field);
238+
final ArrayList<String> sortedList = new ArrayList<String>(values);
239+
Collections.sort(sortedList, StationNamesComparator.INSTANCE);
240+
return sortedList;
241+
}
242+
193243
}

0 commit comments

Comments
 (0)