Skip to content

Commit 437aca7

Browse files
authored
DM-8288: Merge PR #231 from DM-8288-client-images
DM-8288: Add support to show LSST SDSS images in triview
2 parents cde67e6 + 409e532 commit 437aca7

File tree

17 files changed

+251
-68
lines changed

17 files changed

+251
-68
lines changed

src/firefly/html/lsst-api-triview.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
MenuItemKeys: {maskOverlay:true},
2424
imageTabs: [ 'fileUpload', 'url', '2mass', 'wise', 'sdss', 'msx', 'dss', 'iras' ],
2525
irsaCatalogFilter: 'lsstFilter',
26-
catalogSpacialOp: 'polygonWhenPlotExist'
26+
catalogSpacialOp: 'polygonWhenPlotExist',
27+
properties : {
28+
daxUrl: 'http://lsst-qserv-dax01.ncsa.illinois.edu:5000'
29+
}
2730
}
2831
}
2932
};

src/firefly/java/edu/caltech/ipac/firefly/data/table/MetaConst.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,5 @@ public class MetaConst {
3030

3131

3232
public static final String DEFAULT_COLOR="DEFAULT_COLOR";
33-
34-
//11/15/16 Added by LZ
35-
public static final String LSST_SDSS_COADD="LSST_COADD_TABLE";
36-
public static final String LSST_SDSS_SINGLE_EXPOSURE="LSST_SINGLE_EXPORSURE_TABLE";
37-
38-
3933
}
4034

src/firefly/java/edu/caltech/ipac/firefly/server/query/lsst/LSSTCataLogSearch.java

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,40 @@
44
import edu.caltech.ipac.firefly.data.CatalogRequest;
55
import edu.caltech.ipac.firefly.data.ServerRequest;
66
import edu.caltech.ipac.firefly.data.TableServerRequest;
7+
import edu.caltech.ipac.firefly.data.table.MetaConst;
78
import edu.caltech.ipac.firefly.data.table.TableMeta;
8-
import edu.caltech.ipac.firefly.server.query.*;
9+
import edu.caltech.ipac.firefly.server.query.DataAccessException;
10+
import edu.caltech.ipac.firefly.server.query.IpacTablePartProcessor;
11+
import edu.caltech.ipac.firefly.server.query.SearchManager;
12+
import edu.caltech.ipac.firefly.server.query.SearchProcessorImpl;
913
import edu.caltech.ipac.firefly.server.util.Logger;
1014
import edu.caltech.ipac.firefly.server.util.ipactable.DataGroupPart;
1115
import edu.caltech.ipac.firefly.server.util.ipactable.DataGroupWriter;
1216
import edu.caltech.ipac.firefly.util.DataSetParser;
1317
import edu.caltech.ipac.firefly.visualize.VisUtil;
14-
import edu.caltech.ipac.util.*;
18+
import edu.caltech.ipac.util.AppProperties;
19+
import edu.caltech.ipac.util.DataGroup;
20+
import edu.caltech.ipac.util.DataObject;
21+
import edu.caltech.ipac.util.DataType;
22+
import edu.caltech.ipac.util.StringUtils;
1523
import edu.caltech.ipac.util.download.FileData;
1624
import edu.caltech.ipac.util.download.URLDownload;
25+
import edu.caltech.ipac.visualize.plot.CoordinateSys;
1726
import edu.caltech.ipac.visualize.plot.WorldPt;
1827
import org.json.simple.JSONArray;
1928
import org.json.simple.JSONObject;
2029
import org.json.simple.parser.JSONParser;
2130
import org.json.simple.parser.ParseException;
22-
import java.io.*;
31+
32+
import java.io.File;
33+
import java.io.FileReader;
34+
import java.io.IOException;
2335
import java.net.URL;
2436
import java.net.URLEncoder;
2537
import java.util.HashMap;
2638
import java.util.List;
2739
import java.util.Locale;
2840
import java.util.Map;
29-
import java.lang.Exception;
30-
31-
import edu.caltech.ipac.visualize.plot.CoordinateSys;
32-
import edu.caltech.ipac.firefly.data.table.MetaConst;
3341

3442

3543
/**
@@ -552,24 +560,24 @@ public void prepareTableMeta(TableMeta meta, List<DataType> columns, ServerReque
552560

553561
super.prepareTableMeta(meta, columns, request);
554562
String catTable = request.getParam("table_name");
563+
String tUp=catTable.toUpperCase();
564+
555565
String RA = getRA(catTable);
556566
String DEC = getDEC(catTable);
557567
TableMeta.LonLatColumns llc = new TableMeta.LonLatColumns(RA, DEC, CoordinateSys.EQ_J2000);
558568
meta.setCenterCoordColumns(llc);
559-
meta.setAttribute(MetaConst.CATALOG_OVERLAY_TYPE, "LSST");
560-
meta.setCenterCoordColumns(llc);
561-
String tableName = request.getParam("table_name");
562-
switch (tableName.toUpperCase()){
563-
case "SCIENCE_CCD_EXPOSURE":
564-
meta.setAttribute(MetaConst.LSST_SDSS_SINGLE_EXPOSURE, "LSST_CCD");
565-
break;
566-
case "DEEPCOADD":
567-
meta.setAttribute(MetaConst.LSST_SDSS_COADD, "LSST_COADD");
568-
break;
569-
default:
570-
meta.setAttribute(MetaConst.CATALOG_OVERLAY_TYPE, "LSST");
571-
}
572569

570+
if (tUp.equals("SCIENCE_CCD_EXPOSURE") || tUp.equals("DEEPCOADD")) {
571+
TableMeta.LonLatColumns c1= new TableMeta.LonLatColumns("corner1Ra", "corner1Decl", CoordinateSys.EQ_J2000);
572+
TableMeta.LonLatColumns c2= new TableMeta.LonLatColumns("corner2Ra", "corner2Decl", CoordinateSys.EQ_J2000);
573+
TableMeta.LonLatColumns c3= new TableMeta.LonLatColumns("corner3Ra", "corner3Decl", CoordinateSys.EQ_J2000);
574+
TableMeta.LonLatColumns c4= new TableMeta.LonLatColumns("corner4Ra", "corner4Decl", CoordinateSys.EQ_J2000);
575+
meta.setCorners(c1, c2, c3, c4);
576+
meta.setAttribute(MetaConst.DATASET_CONVERTER, "lsst_sdss");
577+
}
578+
else {
579+
meta.setAttribute(MetaConst.CATALOG_OVERLAY_TYPE, "LSST");
580+
}
573581
super.prepareTableMeta(meta, columns, request);
574582
}
575583

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/URLFileRetriever.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public FileData getFile(WebPlotRequest request) throws FailedRequestException, G
6464
params.setLoginName(ro.getUserInfo().getLoginName());
6565
params.setSecurityCookie(ro.getRequestAgent().getAuthKey());
6666
}
67-
params.setCheckForNewer(true);
67+
params.setCheckForNewer(request.getUrlCheckForNewer());
6868
params.setLocalFileExtensions(Arrays.asList(FileUtil.FITS, FileUtil.GZ)); //assuming WebPlotRequest ONLY expect FITS or GZ file.
6969
params.setMaxSizeToDownload(VisContext.FITS_MAX_SIZE);
7070
if (request.getUserDesc() != null) params.setDesc(request.getUserDesc()); // set file description

src/firefly/java/edu/caltech/ipac/firefly/visualize/WebPlotRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public enum GridOnStatus {FALSE,TRUE,TRUE_LABELS_FALSE}
9797
public static final String HAS_MAX_ZOOM_LEVEL = "HasMaxZoomLevel";
9898
public static final String THUMBNAIL_SIZE = "thumbnailSize";
9999
public static final String PIPELINE_ORDER = "pipelineOrder"; // todo: convert, doc, add to allKeys
100+
public static final String URL_CHECK_FOR_NEWER = "urlCheckForNewer"; // todo: convert, doc, add to allKeys
100101

101102
public static final String MASK_BITS= "MaskBits";
102103
public static final String PLOT_AS_MASK= "PlotAsMask";
@@ -884,6 +885,10 @@ public String getURL() {
884885
return getSafeParam(URL);
885886
}
886887

888+
public void setUrlCheckForNewer(boolean check) { setSafeParam(URL_CHECK_FOR_NEWER,check+"");}
889+
890+
public boolean getUrlCheckForNewer() { return getBooleanParam(URL_CHECK_FOR_NEWER);}
891+
887892
public void setServiceType(ServiceType service) {
888893
setParam(SERVICE, service.toString());
889894
}

src/firefly/java/edu/caltech/ipac/util/download/URLDownload.java

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,15 @@ public static FileData getDataToFile(URLConnection conn,
364364
FileData outFileData;
365365
FileData retval;
366366
int responseCode= 200;
367+
Map<String,List<String>> sendHeaders= null;
367368
try {
368369
if (conn instanceof HttpURLConnection) {
369370
HttpURLConnection httpConn= (HttpURLConnection) conn;
370371
if (postData!=null) {
371372
pushPostData(httpConn,postData);
372373
}
373374
if (uncompress) httpConn.setRequestProperty("Accept-Encoding", "gzip, deflate");
375+
sendHeaders= httpConn.getRequestProperties();
374376
if (onlyIfModified) {
375377
outFileData = checkAlreadyDownloaded(httpConn, outfile);
376378
if (outFileData != null) return outFileData;
@@ -385,7 +387,7 @@ public static FileData getDataToFile(URLConnection conn,
385387
//------
386388
OutputStream out;
387389
DataInputStream in;
388-
logHeader(postData, conn);
390+
logHeader(postData, conn, sendHeaders);
389391
if (conn instanceof HttpURLConnection) responseCode= ((HttpURLConnection)conn).getResponseCode();
390392
validFileSize(conn, maxFileSize);
391393
File f = useSuggestedFilename ? makeFile(conn, outfile) : outfile;
@@ -658,18 +660,16 @@ public static void logError(URL url, String postData, Exception e) {
658660
}
659661

660662

661-
public static void logHeader(String postData, URLConnection conn) {
663+
public static void logHeader(String postData, URLConnection conn, Map<String,List<String>> sendHeaders) {
662664
StringBuffer workBuff;
663665
try {
664666
Set hSet= null;
665-
String outStr[];
666-
int extra = postData == null ? 3 : 4;
667+
List<String> outStr= new ArrayList<>(40);
668+
int extra = 30;
667669
if (conn instanceof HttpURLConnection && ((HttpURLConnection)conn).getResponseCode()==-1) {
668-
outStr = new String[extra+1];
669670
}
670671
else {
671672
hSet = conn.getHeaderFields().entrySet();
672-
outStr = new String[hSet.size() + extra];
673673
}
674674
Map.Entry entry;
675675
List values;
@@ -678,18 +678,35 @@ public static void logHeader(String postData, URLConnection conn) {
678678
String key;
679679
Iterator k;
680680
if (conn.getURL() != null) {
681-
outStr[i++] = "----------Sending";
682-
outStr[i++] = conn.getURL().toString();
681+
outStr.add("----------Sending");
682+
outStr.add( conn.getURL().toString());
683+
if (sendHeaders!=null) {
684+
for(Map.Entry<String,List<String>> se: sendHeaders.entrySet()) {
685+
workBuff = new StringBuffer(100);
686+
if (se.getKey() == null) key = "<none>";
687+
else key= se.getKey();
688+
workBuff.append(StringUtils.pad(20,key));
689+
workBuff.append(": ");
690+
if (key.equalsIgnoreCase("cookie")) {
691+
workBuff.append("not shown");
692+
}
693+
else {
694+
workBuff.append(se.getValue());
695+
}
696+
outStr.add(workBuff.toString());
697+
}
698+
699+
}
683700
}
684701
if (postData != null) {
685-
outStr[i++] = StringUtils.pad(20,"Post Data ") + ": " + postData;
702+
outStr.add(StringUtils.pad(20,"Post Data ") + ": " + postData);
686703
}
687704
if (conn instanceof HttpURLConnection) {
688705
int responseCode= ((HttpURLConnection)conn).getResponseCode();
689-
outStr[i++] = "----------Received Headers, response status code: " + responseCode;
706+
outStr.add("----------Received Headers, response status code: " + responseCode);
690707
}
691708
else {
692-
outStr[i++] = "----------Received Headers";
709+
outStr.add("----------Received Headers");
693710
}
694711
if (hSet!=null) {
695712
for (Iterator j = hSet.iterator(); (j.hasNext()); ) {
@@ -704,11 +721,11 @@ public static void logHeader(String postData, URLConnection conn) {
704721
if (m > 0) workBuff.append("; ");
705722
workBuff.append(k.next().toString());
706723
}
707-
outStr[i++] = workBuff.toString();
724+
outStr.add(workBuff.toString());
708725
}
709726
}
710727
else {
711-
outStr[i++] = "No headers or status received, invalid http response, using work around";
728+
outStr.add("No headers or status received, invalid http response, using work around");
712729
}
713730
ClientLog.message(outStr);
714731
} catch (Exception e) {
@@ -717,7 +734,7 @@ public static void logHeader(String postData, URLConnection conn) {
717734
}
718735

719736
public static void logHeader(URLConnection conn) {
720-
logHeader(null, conn);
737+
logHeader(null, conn, null);
721738
}
722739

723740
public static void logCompletedDownload(long size) {

src/firefly/js/data/ServerRequest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class ServerRequest {
160160
static parse(str,req) {
161161
if (!str) return null;
162162
words(str,PARAM_SEP).forEach((p) => {
163-
var outParam= words(p,KW_VAL_SEP);
163+
var outParam= p.split(/=(.+)?/,2);
164164
if (outParam.length===2) {
165165
var newParam= {name : outParam[0], value:outParam[1]};
166166
if (!req.addPredefinedAttrib(newParam)) {

src/firefly/js/metaConvert/ConverterFactory.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import {get, has} from 'lodash';
1111
import {makeWisePlotRequest} from './WiseRequestList.js';
1212
import {make2MassPlotRequest} from './TwoMassRequestList.js';
13+
import {makeLsstSdssPlotRequest} from './LsstSdssRequestList.js';
1314
import {WebPlotRequest, TitleOptions} from '../visualize/WebPlotRequest.js';
1415
import {ZoomType} from '../visualize/ZoomType.js';
1516
import {Band} from '../visualize/Band';
@@ -51,6 +52,20 @@ export const converters = {
5152
K : {color : Band.BLUE, title: 'K'}
5253
}
5354
},
55+
'lsst_sdss' : {
56+
threeColor : true,
57+
hasRelatedBands : true,
58+
canGrid : true,
59+
maxPlots : 12,
60+
makeRequest : makeLsstSdssPlotRequest,
61+
threeColorBands : {
62+
u : {color : null, title: 'u'},
63+
g : {color : Band.RED, title: 'g'},
64+
r : {color : Band.GREEN, title: 'r'},
65+
i : {color : null, title: 'i'},
66+
z : {color : Band.BLUE, title: 'z'}
67+
}
68+
},
5469
'UNKNOWN' : {
5570
threeColor : false,
5671
hasRelatedBands : false,
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
3+
*/
4+
5+
/*
6+
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
7+
*/
8+
9+
10+
import {padStart} from 'lodash';
11+
import {getCellValue} from '../tables/TableUtil.js';
12+
import {RangeValues,STRETCH_LINEAR,SIGMA} from '../visualize/RangeValues.js';
13+
import {ZoomType} from '../visualize/ZoomType.js';
14+
import {WebPlotRequest, TitleOptions} from '../visualize/WebPlotRequest.js';
15+
16+
17+
const DAX_URL= 'http://lsst-qserv-dax01.ncsa.illinois.edu:5000';
18+
19+
20+
function makeCcdReqBuilder(table, rowIdx) {
21+
const rangeValues= RangeValues.makeRV({which:SIGMA, lowerValue:-2, upperValue:10, algorithm:STRETCH_LINEAR});
22+
const run= getCellValue(table, rowIdx, 'run');
23+
const field= padStart(getCellValue(table, rowIdx, 'field'), 4, '0');
24+
const camcol= getCellValue(table, rowIdx, 'camcol');
25+
const baseUrl= `${DAX_URL}/image/v0/calexp/ids`;
26+
27+
return (plotId, title, filterName) => {
28+
29+
// id is run + filterId + camcol + field
30+
// const objId= getCellValue(table, rowIdx, 'scienceCcdExposureId');
31+
// const objId= `${run}${filterId}${camcol}${field}`;
32+
// const url= `http://lsst-qserv-dax01.ncsa.illinois.edu:5000/image/v0/calexp/id?id=${objId}`;
33+
const url= `${baseUrl}?run=${run}&camcol=${camcol}&field=${field}&filter=${filterName}`;
34+
const r= WebPlotRequest.makeURLPlotRequest(url);
35+
r.setTitleOptions(TitleOptions.NONE);
36+
r.setTitle(title);
37+
r.setPlotId(plotId);
38+
r.setMultiImageIdx(0);
39+
r.setPreferenceColorKey('lsst-sdss-color-pref');
40+
r.setZoomType(ZoomType.TO_WIDTH);
41+
r.setInitialRangeValues(rangeValues);
42+
return r;
43+
};
44+
}
45+
46+
/**
47+
* make a list of plot request for wise. This function works with ConverterFactory.
48+
* @param table
49+
* @param row
50+
* @param includeSingle
51+
* @param includeStandard
52+
* @param threeColorOps
53+
* @return {{}}
54+
*/
55+
export function makeLsstSdssPlotRequest(table, row, includeSingle, includeStandard, threeColorOps) {
56+
57+
const bandMap= {u:'0', g:'1',r:'2',i:'3', z:'4'};
58+
const retval= {};
59+
var builder;
60+
if (getCellValue(table, row, 'scienceCcdExposureId')) {
61+
builder= makeCcdReqBuilder(table,row);
62+
}
63+
else {
64+
return {single:null, standard:[]};
65+
}
66+
const filterId= Number(getCellValue(table, row, 'filterId'));
67+
const filterName= getCellValue(table, row, 'filterName');
68+
69+
if (includeSingle) {
70+
retval.single= builder('lsst-sdss-'+filterName,filterName, filterName);
71+
}
72+
73+
if (includeStandard) {
74+
retval.standard= [
75+
builder('lsst-sdss-u', 'u', 'u'),
76+
builder('lsst-sdss-g', 'g', 'g'),
77+
builder('lsst-sdss-r', 'r', 'r'),
78+
builder('lsst-sdss-i', 'i', 'i'),
79+
builder('lsst-sdss-z', 'z', 'z'),
80+
];
81+
if (retval.standard[filterId]) retval.highlightPlotId= retval.standard[filterId].getPlotId();
82+
}
83+
84+
if (threeColorOps) {
85+
retval.threeColor= threeColorOps.map( (b) => b && builder('lsst-sdss-threeC', 'SDSS 3 Color', b) );
86+
}
87+
return retval;
88+
}
89+
90+

src/firefly/js/metaConvert/TwoMassRequestList.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {RangeValues,STRETCH_LINEAR,PERCENTAGE} from '../visualize/RangeValues.js
99
import {getCellValue} from '../tables/TableUtil.js';
1010

1111
const colToUse= [ 'filter', 'scanno', 'fname', 'ordate', 'hemisphere', 'in_ra', 'in_dec', 'image_set' ];
12-
const rangeValues= RangeValues.make(PERCENTAGE, 1, PERCENTAGE, 99);
13-
rangeValues.algorithm= STRETCH_LINEAR;
12+
const rangeValues= RangeValues.makeRV({which:PERCENTAGE, lowerValue:1, upperValue:99, algorithm:STRETCH_LINEAR});
1413

1514
const bandIdx= {'J':0, 'K':1, 'H':2};
1615

src/firefly/js/metaConvert/WiseRequestList.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {RangeValues,STRETCH_LINEAR,SIGMA} from '../visualize/RangeValues.js';
99
import {getCellValue} from '../tables/TableUtil.js';
1010

1111
const colToUse= ['scan_id', 'frame_num', 'coadd_id', 'in_ra', 'in_dec', 'image_set'];
12-
const rangeValues= RangeValues.make(SIGMA, -2, SIGMA, 10);
13-
rangeValues.algorithm= STRETCH_LINEAR;
12+
const rangeValues= RangeValues.makeRV({which:SIGMA, lowerValue:-2, upperValue:10, algorithm:STRETCH_LINEAR});
1413

1514
const bandMap= {b1:'1', b2:'2',b3:'3',b4:'4'};
1615

0 commit comments

Comments
 (0)