List of usage examples for java.lang Double POSITIVE_INFINITY
double POSITIVE_INFINITY
To view the source code for java.lang Double POSITIVE_INFINITY.
Click Source Link
From source file:ffx.xray.parsers.MTZWriter.java
/** * <p>//ww w.ja va 2 s .c om * write</p> */ public void write() { ByteOrder byteOrder = ByteOrder.nativeOrder(); FileOutputStream fileOutputStream; DataOutputStream dataOutputStream; try { if (logger.isLoggable(Level.INFO)) { StringBuilder sb = new StringBuilder(); sb.append(format("\n Writing MTZ HKL file: \"%s\"\n", fileName)); logger.info(sb.toString()); } fileOutputStream = new FileOutputStream(fileName); dataOutputStream = new DataOutputStream(fileOutputStream); byte bytes[] = new byte[80]; int offset = 0; int writeLen = 0; int iMapData; float fMapData; // Header. StringBuilder sb = new StringBuilder(); sb.append("MTZ "); dataOutputStream.writeBytes(sb.toString()); // Header offset. int headerOffset = n * nCol + 21; ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); byteBuffer.order(byteOrder).putInt(headerOffset); // Machine code: double, float, int, uchar // 0x4441 for LE, 0x1111 for BE if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) { iMapData = 0x4441; } else { iMapData = 0x1111; } byteBuffer.order(byteOrder).putInt(iMapData); dataOutputStream.write(bytes, offset, 8); sb = new StringBuilder(); sb.append(" "); sb.setLength(68); dataOutputStream.writeBytes(sb.toString()); // Data. Vector<String> colname = new Vector<>(nCol); char colType[] = new char[nCol]; double res[] = new double[2]; res[0] = Double.POSITIVE_INFINITY; res[1] = Double.NEGATIVE_INFINITY; float colMinMax[][] = new float[nCol][2]; for (int i = 0; i < nCol; i++) { colMinMax[i][0] = Float.POSITIVE_INFINITY; colMinMax[i][1] = Float.NEGATIVE_INFINITY; } ReflectionSpline sigmaASpline = new ReflectionSpline(reflectionList, refinementData.sigmaa.length); int col = 0; colname.add("H"); colType[col++] = 'H'; colname.add("K"); colType[col++] = 'H'; colname.add("L"); colType[col++] = 'H'; writeLen += 12; if (mtzType != MTZType.FCONLY) { colname.add("FO"); colType[col++] = 'F'; colname.add("SIGFO"); colType[col++] = 'Q'; colname.add("FreeR"); colType[col++] = 'I'; writeLen += 12; } if (mtzType != MTZType.DATAONLY) { colname.add("Fs"); colType[col++] = 'F'; colname.add("PHIFs"); colType[col++] = 'P'; colname.add("Fc"); colType[col++] = 'F'; colname.add("PHIFc"); colType[col++] = 'P'; writeLen += 16; } if (mtzType == MTZType.ALL) { colname.add("FOM"); colType[col++] = 'W'; colname.add("PHIW"); colType[col++] = 'P'; colname.add("SigmaAs"); colType[col++] = 'F'; colname.add("SigmaAw"); colType[col++] = 'Q'; colname.add("FWT"); colType[col++] = 'F'; colname.add("PHWT"); colType[col++] = 'P'; colname.add("DELFWT"); colType[col++] = 'F'; colname.add("PHDELWT"); colType[col++] = 'P'; writeLen += 32; } for (HKL ih : reflectionList.hkllist) { col = 0; int i = ih.index(); // Skip the 0 0 0 reflection. if (ih.h() == 0 && ih.k() == 0 && ih.l() == 0) { continue; } double ss = Crystal.invressq(crystal, ih); res[0] = min(ss, res[0]); res[1] = max(ss, res[1]); // HKL first (3) fMapData = ih.h(); colMinMax[col][0] = min(fMapData, colMinMax[0][0]); colMinMax[col][1] = max(fMapData, colMinMax[0][1]); byteBuffer.rewind(); byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = ih.k(); colMinMax[col][0] = min(fMapData, colMinMax[1][0]); colMinMax[col][1] = max(fMapData, colMinMax[1][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = ih.l(); colMinMax[col][0] = min(fMapData, colMinMax[2][0]); colMinMax[col][1] = max(fMapData, colMinMax[2][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; if (mtzType != MTZType.FCONLY) { // F/sigF (2) fMapData = (float) refinementData.getF(i); if (!isNaN(fMapData)) { colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) refinementData.getSigF(i); if (!isNaN(fMapData)) { colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; // Free R (1) fMapData = (float) refinementData.getFreeR(i); if (!isNaN(fMapData)) { colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; } if (mtzType == MTZType.FCONLY) { // Fs (2) fMapData = (float) refinementData.fsF(i); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) toDegrees(refinementData.fsPhi(i)); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; // Fc (unscaled!) (2) fMapData = (float) refinementData.fcF(i); if (!isNaN(fMapData)) { colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) Math.toDegrees(refinementData.fcPhi(i)); if (!isNaN(fMapData)) { colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; } if (mtzType == MTZType.ALL) { // Fs (2) fMapData = (float) refinementData.fsF(i); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) toDegrees(refinementData.fsPhi(i)); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; // Fctot (2) fMapData = (float) refinementData.fcTotF(i); if (!isNaN(fMapData)) { colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) toDegrees(refinementData.fcTotPhi(i)); if (!isNaN(fMapData)) { colMinMax[col][0] = Math.min(fMapData, colMinMax[col][0]); colMinMax[col][1] = Math.max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; // FOM/phase (2) fMapData = (float) refinementData.fomphi[i][0]; if (!isNaN(fMapData)) { colMinMax[col][0] = Math.min(fMapData, colMinMax[col][0]); colMinMax[col][1] = Math.max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) toDegrees(refinementData.fomphi[i][1]); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; // Spline setup. double fh = spline.f(ss, refinementData.spline); double sa = sigmaASpline.f(ss, refinementData.sigmaa); double wa = sigmaASpline.f(ss, refinementData.sigmaw); // sigmaA/w (2) fMapData = (float) sa; if (!isNaN(fMapData)) { colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) wa; if (!isNaN(fMapData)) { colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); } byteBuffer.order(byteOrder).putFloat(fMapData); col++; // Map coeffs (4). fMapData = (float) refinementData.FoFc2F(i); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) toDegrees(refinementData.FoFc2Phi(i)); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) refinementData.foFc1F(i); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; fMapData = (float) toDegrees(refinementData.foFc1Phi(i)); colMinMax[col][0] = min(fMapData, colMinMax[col][0]); colMinMax[col][1] = max(fMapData, colMinMax[col][1]); byteBuffer.order(byteOrder).putFloat(fMapData); col++; } dataOutputStream.write(bytes, offset, writeLen); } // Header. sb = new StringBuilder(); sb.append("VERS MTZ:V1.1 "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss "); sb = new StringBuilder(); sb.append("TITLE FFX output: " + sdf.format(now)); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append(String.format("NCOL %8d %12d %8d", nCol, n, 0)); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("SORT 0 0 0 0 0 "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); char cdata = spaceGroup.shortName.charAt(0); if (cdata == 'H') { cdata = 'R'; } sb.append(String.format("SYMINF %3d %2d %c %5d %22s %5s", spaceGroup.getNumberOfSymOps(), spaceGroup.numPrimitiveSymEquiv, cdata, spaceGroup.number, "'" + spaceGroup.shortName + "'", spaceGroup.pointGroupName)); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); for (int i = 0; i < spaceGroup.symOps.size(); i++) { sb = new StringBuilder(); sb.append("SYMM "); SymOp symop = spaceGroup.symOps.get(i); sb.append(symop.toXYZString()); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); } sb = new StringBuilder(); sb.append(String.format("RESO %8.6f%13s%8.6f", res[0], " ", res[1])); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("VALM NAN "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("NDIF 1 "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("PROJECT 1 project "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("CRYSTAL 1 crystal "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("DATASET 1 dataset "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); for (int j = 0; j < nCol; j++) { sb = new StringBuilder(); sb.append(String.format("COLUMN %-30s %c %17.4f %17.4f 1", colname.get(j), colType[j], colMinMax[j][0], colMinMax[j][1])); dataOutputStream.writeBytes(sb.toString()); } sb = new StringBuilder(); sb.append(String.format("CELL %10.4f %9.4f %9.4f %9.4f %9.4f %9.4f ", crystal.a, crystal.b, crystal.c, crystal.alpha, crystal.beta, crystal.gamma)); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append(String.format("DCELL %9d %10.4f %9.4f %9.4f %9.4f %9.4f %9.4f ", 1, crystal.a, crystal.b, crystal.c, crystal.alpha, crystal.beta, crystal.gamma)); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("DWAVEL 1 1.00000 "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("END "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); sb = new StringBuilder(); sb.append("MTZENDOFHEADERS "); while (sb.length() < 80) { sb.append(" "); } dataOutputStream.writeBytes(sb.toString()); dataOutputStream.close(); } catch (Exception e) { String message = "Fatal exception evaluating structure factors.\n"; logger.log(Level.SEVERE, message, e); } }
From source file:main.java.edu.isistan.genCom.redSocial.RedSocial.java
/** * Returns the degree of reachability by getting the distances of every pair of vertices in the network when a vertices set is removed * network/*from w ww . j a v a 2s. c o m*/ * * Degree of reachability by Borgatti * * @param comission * Nodes to be removed * @return List of distances */ public List<Double> getDegreeOfReachability(List<Investigador> comission) { List<Double> distancias = new ArrayList<>(); try { RedSocial reduced = null; reduced = (RedSocial) this.clone(); Set<Investigador> invSet = new HashSet<>(getNodos()); invSet.removeAll(comission); reduced.reducirA(invSet); UnweightedShortestPath<Investigador, String> uWSP = new UnweightedShortestPath(reduced.getRed()); List<Investigador> nodos = reduced.getNodos(); for (int i = 0; i < nodos.size(); i++) { Investigador inv1 = nodos.get(i); for (int j = 0; j < i; j++) { Investigador inv2 = nodos.get(j); Number dist = uWSP.getDistance(inv1, inv2); Double d = dist != null ? dist.doubleValue() : Double.POSITIVE_INFINITY; distancias.add(d); } } } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return distancias; }
From source file:gmc_hdfs.distribution.ParetoDistribution.java
/** * {@inheritDoc}/* ww w .ja v a2s. c o m*/ * <p> * For scale {@code k} and shape {@code }, the mean is given by * <ul> * <li>{@code } if {@code <= 1},</li> * <li>{@code * k / ( - 1)} otherwise.</li> * </ul> */ public double getNumericalMean() { if (shape <= 1) { return Double.POSITIVE_INFINITY; } return shape * scale / (shape - 1); }
From source file:ffx.xray.CIFFilter.java
/** * {@inheritDoc}//from w w w . j a va2 s.com */ @Override public double getResolution(File cifFile, Crystal crystal) { double res = Double.POSITIVE_INFINITY; try { BufferedReader br = new BufferedReader(new FileReader(cifFile)); String str; int ncol = 0; boolean inhkl = false; while ((str = br.readLine()) != null) { String strarray[] = str.split("\\s+"); if (strarray[0].startsWith("_refln.")) { inhkl = true; br.mark(0); String cifarray[] = strarray[0].split("\\.+"); switch (Header.toHeader(cifarray[1])) { case index_h: h = ncol; break; case index_k: k = ncol; break; case index_l: l = ncol; break; } ncol++; } else if (inhkl) { if (h < 0 || k < 0 || l < 0) { String message = "Fatal error in CIF file - no H K L indexes?\n"; logger.log(Level.SEVERE, message); return -1.0; } break; } } // go back to where the reflections start br.reset(); HKL hkl = new HKL(); while ((str = br.readLine()) != null) { // reached end, break if (str.trim().startsWith("#END")) { break; } else if (str.trim().startsWith("data")) { break; } else if (str.trim().startsWith("#")) { continue; } String strarray[] = str.trim().split("\\s+"); // some files split data on to multiple lines while (strarray.length < ncol) { str = str + " " + br.readLine(); strarray = str.trim().split("\\s+"); } int ih = Integer.parseInt(strarray[h]); int ik = Integer.parseInt(strarray[k]); int il = Integer.parseInt(strarray[l]); hkl.h(ih); hkl.k(ik); hkl.l(il); res = Math.min(res, Crystal.res(crystal, hkl)); } } catch (IOException ioe) { System.out.println("IO Exception: " + ioe.getMessage()); return -1.0; } return res; }
From source file:ch.epfl.leb.sass.models.fluorophores.commands.internal.FluorophoreReceiverIT.java
/** * Test of generateFluorophoresGrid3D method, of class FluorophoreReceiver. *//* w w w . jav a2s.c o m*/ @Test public void testGenerateFluorophoresGrid3D() { GenerateFluorophoresGrid3D.Builder fluorBuilder = new GenerateFluorophoresGrid3D.Builder(); fluorBuilder.spacing(4); // Number of fluorophores fluorBuilder.zLow(0); fluorBuilder.zHigh(5.0); // Create the set of fluorophores. fluorBuilder.camera(camera).psfBuilder(psfBuilder).fluorDynamics(fluorDynamics).illumination(illumination); FluorophoreCommand fluorCommand = fluorBuilder.build(); List<Fluorophore> fluorophores = fluorCommand.generateFluorophores(); assertEquals(49, fluorophores.size()); double minZ = Double.POSITIVE_INFINITY; double maxZ = Double.NEGATIVE_INFINITY; for (Fluorophore f : fluorophores) { if (f.getZ() < minZ) minZ = f.getZ(); if (f.getZ() > maxZ) maxZ = f.getZ(); } assertEquals(5.0, maxZ, 0.0001); assertEquals(0.0, minZ, 0.0001); }
From source file:net.sf.maltcms.chromaui.charts.Chromatogram1DChartProvider.java
/** * * @param fragments/*from www. j av a 2 s . co m*/ * @param ticvar * @param useRT * @return */ public XYPlot provide1DCoPlot(List<IFileFragment> fragments, String ticvar, boolean useRT) { final String satVar = "scan_acquisition_time"; DefaultXYZDataset cd = new DefaultXYZDataset(); int rowIdx = 0; double min = 0; double max = 1; double minRT = Double.POSITIVE_INFINITY; double maxRT = Double.NEGATIVE_INFINITY; int y = 0; for (IFileFragment f : fragments) { double[] domainValues = null; if (useRT) { domainValues = (double[]) f.getChild(satVar).getArray().get1DJavaArray(double.class); } else { domainValues = (double[]) f.getChild("scan_index").getArray().get1DJavaArray(double.class); } double[] tic = (double[]) f.getChild(ticvar).getArray().get1DJavaArray(double.class); double maxtic = MathTools.max(tic); double mintic = MathTools.min(tic); double[][] values = new double[3][tic.length]; for (int i = 0; i < tic.length; i++) { values[0][i] = domainValues[i]; values[1][i] = y; values[2][i] = Math.sqrt((tic[i] - mintic) / (maxtic - mintic)); } y++; cd.addSeries(f.getName(), values); } // ArrayDouble.D1 a = new ArrayDouble.D1(npoints); // int offset = 0; // for (IFileFragment f : t) { // Array tic = f.getChild(ticvar).getArray(); // int len = tic.getShape()[0]; // Array.arraycopy(tic, 0, a, offset, len); // offset += len; // } // histogram with fixed binsize // fill intensities into adequate bin, raise count in bin by one // afterwards, relative frequency within a bin gives a normalization // coefficient XYBlockRenderer xyb = new XYBlockRenderer(); GradientPaintScale ps = new GradientPaintScale(ImageTools.createSampleTable(256), min, max, ImageTools.rampToColorArray(new ColorRampReader().readColorRamp("res/colorRamps/bcgyr.csv"))); xyb.setPaintScale(ps); final String[] colnames = new String[fragments.size()]; for (int i = 0; i < colnames.length; i++) { colnames[i] = StringTools.removeFileExt(fragments.get(i).getName()); } NumberAxis na = null; if (useRT) { na = new NumberAxis("time [s]"); na.setAutoRangeIncludesZero(false); na.setLowerMargin(0); na.setUpperMargin(0); } else { na = new NumberAxis("scan index"); } // na.setVerticalTickLabels(true); XYPlot xyp = new XYPlot(cd, na, new SymbolAxis("chromatogram", colnames), xyb); xyb.setBlockWidth(1); xyp.setBackgroundPaint(Color.BLACK); xyb.setBaseToolTipGenerator(new XYZToolTipGenerator() { @Override public String generateToolTip(XYZDataset xyzd, int i, int i1) { return colnames[xyzd.getY(i, i1).intValue()] + " @" + xyzd.getXValue(i, i1) + " = " + xyzd.getZValue(i, i1); } @Override public String generateToolTip(XYDataset xyd, int i, int i1) { if (xyd instanceof XYZDataset) { return generateToolTip((XYZDataset) xyd, i, i1); } return colnames[xyd.getY(i, i1).intValue()] + ":" + xyd.getXValue(i, i1); } }); return xyp; }
From source file:it.unibo.alchemist.boundary.gui.Perspective.java
private void process(final boolean parallel) { if (sim != null) { sim.addCommand(new Engine.StateCommand<T>().stop().build()); sim.waitFor(Status.STOPPED, 0, TimeUnit.MILLISECONDS); }//from w w w.j ava 2s. c o m try { sim = null; final Environment<T> env; if (fileToLoad.getName().toLowerCase().endsWith("xml")) { final Future<Result<T>> fenv = EnvironmentBuilder.build(new FileInputStream(fileToLoad)); env = fenv.get().getEnvironment(); rand = fenv.get().getRandomGenerator(); } else { rand = null; final Loader loader = new YamlLoader(new FileInputStream(fileToLoad)); env = loader.getDefault(); } sim = new Engine<>(env, new DoubleTime(Double.POSITIVE_INFINITY), parallel); bar.setSimulation(sim); scp.setSimulation(sim); final Thread simThread = new Thread(sim); createMonitor(); simThread.start(); final TimeStepMonitor<T> tm = bar.getTimeMonitor(); sim.addOutputMonitor(tm); bar.setFileOK(true); bar.setProcessOK(true); effectsTab.setEnabled(true); status.setOK(); status.setText(getString("file_processed") + ": " + fileToLoad.getAbsolutePath()); } catch (Exception e) { processError(e); } }
From source file:gdsc.foci.SpotAnalyser.java
public void run(ImageProcessor inputIp) { // Just run the particle analyser noOfParticles = 0;/*w w w . ja v a2s.co m*/ // Avoid destructively modifying the image. Work on the selected channel for thresholding int index = imp.getStackIndex(thresholdChannel, imp.getSlice(), imp.getFrame()); ImageProcessor ip = imp.getImageStack().getProcessor(index).duplicate(); if (!checkData(ip)) { IJ.error(FRAME_TITLE, "Channel has no data range"); resetImage(); return; } if (containsRoiMask && maskOption == 1) { ip = maskIp.duplicate(); ip.setThreshold(254, 255, ImageProcessor.NO_LUT_UPDATE); } else { // Blur the image if (blur > 0) { GaussianBlur gb = new GaussianBlur(); gb.blurGaussian(ip, blur, blur, 0.002); } // Threshold int t = Auto_Threshold.getThreshold(thresholdMethod, ip.getHistogram()); ip.setThreshold(t, 65536, ImageProcessor.NO_LUT_UPDATE); } // Analyse particles ImagePlus particlesImp = new ImagePlus(imp.getTitle() + " Particles", ip); int analyserOptions = ParticleAnalyzer.SHOW_ROI_MASKS + ParticleAnalyzer.IN_SITU_SHOW + ParticleAnalyzer.EXCLUDE_EDGE_PARTICLES; int measurements = 0; ResultsTable rt = new ResultsTable(); double maxSize = Double.POSITIVE_INFINITY; ParticleAnalyzer pa = new ParticleAnalyzer(analyserOptions, measurements, rt, minSize, maxSize); pa.analyze(particlesImp, ip); ImageProcessor particlesIp = particlesImp.getProcessor(); noOfParticles = rt.getCounter(); if (label != null) label.setText(String.format("%d particle%s", noOfParticles, (noOfParticles == 1) ? "" : "s")); // Show the particles inputIp.copyBits(particlesIp, 0, 0, Blitter.COPY); inputIp.setMinAndMax(0, noOfParticles); imp.updateAndDraw(); }
From source file:com.janrain.backplane2.server.dao.redis.RedisBackplaneMessageDAO.java
@Override public List<BackplaneMessage> retrieveMessagesNoScope(@Nullable String sinceIso8601timestamp) throws BackplaneServerException { Jedis jedis = null;//from w w w.ja va 2 s . com try { jedis = Redis.getInstance().getReadJedis(); double sinceInMs = 0; if (StringUtils.isNotBlank(sinceIso8601timestamp)) { sinceInMs = BackplaneMessage.getDateFromId(sinceIso8601timestamp).getTime(); } // every message has a unique timestamp - which serves as a key for indexing Set<byte[]> messageIdBytes = jedis.zrangeByScore(V2_MESSAGES.getBytes(), sinceInMs + 1, Double.POSITIVE_INFINITY); List<BackplaneMessage> messages = new ArrayList<BackplaneMessage>(); Pipeline pipeline = jedis.pipelined(); List<Response<byte[]>> responses = new ArrayList<Response<byte[]>>(); if (messageIdBytes != null) { for (byte[] b : messageIdBytes) { String[] args = new String(b).split(" "); byte[] key = getKey(args[2]); responses.add(pipeline.get(key)); } pipeline.sync(); for (Response<byte[]> response : responses) { if (response.get() != null) { BackplaneMessage backplaneMessage = (BackplaneMessage) SerializationUtils .deserialize(response.get()); messages.add(backplaneMessage); } else { logger.warn("failed to retrieve a message"); } } } Collections.sort(messages, new Comparator<BackplaneMessage>() { @Override public int compare(BackplaneMessage backplaneMessage, BackplaneMessage backplaneMessage1) { return backplaneMessage.getIdValue().compareTo(backplaneMessage1.getIdValue()); } }); return messages; } finally { Redis.getInstance().releaseToPool(jedis); } }
From source file:edu.cornell.med.icb.learning.MinMaxScalingRowProcessor.java
private double getMin(final double[] values) { double min = Double.POSITIVE_INFINITY; for (final double value : values) { min = Math.min(value, min); }/* w w w . j a v a 2 s. c o m*/ return min; }