diff --git a/src/firefly/java/edu/caltech/ipac/firefly/data/FinderChartRequestUtil.java b/src/firefly/java/edu/caltech/ipac/firefly/data/FinderChartRequestUtil.java index e0f22cc503..8024ee68db 100644 --- a/src/firefly/java/edu/caltech/ipac/firefly/data/FinderChartRequestUtil.java +++ b/src/firefly/java/edu/caltech/ipac/firefly/data/FinderChartRequestUtil.java @@ -68,6 +68,38 @@ public class FinderChartRequestUtil { "3a.2;w2", "3a.3;w3", "3a.4;w4"}; + + + /** + * TODO For FC4, need to use config table and new image search, see IRSA-794 and IRSA-816 + * Add reader to parse IRSA configuration table and return a combo depending on the imageset + * For FC3: SEIP + AKARI, we use fixed values for the combos below: + * + * SEIP metadata sent from client (or TODO read from master table) + * thru request so it can be split into schema.table and band, and title. + * THis is passed from the client + * Expected format : metadata expected to be as "schema.table-band;title" + */ + private final static String seipCombo[]={ + "spitzer.seip_science:IRAC1;SEIP IRAC1 (2.4 microns);file_type='science' and fname like '%.mosaic.fits'", + "spitzer.seip_science:IRAC2;SEIP IRAC2 (2.4 microns);file_type='science' and fname like '%.mosaic.fits'", + "spitzer.seip_science:IRAC3;SEIP IRAC3 (2.4 microns);file_type='science' and fname like '%.mosaic.fits'", + "spitzer.seip_science:IRAC4;SEIP IRAC4 (2.4 microns);file_type='science' and fname like '%.mosaic.fits'", + "spitzer.seip_science:MIPS24;SEIP MIPS (2.4 microns);file_type='science' and fname like '%.mosaic.fits'" + }; + + /** + * 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 ';'. + * THis is passed from the client + * Expected format : metadata expected to be as "schema.table-band;title" + */ + private final static String akariCombo[]={ + "akari.images_tbl:N60;FIS N60 (65 micron)", + "akari.images_tbl:WideS;FIS WideS (90 micron)", + "akari.images_tbl:WideL;FIS WideL (140 micron)", + "akari.images_tbl:N160;FIS N160 (160 micron)" + }; + private final static String sDssCombo[]={ "u;u","g;g","r;r","i;i","z;z" }; @@ -78,15 +110,26 @@ public class FinderChartRequestUtil { put("large",256); } }; + private static String regExAtlasKey = ":"; + private static String regExSplitKey = ";"; + /** + * @param pt + * @param radius + * @param width + * @param key string combination of value to be splitted for convenience + * @param expandedTitle + * @param service + * @return + */ public static WebPlotRequest makeWebPlotRequest(WorldPt pt, float radius, int width, - String band, + String key, String expandedTitle, WebPlotRequest.ServiceType service ) { - WebPlotRequest wpReq= getWebPlotRequest(service, band, pt, radius); + WebPlotRequest wpReq= getWebPlotRequest(service, key, pt, radius); if (!StringUtils.isEmpty(expandedTitle)) wpReq.setExpandedTitle(expandedTitle); wpReq.setExpandedTitleOptions(WebPlotRequest.ExpandedTitleOptions.PREFIX); wpReq.setZoomType(ZoomType.TO_WIDTH); @@ -99,48 +142,100 @@ public static WebPlotRequest makeWebPlotRequest(WorldPt pt, wpReq.setHideTitleDetail(true); wpReq.setPreferenceColorKey("FcColorKey"); wpReq.setTitleOptions(WebPlotRequest.TitleOptions.SERVICE_OBS_DATE); - wpReq.setTitle(getComboTitle(band)); + wpReq.setTitle(getComboTitle(key)); return wpReq; } - private static WebPlotRequest getWebPlotRequest(WebPlotRequest.ServiceType service, String band, WorldPt pt, Float radius) { + private static WebPlotRequest getWebPlotRequest(WebPlotRequest.ServiceType service, String key, WorldPt pt, Float radius) { WebPlotRequest wpReq=null; switch (service) { case DSS: - wpReq= WebPlotRequest.makeDSSRequest(pt, getComboValue(band),radius); + wpReq= WebPlotRequest.makeDSSRequest(pt, getComboValue(key),radius); break; case IRIS: - wpReq= WebPlotRequest.makeIRISRequest(pt, getComboValue(band), radius); + wpReq= WebPlotRequest.makeIRISRequest(pt, getComboValue(key), radius); break; case ISSA: - wpReq= WebPlotRequest.makeISSARequest(pt, getComboValue(band),radius); + wpReq= WebPlotRequest.makeISSARequest(pt, getComboValue(key),radius); break; case MSX: - wpReq= WebPlotRequest.makeMSXRequest(pt, getComboValue(band),radius); + wpReq= WebPlotRequest.makeMSXRequest(pt, getComboValue(key),radius); break; case SDSS: - wpReq= WebPlotRequest.makeSloanDSSRequest(pt, getComboValue(band), radius); + wpReq= WebPlotRequest.makeSloanDSSRequest(pt, getComboValue(key), radius); break; case TWOMASS: - wpReq= WebPlotRequest.make2MASSRequest(pt, getComboValue(band),radius); + wpReq= WebPlotRequest.make2MASSRequest(pt, getComboValue(key),radius); + break; + case AKARI: + case SEIP: + case ATLAS: + String surveyKey = extractSurveyKey(getComboValue(key)); + String surveyKeyBand = extractSurveyKeyBand(getComboValue(key)); + String filter = extractFilter(key); + wpReq = WebPlotRequest.makeAtlasRequest(pt, surveyKey, surveyKeyBand, filter, radius); +// if (wpReq != null) +// wpReq.setDrawingSubGroupId(surveyKey.split("\\.")[1]);// Set dataset (table) name as subgroup break; case WISE: - String[] pair= getComboValue(band).split("\\."); + String[] pair= getComboValue(key).split("\\."); wpReq= WebPlotRequest.makeWiseRequest(pt, pair[0], pair[1], radius); break; } - if (wpReq!=null) wpReq.setDrawingSubGroupId(ImageSet.lookup(service).subgroup); + if (wpReq != null) + wpReq.setDrawingSubGroupId(ImageSet.lookup(service).subgroup); return wpReq; } + /** + * Get ATLAS values from schema.table-band (out of the {@link #seipCombo} for example) + * + * @param metadata expected to be as "schema.table:band;title" + * @return the surveyKey, i.e schema.table + */ + public static String extractSurveyKey(String metadata) { + String sAry[] = metadata.split(regExAtlasKey); + return sAry[0]; + } + + /** + * @param metadata key expected to be as "schema.table:band;title" + * @return the surveyKeyBand, i.e irac1 for SEIP + */ + public static String extractSurveyKeyBand(String metadata) { + String sAry[] = metadata.split(regExAtlasKey); + return sAry[1]; + } + + /** + * @param metadata expected to be as "schema.table:band;title;filter" + * @return filter value + */ + public static String extractFilter(String metadata) { + String sAry[] = metadata.split(regExSplitKey); + return sAry.length > 1 ? sAry[2] : ""; + } + + /** + * Value part is the left side of "datax;datay" combo + * + * @param combo string value expected to be of a form "datax;datay" + * @return the first element of the array after splitting the combo into ";" pieces + */ public static String getComboValue(String combo) { - String sAry[]= combo.split(";"); - return sAry.length>0 ? sAry[0] : combo; + String sAry[] = combo.split(regExSplitKey); + return sAry.length > 0 ? sAry[0] : combo; } + /** + * Title part is the right side of "datax;datay" combo + * + * @param combo string value expected to be of the form "datax;datay" + * @return the second element of the array after splitting the combo into ";" pieces + */ public static String getComboTitle(String combo) { - String sAry[]= combo.split(";"); - return sAry.length>1 ? sAry[1] : combo; + String sAry[] = combo.split(regExSplitKey); + return sAry.length > 1 ? sAry[1] : combo; } public static int getPlotWidth(String sizeKey) { @@ -155,15 +250,17 @@ public static int getPlotWidth(String sizeKey) { - public static enum ImageSet {DSS(DEF, "dss", "dss_bands", dssCombo, null, DEF), - IRIS("IRAS (IRIS)", "iris", "iras_bands", irisCombo, "iraspsc", "IRAS"), - ISSA(DEF, "issa", null, issaCombo, null, DEF), - MSX(DEF, "msx", null, msxCombo, null, DEF), - TWOMASS("2MASS", "2mass","twomass_bands", twoMassCombo, "fp_psc", DEF), - WISE("WISE (AllWISE)", "wise", "wise_bands", wiseCombo, "allwise_p3as_psd", DEF), - SDSS("SDSS (DR7)", "sdss", "sdss_bands",sDssCombo, null, "SDSS (DR10)"); + public static enum ImageSet {DSS(WebPlotRequest.ServiceType.DSS, DEF, "dss", "dss_bands", dssCombo, null, DEF ), + IRIS(WebPlotRequest.ServiceType.IRIS,"IRAS (IRIS)", "iris", "iras_bands", irisCombo, "iraspsc", "IRAS"), + ISSA(WebPlotRequest.ServiceType.ISSA, DEF, "issa", null, issaCombo, null, DEF), + MSX(WebPlotRequest.ServiceType.MSX, DEF, "msx", null, msxCombo, null, DEF), + TWOMASS(WebPlotRequest.ServiceType.TWOMASS,"2MASS", "2mass","twomass_bands", twoMassCombo, "fp_psc", DEF), + WISE(WebPlotRequest.ServiceType.WISE, "WISE (AllWISE)", "wise", "wise_bands", wiseCombo, "allwise_p3as_psd", DEF), + SEIP(WebPlotRequest.ServiceType.ATLAS, "Spitzer SEIP","seip","seip_bands",seipCombo,"slphotdr4",DEF), + AKARI(WebPlotRequest.ServiceType.ATLAS, "AKARI","akari","akari_bands",akariCombo,"slphotdr4",DEF), + SDSS(WebPlotRequest.ServiceType.SDSS, "SDSS (DR7)", "sdss", "sdss_bands",sDssCombo, null, "SDSS (DR10)"); - public WebPlotRequest.ServiceType srvType = WebPlotRequest.ServiceType.valueOf(this.name()); + public WebPlotRequest.ServiceType srvType; public String title; public String subgroup; public String band; @@ -171,7 +268,8 @@ public static enum ImageSet {DSS(DEF, "dss", "dss_bands", dssCombo, null, DEF), public String catalog; public String catalogTitle; - ImageSet(String title, String subgroup, String band, String[] comboAry, String catalog, String catalogTitle) { + ImageSet(WebPlotRequest.ServiceType serviceType, String title, String subgroup, String band, String[] comboAry, String catalog, String catalogTitle) { + srvType = serviceType; this.title = title.equals(DEF) ? srvType.toString() : title; this.subgroup = subgroup; this.band = band; @@ -183,8 +281,23 @@ public static enum ImageSet {DSS(DEF, "dss", "dss_bands", dssCombo, null, DEF), public static ImageSet lookup(WebPlotRequest.ServiceType srvType) { return valueOf(srvType.name()); } + public static ImageSet match(String word) { + for (ImageSet s: values()){ + if(word.toLowerCase().contains(s.name().toLowerCase())){ + return s; + } + } + return null; + } } + public static void main(String[] args) { + String[] split = new String("schema.table").split("\\."); + + for (String s:split){ + System.out.println(s); + } + } public static enum Artifact { diff_spikes_3("WISE Diffraction Spikes (dots)", "Wise.Artifact.Spikes.level3.Selected"), @@ -212,9 +325,20 @@ public static boolean isArtifacts(String desc) { } } - public static enum Source {DSS, IRIS, twomass, WISE, SDSS} - public static enum Band {dss_bands, iras_bands, twomass_bands, wise_bands, SDSS_bands} - + /** + * TODO remove that if not needed, i couldn't find any reference but please double check before rmeoving it! + * @deprecated + */ + public static enum Source {DSS, IRIS, twomass, WISE, ATLAS, SDSS} + /** + * TODO remove that if not needed, i couldn't find any reference but please double check before rmeoving it! + * @deprecated + */ + public static enum Band {dss_bands, iras_bands, twomass_bands, wise_bands, spitzer_bands, SDSS_bands} + /** + * TODO remove that if not needed, i couldn't find any reference but please double check before rmeoving it! + * @deprecated + */ public static enum Radius {iras_radius, twomass_radius, wise_radius, sdss_radius} } diff --git a/src/firefly/java/edu/caltech/ipac/firefly/data/fuse/provider/FinderChartDataSetInfoConverter.java b/src/firefly/java/edu/caltech/ipac/firefly/data/fuse/provider/FinderChartDataSetInfoConverter.java index a279998fe0..ca476da38e 100644 --- a/src/firefly/java/edu/caltech/ipac/firefly/data/fuse/provider/FinderChartDataSetInfoConverter.java +++ b/src/firefly/java/edu/caltech/ipac/firefly/data/fuse/provider/FinderChartDataSetInfoConverter.java @@ -334,10 +334,14 @@ private static String getID(WebPlotRequest.ServiceType service, String band) { else if (band.endsWith("3")) retID= ID.WISE_3.name(); else if (band.endsWith("4")) retID= ID.WISE_4.name(); break; + case SEIP: + case AKARI: + case ATLAS: retID= ID.WISE_1.name(); + break; case MSX: case NONE: default: - retID= ID.TWOMASS_J.name(); + retID= service.name()+"-"+band; break; } return retID; diff --git a/src/firefly/java/edu/caltech/ipac/firefly/server/packagedata/Packager.java b/src/firefly/java/edu/caltech/ipac/firefly/server/packagedata/Packager.java index 18d9f98562..d97636edfb 100644 --- a/src/firefly/java/edu/caltech/ipac/firefly/server/packagedata/Packager.java +++ b/src/firefly/java/edu/caltech/ipac/firefly/server/packagedata/Packager.java @@ -70,7 +70,6 @@ public Packager(String packageID, backgroundInfoCacher = packageInfo; _fgList = fgList; _maxBundleBytes = maxBundleBytes; - resolveUrlData(); computeEstimate(); } @@ -271,33 +270,25 @@ public String getID() { return _packageID; } - private void resolveUrlData() { + private void computeEstimate() { + long totalSize = 0; + int totalFiles = 0; + // use dynamically created bundles for (FileGroup fg : _fgList) { - for (FileInfo f : fg) { - String urlStr = f.getInternalFilename(); - if (urlStr.contains("://")) { - long size = f.getSizeInBytes(); + if(fg.getSizeInBytes()==0) { + long size = 0; + for (FileInfo f : fg) { + size = f.getSizeInBytes(); if (size == 0) { size = DEFAULT_DATA_BYTES; f.setSizeInBytes(size); - fg.setSizeInBytes(fg.getSizeInBytes() + size); } + fg.setSizeInBytes(fg.getSizeInBytes() + size); } } - } - } - - private void computeEstimate() { - long totalSize = 0; - int totalFiles = 0; - - // use dynamically created bundles - for (FileGroup fg : _fgList) { totalSize += fg.getSizeInBytes(); - for (FileInfo f : fg) { - totalFiles++; - } + totalFiles +=fg.getSize(); } PackagedBundle bundle= new PackagedBundle(0, 0, totalFiles, totalSize); bundleList.add(bundle); diff --git a/src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceDesc.java b/src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceDesc.java index c91fc39f7c..2e541daf97 100644 --- a/src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceDesc.java +++ b/src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceDesc.java @@ -23,6 +23,8 @@ public static String get(WebPlotRequest r) { case DSS: return getDssDesc(r); case SDSS: return getSloanDssDesc(r); case WISE: return getWiseDesc(r); + case AKARI: + case SEIP: case ATLAS: return getAtlasDesc(r); default: return r.getServiceType()+""; } @@ -32,9 +34,9 @@ public static String get(WebPlotRequest r) { private static String getAtlasDesc(WebPlotRequest r) { String schema= r.getParam(AtlasIbeDataSource.DATASET_KEY); - String instrument=r.getParam(AtlasIbeDataSource.TABLE_KEY); + String table=r.getParam(AtlasIbeDataSource.TABLE_KEY); String band= r.getSurveyBand(); - return schema + " "+instrument+ " " + band; + return schema + " "+table+ " " + band; } diff --git a/src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceRetriever.java b/src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceRetriever.java index bd7ca3a503..d3faef920c 100644 --- a/src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceRetriever.java +++ b/src/firefly/java/edu/caltech/ipac/firefly/server/visualize/imageretrieve/ServiceRetriever.java @@ -36,6 +36,8 @@ public FileInfo getFile(WebPlotRequest r) throws FailedRequestException { case DSS: return getDssPlot(r); case SDSS: return getSloanDSSPlot(r); case WISE: return getWisePlot(r); + case AKARI: + case SEIP: case ATLAS: return getAtlasPlot(r); case DSS_OR_IRIS: return getDSSorIris(r); default: throw new FailedRequestException("Unsupported Service"); @@ -126,8 +128,18 @@ private FileInfo getAtlasPlot(WebPlotRequest r) throws FailedRequestException { AtlasImageParams params = new AtlasImageParams(); params.setWorldPt(circle.getCenter()); params.setBand(r.getSurveyBand()); - params.setSchema(r.getParam(AtlasIbeDataSource.DATASET_KEY)); - params.setTable(r.getParam(AtlasIbeDataSource.TABLE_KEY)); + // New image search deals with atlas surveyKey formatted such as 'schema.table' + String datasetAtlas = r.getSurveyKey(); + String schema, table; + if(datasetAtlas!=null && datasetAtlas.split("\\.").length==2){ + schema = datasetAtlas.split("\\.")[0]; + table = datasetAtlas.split("\\.")[1]; + }else{ + schema = r.getParam(AtlasIbeDataSource.DATASET_KEY); + table = r.getParam(AtlasIbeDataSource.TABLE_KEY); + } + params.setSchema(schema); + params.setTable(table); params.setInstrument(r.getParam(AtlasIbeDataSource.INSTRUMENT_KEY)); params.setXtraFilter(r.getParam(AtlasIbeDataSource.XTRA_KEY)); params.setSize((float)circle.getRadius()); diff --git a/src/firefly/java/edu/caltech/ipac/firefly/visualize/WebPlotRequest.java b/src/firefly/java/edu/caltech/ipac/firefly/visualize/WebPlotRequest.java index aec1875878..f2a0991bad 100644 --- a/src/firefly/java/edu/caltech/ipac/firefly/visualize/WebPlotRequest.java +++ b/src/firefly/java/edu/caltech/ipac/firefly/visualize/WebPlotRequest.java @@ -30,8 +30,9 @@ */ public class WebPlotRequest extends ServerRequest { + // TODO this is actually coupled with edu.caltech.ipac.firefly.data.FinderChartRequestUtil.ImageSet.ImageSet and so we need to add imageset here although SEIP, AKARI are using ATLAS services. public enum - ServiceType {IRIS, ATLAS, ISSA, DSS, SDSS, TWOMASS, MSX, DSS_OR_IRIS, WISE, NONE} + ServiceType {IRIS, SEIP, AKARI, ATLAS, ISSA, DSS, SDSS, TWOMASS, MSX, DSS_OR_IRIS, WISE, NONE} public enum TitleOptions {NONE, // use what it in the title PLOT_DESC, // use the plot description key FILE_NAME, // use the file name or analyze the URL and make a title from that @@ -377,6 +378,29 @@ public static WebPlotRequest makeWiseRequest(WorldPt wp, return req; } + /** + * @param wp + * @param survey for atlas, survey is in form of 'schema.table' + * @param band SEIP exmaple 'irac1' + * @param filter for SEIP, it should loo like type=science and fname like %.mosaic.fits + * @param sizeInDeg + * @return + */ + public static WebPlotRequest makeAtlasRequest(WorldPt wp, + String survey, + String band, String filter, + float sizeInDeg) { + WebPlotRequest req = makePlotServiceReq(ServiceType.ATLAS, wp, survey, sizeInDeg); + req.setParam(SURVEY_KEY, survey.split("\\.")[0]); + req.setParam("dataset", survey.split("\\.")[0]); + req.setParam("table", survey.split("\\.")[1]); + req.setParam("filter", filter); //Needed for the query but not for fetching the data (see QueryIBE metadata) + req.setParam(SURVEY_KEY_BAND, band + ""); + req.setTitle(survey + "," + band); + // TODO drawingSubGroupId TO BE SET OUTSIDE here! ATLAS has many dataset and it will depend on the app to group those images, example: See ImageSelectPanelResult.js, Finderrchart... + //req.setDrawingSubGroupId(survey.split(".")[1]); // 'spitzer.seip_science' + return req; + } //======================== DSS or IRIS ===================================== public static WebPlotRequest makeDSSOrIRISRequest(WorldPt wp, diff --git a/src/firefly/js/core/background/BackgroundMonitor.jsx b/src/firefly/js/core/background/BackgroundMonitor.jsx index aecb1b968f..bdf6add0e1 100644 --- a/src/firefly/js/core/background/BackgroundMonitor.jsx +++ b/src/firefly/js/core/background/BackgroundMonitor.jsx @@ -266,9 +266,9 @@ function PackageItem(progress) { var pct= BY_SIZE ? (processedBytes / totalBytes) : (processedFiles / totalFiles); pct = Math.round(100 * pct); - const pctOf = BY_SIZE ? Math.round(totalBytes/1024/1024) + ' MB' : + const pctOf = BY_SIZE ? Math.round(Math.max(totalBytes/1024/1024,1)) + ' MB' : totalFiles + ' files'; - const finalSize = Math.round(finalCompressedBytes/1024/1024, -1); + const finalSize = Math.round(Math.max(finalCompressedBytes/1024/1024,1)); const dlmsg = SINGLE ? 'Download Now' : `Download Part #${INDEX+1}`; if (isSuccess(STATE) || pct === 100) { // because when there is only 1 item, state is set to success but pct does not calculate to 100% diff --git a/src/firefly/js/ui/FitsDownloadDialog.jsx b/src/firefly/js/ui/FitsDownloadDialog.jsx index 357bc8daf8..598efec3e6 100644 --- a/src/firefly/js/ui/FitsDownloadDialog.jsx +++ b/src/firefly/js/ui/FitsDownloadDialog.jsx @@ -485,6 +485,9 @@ function makeServiceFileName(req,plot, band) { case ServiceType.WISE: retval= 'wise-'+req.getSurveyKey()+'-'+req.getSurveyBand()+'.fits'; break; + case ServiceType.ATLAS: + retval= 'atlas-'+req.getSurveyKey()+'-'+req.getSurveyBand()+'.fits'; + break; case ServiceType.NONE: retval= makeTitleFileName(plot, band); break;