public class DataUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
STD_ATMOSPHERE
flag for standard atmosphere coordinate system class
|
static java.lang.String |
VIS5D_VERTICALCS
flag for Vis5D pressure to height coordinate system class
|
Constructor and Description |
---|
DataUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
absoluteValue(float[][] originalValues,
float[][] newValues,
int[] indexArray)
copy the originalValues to the new values.
|
static void |
average(float[][] originalValues,
float[][] newValues,
int[] indexArray)
set newValues to be the average of the original values in the index array
|
static java.lang.String |
cleanName(java.lang.String name)
Make a valid VisAD RealType name from the string.
|
static float[][] |
cloneArray(float[][] a)
clone the array
|
static void |
exportCsvAllTimes(visad.FieldImpl field,
java.lang.String filename)
Write a csv file for a time series point data
|
static java.util.List |
fieldToRows(visad.FieldImpl field)
output a list for a time series point data
|
static visad.FlatField |
getFlatField(visad.Data field)
This method find the flat field somewhere in the given data
|
static visad.CoordinateSystem |
getPressureToHeightCS(java.lang.String type)
Get the appropriate vertical coordinate system
|
static java.util.Date |
makeDate(ucar.nc2.time.CalendarDate cdate)
Make a date object corresponding the the calendar date
|
static ucar.visad.data.CalendarDateTime |
makeDateTime(ucar.nc2.time.CalendarDate cdate)
Make a CalendarDateTime object corresponding the the calendar date
|
static java.util.List<ucar.visad.data.CalendarDateTime> |
makeDateTimes(ucar.nc2.dataset.CoordinateAxis1DTime timeAxis)
Make a List of CalendarDateTime objects from the times in the timeAxis
|
static java.util.List<ucar.visad.data.CalendarDateTime> |
makeDateTimes(ucar.nc2.ft2.coverage.CoverageCoordAxis1D timeAxis)
Make a List of CalendarDateTime objects from the times in the timeAxis
|
static float[][] |
makeFloatArray(int rows,
int cols,
float value)
Make a float array of the sizes indicated with the value
|
static visad.RealType |
makeRealType(java.lang.String name,
visad.Unit unit)
Try to create a RealType from the name and unit.
|
static java.lang.String |
makeSamplingLabel(int xStride,
int yStride,
java.lang.String pointType)
Make a label for the stride/sampling
|
static visad.TextType |
makeTextType(java.lang.String name)
Try to create a TextType from the name.
|
static void |
max(float[][] originalValues,
float[][] newValues,
int[] indexArray,
float value)
Copy the values in originalValues[indexArray] that are greater than the given value to newValues
|
static void |
min(float[][] originalValues,
float[][] newValues,
int[] indexArray,
float value)
If the originalValues < given value then set the newValues = value
|
static visad.Unit |
parseUnit(java.lang.String unitString)
Tries to parse the string.
|
static boolean |
pointInside(float[][] pts,
float x,
float y)
Determine if the given point is inside the given polygon
Code originally taken from: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
Copyright (c) 1970-2003, Wm.
|
static java.util.List<java.util.Date> |
selectDatesFromList(java.util.List sourceTimes,
java.util.List<visad.DateTime> driverTimes)
Select the dates from sourceTimes that most closely match
the selectionTimes;
|
static java.util.List<visad.DateTime> |
selectTimesFromList(java.util.List sourceTimes,
java.util.List<visad.DateTime> selectionTimes)
Select the times from sourceTimes that most closely match
the selectionTimes;
|
static void |
setValue(float[][] originalValues,
float[][] newValues,
int[] indexArray,
float value)
set the values in the indices in newValues = the given value
|
static char[] |
toCharArray(ucar.ma2.Array arr)
Get the 1D values for an array as chars.
|
static double[] |
toDoubleArray(ucar.ma2.Array arr)
Get the 1D values for an array as doubles.
|
static float[] |
toFloatArray(ucar.ma2.Array arr)
Get the 1D values for an array as floats.
|
static float[] |
toFloatArray(ucar.ma2.Array[] arr)
Get the 1D values for an array as floats.
|
static java.lang.String[] |
toStringArray(ucar.ma2.Array arr)
Get the 1D values for an array as Strings.
|
static void |
writeCsv(java.lang.String filename,
java.util.List rows)
Write a csv file.
|
static void |
writeXls(java.lang.String filename,
java.util.List rows)
Write to an excel spreadsheet
|
static void |
writeXls(java.lang.String filename,
java.util.List<java.util.List> rowsList,
java.util.List<java.lang.String> names)
Write to an excel spreadsheet
|
static java.lang.String |
xlsToCsv(java.lang.String filename)
Convert excel to csv
|
static java.lang.String |
xlsToCsv(java.lang.String filename,
boolean skipToFirstNumeric,
java.text.SimpleDateFormat sdf)
Convert excel to csv
|
public static final java.lang.String STD_ATMOSPHERE
public static final java.lang.String VIS5D_VERTICALCS
public static float[] toFloatArray(ucar.ma2.Array arr)
arr
- Array of valuespublic static float[] toFloatArray(ucar.ma2.Array[] arr)
arr
- Array of valuespublic static double[] toDoubleArray(ucar.ma2.Array arr)
arr
- Array of valuespublic static java.lang.String[] toStringArray(ucar.ma2.Array arr)
arr
- Array of valuespublic static char[] toCharArray(ucar.ma2.Array arr)
arr
- Array of valuespublic static visad.Unit parseUnit(java.lang.String unitString)
unitString
- The unit stringpublic static visad.TextType makeTextType(java.lang.String name)
name
- name of typepublic static visad.RealType makeRealType(java.lang.String name, visad.Unit unit)
name
- name of typeunit
- can be nullpublic static java.lang.String cleanName(java.lang.String name)
name
- name to cleanpublic static visad.CoordinateSystem getPressureToHeightCS(java.lang.String type) throws visad.VisADException
type
- type of pressure to height csvisad.VisADException
- couldn't create the CSpublic static float[][] makeFloatArray(int rows, int cols, float value)
rows
- number of arrayscols
- number of values in each rowvalue
- fill valuepublic static float[][] cloneArray(float[][] a)
a
- incoming arraypublic static void absoluteValue(float[][] originalValues, float[][] newValues, int[] indexArray)
originalValues
- original valuesnewValues
- new valuesindexArray
- The indices to changepublic static void max(float[][] originalValues, float[][] newValues, int[] indexArray, float value)
originalValues
- original valuesnewValues
- new ValuesindexArray
- indicesvalue
- the threshold valuepublic static void setValue(float[][] originalValues, float[][] newValues, int[] indexArray, float value)
originalValues
- originalValuesnewValues
- newValuesindexArray
- indicesvalue
- valuepublic static void min(float[][] originalValues, float[][] newValues, int[] indexArray, float value)
originalValues
- originalValuesnewValues
- newValuesindexArray
- indicesvalue
- valuepublic static void average(float[][] originalValues, float[][] newValues, int[] indexArray)
originalValues
- original valuesnewValues
- new valueindexArray
- indicespublic static visad.FlatField getFlatField(visad.Data field) throws visad.VisADException, java.rmi.RemoteException
field
- fieldjava.rmi.RemoteException
- on badnessvisad.VisADException
- on badnesspublic static void exportCsvAllTimes(visad.FieldImpl field, java.lang.String filename)
filename
- file to write tofield
- datapublic static java.util.List fieldToRows(visad.FieldImpl field)
field
- datapublic static void writeCsv(java.lang.String filename, java.util.List rows)
filename
- file to write torows
- datapublic static void writeXls(java.lang.String filename, java.util.List rows) throws java.lang.Exception
filename
- filerows
- datajava.lang.Exception
- On badnesspublic static void writeXls(java.lang.String filename, java.util.List<java.util.List> rowsList, java.util.List<java.lang.String> names) throws java.lang.Exception
filename
- filerowsList
- datanames
- sheet namesjava.lang.Exception
- On badnesspublic static java.lang.String xlsToCsv(java.lang.String filename) throws java.lang.Exception
filename
- excel filejava.lang.Exception
- On badnesspublic static java.lang.String xlsToCsv(java.lang.String filename, boolean skipToFirstNumeric, java.text.SimpleDateFormat sdf) throws java.lang.Exception
filename
- excel fileskipToFirstNumeric
- if true, skip to first numericsdf
- If non null then use this to format any date cellsjava.lang.Exception
- On badnesspublic static boolean pointInside(float[][] pts, float x, float y)
pts
- the xy outline pointsx
- x valuey
- y valuepublic static java.util.List<java.util.Date> selectDatesFromList(java.util.List sourceTimes, java.util.List<visad.DateTime> driverTimes) throws java.lang.Exception
sourceTimes
- set of available timesdriverTimes
- times we want to matchjava.lang.Exception
- problem creating timespublic static java.util.List<visad.DateTime> selectTimesFromList(java.util.List sourceTimes, java.util.List<visad.DateTime> selectionTimes) throws java.lang.Exception
sourceTimes
- set of available timesselectionTimes
- times we want to matchjava.lang.Exception
- problem creating timespublic static ucar.visad.data.CalendarDateTime makeDateTime(ucar.nc2.time.CalendarDate cdate) throws visad.VisADException
cdate
- the CalendarDatevisad.VisADException
- problem parsing cdatepublic static java.util.List<ucar.visad.data.CalendarDateTime> makeDateTimes(ucar.nc2.dataset.CoordinateAxis1DTime timeAxis) throws visad.VisADException
timeAxis
- the time axisvisad.VisADException
- problem parsing timeAxis calendar datespublic static java.util.List<ucar.visad.data.CalendarDateTime> makeDateTimes(ucar.nc2.ft2.coverage.CoverageCoordAxis1D timeAxis) throws visad.VisADException
timeAxis
- the time axisvisad.VisADException
- problem parsing timeAxis calendar datespublic static java.util.Date makeDate(ucar.nc2.time.CalendarDate cdate) throws visad.VisADException
cdate
- the CalendarDatevisad.VisADException
- problem parsing cdatepublic static java.lang.String makeSamplingLabel(int xStride, int yStride, java.lang.String pointType)
xStride
- the x strideyStride
- the y stridepointType
- the name for the point type