Skip to content

Commit b3b2f2e

Browse files
committed
Merge branch 'dev' of https://github.com/Caltech-IPAC/Firefly into dev
2 parents 9fa5ee3 + 5d85142 commit b3b2f2e

File tree

10 files changed

+215
-63
lines changed

10 files changed

+215
-63
lines changed

src/firefly/java/edu/caltech/ipac/firefly/data/FinderChartRequestUtil.java

Lines changed: 152 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,38 @@ public class FinderChartRequestUtil {
6868
"3a.2;w2",
6969
"3a.3;w3",
7070
"3a.4;w4"};
71+
72+
73+
/**
74+
* TODO For FC4, need to use config table and new image search, see IRSA-794 and IRSA-816
75+
* Add reader to parse IRSA configuration table and return a combo depending on the imageset
76+
* For FC3: SEIP + AKARI, we use fixed values for the combos below:
77+
*
78+
* SEIP metadata sent from client (or TODO read from master table)
79+
* thru request so it can be split into schema.table and band, and title.
80+
* THis is passed from the client
81+
* Expected format : metadata expected to be as "schema.table-band;title"
82+
*/
83+
private final static String seipCombo[]={
84+
"spitzer.seip_science:IRAC1;SEIP IRAC1 (2.4 microns);file_type='science' and fname like '%.mosaic.fits'",
85+
"spitzer.seip_science:IRAC2;SEIP IRAC2 (2.4 microns);file_type='science' and fname like '%.mosaic.fits'",
86+
"spitzer.seip_science:IRAC3;SEIP IRAC3 (2.4 microns);file_type='science' and fname like '%.mosaic.fits'",
87+
"spitzer.seip_science:IRAC4;SEIP IRAC4 (2.4 microns);file_type='science' and fname like '%.mosaic.fits'",
88+
"spitzer.seip_science:MIPS24;SEIP MIPS (2.4 microns);file_type='science' and fname like '%.mosaic.fits'"
89+
};
90+
91+
/**
92+
* AKARI metadata sent from client thru request so it can be split into schema.table, band on one hand, label title on another hand, all separated by ';'.
93+
* THis is passed from the client
94+
* Expected format : metadata expected to be as "schema.table-band;title"
95+
*/
96+
private final static String akariCombo[]={
97+
"akari.images_tbl:N60;FIS N60 (65 micron)",
98+
"akari.images_tbl:WideS;FIS WideS (90 micron)",
99+
"akari.images_tbl:WideL;FIS WideL (140 micron)",
100+
"akari.images_tbl:N160;FIS N160 (160 micron)"
101+
};
102+
71103
private final static String sDssCombo[]={
72104
"u;u","g;g","r;r","i;i","z;z"
73105
};
@@ -78,15 +110,26 @@ public class FinderChartRequestUtil {
78110
put("large",256);
79111
}
80112
};
113+
private static String regExAtlasKey = ":";
114+
private static String regExSplitKey = ";";
81115

116+
/**
117+
* @param pt
118+
* @param radius
119+
* @param width
120+
* @param key string combination of value to be splitted for convenience
121+
* @param expandedTitle
122+
* @param service
123+
* @return
124+
*/
82125
public static WebPlotRequest makeWebPlotRequest(WorldPt pt,
83126
float radius,
84127
int width,
85-
String band,
128+
String key,
86129
String expandedTitle,
87130
WebPlotRequest.ServiceType service ) {
88131

89-
WebPlotRequest wpReq= getWebPlotRequest(service, band, pt, radius);
132+
WebPlotRequest wpReq= getWebPlotRequest(service, key, pt, radius);
90133
if (!StringUtils.isEmpty(expandedTitle)) wpReq.setExpandedTitle(expandedTitle);
91134
wpReq.setExpandedTitleOptions(WebPlotRequest.ExpandedTitleOptions.PREFIX);
92135
wpReq.setZoomType(ZoomType.TO_WIDTH);
@@ -99,48 +142,100 @@ public static WebPlotRequest makeWebPlotRequest(WorldPt pt,
99142
wpReq.setHideTitleDetail(true);
100143
wpReq.setPreferenceColorKey("FcColorKey");
101144
wpReq.setTitleOptions(WebPlotRequest.TitleOptions.SERVICE_OBS_DATE);
102-
wpReq.setTitle(getComboTitle(band));
145+
wpReq.setTitle(getComboTitle(key));
103146
return wpReq;
104147
}
105148

106-
private static WebPlotRequest getWebPlotRequest(WebPlotRequest.ServiceType service, String band, WorldPt pt, Float radius) {
149+
private static WebPlotRequest getWebPlotRequest(WebPlotRequest.ServiceType service, String key, WorldPt pt, Float radius) {
107150
WebPlotRequest wpReq=null;
108151
switch (service) {
109152
case DSS:
110-
wpReq= WebPlotRequest.makeDSSRequest(pt, getComboValue(band),radius);
153+
wpReq= WebPlotRequest.makeDSSRequest(pt, getComboValue(key),radius);
111154
break;
112155
case IRIS:
113-
wpReq= WebPlotRequest.makeIRISRequest(pt, getComboValue(band), radius);
156+
wpReq= WebPlotRequest.makeIRISRequest(pt, getComboValue(key), radius);
114157
break;
115158
case ISSA:
116-
wpReq= WebPlotRequest.makeISSARequest(pt, getComboValue(band),radius);
159+
wpReq= WebPlotRequest.makeISSARequest(pt, getComboValue(key),radius);
117160
break;
118161
case MSX:
119-
wpReq= WebPlotRequest.makeMSXRequest(pt, getComboValue(band),radius);
162+
wpReq= WebPlotRequest.makeMSXRequest(pt, getComboValue(key),radius);
120163
break;
121164
case SDSS:
122-
wpReq= WebPlotRequest.makeSloanDSSRequest(pt, getComboValue(band), radius);
165+
wpReq= WebPlotRequest.makeSloanDSSRequest(pt, getComboValue(key), radius);
123166
break;
124167
case TWOMASS:
125-
wpReq= WebPlotRequest.make2MASSRequest(pt, getComboValue(band),radius);
168+
wpReq= WebPlotRequest.make2MASSRequest(pt, getComboValue(key),radius);
169+
break;
170+
case AKARI:
171+
case SEIP:
172+
case ATLAS:
173+
String surveyKey = extractSurveyKey(getComboValue(key));
174+
String surveyKeyBand = extractSurveyKeyBand(getComboValue(key));
175+
String filter = extractFilter(key);
176+
wpReq = WebPlotRequest.makeAtlasRequest(pt, surveyKey, surveyKeyBand, filter, radius);
177+
// if (wpReq != null)
178+
// wpReq.setDrawingSubGroupId(surveyKey.split("\\.")[1]);// Set dataset (table) name as subgroup
126179
break;
127180
case WISE:
128-
String[] pair= getComboValue(band).split("\\.");
181+
String[] pair= getComboValue(key).split("\\.");
129182
wpReq= WebPlotRequest.makeWiseRequest(pt, pair[0], pair[1], radius);
130183
break;
131184
}
132-
if (wpReq!=null) wpReq.setDrawingSubGroupId(ImageSet.lookup(service).subgroup);
185+
if (wpReq != null)
186+
wpReq.setDrawingSubGroupId(ImageSet.lookup(service).subgroup);
133187
return wpReq;
134188
}
135189

190+
/**
191+
* Get ATLAS values from schema.table-band (out of the {@link #seipCombo} for example)
192+
*
193+
* @param metadata expected to be as "schema.table:band;title"
194+
* @return the surveyKey, i.e schema.table
195+
*/
196+
public static String extractSurveyKey(String metadata) {
197+
String sAry[] = metadata.split(regExAtlasKey);
198+
return sAry[0];
199+
}
200+
201+
/**
202+
* @param metadata key expected to be as "schema.table:band;title"
203+
* @return the surveyKeyBand, i.e irac1 for SEIP
204+
*/
205+
public static String extractSurveyKeyBand(String metadata) {
206+
String sAry[] = metadata.split(regExAtlasKey);
207+
return sAry[1];
208+
}
209+
210+
/**
211+
* @param metadata expected to be as "schema.table:band;title;filter"
212+
* @return filter value
213+
*/
214+
public static String extractFilter(String metadata) {
215+
String sAry[] = metadata.split(regExSplitKey);
216+
return sAry.length > 1 ? sAry[2] : "";
217+
}
218+
219+
/**
220+
* Value part is the left side of "datax;datay" combo
221+
*
222+
* @param combo string value expected to be of a form "datax;datay"
223+
* @return the first element of the array after splitting the combo into ";" pieces
224+
*/
136225
public static String getComboValue(String combo) {
137-
String sAry[]= combo.split(";");
138-
return sAry.length>0 ? sAry[0] : combo;
226+
String sAry[] = combo.split(regExSplitKey);
227+
return sAry.length > 0 ? sAry[0] : combo;
139228
}
140229

230+
/**
231+
* Title part is the right side of "datax;datay" combo
232+
*
233+
* @param combo string value expected to be of the form "datax;datay"
234+
* @return the second element of the array after splitting the combo into ";" pieces
235+
*/
141236
public static String getComboTitle(String combo) {
142-
String sAry[]= combo.split(";");
143-
return sAry.length>1 ? sAry[1] : combo;
237+
String sAry[] = combo.split(regExSplitKey);
238+
return sAry.length > 1 ? sAry[1] : combo;
144239
}
145240

146241
public static int getPlotWidth(String sizeKey) {
@@ -155,23 +250,26 @@ public static int getPlotWidth(String sizeKey) {
155250

156251

157252

158-
public static enum ImageSet {DSS(DEF, "dss", "dss_bands", dssCombo, null, DEF),
159-
IRIS("IRAS (IRIS)", "iris", "iras_bands", irisCombo, "iraspsc", "IRAS"),
160-
ISSA(DEF, "issa", null, issaCombo, null, DEF),
161-
MSX(DEF, "msx", null, msxCombo, null, DEF),
162-
TWOMASS("2MASS", "2mass","twomass_bands", twoMassCombo, "fp_psc", DEF),
163-
WISE("WISE (AllWISE)", "wise", "wise_bands", wiseCombo, "allwise_p3as_psd", DEF),
164-
SDSS("SDSS (DR7)", "sdss", "sdss_bands",sDssCombo, null, "SDSS (DR10)");
253+
public static enum ImageSet {DSS(WebPlotRequest.ServiceType.DSS, DEF, "dss", "dss_bands", dssCombo, null, DEF ),
254+
IRIS(WebPlotRequest.ServiceType.IRIS,"IRAS (IRIS)", "iris", "iras_bands", irisCombo, "iraspsc", "IRAS"),
255+
ISSA(WebPlotRequest.ServiceType.ISSA, DEF, "issa", null, issaCombo, null, DEF),
256+
MSX(WebPlotRequest.ServiceType.MSX, DEF, "msx", null, msxCombo, null, DEF),
257+
TWOMASS(WebPlotRequest.ServiceType.TWOMASS,"2MASS", "2mass","twomass_bands", twoMassCombo, "fp_psc", DEF),
258+
WISE(WebPlotRequest.ServiceType.WISE, "WISE (AllWISE)", "wise", "wise_bands", wiseCombo, "allwise_p3as_psd", DEF),
259+
SEIP(WebPlotRequest.ServiceType.ATLAS, "Spitzer SEIP","seip","seip_bands",seipCombo,"slphotdr4",DEF),
260+
AKARI(WebPlotRequest.ServiceType.ATLAS, "AKARI","akari","akari_bands",akariCombo,"slphotdr4",DEF),
261+
SDSS(WebPlotRequest.ServiceType.SDSS, "SDSS (DR7)", "sdss", "sdss_bands",sDssCombo, null, "SDSS (DR10)");
165262

166-
public WebPlotRequest.ServiceType srvType = WebPlotRequest.ServiceType.valueOf(this.name());
263+
public WebPlotRequest.ServiceType srvType;
167264
public String title;
168265
public String subgroup;
169266
public String band;
170267
public String[] comboAry;
171268
public String catalog;
172269
public String catalogTitle;
173270

174-
ImageSet(String title, String subgroup, String band, String[] comboAry, String catalog, String catalogTitle) {
271+
ImageSet(WebPlotRequest.ServiceType serviceType, String title, String subgroup, String band, String[] comboAry, String catalog, String catalogTitle) {
272+
srvType = serviceType;
175273
this.title = title.equals(DEF) ? srvType.toString() : title;
176274
this.subgroup = subgroup;
177275
this.band = band;
@@ -183,8 +281,23 @@ public static enum ImageSet {DSS(DEF, "dss", "dss_bands", dssCombo, null, DEF),
183281
public static ImageSet lookup(WebPlotRequest.ServiceType srvType) {
184282
return valueOf(srvType.name());
185283
}
284+
public static ImageSet match(String word) {
285+
for (ImageSet s: values()){
286+
if(word.toLowerCase().contains(s.name().toLowerCase())){
287+
return s;
288+
}
289+
}
290+
return null;
291+
}
186292
}
187293

294+
public static void main(String[] args) {
295+
String[] split = new String("schema.table").split("\\.");
296+
297+
for (String s:split){
298+
System.out.println(s);
299+
}
300+
}
188301

189302
public static enum Artifact {
190303
diff_spikes_3("WISE Diffraction Spikes (dots)", "Wise.Artifact.Spikes.level3.Selected"),
@@ -212,9 +325,20 @@ public static boolean isArtifacts(String desc) {
212325
}
213326
}
214327

215-
public static enum Source {DSS, IRIS, twomass, WISE, SDSS}
216-
public static enum Band {dss_bands, iras_bands, twomass_bands, wise_bands, SDSS_bands}
217-
328+
/**
329+
* TODO remove that if not needed, i couldn't find any reference but please double check before rmeoving it!
330+
* @deprecated
331+
*/
332+
public static enum Source {DSS, IRIS, twomass, WISE, ATLAS, SDSS}
333+
/**
334+
* TODO remove that if not needed, i couldn't find any reference but please double check before rmeoving it!
335+
* @deprecated
336+
*/
337+
public static enum Band {dss_bands, iras_bands, twomass_bands, wise_bands, spitzer_bands, SDSS_bands}
338+
/**
339+
* TODO remove that if not needed, i couldn't find any reference but please double check before rmeoving it!
340+
* @deprecated
341+
*/
218342
public static enum Radius {iras_radius, twomass_radius, wise_radius, sdss_radius}
219343

220344
}

src/firefly/java/edu/caltech/ipac/firefly/data/fuse/provider/FinderChartDataSetInfoConverter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,14 @@ private static String getID(WebPlotRequest.ServiceType service, String band) {
334334
else if (band.endsWith("3")) retID= ID.WISE_3.name();
335335
else if (band.endsWith("4")) retID= ID.WISE_4.name();
336336
break;
337+
case SEIP:
338+
case AKARI:
339+
case ATLAS: retID= ID.WISE_1.name();
340+
break;
337341
case MSX:
338342
case NONE:
339343
default:
340-
retID= ID.TWOMASS_J.name();
344+
retID= service.name()+"-"+band;
341345
break;
342346
}
343347
return retID;

src/firefly/java/edu/caltech/ipac/firefly/server/packagedata/Packager.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public Packager(String packageID,
7070
backgroundInfoCacher = packageInfo;
7171
_fgList = fgList;
7272
_maxBundleBytes = maxBundleBytes;
73-
resolveUrlData();
7473
computeEstimate();
7574
}
7675

@@ -271,33 +270,25 @@ public String getID() {
271270
return _packageID;
272271
}
273272

274-
private void resolveUrlData() {
273+
private void computeEstimate() {
274+
long totalSize = 0;
275+
int totalFiles = 0;
275276

277+
// use dynamically created bundles
276278
for (FileGroup fg : _fgList) {
277-
for (FileInfo f : fg) {
278-
String urlStr = f.getInternalFilename();
279-
if (urlStr.contains("://")) {
280-
long size = f.getSizeInBytes();
279+
if(fg.getSizeInBytes()==0) {
280+
long size = 0;
281+
for (FileInfo f : fg) {
282+
size = f.getSizeInBytes();
281283
if (size == 0) {
282284
size = DEFAULT_DATA_BYTES;
283285
f.setSizeInBytes(size);
284-
fg.setSizeInBytes(fg.getSizeInBytes() + size);
285286
}
287+
fg.setSizeInBytes(fg.getSizeInBytes() + size);
286288
}
287289
}
288-
}
289-
}
290-
291-
private void computeEstimate() {
292-
long totalSize = 0;
293-
int totalFiles = 0;
294-
295-
// use dynamically created bundles
296-
for (FileGroup fg : _fgList) {
297290
totalSize += fg.getSizeInBytes();
298-
for (FileInfo f : fg) {
299-
totalFiles++;
300-
}
291+
totalFiles +=fg.getSize();
301292
}
302293
PackagedBundle bundle= new PackagedBundle(0, 0, totalFiles, totalSize);
303294
bundleList.add(bundle);

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceDesc.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public static String get(WebPlotRequest r) {
2323
case DSS: return getDssDesc(r);
2424
case SDSS: return getSloanDssDesc(r);
2525
case WISE: return getWiseDesc(r);
26+
case AKARI:
27+
case SEIP:
2628
case ATLAS: return getAtlasDesc(r);
2729
default: return r.getServiceType()+"";
2830
}
@@ -32,9 +34,9 @@ public static String get(WebPlotRequest r) {
3234
private static String getAtlasDesc(WebPlotRequest r) {
3335

3436
String schema= r.getParam(AtlasIbeDataSource.DATASET_KEY);
35-
String instrument=r.getParam(AtlasIbeDataSource.TABLE_KEY);
37+
String table=r.getParam(AtlasIbeDataSource.TABLE_KEY);
3638
String band= r.getSurveyBand();
37-
return schema + " "+instrument+ " " + band;
39+
return schema + " "+table+ " " + band;
3840
}
3941

4042

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceRetriever.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public FileInfo getFile(WebPlotRequest r) throws FailedRequestException {
3636
case DSS: return getDssPlot(r);
3737
case SDSS: return getSloanDSSPlot(r);
3838
case WISE: return getWisePlot(r);
39+
case AKARI:
40+
case SEIP:
3941
case ATLAS: return getAtlasPlot(r);
4042
case DSS_OR_IRIS: return getDSSorIris(r);
4143
default: throw new FailedRequestException("Unsupported Service");
@@ -126,8 +128,18 @@ private FileInfo getAtlasPlot(WebPlotRequest r) throws FailedRequestException {
126128
AtlasImageParams params = new AtlasImageParams();
127129
params.setWorldPt(circle.getCenter());
128130
params.setBand(r.getSurveyBand());
129-
params.setSchema(r.getParam(AtlasIbeDataSource.DATASET_KEY));
130-
params.setTable(r.getParam(AtlasIbeDataSource.TABLE_KEY));
131+
// New image search deals with atlas surveyKey formatted such as 'schema.table'
132+
String datasetAtlas = r.getSurveyKey();
133+
String schema, table;
134+
if(datasetAtlas!=null && datasetAtlas.split("\\.").length==2){
135+
schema = datasetAtlas.split("\\.")[0];
136+
table = datasetAtlas.split("\\.")[1];
137+
}else{
138+
schema = r.getParam(AtlasIbeDataSource.DATASET_KEY);
139+
table = r.getParam(AtlasIbeDataSource.TABLE_KEY);
140+
}
141+
params.setSchema(schema);
142+
params.setTable(table);
131143
params.setInstrument(r.getParam(AtlasIbeDataSource.INSTRUMENT_KEY));
132144
params.setXtraFilter(r.getParam(AtlasIbeDataSource.XTRA_KEY));
133145
params.setSize((float)circle.getRadius());

0 commit comments

Comments
 (0)