Package ucar.nc2.iosp.cinrad
Class Cinrad2Record
- java.lang.Object
-
- ucar.nc2.iosp.cinrad.Cinrad2Record
-
public class Cinrad2Record extends Object
This class reads one record (radial) in an CINRAD level II file. File must be uncompressed. Not handling messages yet, only data.10/16/05: Now returns data as a byte, so use scale and offset. Adapted with permission from the Java Iras software developed by David Priegnitz at NSSL.
-
-
Field Summary
Fields Modifier and Type Field Description static byte
BELOW_THRESHOLD
CalendarDate
dateTime0
CalendarDate
dateTimeE
static int
DOPPLER_RESOLUTION_HIGH_CODE
High doppler resolution codestatic int
DOPPLER_RESOLUTION_LOW_CODE
Low doppler resolution codestatic float
HORIZONTAL_BEAM_WIDTH
Horizontal beam widthbyte
message_type
static byte
MISSING_DATA
Initialization flag for lookup tables public static int data_lut_init_flag = 0; /** Reflectivity look up table public static float[] Reflectivity_LUT = new float[256]; /** 1 km Velocity look up table public static float[] Velocity_1km_LUT = new float[256]; /** 1/2 km Velocity look up table public static float[] Velocity_hkm_LUT = new float[256]; static { Reflectivity_LUT[0] = 0.0f; // Float.NaN; //(float) SIGNAL_BELOW_THRESHOLD; Reflectivity_LUT[1] = Float.NaN; //(float) SIGNAL_OVERLAID; Velocity_1km_LUT[0] = 0.0f; // Float.NaN; //(float) SIGNAL_BELOW_THRESHOLD; Velocity_1km_LUT[1] = Float.NaN; //(float) SIGNAL_OVERLAID; Velocity_hkm_LUT[0] = 0.0f; // Float.NaN; //(float) SIGNAL_BELOW_THRESHOLD; Velocity_hkm_LUT[1] = Float.NaN; //(float) SIGNAL_OVERLAID; for (int i = 2; i < 256; i++) { Reflectivity_LUT[i] = (float) (i / 2.0 - 33.0); Velocity_1km_LUT[i] = (float) (i - 129.0); Velocity_hkm_LUT[i] = (float) (i / 2.0 - 64.5); // also spectrum width } }static int
REFLECTIVITY
Reflectivity moment identifierstatic int
SPECTRUM_WIDTH
Sprectrum Width moment identifierucar.nc2.iosp.cinrad.Cinrad2Record.SweepInfo[]
sweepInfo
static int
VELOCITY_HI
Radial Velocity moment identifierstatic int
VELOCITY_LOW
Radial Velocity moment identifier
-
Constructor Summary
Constructors Constructor Description Cinrad2Record(RandomAccessFile din, int record)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
bytesToInt(byte[] bytes, boolean swapBytes)
static int
bytesToShort(byte[] bytes, boolean swapBytes)
boolean
checkOk()
short
convertunsignedByte2Short(byte b)
void
dump(PrintStream out)
void
dump2(PrintStream out)
void
dumpMessage(PrintStream out, Date d)
static Cinrad2Record
factory(RandomAccessFile din, int record)
int
findClosestIdx(int[] numbers, short myNumber)
float
getAzimuth()
Get the azimuth in degreesstatic float
getDatatypeAddOffset(int datatype)
static String
getDatatypeName(int datatype)
static float
getDatatypeScaleFactor(int datatype)
static String
getDatatypeUnits(int datatype)
Date
getDate()
static Date
getDate(int julianDays, int msecs)
float
getElevation()
Get the elevation angle in degreesint
getGateCount(int datatype)
This method returns the number of gatesint
getGateSize(int datatype)
This method returns the gate size in metersint
getGateStart(int datatype)
This method returns the starting gate in metersstatic String
getMessageTypeName(int code)
static String
getRadialStatusName(int code)
static String
getVolumeCoveragePatternName(int code)
void
readCC20Header(RandomAccessFile din)
void
readCCHeader(RandomAccessFile din)
void
readData(RandomAccessFile raf, int datatype, Range gateRange, IndexIterator ii)
Read data from this record.void
readData0(RandomAccessFile raf, int datatype, Range gateRange, IndexIterator ii)
void
readData1(RandomAccessFile raf, int datatype, Range gateRange, IndexIterator ii)
void
readSCHeader(RandomAccessFile din)
String
toString()
Instances which have same content are equal.
-
-
-
Field Detail
-
REFLECTIVITY
public static final int REFLECTIVITY
Reflectivity moment identifier- See Also:
- Constant Field Values
-
VELOCITY_HI
public static final int VELOCITY_HI
Radial Velocity moment identifier- See Also:
- Constant Field Values
-
VELOCITY_LOW
public static final int VELOCITY_LOW
Radial Velocity moment identifier- See Also:
- Constant Field Values
-
SPECTRUM_WIDTH
public static final int SPECTRUM_WIDTH
Sprectrum Width moment identifier- See Also:
- Constant Field Values
-
DOPPLER_RESOLUTION_LOW_CODE
public static final int DOPPLER_RESOLUTION_LOW_CODE
Low doppler resolution code- See Also:
- Constant Field Values
-
DOPPLER_RESOLUTION_HIGH_CODE
public static final int DOPPLER_RESOLUTION_HIGH_CODE
High doppler resolution code- See Also:
- Constant Field Values
-
HORIZONTAL_BEAM_WIDTH
public static final float HORIZONTAL_BEAM_WIDTH
Horizontal beam width- See Also:
- Constant Field Values
-
MISSING_DATA
public static byte MISSING_DATA
Initialization flag for lookup tables public static int data_lut_init_flag = 0; /** Reflectivity look up table public static float[] Reflectivity_LUT = new float[256]; /** 1 km Velocity look up table public static float[] Velocity_1km_LUT = new float[256]; /** 1/2 km Velocity look up table public static float[] Velocity_hkm_LUT = new float[256]; static { Reflectivity_LUT[0] = 0.0f; // Float.NaN; //(float) SIGNAL_BELOW_THRESHOLD; Reflectivity_LUT[1] = Float.NaN; //(float) SIGNAL_OVERLAID; Velocity_1km_LUT[0] = 0.0f; // Float.NaN; //(float) SIGNAL_BELOW_THRESHOLD; Velocity_1km_LUT[1] = Float.NaN; //(float) SIGNAL_OVERLAID; Velocity_hkm_LUT[0] = 0.0f; // Float.NaN; //(float) SIGNAL_BELOW_THRESHOLD; Velocity_hkm_LUT[1] = Float.NaN; //(float) SIGNAL_OVERLAID; for (int i = 2; i < 256; i++) { Reflectivity_LUT[i] = (float) (i / 2.0 - 33.0); Velocity_1km_LUT[i] = (float) (i - 129.0); Velocity_hkm_LUT[i] = (float) (i / 2.0 - 64.5); // also spectrum width } }
-
BELOW_THRESHOLD
public static final byte BELOW_THRESHOLD
- See Also:
- Constant Field Values
-
message_type
public byte message_type
-
dateTime0
public CalendarDate dateTime0
-
dateTimeE
public CalendarDate dateTimeE
-
sweepInfo
public ucar.nc2.iosp.cinrad.Cinrad2Record.SweepInfo[] sweepInfo
-
-
Constructor Detail
-
Cinrad2Record
public Cinrad2Record(RandomAccessFile din, int record) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getDatatypeName
public static String getDatatypeName(int datatype)
-
getDatatypeUnits
public static String getDatatypeUnits(int datatype)
-
getDatatypeScaleFactor
public static float getDatatypeScaleFactor(int datatype)
-
getDatatypeAddOffset
public static float getDatatypeAddOffset(int datatype)
-
getMessageTypeName
public static String getMessageTypeName(int code)
-
getRadialStatusName
public static String getRadialStatusName(int code)
-
getVolumeCoveragePatternName
public static String getVolumeCoveragePatternName(int code)
-
getDate
public static Date getDate(int julianDays, int msecs)
-
factory
public static Cinrad2Record factory(RandomAccessFile din, int record) throws IOException
- Throws:
IOException
-
convertunsignedByte2Short
public short convertunsignedByte2Short(byte b)
-
readSCHeader
public void readSCHeader(RandomAccessFile din) throws IOException
- Throws:
IOException
-
readCCHeader
public void readCCHeader(RandomAccessFile din) throws IOException
- Throws:
IOException
-
readCC20Header
public void readCC20Header(RandomAccessFile din) throws IOException
- Throws:
IOException
-
findClosestIdx
public int findClosestIdx(int[] numbers, short myNumber)
-
bytesToInt
public static int bytesToInt(byte[] bytes, boolean swapBytes)
-
bytesToShort
public static int bytesToShort(byte[] bytes, boolean swapBytes)
-
dumpMessage
public void dumpMessage(PrintStream out, Date d)
-
dump
public void dump(PrintStream out)
-
dump2
public void dump2(PrintStream out)
-
checkOk
public boolean checkOk()
-
getAzimuth
public float getAzimuth()
Get the azimuth in degrees- Returns:
- azimuth angle in degrees 0 = true north, 90 = east
-
getElevation
public float getElevation()
Get the elevation angle in degrees- Returns:
- elevation angle in degrees 0 = parellel to pedestal base, 90 = perpendicular
-
getGateSize
public int getGateSize(int datatype)
This method returns the gate size in meters
-
getGateStart
public int getGateStart(int datatype)
This method returns the starting gate in meters
-
getGateCount
public int getGateCount(int datatype)
This method returns the number of gates
-
getDate
public Date getDate()
-
readData
public void readData(RandomAccessFile raf, int datatype, Range gateRange, IndexIterator ii) throws IOException
Read data from this record.- Parameters:
raf
- read from this filedatatype
- which data type we wantgateRange
- handles the possible subset of data to returnii
- put the data here- Throws:
IOException
-
readData0
public void readData0(RandomAccessFile raf, int datatype, Range gateRange, IndexIterator ii) throws IOException
- Throws:
IOException
-
readData1
public void readData1(RandomAccessFile raf, int datatype, Range gateRange, IndexIterator ii) throws IOException
- Throws:
IOException
-
toString
public String toString()
Instances which have same content are equal. public boolean equals(Object oo) { if (this == oo) return true; if ( !(oo instanceof Cinrad2Record)) return false; return hashCode() == oo.hashCode(); } /** Override Object.hashCode() to implement equals. * public int hashCode() { if (hashCode == 0) { int result = 17; result = 37*result + elevation_num; //result = 37*result + cut; //result = 37*result + datatype; hashCode = result; } return hashCode; } private volatile int hashCode = 0;
-
-