List of usage examples for java.lang Float NaN
float NaN
To view the source code for java.lang Float NaN.
Click Source Link
From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java
/** * Convert screen to source y coordinate. *//*w w w. j a va2 s . co m*/ private float viewToSourceY(float vy) { if (vTranslate == null) { return Float.NaN; } return (vy - vTranslate.y) / scale; }
From source file:gov.noaa.pfel.coastwatch.Projects.java
/** * This is the 4th processing (Jan 2008) of data from Kushner/KFM project. * * <p>This year I didn't convert .tab to .tsv in CoStat and rearrange columns. * I just rearranged the columns below.// w w w . j a v a2 s. c om * * <p>In KFM1mQuadrat.tab line 2158, I replaced the missing stdDev and stdErr with NaNs. * <br>and line 3719: 8 Santa Cruz Pelican Bay 11007.00 Parastichopus parvimensis Warty sea cucumber 1983 NaN NaN NaN * * I will put the results in otter /u00/bob/kfm2008/ which mimics my f:/programs/kfm200801 . */ public static void kfmBiological200801() throws Exception { String2.log("\n*** Projects.kfmBiological200801"); //'_' in tabNames will be converted to ' ' for tempID below //Station .nc files will be stored in subdirectories named tabName. String tabDir = "c:/programs/kfm200801/"; //order not important String tabNames[] = { "KFM5mQuadrat", "KFM1mQuadrat", "KFMRandomPointContact", "KFMBandTransect" }; String titles[] = { "Survey, 5m Quadrat", "Survey, 1m Quadrat", "Survey, Random Point Contact", "Survey, Band Transect" }; //read KFM_Site_Info.tsv: col 0)island e.g., "Anacapa", 1=siteID (e.g., Admiral's Reef)", // 2) lat(deg. N), 3) lon(deg. E), 4) depth(m) Table site = new Table(); site.readASCII(tabDir + "KFM_Site_Info.tsv"); //read siteInfo StringArray sitePa = (StringArray) site.getColumn(1); Test.ensureEqual(site.getStringData(0, 0), "San Miguel", ""); Test.ensureEqual(sitePa.get(0), "Wyckoff Ledge", ""); Test.ensureEqual(site.getFloatData(2, 0), 34.0166666666667f, ""); //lat, !!! already rounded to nearest minute at Kushner's request Test.ensureEqual(site.getFloatData(3, 0), -120.383333333333f, ""); //lon, !!! already rounded to nearest minute at Kushner's request Test.ensureEqual(site.getFloatData(4, 0), 13, ""); //depth //go through the source tab-separated-value files StringArray missingSites = new StringArray(); // for (int tabI = 1; tabI <= 1; tabI++) { for (int tabI = 0; tabI < tabNames.length; tabI++) { String tabName = tabNames[tabI]; String title = titles[tabI]; String2.log("processing " + tabDir + tabName + ".tab"); //empty the results directory File2.deleteAllFiles(tabDir + tabName + "/"); //read datafile into a table //initially 0=SiteNumber 1=Island 2=SiteName 3=Species 4=SpeciesName //5=CommonName 6=Year 7=...Per Square Meter [8=StdDev] [9=Std Error] Table data = new Table(); data.readASCII(tabDir + tabName + ".tab"); int dataNRows = data.nRows(); //create x,y,z,t,id columns (numeric coordinate columns are all doubles) DoubleArray xPa = new DoubleArray(dataNRows, false); DoubleArray yPa = new DoubleArray(dataNRows, false); DoubleArray zPa = new DoubleArray(dataNRows, false); DoubleArray tPa = new DoubleArray(dataNRows, false); StringArray idPa = new StringArray(dataNRows, false); for (int row = 0; row < dataNRows; row++) { String tSiteName = data.getStringData(2, row); int siteRow = sitePa.indexOf(tSiteName); if (siteRow == -1) { int tpo = missingSites.indexOf(tSiteName); if (tpo == -1) missingSites.add(tSiteName); siteRow = 0; //clumsy, but lets me collect all the missing sites } xPa.add(site.getNiceDoubleData(3, siteRow)); yPa.add(site.getNiceDoubleData(2, siteRow)); zPa.add(site.getNiceDoubleData(4, siteRow)); //they are just year #'s. no time zone issues. //Times are vague (may to oct), so assign to July 1 (middle of year). String tYear = data.getStringData(6, row); Test.ensureEqual(tYear.length(), 4, "Unexpected year=" + tYear + " on row=" + row); tPa.add(Calendar2.isoStringToEpochSeconds(tYear + "-07-01")); idPa.add(site.getStringData(0, siteRow) + " (" + tSiteName + ")"); } //put x,y,z,t,id columns in place data.removeColumn(6); //Year data.removeColumn(2); //SiteName data.removeColumn(1); //Island data.removeColumn(0); //SiteNumber data.addColumn(0, "LON", xPa, new Attributes()); data.addColumn(1, "LAT", yPa, new Attributes()); data.addColumn(2, "DEPTH", zPa, new Attributes()); data.addColumn(3, "TIME", tPa, new Attributes()); data.addColumn(4, "ID", idPa, new Attributes()); data.columnAttributes(4).set("long_name", "Station Identifier"); //data.columnAttributes(4).set("units", DataHelper.UNITLESS); Test.ensureEqual(data.getColumnName(5), "Species", ""); Test.ensureEqual(data.getColumnName(6), "SpeciesName", ""); Test.ensureEqual(data.getColumnName(7), "CommonName", ""); String newDataName = null, newDataUnits = null; String ts = data.getColumnName(8); if (ts.endsWith(" Per Square Meter")) { newDataName = ts.substring(0, ts.length() - " Per Square Meter".length()); newDataUnits = "m-2"; } else if (ts.endsWith(" Percent Cover")) { newDataName = ts.substring(0, ts.length() - " Percent Cover".length()); newDataUnits = "percent cover"; } else Test.error(ts); Test.ensureEqual(data.getColumnName(9), "StdDev", ""); Test.ensureEqual(data.getColumnName(10), "Std Error", ""); int sppCol = 6; int commonCol = 7; int dataCol = 8; int sdCol = 9; int seCol = 10; String2.log("newDataName=" + newDataName + " newDataUnits=" + newDataUnits); //add metadata for data columns //standardNames from http://cfconventions.org/Data/cf-standard-names/27/build/cf-standard-name-table.html //none seem relevant here for (int col = 5; col < data.nColumns(); col++) { String pm2 = " per square meter"; //must be all lowercase String colName = data.getColumnName(col); data.setColumnName(col, colName); if (colName.toLowerCase().endsWith(pm2)) { colName = colName.substring(0, colName.length() - pm2.length()); data.setColumnName(col, colName); data.columnAttributes(col).set("long_name", colName); data.columnAttributes(col).set("units", "m-2"); } else if (colName.equals("Species")) { data.columnAttributes(col).set("long_name", "Species"); //data.columnAttributes(col).set("units", DataHelper.UNITLESS); } else if (colName.equals("SpeciesName")) { data.columnAttributes(col).set("long_name", "Species Name"); //data.columnAttributes(col).set("units", DataHelper.UNITLESS); } else if (colName.equals("CommonName")) { data.columnAttributes(col).set("long_name", "Common Name"); //data.columnAttributes(col).set("units", DataHelper.UNITLESS); } else if (colName.equals("Mean Percent Cover")) { data.setColumnName(col, "Mean"); data.columnAttributes(col).set("long_name", "Mean"); data.columnAttributes(col).set("units", "percent cover"); } else if (colName.equals("StdDev")) { data.columnAttributes(col).set("long_name", "Standard Deviation"); //data.columnAttributes(col).set("units", DataHelper.UNITLESS); } else if (colName.equals("Std Error")) { data.setColumnName(col, "StdErr"); data.columnAttributes(col).set("long_name", "Standard Error"); //data.columnAttributes(col).set("units", DataHelper.UNITLESS); } else { Test.error("Unexpected column name=" + colName); } } //summaries are verbatim (except for the first few words) //from c:\content\kushner\NOAA Web page KFM protocol descriptions.doc //from Kushner's 2007-04-11 email. String summary = null; if (tabName.equals("KFM5mQuadrat")) summary = "This dataset from the Channel Islands National Park's Kelp Forest Monitoring Program has measurements of the abundance of selected rare, clumped, sedentary indicator species. " + "The summary data presented here represents the mean density per square meter. " + "Sampling is conducted annually between the months of May-October, " + "so the Time data in this file is July 1 of each year (a nominal value). " + "The original measurements were taken at various depths, " + "so the Depth data in this file is the depth of the station's temperature logger, which is a typical depth."; else if (tabName.equals("KFM1mQuadrat")) summary = "This dataset from the Channel Islands National Park's Kelp Forest Monitoring Program has measurements of the abundance (density) of relatively abundant selected sedentary indicator species. " + "The summary data presented here represents the mean density per square meter. " + "Sampling is conducted annually between the months of May-October, " + "so the Time data in this file is July 1 of each year (a nominal value). " + "The actual measurements were taken at various depths, " + "so the Depth data in this file is the depth of the station's temperature logger, which is a typical depth."; else if (tabName.equals("KFMRandomPointContact")) summary = "This dataset from the Channel Islands National Park's Kelp Forest Monitoring Program has estimates of substrate composition and percent cover of selected algal and invertebrate taxa. " + "The summary data presented here represents the mean percent cover of the indicator species at the site. " + "Sampling is conducted annually between the months of May-October, " + "so the Time data in this file is July 1 of each year (a nominal value). " + "The actual measurements were taken at various depths, " + "so the Depth data in this file is the depth of the station's temperature logger, which is a typical depth."; else if (tabName.equals("KFMBandTransect")) summary = "This dataset from the Channel Islands National Park's Kelp Forest Monitoring Program has measurements of the abundance and distribution of rare and clumped organisms not adequately sampled by quadrats. " + "The summary data presented here represents the mean density per square meter. " + "Sampling is conducted annually between the months of May-October, " + "so the Time data in this file is July 1 of each year (a nominal value). " + "The actual measurements were taken at various depths, " + "so the Depth data in this file is the depth of the station's temperature logger, which is a typical depth."; else Test.error("Unexpected tabName=" + tabName); //sort by id, x,y,z,t data.sort(new int[] { 4, 0, 1, 2, 3 }, new boolean[] { true, true, true, true, true }); //find unique spp IntArray sppIndices = new IntArray(); StringArray uniqueSpp = (StringArray) data.getColumn(sppCol).makeIndices(sppIndices); int nUniqueSpp = uniqueSpp.size(); for (int sp = 0; sp < nUniqueSpp; sp++) uniqueSpp.set(sp, convertSpeciesName(uniqueSpp.get(sp))); String2.log("uniqueSpp = " + uniqueSpp); //find unique years IntArray yearIndices = new IntArray(); PrimitiveArray uniqueYear = data.getColumn(3).makeIndices(yearIndices); int nUniqueYear = uniqueYear.size(); String2.log("uniqueYear = " + uniqueYear); //make a separate file for each station int startRow = 0; for (int row = 1; row <= dataNRows; row++) { //yes 1..= //id changed? if (row == dataNRows || //test this first !data.getStringData(4, startRow).equals(data.getStringData(4, row))) { //make stationTable x,y,z(constant), t, col for each sp Table stationTable = new Table(); data.globalAttributes().copyTo(stationTable.globalAttributes()); for (int col = 0; col < 5; col++) { stationTable.addColumn(col, data.getColumnName(col), PrimitiveArray.factory(data.getColumn(col).elementClass(), dataCol, false), (Attributes) data.columnAttributes(col).clone()); } //add data columns for (int col = 0; col < nUniqueSpp; col++) { String ulDataName = String2.replaceAll(newDataName, ' ', '_'); stationTable.addColumn(5 + col * 3 + 0, uniqueSpp.get(col) + "_" + ulDataName, new FloatArray(), (Attributes) data.columnAttributes(dataCol).clone()); stationTable.addColumn(5 + col * 3 + 1, uniqueSpp.get(col) + "_StdDev", new FloatArray(), (Attributes) data.columnAttributes(sdCol).clone()); stationTable.addColumn(5 + col * 3 + 2, uniqueSpp.get(col) + "_StdErr", new FloatArray(), (Attributes) data.columnAttributes(seCol).clone()); stationTable.columnAttributes(5 + col * 3 + 0).set("long_name", String2.replaceAll(uniqueSpp.get(col) + "_" + newDataName, '_', ' ')); stationTable.columnAttributes(5 + col * 3 + 1).set("long_name", String2.replaceAll(uniqueSpp.get(col) + "_StdDev", '_', ' ')); stationTable.columnAttributes(5 + col * 3 + 2).set("long_name", String2.replaceAll(uniqueSpp.get(col) + "_StdErr", '_', ' ')); int rowWithThisSpp = sppIndices.indexOf("" + col); stationTable.columnAttributes(5 + col * 3 + 0).set("comment", "Common name: " + data.getStringData(commonCol, rowWithThisSpp)); } //fill the stationTable with axis info and blanks for (int tRow = 0; tRow < nUniqueYear; tRow++) { //x,y,z,t,id stationTable.getColumn(0).addDouble(data.getDoubleData(0, startRow)); stationTable.getColumn(1).addDouble(data.getDoubleData(1, startRow)); stationTable.getColumn(2).addDouble(data.getDoubleData(2, startRow)); stationTable.getColumn(3).addDouble(uniqueYear.getDouble(tRow)); stationTable.getColumn(4).addString(data.getStringData(4, startRow)); //spp for (int col = 0; col < nUniqueSpp; col++) { stationTable.getColumn(5 + col * 3 + 0).addFloat(Float.NaN); stationTable.getColumn(5 + col * 3 + 1).addFloat(Float.NaN); stationTable.getColumn(5 + col * 3 + 2).addFloat(Float.NaN); } } //fill the stationTable with data for (int tRow = startRow; tRow < row; tRow++) { float tm = data.getFloatData(dataCol, tRow); float td = data.getFloatData(sdCol, tRow); float te = data.getFloatData(seCol, tRow); if (tm < -9000) Test.error("tm=" + tm + " is < -9000."); stationTable.setFloatData(5 + sppIndices.get(tRow) * 3 + 0, yearIndices.get(tRow), tm); stationTable.setFloatData(5 + sppIndices.get(tRow) * 3 + 1, yearIndices.get(tRow), td); stationTable.setFloatData(5 + sppIndices.get(tRow) * 3 + 2, yearIndices.get(tRow), te); } //setAttributes String id = data.getStringData(4, startRow); //e.g., "San Miguel (Wyckoff Ledge)" int pPo = id.indexOf('('); Test.ensureNotEqual(pPo, -1, "'(' in id=" + id); String island = id.substring(0, pPo - 1); String station = id.substring(pPo + 1, id.length() - 1); stationTable.setAttributes(0, 1, 2, 3, //x,y,z,t title + " (Kelp Forest Monitoring, Channel Islands)", //bold title //don't make specific to this station; when aggregated, just one boldTitle will be used //", " + island + ", " + station + ")", "Station", //cdmDataType DataHelper.ERD_CREATOR_EMAIL, DataHelper.ERD_CREATOR_NAME, DataHelper.ERD_CREATOR_URL, DataHelper.ERD_PROJECT, tabName, //id //don't make specific to this station; when aggregated, just one id will be used "GCMD Science Keywords", //keywordsVocabulary, //see http://gcmd.gsfc.nasa.gov/Resources/valids/gcmd_parameters.html //there are plands and invertebrates, so habitat seems closest keyword "Oceans > Marine Biology > Marine Habitat", //keywords //references from 2006-12-19 email from Kushner "Channel Islands National Parks Inventory and Monitoring information: " + "http://nature.nps.gov/im/units/medn . " + "Kelp Forest Monitoring Protocols: " + "http://www.nature.nps.gov/im/units/chis/Reports_PDF/Marine/KFM-HandbookVol1.pdf .", //summary from 2006-12-19 email from Kushner summary, //my old summary //"Temperatures were recorded by David Kushner (David_Kushner@nps.gov) " + // "using Onset Computer Corp. temperature loggers, accurate to +/- 0.2 C. The raw time values " + // "(Pacific Daylight Savings Time) were converted to Zulu time by adding 7 hours and then stored in this file. " + // "LAT and LON values were stored without seconds values to obscure the station's exact location.", //courtesy, see 2006-12-12 email, but order reversed to current in 2006-12-19 email from Kushner "Channel Islands National Park, National Park Service", null); //timeLongName use default long name //add the National Park Service disclaimer from 2006-12-19 email String license = stationTable.globalAttributes().getString("license") + " National Park Service Disclaimer: " + "The National Park Service shall not be held liable for " + "improper or incorrect use of the data described and/or contained " + "herein. These data and related graphics are not legal documents and " + "are not intended to be used as such. The information contained in " + "these data is dynamic and may change over time. The data are not " + "better than the original sources from which they were derived. It is " + "the responsibility of the data user to use the data appropriately and " + "consistent within the limitation of geospatial data in general and " + "these data in particular. The related graphics are intended to aid " + "the data user in acquiring relevant data; it is not appropriate to " + "use the related graphics as data. The National Park Service gives no " + "warranty, expressed or implied, as to the accuracy, reliability, or " + "completeness of these data. It is strongly recommended that these " + "data are directly acquired from an NPS server and not indirectly " + "through other sources which may have changed the data in some way. " + "Although these data have been processed successfully on computer " + "systems at the National Park Service, no warranty expressed or " + "implied is made regarding the utility of the data on other systems " + "for general or scientific purposes, nor shall the act of distribution " + "constitute any such warranty. This disclaimer applies both to " + "individual use of the data and aggregate use with other data."; stationTable.globalAttributes().set("license", license); //fix up the attributes stationTable.globalAttributes().set("acknowledgement", stationTable.globalAttributes().getString("acknowledgement") + ", " + "Channel Islands National Park, National Park Service"); //review the table if (tabI == 0 && (startRow == 0 || row == dataNRows)) { String2.log(stationTable.toString(100)); String2.pressEnterToContinue("Check if the file (above) is ok, then..."); } String2.log(" startRow=" + startRow + " end=" + (row - 1) + " island=" + island + " station=" + station); //save the data table String tFileName = tabDir + tabName + "/" + tabName + "_" + String2.replaceAll(island, " ", "") + "_" + String2.replaceAll(station, " ", "") + ".nc"; tFileName = String2.replaceAll(tFileName, ' ', '_'); tFileName = String2.replaceAll(tFileName, "'", ""); //change ><= in columnNames to GT LT EQ for (int col = 0; col < stationTable.nColumns(); col++) { String colName = stationTable.getColumnName(col); colName = String2.replaceAll(colName, ">", "GT"); colName = String2.replaceAll(colName, "<", "LT"); colName = String2.replaceAll(colName, "=", "EQ"); stationTable.setColumnName(col, colName); } stationTable.saveAs4DNcWithStringVariable(tFileName, 0, 1, 2, 3, 4); startRow = row; } } } if (missingSites.size() > 0) { String2.log("\n*** Projects.kfmBiological200801 FAILED. Missing sites=" + missingSites); } else { String2.log("\n*** Projects.kfmBiological200801 finished successfully."); } }
From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java
/** * Convert source to screen x coordinate. *//*from w ww. j a v a2s .c om*/ private float sourceToViewX(float sx) { if (vTranslate == null) { return Float.NaN; } return (sx * scale) + vTranslate.x; }
From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java
/** * Convert source to screen y coordinate. *//*from w w w . j a va2 s . c om*/ private float sourceToViewY(float sy) { if (vTranslate == null) { return Float.NaN; } return (sy * scale) + vTranslate.y; }
From source file:com.github.jonmarsh.waveform_processing_for_imagej.WaveformUtils.java
/** * Computes simple derivative of input array with input spacing given by * {@code dx}. The returned array is the same length as the input array. * Derivative at index {@code i} is given by {@code (a[i+1]-a[i-1])/(2*dx)}, * with initial value approximated by {@code (a[1]-a[0])/dx}, and the final * value computed similarly. If {@code a} is {@code null}, a {@code null} * array is returned. If {@code a.length==2}, the returned array is the same * length with both values given by {@code (a[1]-a[0])/dx}. If * {@code a.length==1}, the return array has length one with value * {@code [Float.NaN]}. If {@code a.length==0}, the return array is * zero-length.//ww w . ja v a2 s . c o m * * @param a input array * @param dx spacing between elements of input array * @return simple derivative of input array */ public static final float[] simpleDerivative(float[] a, float dx) { float[] deriv = null; if (a != null) { if (a.length > 2) { // initialize output array deriv = new float[a.length]; float oneOverDx = 1.0f / dx; float oneOver2Dx = oneOverDx * 0.5f; // approximate derivative at first point deriv[0] = oneOverDx * (a[1] - a[0]); // compute derivative at intermediate points for (int i = 1; i < (deriv.length - 1); i++) { deriv[i] = oneOver2Dx * (a[i + 1] - a[i - 1]); } // approximate slope at final point deriv[a.length - 1] = oneOverDx * (a[a.length - 1] - a[a.length - 2]); } else if (a.length == 2) { float slope = (a[1] - a[0]) / dx; deriv = new float[] { slope, slope }; } else if (a.length == 1) { deriv = new float[] { Float.NaN }; } else { deriv = new float[0]; } } return deriv; }
From source file:com.mantz_it.rfanalyzer.MainActivity.java
public float requestCurrentSquelch() { if (analyzerSurface != null) return analyzerSurface.getSquelch(); else/* w w w .j a va 2 s. c om*/ return Float.NaN; }
From source file:com.actelion.research.table.view.JVisualization.java
/** * Based on axis column assignments and on hvIndices of VisualizationPoints * this method assigns all visible VisualizationPoints to boxes and to color categories * within these boxes. It also calculates statistical parameters of all boxes. * @param hvCount/*from w w w. ja v a2 s. com*/ */ protected void calculateBoxPlot() { int doubleAxis = determineBoxPlotDoubleAxis(); calculateCategoryCounts(doubleAxis); Color[] colorList = mMarkerColor.getColorList(); int focusFlagNo = getFocusFlag(); int basicColorCount = colorList.length + 1; int colorCount = basicColorCount * ((focusFlagNo == -1) ? 1 : 2); int catCount = mCaseSeparationCategoryCount; for (int axis = 0; axis < mDimensions; axis++) if (axis != doubleAxis) catCount *= mCategoryVisibleCount[axis]; BoxPlotViewInfo boxPlotInfo = new BoxPlotViewInfo(mHVCount, catCount, colorCount); mChartInfo = boxPlotInfo; boxPlotInfo.barAxis = doubleAxis; // create array with all visible values separated by hv and cat int[][] vCount = new int[mHVCount][catCount]; for (int i = 0; i < mDataPoints; i++) { if (isVisibleExcludeNaN(mPoint[i])) { int cat = getChartCategoryIndex(mPoint[i]); int hv = mPoint[i].hvIndex; vCount[hv][cat]++; } } double[][][] value = new double[mHVCount][catCount][]; for (int hv = 0; hv < mHVCount; hv++) for (int cat = 0; cat < catCount; cat++) if (vCount[hv][cat] != 0) value[hv][cat] = new double[vCount[hv][cat]]; // fill in values vCount = new int[mHVCount][catCount]; for (int i = 0; i < mDataPoints; i++) { if (isVisibleExcludeNaN(mPoint[i])) { int hv = mPoint[i].hvIndex; int cat = getChartCategoryIndex(mPoint[i]); float d = getValue(mPoint[i].record, boxPlotInfo.barAxis); boxPlotInfo.barValue[hv][cat] += d; value[hv][cat][vCount[hv][cat]] = d; vCount[hv][cat]++; } } boxPlotInfo.boxQ1 = new float[mHVCount][catCount]; boxPlotInfo.median = new float[mHVCount][catCount]; boxPlotInfo.boxQ3 = new float[mHVCount][catCount]; boxPlotInfo.boxLAV = new float[mHVCount][catCount]; boxPlotInfo.boxUAV = new float[mHVCount][catCount]; // calculate statistical parameters from sorted values for (int hv = 0; hv < mHVCount; hv++) { for (int cat = 0; cat < catCount; cat++) { if (vCount[hv][cat] != 0) { Arrays.sort(value[hv][cat]); boxPlotInfo.boxQ1[hv][cat] = getPercentile(value[hv][cat], 0.25f); boxPlotInfo.median[hv][cat] = getPercentile(value[hv][cat], 0.50f); boxPlotInfo.boxQ3[hv][cat] = getPercentile(value[hv][cat], 0.75f); boxPlotInfo.barValue[hv][cat] /= vCount[hv][cat]; // set lower and upper adjacent values float iqr = boxPlotInfo.boxQ3[hv][cat] - boxPlotInfo.boxQ1[hv][cat]; float lowerLimit = boxPlotInfo.boxQ1[hv][cat] - 1.5f * iqr; float upperLimit = boxPlotInfo.boxQ3[hv][cat] + 1.5f * iqr; int i = 0; while (value[hv][cat][i] < lowerLimit) i++; boxPlotInfo.boxLAV[hv][cat] = (float) value[hv][cat][i]; i = value[hv][cat].length - 1; while (value[hv][cat][i] > upperLimit) i--; boxPlotInfo.boxUAV[hv][cat] = (float) value[hv][cat][i]; if (mChartType == cChartTypeWhiskerPlot) boxPlotInfo.pointsInCategory[hv][cat] = vCount[hv][cat]; } } } int pValueColumn = getPValueColumn(); if (pValueColumn != cColumnUnassigned) { int categoryIndex = getCategoryIndex(pValueColumn, mPValueRefCategory); if (categoryIndex != -1) { if (mBoxplotShowFoldChange) boxPlotInfo.foldChange = new float[mHVCount][catCount]; if (mBoxplotShowPValue) boxPlotInfo.pValue = new float[mHVCount][catCount]; int[] individualIndex = new int[1 + mDimensions]; for (int hv = 0; hv < mHVCount; hv++) { for (int cat = 0; cat < catCount; cat++) { if (vCount[hv][cat] != 0) { int refHV = getReferenceHV(hv, pValueColumn, categoryIndex); int refCat = getReferenceCat(cat, pValueColumn, categoryIndex, individualIndex); if ((refHV != hv || refCat != cat) && vCount[refHV][refCat] != 0) { if (mBoxplotShowFoldChange) { if (mTableModel.isLogarithmicViewMode(mAxisIndex[boxPlotInfo.barAxis])) boxPlotInfo.foldChange[hv][cat] = 3.321928094887363f * (boxPlotInfo.barValue[hv][cat] - boxPlotInfo.barValue[refHV][refCat]); // this is the log2(fc) else boxPlotInfo.foldChange[hv][cat] = boxPlotInfo.barValue[hv][cat] / boxPlotInfo.barValue[refHV][refCat]; } if (mBoxplotShowPValue) { try { boxPlotInfo.pValue[hv][cat] = (float) new TTestImpl().tTest(value[hv][cat], value[refHV][refCat]); } catch (IllegalArgumentException e) { boxPlotInfo.pValue[hv][cat] = Float.NaN; } catch (MathException e) { boxPlotInfo.pValue[hv][cat] = Float.NaN; } } } else { if (mBoxplotShowFoldChange) boxPlotInfo.foldChange[hv][cat] = Float.NaN; if (mBoxplotShowPValue) boxPlotInfo.pValue[hv][cat] = Float.NaN; } } } } } } // for this chart type we need the statistical parameters, but no colored bar if (mChartType == cChartTypeWhiskerPlot) return; // create color list for (int i = 0; i < colorList.length; i++) boxPlotInfo.color[i] = colorList[i]; boxPlotInfo.color[colorList.length] = VisualizationColor.cSelectedColor; if (focusFlagNo != -1) { for (int i = 0; i < colorList.length; i++) boxPlotInfo.color[i + basicColorCount] = VisualizationColor.grayOutColor(colorList[i]); boxPlotInfo.color[colorList.length + basicColorCount] = VisualizationColor .grayOutColor(VisualizationColor.cSelectedColor); } boxPlotInfo.outlierCount = new int[mHVCount][catCount]; for (int i = 0; i < mDataPoints; i++) { if (isVisibleExcludeNaN(mPoint[i])) { int cat = getChartCategoryIndex(mPoint[i]); int hv = mPoint[i].hvIndex; if (boxPlotInfo.isOutsideValue(hv, cat, getValue(mPoint[i].record, boxPlotInfo.barAxis))) { boxPlotInfo.outlierCount[hv][cat]++; } else { int colorIndex = ((mPoint[i].record.getFlags() & CompoundRecord.cFlagMaskSelected) != 0 && mFocusHitlist != cFocusOnSelection) ? colorList.length : mPoint[i].colorIndex; if (focusFlagNo != -1 && !mPoint[i].record.isFlagSet(focusFlagNo)) colorIndex += basicColorCount; boxPlotInfo.pointsInCategory[hv][cat]++; boxPlotInfo.pointsInColorCategory[hv][cat][colorIndex]++; } } } int[][][] count = new int[mHVCount][catCount][colorCount]; for (int hv = 0; hv < mHVCount; hv++) for (int cat = 0; cat < catCount; cat++) for (int color = 1; color < colorCount; color++) count[hv][cat][color] = count[hv][cat][color - 1] + boxPlotInfo.pointsInColorCategory[hv][cat][color - 1]; for (int i = 0; i < mDataPoints; i++) { if (isVisible(mPoint[i])) { float v = getValue(mPoint[i].record, boxPlotInfo.barAxis); if (Float.isNaN(v)) { mPoint[i].chartGroupIndex = -1; } else { int hv = mPoint[i].hvIndex; int cat = getChartCategoryIndex(mPoint[i]); if (boxPlotInfo.isOutsideValue(hv, cat, v)) { mPoint[i].chartGroupIndex = -1; } else { CompoundRecord record = mPoint[i].record; int colorIndex = (record.isSelected() && mFocusHitlist != cFocusOnSelection) ? colorList.length : mPoint[i].colorIndex; if (focusFlagNo != -1 && !record.isFlagSet(focusFlagNo)) colorIndex += basicColorCount; mPoint[i].chartGroupIndex = count[hv][cat][colorIndex]; count[hv][cat][colorIndex]++; } } } } }
From source file:jp.furplag.util.commons.NumberUtilsTest.java
/** * {@link jp.furplag.util.commons.NumberUtils.NumberObject} *//*from w ww .jav a2s . c o m*/ @SuppressWarnings("unchecked") @Test public void NumberObjectTest() { try { Class<?> numberObject = ClassLoader.getSystemClassLoader() .loadClass(NumberUtils.class.getName() + "$NumberObject"); Constructor<?> c = numberObject.getDeclaredConstructor(Class.class); c.setAccessible(true); Method ofType = numberObject.getMethod("of", Class.class); ofType.setAccessible(true); Method ofN = numberObject.getMethod("of", Number.class); ofN.setAccessible(true); Method parsable = numberObject.getDeclaredMethod("parsable", Number.class); parsable.setAccessible(true); Method contains = numberObject.getDeclaredMethod("contains", Number.class); contains.setAccessible(true); Method valueOf = numberObject.getDeclaredMethod("valueOf", Number.class); valueOf.setAccessible(true); for (Class<?> type : NUMBERS) { Object o = c.newInstance(type); Class<? extends Number> wrapper = (Class<? extends Number>) ClassUtils.primitiveToWrapper(type); Object numob = ofType.invoke(null, type); assertEquals("ofType: " + type.getSimpleName(), o, numob); Number n = null; if (!type.isPrimitive()) { if (ClassUtils.isPrimitiveWrapper(type)) { n = (Number) ClassUtils.primitiveToWrapper(type).getMethod("valueOf", String.class) .invoke(null, "1"); } else { n = (Number) type.getField("ONE").get(null); } if (type.equals(byte.class)) assertEquals("ofN: 1: " + type.getSimpleName(), o, ofN.invoke(null, n)); } assertEquals("parsable: -1: " + type.getSimpleName(), true, parsable.invoke(numob, -1)); assertEquals("parsable: 0: " + type.getSimpleName(), true, parsable.invoke(numob, 0)); assertEquals("parsable: 1: " + type.getSimpleName(), true, parsable.invoke(numob, 1)); assertEquals("parsable: null: " + type.getSimpleName(), !type.isPrimitive(), parsable.invoke(numob, (Number) null)); Object expected = ObjectUtils.isAny(wrapper, Float.class, Double.class, BigDecimal.class, BigInteger.class); assertEquals("parsable: Infinity: Double: " + type.getSimpleName(), expected, parsable.invoke(numob, Double.POSITIVE_INFINITY)); assertEquals("parsable: Infinity: Double: BigDecimal: " + type.getSimpleName(), expected, parsable.invoke(numob, INFINITY_DOUBLE)); assertEquals("parsable: Infinity: Double: BigInteger: " + type.getSimpleName(), expected, parsable.invoke(numob, INFINITY_DOUBLE.toBigInteger())); assertEquals("parsable: Infinity: Float: " + type.getSimpleName(), expected, parsable.invoke(numob, Float.POSITIVE_INFINITY)); assertEquals("parsable: Infinity: Float: BigDecimal: " + type.getSimpleName(), expected, parsable.invoke(numob, INFINITY_FLOAT)); assertEquals("parsable: Infinity: Float: BigInteger: " + type.getSimpleName(), expected, parsable.invoke(numob, INFINITY_FLOAT.toBigInteger())); assertEquals("parsable: -Infinity: Double: " + type.getSimpleName(), expected, parsable.invoke(numob, Double.NEGATIVE_INFINITY)); assertEquals("parsable: -Infinity: Double: BigDecimal: " + type.getSimpleName(), expected, parsable.invoke(numob, INFINITY_DOUBLE.negate())); assertEquals("parsable: -Infinity: Double: BigInteger: " + type.getSimpleName(), expected, parsable.invoke(numob, INFINITY_DOUBLE.negate().toBigInteger())); assertEquals("parsable: -Infinity: Float: " + type.getSimpleName(), expected, parsable.invoke(numob, Float.NEGATIVE_INFINITY)); assertEquals("parsable: -Infinity: Float: BigDecimal: " + type.getSimpleName(), expected, parsable.invoke(numob, INFINITY_FLOAT.negate())); assertEquals("parsable: -Infinity: Float: BigInteger: " + type.getSimpleName(), expected, parsable.invoke(numob, INFINITY_FLOAT.negate().toBigInteger())); expected = ObjectUtils.isAny(wrapper, Float.class, Double.class); assertEquals("parsable: NaN: Float: " + type.getSimpleName(), expected, parsable.invoke(numob, Float.NaN)); assertEquals("parsable: NaN: Double: " + type.getSimpleName(), expected, parsable.invoke(numob, Double.NaN)); if (Byte.class.equals(wrapper)) { assertEquals("parsable: contains: min: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MIN_VALUE").getByte(null))); assertEquals("parsable: contains: max: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MAX_VALUE").getByte(null))); assertEquals("parsable: overflow: min: " + type.getSimpleName(), false, parsable.invoke(numob, Short.MIN_VALUE)); assertEquals("parsable: overflow: max: " + type.getSimpleName(), false, parsable.invoke(numob, Short.MAX_VALUE)); assertEquals("parsable: fraction: " + type.getSimpleName(), false, parsable.invoke(numob, 123.456f)); assertEquals("contains: min: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MIN_VALUE").getByte(null))); assertEquals("contains: max: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MAX_VALUE").getByte(null))); assertEquals("contains: overflow: min: " + type.getSimpleName(), false, contains.invoke(numob, Short.MIN_VALUE)); assertEquals("contains: overflow: max: " + type.getSimpleName(), false, contains.invoke(numob, Short.MAX_VALUE)); assertEquals("contains: fraction: " + type.getSimpleName(), true, contains.invoke(numob, 123.456f)); assertEquals("contains: overflow: fraction: " + type.getSimpleName(), false, contains.invoke(numob, 1234.56f)); } if (Short.class.equals(wrapper)) { assertEquals("parsable: contains: min: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MIN_VALUE").getShort(null))); assertEquals("parsable: contains: max: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MAX_VALUE").getShort(null))); assertEquals("parsable: overflow: min: " + type.getSimpleName(), false, parsable.invoke(numob, Integer.MIN_VALUE)); assertEquals("parsable: overflow: max: " + type.getSimpleName(), false, parsable.invoke(numob, Integer.MAX_VALUE)); assertEquals("parsable: fraction: " + type.getSimpleName(), false, parsable.invoke(numob, 123.456f)); assertEquals("contains: min: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MIN_VALUE").getShort(null))); assertEquals("contains: max: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MAX_VALUE").getShort(null))); assertEquals("contains: overflow: min: " + type.getSimpleName(), false, contains.invoke(numob, Integer.MIN_VALUE)); assertEquals("contains: overflow: max: " + type.getSimpleName(), false, contains.invoke(numob, Integer.MAX_VALUE)); assertEquals("contains: fraction: " + type.getSimpleName(), true, contains.invoke(numob, 12345.6f)); assertEquals("contains: overflow: fraction: " + type.getSimpleName(), false, contains.invoke(numob, 123456.789f)); } if (Integer.class.equals(wrapper)) { assertEquals("parsable: contains: min: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MIN_VALUE").getInt(null))); assertEquals("parsable: contains: max: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MAX_VALUE").getInt(null))); assertEquals("parsable: overflow: min: " + type.getSimpleName(), false, parsable.invoke(numob, Long.MIN_VALUE)); assertEquals("parsable: overflow: max: " + type.getSimpleName(), false, parsable.invoke(numob, Long.MAX_VALUE)); assertEquals("parsable: fraction: " + type.getSimpleName(), false, parsable.invoke(numob, 123456.789f)); assertEquals("contains: min: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MIN_VALUE").getInt(null))); assertEquals("contains: max: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MAX_VALUE").getInt(null))); assertEquals("contains: overflow: min: " + type.getSimpleName(), false, contains.invoke(numob, Long.MIN_VALUE)); assertEquals("contains: overflow: max: " + type.getSimpleName(), false, contains.invoke(numob, Long.MAX_VALUE)); assertEquals("contains: fraction: " + type.getSimpleName(), true, contains.invoke(numob, 123456.789f)); assertEquals("contains: overflow: fraction: " + type.getSimpleName(), false, contains.invoke(numob, 12345678912345678912.3456d)); } if (Long.class.equals(wrapper)) { assertEquals("parsable: contains: min: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MIN_VALUE").getLong(null))); assertEquals("parsable: contains: max: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MAX_VALUE").getLong(null))); assertEquals("parsable: overflow: min: " + type.getSimpleName(), false, parsable.invoke(numob, BigInteger.valueOf(Long.MIN_VALUE).pow(2))); assertEquals("parsable: overflow: max: " + type.getSimpleName(), false, parsable.invoke(numob, BigInteger.valueOf(Long.MAX_VALUE).pow(2))); assertEquals("parsable: fraction: " + type.getSimpleName(), false, parsable.invoke(numob, 123.456f)); assertEquals("contains: min: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MIN_VALUE").getLong(null))); assertEquals("contains: max: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MAX_VALUE").getLong(null))); assertEquals("contains: overflow: min: " + type.getSimpleName(), false, contains.invoke(numob, BigInteger.valueOf(Long.MIN_VALUE).pow(2))); assertEquals("contains: overflow: max: " + type.getSimpleName(), false, contains.invoke(numob, BigInteger.valueOf(Long.MAX_VALUE).pow(2))); assertEquals("contains: fraction: " + type.getSimpleName(), true, contains.invoke(numob, 123456.789f)); assertEquals("contains: overflow: fraction: " + type.getSimpleName(), false, contains.invoke(numob, 12345678912345678912.3456f)); } if (Float.class.equals(wrapper)) { assertEquals("parsable: contains: min: " + type.getSimpleName(), true, parsable.invoke(numob, -wrapper.getField("MAX_VALUE").getFloat(null))); assertEquals("parsable: contains: max: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MAX_VALUE").getFloat(null))); assertEquals("parsable: overflow: max: " + type.getSimpleName(), false, parsable.invoke(numob, -Double.MAX_VALUE)); assertEquals("parsable: overflow: max: " + type.getSimpleName(), false, parsable.invoke(numob, Double.MAX_VALUE)); assertEquals("contains: min: " + type.getSimpleName(), true, contains.invoke(numob, -wrapper.getField("MAX_VALUE").getFloat(null))); assertEquals("contains: max: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MAX_VALUE").getFloat(null))); assertEquals("contains: overflow: max: " + type.getSimpleName(), false, contains.invoke(numob, -Double.MAX_VALUE)); assertEquals("contains: overflow: max: " + type.getSimpleName(), false, contains.invoke(numob, Double.MAX_VALUE)); } if (Double.class.equals(wrapper)) { assertEquals("parsable: contains: min: " + type.getSimpleName(), true, parsable.invoke(numob, -wrapper.getField("MAX_VALUE").getDouble(null))); assertEquals("parsable: contains: max: " + type.getSimpleName(), true, parsable.invoke(numob, wrapper.getField("MAX_VALUE").getDouble(null))); assertEquals("parsable: overflow: min: " + type.getSimpleName(), true, parsable.invoke(numob, INFINITY_DOUBLE.multiply(BigDecimal.TEN).negate())); assertEquals("parsable: overflow: max: " + type.getSimpleName(), true, parsable.invoke(numob, INFINITY_DOUBLE.multiply(BigDecimal.TEN))); assertEquals("contains: min: " + type.getSimpleName(), true, contains.invoke(numob, -wrapper.getField("MAX_VALUE").getDouble(null))); assertEquals("contains: max: " + type.getSimpleName(), true, contains.invoke(numob, wrapper.getField("MAX_VALUE").getDouble(null))); assertEquals("contains: overflow: min: " + type.getSimpleName(), false, contains.invoke(numob, INFINITY_DOUBLE.multiply(BigDecimal.TEN).negate())); assertEquals("contains: overflow: max: " + type.getSimpleName(), false, contains.invoke(numob, INFINITY_DOUBLE.multiply(BigDecimal.TEN))); } if (!ClassUtils.isPrimitiveWrapper(wrapper)) { assertEquals("parsable: fraction: " + type.getSimpleName(), BigDecimal.class.equals(type), parsable.invoke(numob, 123.456f)); assertEquals("contains: fraction: " + type.getSimpleName(), true, contains.invoke(numob, 123.456f)); } if (ClassUtils.isPrimitiveWrapper(wrapper)) { expected = wrapper.getMethod("valueOf", String.class).invoke(null, "123"); } else { expected = new BigDecimal("123"); if (BigInteger.class.equals(wrapper)) expected = ((BigDecimal) expected).toBigInteger(); } for (Class<?> valueType : OBJECTS) { if (ClassUtils.isPrimitiveWrapper(valueType)) { n = (Number) valueType.getMethod("valueOf", String.class).invoke(null, "123"); } else { n = new BigDecimal("123"); if (BigInteger.class.equals(valueType)) n = ((BigDecimal) n).toBigInteger(); } assertEquals( "valueOf: " + n + " (" + n.getClass().getSimpleName() + "): " + type.getSimpleName(), expected, valueOf.invoke(numob, n)); assertEquals( "valueOf: " + n + " (" + n.getClass().getSimpleName() + "): class: " + type.getSimpleName(), expected.getClass(), valueOf.invoke(numob, n).getClass()); } n = 123.456f; if (ObjectUtils.isAny(wrapper, Float.class, Double.class)) { expected = wrapper.getMethod("valueOf", String.class).invoke(null, n.toString()); } else if (ClassUtils.isPrimitiveWrapper(wrapper)) { expected = wrapper.getMethod("valueOf", String.class).invoke(null, Integer.toString(((Float) n).intValue())); } else { expected = new BigDecimal(n.toString()); if (BigInteger.class.equals(wrapper)) expected = ((BigDecimal) expected).toBigInteger(); } assertEquals("valueOf: " + n + " (" + n.getClass().getSimpleName() + "): " + type.getSimpleName(), expected, valueOf.invoke(numob, n)); assertEquals( "valueOf: " + n + " (" + n.getClass().getSimpleName() + "): class: " + type.getSimpleName(), expected.getClass(), valueOf.invoke(numob, n).getClass()); n = 1.23456789E-6d; if (ObjectUtils.isAny(wrapper, Float.class, Double.class)) { expected = wrapper.getMethod("valueOf", String.class).invoke(null, n.toString()); } else if (ClassUtils.isPrimitiveWrapper(wrapper)) { expected = wrapper.getMethod("valueOf", String.class).invoke(null, Integer.toString(((Double) n).intValue())); } else { expected = new BigDecimal(n.toString()); if (BigInteger.class.equals(wrapper)) expected = ((BigDecimal) expected).toBigInteger(); } assertEquals("valueOf: " + n + " (" + n.getClass().getSimpleName() + "): " + type.getSimpleName(), expected, valueOf.invoke(numob, n)); assertEquals( "valueOf: " + n + " (" + n.getClass().getSimpleName() + "): class: " + type.getSimpleName(), expected.getClass(), valueOf.invoke(numob, n).getClass()); n = INFINITY_DOUBLE.pow(2); if (ObjectUtils.isAny(wrapper, Float.class, Double.class)) { expected = wrapper.getField("POSITIVE_INFINITY").get(null); } else if (ClassUtils.isPrimitiveWrapper(wrapper)) { expected = wrapper.getField("MAX_VALUE").get(null); } else { expected = new BigDecimal(n.toString()); if (BigInteger.class.equals(wrapper)) expected = ((BigDecimal) expected).toBigInteger(); } assertEquals("valueOf: Huge: " + type.getSimpleName(), expected, valueOf.invoke(numob, n)); assertEquals("valueOf: Huge: class: " + type.getSimpleName(), expected.getClass(), valueOf.invoke(numob, n).getClass()); n = INFINITY_DOUBLE.pow(2).negate(); if (ObjectUtils.isAny(wrapper, Float.class, Double.class)) { expected = wrapper.getField("NEGATIVE_INFINITY").get(null); } else if (ClassUtils.isPrimitiveWrapper(wrapper)) { expected = wrapper.getField("MIN_VALUE").get(null); } else { expected = new BigDecimal(n.toString()); if (BigInteger.class.equals(wrapper)) expected = ((BigDecimal) expected).toBigInteger(); } assertEquals("valueOf: Huge: negative: " + type.getSimpleName(), expected, valueOf.invoke(numob, n)); assertEquals("valueOf: Huge: negative: class: " + type.getSimpleName(), expected.getClass(), valueOf.invoke(numob, n).getClass()); } } catch (Exception e) { e.printStackTrace(); fail(e.getMessage() + "\n" + Arrays.toString(e.getStackTrace())); } }
From source file:com.actelion.research.table.view.JVisualization.java
public void setMarkerSizeZoomAdaption(boolean adapt) { if (Float.isNaN(mMarkerSizeZoomAdaption) == adapt) { if (adapt) mMarkerSizeZoomAdaption = calculateZoomState(); else/* w w w. j a va 2 s . c om*/ mMarkerSizeZoomAdaption = Float.NaN; invalidateOffImage(false); } }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private float[][] parseWeightingData() { float[][] weightingData = new float[7][7]; for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { weightingData[i][j] = Float.NaN; }/*from w w w .ja v a 2s . c o m*/ } String text = textAreaWeighting.getText(); String[] lines = text.split("\n"); for (int i = 0; i < lines.length; i++) { if (lines.length != 7) { showErrorDialog( new Exception("Error occured while parsing weighting data, unsufficient number of lines.")); return null; } String[] columns = lines[i].split(" "); for (int j = 0; j < columns.length; j++) { if (columns.length == 0) { showErrorDialog(new Exception("Error occured while parsing weighting data, invalid column.")); return null; } try { weightingData[i][j] = Float.valueOf(columns[j]); } catch (Exception ex) { showErrorDialog(new Exception("Error occured while parsing weighting data, not a number.", ex)); return null; } } } return weightingData; }