Package ucar.unidata.data.radar
Class CDMRadarAdapter
java.lang.Object
ucar.unidata.data.radar.CDMRadarAdapter
- All Implemented Interfaces:
RadarAdapter
,RadarConstants
A data adapter for Common Data Model radial data
(Level II, Level III, DORADE)
- Version:
- $Revision: 1.54 $
- Author:
- IDV Development Team
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
Neighbors is the class used to store values of 8 points near any grid point.static class
SearchPoint is the class used to store all information associated with each ray. -
Field Summary
Fields inherited from interface ucar.unidata.data.radar.RadarAdapter
AZIMUTH_ANGLE_TYPE, AZIMUTH_TYPE, ELEVATION_ANGLE_TYPE, RANGE_TYPE
Fields inherited from interface ucar.unidata.data.radar.RadarConstants
AZIMUTH, AZIMUTH_ANGLE, ELEVATION_ANGLE, PROP_2DOR3D, PROP_ANGLE, PROP_ANGLES, PROP_AZIMUTH, PROP_AZIMUTHS, PROP_CAPPI_LEVEL, PROP_CAPPI_LEVELS, PROP_TIMEHEIGHT, PROP_VCS, PROP_VCS_END, PROP_VCS_START, PROP_VOLUMEORSWEEP, PROP_VWP, RADAR_MOST_RECENT, RADIAL_VELOCITY_NAME, RANGE, REFLECTIVITY, REFLECTIVITY_NAME, SPECTRUM_WIDTH, SPECTRUM_WIDTH_NAME, STATION_LOCATION, VALUE_2D, VALUE_3D, VALUE_SWEEP, VALUE_VOLUME, VELOCITY
-
Constructor Summary
ConstructorsConstructorDescriptionZero-argument constructor for construction via unpersistence.CDMRadarAdapter
(DataSourceImpl source, String fileName) Construct a new DORADE adapter. -
Method Summary
Modifier and TypeMethodDescriptionstatic double
angDist
(double deltaEl, double deltaAz) angDist calculate sqrt of deltaEL and AZstatic void
calAccumInterp
(ucar.unidata.data.radar.CDMRadarAdapter.Ray ray, int igateInner, int igateOuter, double wtInner, double wtOuter, double[] sumVals, double[] sumWts, int[] nContrib) static void
calculateNearest
(ucar.unidata.data.radar.CDMRadarAdapter.Ray ray, int igateInner, int igateOuter, double wtInner, double wtOuter, double[] closestVal, double[] maxWt, int[] nContrib) void
Clear the rds dataucar.unidata.data.radar.CDMRadarAdapter.GridLoc[][][]
computeGridRow
(int numCols, int numRows, int numLevels, float[] latRows, float[] lonCols, float[] altLevels) computeGridRow calculate gridloc for each grid pointvoid
doRemove()
Clean up whatever we need to when we are removed.boolean
Check to see if thisCDMDataSource
is equal to the object in question.static int
findInsertIndex
(double[] sortedArray, double value) static double
fmod
(double a, double b) fmod calculate modulus for float/doubleprotected double[]
Get the angles for this parameterGet the base time for this sweepucar.unidata.geoloc.Bearing
getBearing
(double lat, double lon) calculate the bearing of one location to the radar locationThis api is based on the rsl c library from TRMM Office Radar Software Library.Object[]
getCutIdx
(ucar.nc2.dt.RadialDatasetSweep.RadialVariable sweepVar) get radar sweep indexgetData
(DataChoice dataChoice, DataSelection subset, Hashtable requestProperties) Get the data for the given DataChoice and selection criteria.Get the data format name (e.g.float[]
getFloatNaN
(int n) get float array init with NaNgetGridVolume
(int moment, String varName) Makes a field of all data from one common data model radar adapter;float[]
getIntersectionOfRayAndLine
(EarthLocation radarCenter, float azi, float lat3, float lon3, float lat4, float lon4) calculate the intersection of ray and a linefloat[]
getIntersectionOfTwoLines
(float lat1, float lon1, float lat2, float lon2, float lat3, float lon3, float lat4, float lon4) alculate the intersection of two linesgetName()
Return the name of the filestatic int[][]
getNeighborRays
(double az, double elev, double[] elevs, double[][] azims, int[][] azidx) protected RealType[]
Get the parameters for this adaptergetRadarCrossSection
(int moment, String varName, LatLonPoint p1, LatLonPoint p2) Makes a field of all data from one common data model radar adapter;Get the radar location from the dataset.Create the initial spatial domainMakes a field of all data from one common data model radar adapter;Makes a field of all data from one common data model radar adapter;getRHISweep
(int moment, double azimus, String varName, int idx, boolean want3D) Makes a field of all data from one common data model radar adapter;getRHIVolume
(int moment, String varName) Makes a field of all data from one common data model radar adapter;Get the station IDGet the parameters for this adapterGet the parameters for this adapterMakes a field of all data from one common data model radar adapter;int
getSweepNumber
(String vname, double angle) Get the sweep number for the particular variable and elevation angleprotected double
getVCPAngle
(double angle, short id) Find the closest angle to the given VCP anglesprotected double[]
getVCPAngles
(short id, double[] origAngles) Get the parameters for this adapterprotected short
Get the parameters for this adapterMakes a field of all data from one common data model radar adapter;getVolumeG
(int moment, String varName) Makes a field of all data from one common data model radar adapter;static CDMRadarAdapter.Neighbors
getWtsFor2ValidRays
(ucar.unidata.data.radar.CDMRadarAdapter.GridLoc loc, CDMRadarAdapter.SearchPoint ll, CDMRadarAdapter.SearchPoint ul, CDMRadarAdapter.SearchPoint lr, CDMRadarAdapter.SearchPoint ur, double wtInner, double wtOuter) loadWtsFor2ValidRays calculate neighbour valuesstatic CDMRadarAdapter.Neighbors
getWtsFor3Or4ValidRays
(ucar.unidata.data.radar.CDMRadarAdapter.GridLoc loc, CDMRadarAdapter.SearchPoint ll, CDMRadarAdapter.SearchPoint ul, CDMRadarAdapter.SearchPoint lr, CDMRadarAdapter.SearchPoint ur, double wtInner, double wtOuter) getWtsFor3Or4ValidRays calculate neighbour valuesint
hashCode()
Get the hash code for this object.static double[]
interpGridRow
(int iz, int iy, ucar.unidata.data.radar.CDMRadarAdapter.GridLoc[][][] loc, ucar.unidata.data.radar.CDMRadarAdapter.Ray[][] rays, double[] elevs, double[][] azims, int[][] azidx) boolean
isRaster()
Get the parameters for this adapterboolean
isRHI()
Get the parameters for this adapterboolean
isVolume()
Get the parameters for this adaptervoid
latLon2RTheta
(double lat1, double lon1, double lat2, double lon2, double[] r, double[] theta) latLon2RTheta calculate r and theta of two latlon pointsstatic double
loadInterpGridPt
(int igateInner, int igateOuter, CDMRadarAdapter.SearchPoint ll, CDMRadarAdapter.SearchPoint ul, CDMRadarAdapter.SearchPoint lr, CDMRadarAdapter.SearchPoint ur, CDMRadarAdapter.Neighbors wts) static double
loadNearestGridPt
(int igateInner, int igateOuter, CDMRadarAdapter.SearchPoint ll, CDMRadarAdapter.SearchPoint ul, CDMRadarAdapter.SearchPoint lr, CDMRadarAdapter.SearchPoint ur, CDMRadarAdapter.Neighbors wts) loadNearestGridPt return the nearest radial pointstatic void
mainstatic void
mainDorade
(String[] args) Test mainstatic double[]
removeNaNfromSortedArray
(double[] sortedArr) the sorted array may have some NaN at the end of the arraysetCrossSectionLinePosition
(float azi) setting the init crosssection line position with azimuth anglevoid
Set the station locationstatic int[]
sortFloatArrayWithNaNAndIndices
(double[] arr) This is api by chatgpt to sort an array and put the NaN at its endtoString()
to String.
-
Constructor Details
-
CDMRadarAdapter
public CDMRadarAdapter()Zero-argument constructor for construction via unpersistence. -
CDMRadarAdapter
Construct a new DORADE adapter.- Parameters:
source
- DataSource (may be null)fileName
- name of the DORADE file to read- Throws:
VisADException
- problem creating data
-
-
Method Details
-
equals
Check to see if thisCDMDataSource
is equal to the object in question. -
hashCode
public int hashCode()Get the hash code for this object. -
getRadarStationInFile
Get the radar location from the dataset.- Returns:
- EarthLocation.
-
toString
to String. -
getAngles
Get the angles for this parameter- Parameters:
vname
- variable name- Returns:
- angles for that variable
-
getBaseTime
Get the base time for this sweep- Specified by:
getBaseTime
in interfaceRadarAdapter
- Returns:
- time of sweep
-
getVCPid
Get the parameters for this adapter- Parameters:
vname
- variable name- Returns:
- id for that variable
-
getVCPAngles
protected double[] getVCPAngles(short id, double[] origAngles) Get the parameters for this adapter- Parameters:
id
- vcp id numberorigAngles
- The original angles- Returns:
- dd vcp angles
-
getVCPAngle
protected double getVCPAngle(double angle, short id) Find the closest angle to the given VCP angles- Parameters:
angle
- to findid
- of VCP- Returns:
- ang for angle;
-
getCAPPI
public FieldImpl getCAPPI(int moment, String varName, Real level) throws VisADException, RemoteException, IOException This api is based on the rsl c library from TRMM Office Radar Software Library.- Parameters:
moment
- the momentvarName
- variable namelevel
- the level- Returns:
- capi as a FieldImpl
- Throws:
IOException
- problem reading the fileRemoteException
- problem with Java RMIVisADException
- problem creating VisAD object
-
getData
public DataImpl getData(DataChoice dataChoice, DataSelection subset, Hashtable requestProperties) throws VisADException, RemoteException Get the data for the given DataChoice and selection criteria.- Specified by:
getData
in interfaceRadarAdapter
- Parameters:
dataChoice
- DataChoice for selectionsubset
- subsetting criteriarequestProperties
- extra request properties- Returns:
- the Data object for the request
- Throws:
RemoteException
- couldn't create a remote data objectVisADException
- couldn't create the data
-
clearCachedData
public void clearCachedData()Clear the rds data- Specified by:
clearCachedData
in interfaceRadarAdapter
-
getName
Return the name of the file- Specified by:
getName
in interfaceRadarAdapter
- Returns:
- name
-
getParams
Get the parameters for this adapter- Returns:
- parameters
-
getRHIOld
public FieldImpl getRHIOld(int moment, String varName, double rhiAz) throws VisADException, RemoteException, IOException Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentvarName
- variable namerhiAz
- azimuth for RHI- Returns:
- rhi as a FieldImpl
- Throws:
IOException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- Couldn't create VisAD Object
-
getRadarCrossSection
public FieldImpl getRadarCrossSection(int moment, String varName, LatLonPoint p1, LatLonPoint p2) throws VisADException, IOException Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentvarName
- variable namep1
- cross lint start pointp2
- cross lint end point- Returns:
- a FieldImpl
- Throws:
IOException
- Problem reading dataVisADException
- Couldn't create VisAD Object
-
getBearing
public ucar.unidata.geoloc.Bearing getBearing(double lat, double lon) calculate the bearing of one location to the radar location- Parameters:
lat
- input latitudelon
- input longitude- Returns:
- bearing
-
setCrossSectionLinePosition
setting the init crosssection line position with azimuth angle- Parameters:
azi
- input azimuth angle- Returns:
- lat lon point
- Throws:
RemoteException
- for badVisADException
- for bad
-
getIntersectionOfRayAndLine
public float[] getIntersectionOfRayAndLine(EarthLocation radarCenter, float azi, float lat3, float lon3, float lat4, float lon4) calculate the intersection of ray and a line- Parameters:
radarCenter
- earthlocation of radarazi
- ray azimuthlat3
- line latitude of one endlon3
- line longitude of one endlat4
- line latitude of another endlon4
- _more_- Returns:
- lat lon points
-
getIntersectionOfTwoLines
public float[] getIntersectionOfTwoLines(float lat1, float lon1, float lat2, float lon2, float lat3, float lon3, float lat4, float lon4) alculate the intersection of two lines- Parameters:
lat1
- latitude of line 1lon1
- longitude of line 1lat2
- latitude of line 1lon2
- longitude of line 1lat3
- latitude of line 2lon3
- longitude of line 2lat4
- latitude of line 2lon4
- longitude of line 2- Returns:
- lat lon float array
-
getRHI
public FieldImpl getRHI(int moment, String varName, double rhiAz) throws VisADException, RemoteException, IOException Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentvarName
- variable namerhiAz
- azimuth for RHI- Returns:
- rhi as a FieldImpl
- Throws:
IOException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- Couldn't create VisAD Object
-
getStationID
Get the station ID- Returns:
- the station ID
-
getStationLocation
Get the parameters for this adapter- Returns:
- parameters
-
setStationLocation
Set the station location- Parameters:
el
- location of the radar- Throws:
VisADException
- couldn't create VisAD objectRemoteException
- couldn't create remote object
-
getStationName
Get the parameters for this adapter- Returns:
- parameters
-
getDataFormatName
Get the data format name (e.g. Level II, DORADE, etc)- Returns:
- the format name
-
getRaster
public FlatField getRaster(int moment, String varName) throws VisADException, RemoteException, IOException, ucar.ma2.InvalidRangeException Create the initial spatial domain- Parameters:
moment
- idxvarName
- variable name- Returns:
- The initial spatial domain
- Throws:
IOException
- Problem reading dataucar.ma2.InvalidRangeException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- problem creating domain
-
getRHISweep
public FieldImpl getRHISweep(int moment, double azimus, String varName, int idx, boolean want3D) throws VisADException, RemoteException, IOException Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentazimus
- azimuth anglevarName
- variable nameidx
- indexwant3D
- true if should return a 3D field- Returns:
- sweep as a FieldImpl
- Throws:
IOException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- Couldn't create VisAD Object
-
getSweep
public FlatField getSweep(int moment, double elevation, String varName, int idx, boolean want3D) throws VisADException, RemoteException, IOException Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentelevation
- elevation anglevarName
- variable nameidx
- _more_want3D
- true if should return a 3D field- Returns:
- sweep as a FieldImpl
- Throws:
IOException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- Couldn't create VisAD Object
-
getSweepNumber
Get the sweep number for the particular variable and elevation angle- Parameters:
vname
- variable nameangle
- elevation angle- Returns:
- the index of the sweep in the dataset
-
getCutIdx
get radar sweep index- Parameters:
sweepVar
- radar variable- Returns:
- sweep index array
-
getVolume
public FlatField getVolume(int moment, String varName) throws VisADException, RemoteException, IOException Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentvarName
- variable name- Returns:
- volume as a FieldImpl
- Throws:
IOException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- Couldn't create VisAD Object
-
getGridVolume
Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentvarName
- variable name- Returns:
- gridded volume as a FieldImpl
- Throws:
IOException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- Couldn't create VisAD Object
-
getVolumeG
Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentvarName
- variable name- Returns:
- gridded volume as a FieldImpl
- Throws:
IOException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- Couldn't create VisAD Object
-
removeNaNfromSortedArray
public static double[] removeNaNfromSortedArray(double[] sortedArr) the sorted array may have some NaN at the end of the array- Parameters:
sortedArr
- _more_- Returns:
- sorted array with valid value
-
sortFloatArrayWithNaNAndIndices
public static int[] sortFloatArrayWithNaNAndIndices(double[] arr) This is api by chatgpt to sort an array and put the NaN at its end- Parameters:
arr
- _more_- Returns:
- int array
-
getRHIVolume
public FlatField getRHIVolume(int moment, String varName) throws VisADException, RemoteException, IOException Makes a field of all data from one common data model radar adapter;- Parameters:
moment
- momentvarName
- variable name- Returns:
- volume as a FieldImpl
- Throws:
IOException
- Problem reading dataRemoteException
- Java RMI problemVisADException
- Couldn't create VisAD Object
-
getFloatNaN
public float[] getFloatNaN(int n) get float array init with NaN- Parameters:
n
- 1 D array length- Returns:
- float array
-
isRaster
public boolean isRaster()Get the parameters for this adapter- Returns:
- parameters
-
isVolume
public boolean isVolume()Get the parameters for this adapter- Returns:
- parameters
-
isRHI
public boolean isRHI()Get the parameters for this adapter- Returns:
- parameters
-
mainDorade
Test main- Parameters:
args
- cmd line args- Throws:
Exception
- when bad things happen
-
main
main- Parameters:
args
- args- Throws:
Exception
- On badness
-
doRemove
public void doRemove()Clean up whatever we need to when we are removed.- Specified by:
doRemove
in interfaceRadarAdapter
-
latLon2RTheta
public void latLon2RTheta(double lat1, double lon1, double lat2, double lon2, double[] r, double[] theta) latLon2RTheta calculate r and theta of two latlon points- Parameters:
lat1
- latitudelon1
- longitudelat2
- latitudelon2
- longituder
- radiustheta
- angle
-
fmod
public static double fmod(double a, double b) fmod calculate modulus for float/double- Parameters:
a
- any doubleb
- any double- Returns:
- fmod
-
computeGridRow
public ucar.unidata.data.radar.CDMRadarAdapter.GridLoc[][][] computeGridRow(int numCols, int numRows, int numLevels, float[] latRows, float[] lonCols, float[] altLevels) computeGridRow calculate gridloc for each grid point- Parameters:
numCols
- columnnumRows
- rownumLevels
- levellatRows
- latitudelonCols
- longitudealtLevels
- altitude- Returns:
- grid location
-
angDist
public static double angDist(double deltaEl, double deltaAz) angDist calculate sqrt of deltaEL and AZ- Parameters:
deltaEl
- elevation diffdeltaAz
- azimuth diff- Returns:
- angle distance
-
getWtsFor2ValidRays
public static CDMRadarAdapter.Neighbors getWtsFor2ValidRays(ucar.unidata.data.radar.CDMRadarAdapter.GridLoc loc, CDMRadarAdapter.SearchPoint ll, CDMRadarAdapter.SearchPoint ul, CDMRadarAdapter.SearchPoint lr, CDMRadarAdapter.SearchPoint ur, double wtInner, double wtOuter) loadWtsFor2ValidRays calculate neighbour values- Parameters:
loc
- grid locationll
- pointul
- pointlr
- pointur
- pointwtInner
- inner weightwtOuter
- outer weight- Returns:
- neighbors
-
getWtsFor3Or4ValidRays
public static CDMRadarAdapter.Neighbors getWtsFor3Or4ValidRays(ucar.unidata.data.radar.CDMRadarAdapter.GridLoc loc, CDMRadarAdapter.SearchPoint ll, CDMRadarAdapter.SearchPoint ul, CDMRadarAdapter.SearchPoint lr, CDMRadarAdapter.SearchPoint ur, double wtInner, double wtOuter) getWtsFor3Or4ValidRays calculate neighbour values- Parameters:
loc
- grid locationll
- pointul
- pointlr
- pointur
- pointwtInner
- neighborswtOuter
- neighbors- Returns:
- neighbors
-
loadNearestGridPt
public static double loadNearestGridPt(int igateInner, int igateOuter, CDMRadarAdapter.SearchPoint ll, CDMRadarAdapter.SearchPoint ul, CDMRadarAdapter.SearchPoint lr, CDMRadarAdapter.SearchPoint ur, CDMRadarAdapter.Neighbors wts) loadNearestGridPt return the nearest radial point- Parameters:
igateInner
- gateigateOuter
- garell
- pointul
- pointlr
- pointur
- pointwts
- neighbors- Returns:
- nearest point
-
calculateNearest
public static void calculateNearest(ucar.unidata.data.radar.CDMRadarAdapter.Ray ray, int igateInner, int igateOuter, double wtInner, double wtOuter, double[] closestVal, double[] maxWt, int[] nContrib) - Parameters:
ray
- _more_igateInner
- _more_igateOuter
- _more_wtInner
- _more_wtOuter
- _more_closestVal
- _more_maxWt
- _more_nContrib
- _more_
-
loadInterpGridPt
public static double loadInterpGridPt(int igateInner, int igateOuter, CDMRadarAdapter.SearchPoint ll, CDMRadarAdapter.SearchPoint ul, CDMRadarAdapter.SearchPoint lr, CDMRadarAdapter.SearchPoint ur, CDMRadarAdapter.Neighbors wts) - Parameters:
igateInner
- _more_igateOuter
- _more_ll
- _more_ul
- _more_lr
- _more_ur
- _more_wts
- _more_- Returns:
- interporated val loadInterpGridPt calculate each grid point value with 8 nearby radial point and return the interporated value
-
calAccumInterp
public static void calAccumInterp(ucar.unidata.data.radar.CDMRadarAdapter.Ray ray, int igateInner, int igateOuter, double wtInner, double wtOuter, double[] sumVals, double[] sumWts, int[] nContrib) - Parameters:
ray
- _more_igateInner
- _more_igateOuter
- _more_wtInner
- _more_wtOuter
- _more_sumVals
- _more_sumWts
- _more_nContrib
- _more_ calAccumInterp return the interporate grid point value with the nearby radial points on the same ray
-
interpGridRow
public static double[] interpGridRow(int iz, int iy, ucar.unidata.data.radar.CDMRadarAdapter.GridLoc[][][] loc, ucar.unidata.data.radar.CDMRadarAdapter.Ray[][] rays, double[] elevs, double[][] azims, int[][] azidx) - Parameters:
iz
- _more_iy
- _more_loc
- _more_rays
- _more_elevs
- _more_azims
- _more_azidx
- _more_- Returns:
- interprow interpRow return each row data For each grid point use radial coordinate information in the gridloc to find the neighbour rays, calculate the neighbour values, and finally calculate the value of the grid point.
-
getNeighborRays
public static int[][] getNeighborRays(double az, double elev, double[] elevs, double[][] azims, int[][] azidx) - Parameters:
az
- _more_elev
- _more_elevs
- _more_azims
- _more_azidx
- _more_azims
- is sorted azimuths with original idex in azidx- Returns:
- rays this is API for finding the neighboring's ray of given az and elev the returns of the ray index of ll = 0, lr = 1, ul = 2, ur = 3
-
findInsertIndex
public static int findInsertIndex(double[] sortedArray, double value) - Parameters:
sortedArray
- _more_value
- _more_- Returns:
- idx index findInsertIndex return the inserting index this is used for the azimuth arrays
-