Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/firefly/html/firefly.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<title>IRSA Viewer</title>

<script>
window.firefly = {app: {}};
window.firefly = {
app: {},
MenuItemKeys: {maskOverlay:true}
};
</script>
<script type="text/javascript" src="firefly_loader.js"></script>
</head>
Expand All @@ -19,6 +22,9 @@
<!-- attached loaction for firefly app -->
<div id='app'/>




</body>

</html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ServerContext {
private static final int PFX_START_LEN= PFX_START.length();
public static final String PFX_END= "}";
private static final int PFX_TOTAL_CHAR= 3;
public static final boolean FITS_SECURITY = AppProperties.getBooleanProperty("visualize.fits.Security", true);
public static boolean FITS_SECURITY;
public static final String VIS_SEARCH_PATH= "visualize.fits.search.path";
public final static Map<File, Long> _visSessionDirs= new ConcurrentHashMap<File, Long>(617);
public static boolean DEBUG_MODE;
Expand Down Expand Up @@ -146,6 +146,10 @@ public static void configInit() {
// disable caching is it's a preference
CacheManager.setDisabled(AppProperties.getBooleanProperty(CACHEMANAGER_DISABLED_PROP, false));


// Must be done after property init
FITS_SECURITY = AppProperties.getBooleanProperty("visualize.fits.Security", true);

// use EhCache for caching.
CacheManager.setCacheProvider(EhcacheProvider.class.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ private static ImagePlotInfo[] makeNewPlots(String workingCtxStr,
VisContext.purgeOtherPlots(state);
state.setOriginalImageIdx(idx, NO_BAND);
state.setImageIdx(idx, NO_BAND);
state.setMultiImageFile(true,Band.NO_BAND);
//todo: here
plotInfo[0] = ImagePlotCreator.makeOneImagePerBand(workingCtxStr, state, readInfoMap, zoomChoice);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ static ImagePlot createImagePlot(PlotState state,
if (plot.getImageDataWidth()!=rWidth || plot.getImageDataWidth()!=rHeight) {
String primDim= rWidth+"x"+rHeight;
String overDim= plot.getImageDataWidth()+"x"+plot.getImageDataHeight();
throw new FitsException("Mask Overlay does not match the primary plot dimensions ("+
overDim+" vs "+primDim+")");
// throw new FitsException("Mask Overlay does not match the primary plot dimensions ("+
// overDim+" vs "+primDim+")");
_log.warn( "Mask Overlay does not match the primary plot dimensions ("+ overDim+" vs "+primDim+")");
}
}
else { // standard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public static void initRequestFromState(WebPlotRequest req, PlotState oldState,
req.setInitialRangeValues(oldState.getRangeValues(band));
req.setInitialColorTable(oldState.getColorTableId());
req.setInitialZoomLevel(oldState.getZoomLevel());
WebPlotRequest oldReq= oldState.getPrimaryRequest();
if (oldReq.isPlotAsMask()) {
req.setPlotAsMask(true);
req.setMaskBits(req.getMaskBits());
req.setMaskColors(req.getMaskColors().toArray(new String[3]));
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import edu.caltech.ipac.firefly.visualize.InsertBandInitializer;
import edu.caltech.ipac.firefly.visualize.PlotImages;
import edu.caltech.ipac.firefly.visualize.PlotState;
import edu.caltech.ipac.firefly.visualize.ProjectionSerializer;
import edu.caltech.ipac.firefly.visualize.StretchData;
import edu.caltech.ipac.firefly.visualize.WebFitsData;
import edu.caltech.ipac.firefly.visualize.WebPlotInitializer;
Expand Down Expand Up @@ -71,7 +70,8 @@ public static JSONObject serializeWebPlotInitializerDeep(WebPlotInitializer wpIn
}

public static JSONObject serializeProjection(WebPlotInitializer wpInit) {
Projection proj= ProjectionSerializer.deserializeProjection(wpInit.getProjectionSerialized());
// Projection proj= ProjectionSerializer.deserializeProjection(wpInit.getProjectionSerialized());
Projection proj= wpInit.getProjection();
if (proj==null) return null;
JSONObject map = new JSONObject();
map.put("coorindateSys", proj.getCoordinateSys().toString());
Expand Down Expand Up @@ -133,6 +133,10 @@ public static JSONObject serializeProjectionParams(ProjectionParams p) {
map.put("map_distortion", p.map_distortion);
map.put("keyword", p.keyword);

for(Map.Entry<String,String> e : p.additionalHeaders.entrySet() ) {
map.put(e.getKey(),e.getValue());
}

return map;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
* Time: 1:27 PM
*/

import edu.caltech.ipac.firefly.data.DataEntry;
import edu.caltech.ipac.firefly.data.ServerParams;
import edu.caltech.ipac.firefly.data.TableServerRequest;
import edu.caltech.ipac.firefly.data.table.TableMeta;
import edu.caltech.ipac.firefly.server.ServerCommandAccess;
import edu.caltech.ipac.firefly.server.servlets.CommandService;
import edu.caltech.ipac.firefly.server.util.Logger;
Expand All @@ -23,18 +21,18 @@
import edu.caltech.ipac.firefly.visualize.WebPlotRequest;
import edu.caltech.ipac.firefly.visualize.WebPlotResult;
import edu.caltech.ipac.firefly.visualize.draw.StaticDrawInfo;
import edu.caltech.ipac.util.FileUtil;
import edu.caltech.ipac.util.DataGroup;
import edu.caltech.ipac.visualize.plot.ImagePt;

import nom.tam.fits.FitsException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author Trey Roby
Expand Down Expand Up @@ -77,16 +75,28 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx


SrvParam sp= new SrvParam(paramMap);
PlotState state= sp.getState();
// PlotState state= sp.getState();
PlotState stateAry[]= sp.getStateAry();
PlotState state= stateAry[0];
ImagePt pt = sp.getRequiredImagePt("pt");

FileAndHeaderInfo fahAry[];
List<FileAndHeaderInfo> list = new ArrayList<FileAndHeaderInfo>(state.getBands().length);
for(Band b : state.getBands()) {
list.add(state.getFileAndHeaderInfo(b));
}

if (stateAry.length>1) {
for(int i=1; (i<stateAry.length);i++) {
list.add(stateAry[i].getFileAndHeaderInfo(Band.NO_BAND) );
}
}



fahAry = list.toArray(new FileAndHeaderInfo[list.size()]);


String[] res = VisServerOps.getFileFlux(fahAry, pt);


Expand All @@ -96,9 +106,19 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx

JSONObject data= new JSONObject();
Band[] bands = state.getBands();
for (int i=0; i<res.length; i++){
data.put(bands[i].toString(), res[i]);
int resultCnt=0;
for (;resultCnt<res.length && resultCnt<bands.length; resultCnt++){
data.put(bands[resultCnt].toString(), res[resultCnt]);
}


if (stateAry.length>1) {
for(int i=1; (i<stateAry.length);i++) {
data.put("overlay-"+(i-1), res[resultCnt++]);
}
}


data.put("success", true);

JSONArray wrapperAry= new JSONArray();
Expand Down Expand Up @@ -392,8 +412,9 @@ public static class FlipImageOnY extends ServerCommandAccess.ServCommand {

public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentException {
SrvParam sp= new SrvParam(paramMap);
PlotState state= sp.getState();
WebPlotResult result = VisServerOps.flipImageOnY(state);
PlotState stateAry[]= sp.getStateAry();
// PlotState state= sp.getState();
WebPlotResult result = VisServerOps.flipImageOnY(stateAry);
return WebPlotResultSerializer.createJson(result, sp.isJsonDeep());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ public static WebPlotResult crop(PlotState state, ImagePt c1, ImagePt c2, boolea

File workingFilsFile = PlotStateUtil.getWorkingFitsFile(state, bands[i]);
String fName = workingFilsFile.getName();
File cropFile = File.createTempFile(FileUtil.getBase(fName) + "-crop",
String multiStr= state.isMultiImageFile(bands[i]) ? "-multi" : "-"+state.getImageIdx(bands[i]);
File cropFile = File.createTempFile(FileUtil.getBase(fName) + multiStr + "-crop",
"." + FileUtil.FITS,
ServerContext.getVisSessionDir());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class WebPlotInitializer implements Serializable, DataEntry {
private WebFitsData _fitsData[];
private String _desc;
private String _dataDesc;
private transient Projection _projection;



Expand All @@ -55,6 +56,7 @@ public WebPlotInitializer(PlotState plotState,
_initImages= images;
_imageCoordSys= imageCoordSys;
_projectionSerialized= ProjectionSerializer.serializeProjection(projection);
_projection= projection;
_dataWidth= dataWidth;
_dataHeight= dataHeight;
_imageScaleFactor= imageScaleFactor;
Expand All @@ -73,7 +75,7 @@ public WebPlotInitializer(PlotState plotState,

public Projection getProjection() {
// return _projection;
return ProjectionSerializer.deserializeProjection(_projectionSerialized);
return _projection!=null ? _projection : ProjectionSerializer.deserializeProjection(_projectionSerialized);
}

public String getProjectionSerialized() { return _projectionSerialized; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,12 @@ public void setMaskColors(String colors[]) {
public List<String> getMaskColors() {
if (containsParam(MASK_COLORS)) {
String data= getParam(MASK_COLORS);
return StringUtils.parseStringList(data,";");
List<String> retval= StringUtils.parseStringList(data,";");
if (retval.size()==0 && data.length()>0) {
retval= new ArrayList<>(1);
retval.add(data);
}
return retval;
}
else {
return Collections.emptyList();
Expand Down
28 changes: 15 additions & 13 deletions src/firefly/java/edu/caltech/ipac/visualize/plot/FitsRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class FitsRead implements Serializable {
private final int extension_number;
private final BasicHDU hdu;
private float[] float1d;
private Fits fits;
// private Fits fits;
private ImageHeader imageHeader;
private Header header;
private int indexInFile = -1; // -1 unknown, >=0 index in file
Expand All @@ -89,8 +89,8 @@ public class FitsRead implements Serializable {
private FitsRead(Fits fits, ImageHDU imageHdu) throws FitsException {

//assign some instant variables
this.fits = fits;
hdu = imageHdu;
// this.fits = fits;
this.hdu = imageHdu;
header = imageHdu.getHeader();

planeNumber = header.getIntValue("SPOT_PL", 0);
Expand Down Expand Up @@ -132,8 +132,8 @@ private FitsRead(Fits fits, ImageHDU imageHdu) throws FitsException {
private FitsRead(Fits fits, ImageHDU imageHdu, int maskExtension) throws FitsException {

//assign some instant variables
this.fits = fits;
hdu = imageHdu;
// this.fits = fits;
this.hdu = imageHdu;
header = imageHdu.getHeader();
planeNumber = header.getIntValue("SPOT_PL", 0);
extension_number = header.getIntValue("SPOT_EXT", -1);
Expand All @@ -146,7 +146,7 @@ private FitsRead(Fits fits, ImageHDU imageHdu, int maskExtension) throws FitsExc
}
//get the data and store into float array
float1d = getImageHDUDataInFloatArray(imageHdu);
masks = getMasksInFits(maskExtension);
masks = getMasksInFits(fits, maskExtension);

hist= computeHistogram();

Expand All @@ -162,7 +162,7 @@ private FitsRead(Fits fits, ImageHDU imageHdu, int maskExtension) throws FitsExc

}

private short[] getMasksInFits(int maskExtension) throws FitsException {
private short[] getMasksInFits(Fits fits, int maskExtension) throws FitsException {

//get all the Header Data Unit from the fits file
BasicHDU[] HDUs = fits.read();
Expand Down Expand Up @@ -281,8 +281,10 @@ public static FitsImageCube createFitsImageCube(Fits fits)throws FitsException {

public static FitsRead createFitsReadFlipLR(FitsRead aFitsReader)
throws FitsException, GeomException {
FlipLR flipLr = new FlipLR();
return (flipLr.do_flip(aFitsReader));

return new FlipXY(aFitsReader,"yAxis").doFlip();
// FlipLR flipLr = new FlipLR();
// return (flipLr.do_flip(aFitsReader));
}

/**
Expand Down Expand Up @@ -1653,9 +1655,9 @@ public boolean isSameProjection(FitsRead secondFitsread) {
}


public Fits getFits() {
return (fits);
}
// public Fits getFits() {
// return (fits);
// }

public BasicHDU getHDU() {
return hdu;
Expand Down Expand Up @@ -1838,7 +1840,7 @@ public static float[][] getDataFloat(ImageHDU imageHDU)

public void freeResources() {
float1d = null;
fits = null;
// fits = null;
imageHeader = null;
header = null;

Expand Down
20 changes: 20 additions & 0 deletions src/firefly/java/edu/caltech/ipac/visualize/plot/ImageHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
import edu.caltech.ipac.visualize.plot.projection.ProjectionParams;
import nom.tam.fits.FitsException;
import nom.tam.fits.Header;
import nom.tam.fits.HeaderCard;
import nom.tam.util.Cursor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;


public class ImageHeader implements Serializable
Expand Down Expand Up @@ -73,6 +77,7 @@ public class ImageHeader implements Serializable
public double bp[][] = new double[ProjectionParams.MAX_SIP_LENGTH][ProjectionParams.MAX_SIP_LENGTH];
public boolean map_distortion = false;
public String keyword;
public Map<String,String> additionalHeaders= new HashMap<>(77);


public ImageHeader()
Expand Down Expand Up @@ -101,6 +106,18 @@ public ImageHeader(Header header, long HDU_offset, int _plane_number)
String ctype1_trim = null;

long header_size = header.getOriginalSize();

Cursor extraIter= header.iterator();
for(;extraIter.hasNext();) {
HeaderCard hc= (HeaderCard)extraIter.next();
if (hc.getKey().startsWith("MP") || hc.getKey().startsWith("HIERARCH.MP")) {
additionalHeaders.put(hc.getKey(), hc.getValue());
}
}




data_offset = HDU_offset + header_size;
plane_number = _plane_number;

Expand Down Expand Up @@ -709,6 +726,7 @@ public Projection createProjection(CoordinateSys csys) {
public static ProjectionParams createProjectionParams(ImageHeader hdr) {
ProjectionParams params= new ProjectionParams();

params.additionalHeaders= hdr.additionalHeaders;
params.bitpix= hdr.bitpix;
params.naxis = hdr.naxis;
params.naxis1= hdr.naxis1;
Expand Down Expand Up @@ -765,6 +783,8 @@ public static ProjectionParams createProjectionParams(ImageHeader hdr) {
params.map_distortion= hdr.map_distortion;
params.keyword= hdr.keyword;



return params;

}
Expand Down
Loading