/*
VisAD system for interactive analysis and visualization of numerical
data. Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
//
// TCData.java
//
// Version 3 April 2001
package visad.bom;
import visad.*;
import visad.util.Util;
import java.rmi.RemoteException;
public class TCData {
// this is the actual TC data object
FieldImpl data = null;
// Time
static RealType rtTime = RealType.Time;
// Location
static RealType rtConfidence;
static RealType rtLat;
static RealType rtLon;
static RealType rtError;
static RealType rtLocationStyle;
static RealTupleType locationTuple;
static FunctionType locationFunction;
// Intensity
static RealType rtWindMean;
static RealType rtWindGust;
static RealType rtCentralPressure;
static RealType rtCategory;
static RealType rtIntensityStyle;
// Size
static RealType rtGaleRadius;
static RealType rtStormRadius;
static RealType rtHurricaneRadius;
static RealType rtRadiusOfMaximumWinds;
static RealType rtSizeStyle;
// Structure
static RealType rtDepth;
static RealType rtEyeDiameter;
static RealType rtPressureOfLastClosedIsobar;
static RealType rtStructureStyle;
// Track
static RealType rtTrackID;
static TextType ttTrackType;
static TextType ttTrackName;
static RealType rtBaseDateTime;
static RealType rtCreateDateTime;
static TextType ttTrackStyle;
static TupleType ttTrack;
static FunctionType ftId2Track;
// Disturbance
static RealType rtDisturbanceID;
static TextType ttCountry;
static TextType ttState;
static RealType rtYear;
static RealType rtNumber;
static TextType ttHistoricalName;
static RealType rtOpenDate;
static RealType rtCloseDate;
static RealType rtArchiveMode;
static RealType rtRealtimeMode;
static TupleType ttDisturbance;
static FunctionType ftId2Disturbance;
static FunctionType mtTC;
public TCData() throws VisADException {
if (mtTC == null) {
rtTime = RealType.Time;
// Location
rtConfidence = RealType.getRealType("CONFIDENCE", null, null);
rtLat = RealType.Latitude;
rtLon = RealType.Longitude;
rtError = RealType.getRealType("ERROR", null, null);
rtLocationStyle = RealType.getRealType("LOCATIONSTYLE", null, null);
// Intensity
rtWindMean = RealType.getRealType("WINDMEAN", null, null);
rtWindGust = RealType.getRealType("WINDGUST", null, null);
rtCentralPressure = RealType.getRealType("CENTRALPRESSURE", null, null);
rtCategory = RealType.getRealType("CATEGORY", null, null);
rtIntensityStyle = RealType.getRealType("INTENSITYSTYLE", null, null);
// Size
rtGaleRadius = RealType.getRealType("GALERADIUS", null, null);
rtStormRadius = RealType.getRealType("STORMRADIUS", null, null);
rtHurricaneRadius = RealType.getRealType("HURRICANERADIUS", null, null);
rtRadiusOfMaximumWinds = RealType.getRealType("RADIUSOFMAXIMUMWINDS", null, null);
rtSizeStyle = RealType.getRealType("SIZESTYLE", null, null);
// Structure
rtDepth = RealType.getRealType("DEPTH", null, null);
rtEyeDiameter = RealType.getRealType("EYEDIAMETER", null, null);
rtPressureOfLastClosedIsobar = RealType.getRealType("PRESSUREOFLASTCLOSEDISOBAR", null, null);
rtStructureStyle = RealType.getRealType("STRUCTURESTYLE", null, null);
RealTupleType locationTuple = new RealTupleType(new RealType[]
{rtLat, rtLon, rtError, rtConfidence, rtLocationStyle,
rtWindMean, rtWindGust, rtCentralPressure, rtCategory, rtIntensityStyle,
rtGaleRadius, rtStormRadius, rtHurricaneRadius, rtRadiusOfMaximumWinds, rtSizeStyle,
rtDepth, rtEyeDiameter, rtPressureOfLastClosedIsobar, rtStructureStyle });
locationFunction = new FunctionType(rtTime, locationTuple);
// Track
rtTrackID = RealType.getRealType("TRACKID", null, null);
ttTrackType = TextType.getTextType("TRACKTYPE");
ttTrackName = TextType.getTextType("TRACKNAME");
rtBaseDateTime = RealType.getRealType("BASEDATETIME", null, null);
rtCreateDateTime = RealType.getRealType("CREATEDATETIME", null, null);
ttTrackStyle = TextType.getTextType("TRACKSTYLE");
ttTrack = new TupleType(new MathType[]
{ttTrackType, ttTrackName, rtBaseDateTime, rtCreateDateTime,
ttTrackStyle, locationFunction});
ftId2Track = new FunctionType(rtTrackID, ttTrack);
// Disturbance
rtDisturbanceID = RealType.getRealType("DISTURBANCEID", null, null);
ttCountry = TextType.getTextType("COUNTRY");
ttState = TextType.getTextType("STATE");
ttHistoricalName = TextType.getTextType("HISTORICALNAME");
rtYear = RealType.getRealType("YEAR", null, null);
rtNumber = RealType.getRealType("NUM", null, null);
rtOpenDate = RealType.getRealType("OPENDATE", null, null);
rtCloseDate = RealType.getRealType("CLOSEDATE", null, null);
rtArchiveMode = RealType.getRealType("ARCHIVEMODE", null, null);
rtRealtimeMode = RealType.getRealType("REALTIMEMODE", null, null);
TupleType ttDisturbance = new TupleType(new MathType[]
{ttCountry, ttState, rtYear, rtNumber, ttHistoricalName,
rtOpenDate, rtCloseDate, rtArchiveMode, rtRealtimeMode, ftId2Track});
FunctionType ftId2Disturbance =
new FunctionType(rtDisturbanceID, ttDisturbance);
mtTC = ftId2Disturbance;
}
}
public FieldImpl getData() {
return data;
}
public MathType getType() {
return mtTC;
}
public synchronized void addLocation(int disturbanceID, int trackID, double time,
RealTuple location)
throws VisADException, RemoteException {
addToTrack(disturbanceID, trackID, time, 5, locationFunction, location);
}
/*
public synchronized void addIntensity(int disturbanceID, int trackID, double time,
RealTuple intensity)
throws VisADException, RemoteException {
addToTrack(disturbanceID, trackID, time, 6, intensityFunction, intensity);
}
public synchronized void addSize(int disturbanceID, int trackID, double time,
RealTuple size)
throws VisADException, RemoteException {
addToTrack(disturbanceID, trackID, time, 7, sizeFunction, size);
}
public synchronized void addSteering(int disturbanceID, int trackID, double time,
RealTuple steering)
throws VisADException, RemoteException {
addToTrack(disturbanceID, trackID, time, 8, steeringFunction, steering);
}
*/
private void addToTrack(int disturbanceID, int trackID, double time,
int tuple_index, FunctionType function_type,
RealTuple rt)
throws VisADException, RemoteException {
Tuple disturbance = getDisturbance(disturbanceID);
if (disturbance == null) {
throw new VisADException("invalid disturbanceID");
}
Tuple track = getTrack(trackID, disturbance);
if (track == null) {
throw new VisADException("invalid trackID");
}
FlatField field = (FlatField) track.getComponent(tuple_index);
Gridded1DDoubleSet set = (Gridded1DDoubleSet) field.getDomainSet();
double[][] times = set.getDoubles(false);
int length = set.getLength();
double[][] new_times = new double[1][length + 1];
float[][] values = field.getFloats(false);
int dim = values.length;
float[][] new_values = new float[dim][length + 1];
int k = 0;
int m = -1;
for (int i=0; i= 0) data.setSample(index, disturbance);
}
private int findDisturbance(int disturbanceID)
throws VisADException, RemoteException {
if (data == null) {
return -1;
}
Gridded1DSet set = (Gridded1DSet) data.getDomainSet();
float[][] ids = set.getSamples(false);
int length = set.getLength();
float fid = disturbanceID;
for (int i=0; i= 0) {
FieldImpl field = (FieldImpl) disturbance.getComponent(9);
field.setSample(index, track);
}
}
private int findTrack(int trackID, Tuple disturbance)
throws VisADException, RemoteException {
if (disturbance == null) {
return -1;
}
FieldImpl field = (FieldImpl) disturbance.getComponent(9);
if (field == null) {
return -1;
}
Gridded1DSet set = (Gridded1DSet) field.getDomainSet();
float[][] ids = set.getSamples(false);
int length = set.getLength();
float fid = trackID;
for (int i=0; i intensityTuple)
*/
/*
public static FlatField makeMissingSteerings()
throws VisADException, RemoteException {
double[] daTimes = {Double.NaN};
int[] iaSteeringIds = {-1};
float[] faSteering_directions = {Float.NaN};
int[] iaSteeringStyles = {-1};
FlatField ffSteerings = TCData.makeSteerings( daTimes, iaSteeringIds, faSteering_directions,
iaSteeringStyles);
return ffSteerings;
}
*/
public static void main(String[] args)
throws VisADException, RemoteException {
MathType mtTC;
TCData data = new TCData();
mtTC = data.getType();
System.out.println("MathType:\n" + mtTC);
/*
C:\jamesk\java\tc\visad\bom>java visad.bom.TCDataTest
MathType:
(DISTURBANCEID -> (COUNTRY(Text),
STATE(Text),
YEAR,
NUM,
HISTORICALNAME(Text),
OPENDATE,
CLOSEDATE,
ARCHIVEMODE,
REALTIMEMODE,
(TRACKID -> (TRACKTYPE(Text),
TRACKNAME(Text),
BASEDATETIME,
CREATEDATETIME,
TRACKSTYLE(Text),
(Time -> (Latitude,
Longitude,
ERROR,
CONFIDENCE,
LOCATIONSTYLE,
WINDMEAN,
WINDGUST,
CENTRALPRESSURE,
CATEGORY,
INTENSITYSTYLE,
GALERADIUS,
STORMRADIUS,
HURRICANERADIUS,
RADIUSOFMAXIMUMWINDS,
SIZESTYLE,
DEPTH,
EYEDIAMETER,
PRESSUREOFLASTCLOSEDISOBAR,
STRUCTURESTYLE))))))
was:
doll% java visad.bom.TCData
MathType:
(DisturbanceID -> (Country(Text),
State(Text),
Year,
Number,
HistoricalName(Text),
OpenDate,
CloseDate,
ArchiveMode,
RealtimeMode,
(TrackID -> (TrackType(Text),
TrackName(Text),
BaseDateTime,
CreateDateTime,
TrackStyle(Text),
(Time -> (LocationID, Latitude, Longitude, Error, LocationStyle)),
(Time -> (IntensityID, WindMean, WindGust, CentralPressure, Category)),
(Time -> (SizeID, GaleRadius, StormRadius, HurricaneRadius, RadiusOfMaximumWinds, SizeStyle)),
(Time -> (SteeringID, SteeringDirection, SteeringStyle))))))
*/
}
}
Ads help maintain this website.