mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add functions to get radar ppi grid, cappi, and 3D grid interpolation data
This commit is contained in:
parent
3c38064424
commit
94983e6888
@ -148,6 +148,15 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a radial record is in velocity group or not
|
||||
* @param record The radial record
|
||||
* @return Velocity group or not
|
||||
*/
|
||||
public boolean isVelocityGroup(RadialRecord record) {
|
||||
return velocityGroup.contains(record.product);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidFile(RandomAccessFile raf) {
|
||||
try {
|
||||
@ -307,6 +316,9 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
for (int i = 0; i < radialHeader.momentNumber; i++) {
|
||||
MomentHeader momentHeader = new MomentHeader(raf);
|
||||
String product = this.productMap.get(momentHeader.dataType);
|
||||
/*if (product.equals("dBZ")) {
|
||||
System.out.printf("scale: %d; offset: %d\n", momentHeader.scale, momentHeader.offset);
|
||||
}*/
|
||||
RadialRecord record;
|
||||
if (this.recordMap.containsKey(product)) {
|
||||
record = this.recordMap.get(product);
|
||||
@ -322,9 +334,15 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
record.elevation.add(new ArrayList<>());
|
||||
record.azimuth.add(new ArrayList<>());
|
||||
record.azimuthMinIndex.add(0);
|
||||
record.disResolution.add(cutConfigs.get(radialHeader.elevationNumber - 1).logResolution);
|
||||
record.distance.add(ArrayUtil.arrayRange1(0, momentHeader.dataLength / momentHeader.binLength,
|
||||
cutConfigs.get(radialHeader.elevationNumber - 1).logResolution));
|
||||
if (isVelocityGroup(record)) {
|
||||
record.disResolution.add(cutConfigs.get(radialHeader.elevationNumber - 1).dopplerResolution);
|
||||
record.distance.add(ArrayUtil.arrayRange1(0, momentHeader.dataLength / momentHeader.binLength,
|
||||
cutConfigs.get(radialHeader.elevationNumber - 1).dopplerResolution));
|
||||
} else {
|
||||
record.disResolution.add(cutConfigs.get(radialHeader.elevationNumber - 1).logResolution);
|
||||
record.distance.add(ArrayUtil.arrayRange1(0, momentHeader.dataLength / momentHeader.binLength,
|
||||
cutConfigs.get(radialHeader.elevationNumber - 1).logResolution));
|
||||
}
|
||||
record.newScanData();
|
||||
}
|
||||
record.elevation.get(record.elevation.size() - 1).add(radialHeader.elevation);
|
||||
@ -613,13 +631,13 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
Array array = arrays.get(i);
|
||||
for (int j = xRange.first(); j <= xRange.last(); j += xRange.stride()) {
|
||||
if (j < array.getSize())
|
||||
iter.setObjectNext(array.getObject(j));
|
||||
iter.setFloatNext(array.getFloat(j));
|
||||
else
|
||||
iter.setObjectNext(Float.NaN);
|
||||
iter.setFloatNext(Float.NaN);
|
||||
}
|
||||
} else {
|
||||
for (int j = xRange.first(); j <= xRange.last(); j += xRange.stride()) {
|
||||
iter.setObjectNext(Float.NaN);
|
||||
iter.setFloatNext(Float.NaN);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -741,6 +759,159 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read grid ppi data
|
||||
* @param varName Variable name
|
||||
* @param scanIdx Scan index
|
||||
* @param xa X coordinates array
|
||||
* @param ya Y coordinates array
|
||||
* @param h Radar height
|
||||
* @return Grid ppi data
|
||||
*/
|
||||
public Array readGridData(String varName, int scanIdx, Array xa, Array ya, Float h) {
|
||||
RadialRecord record = this.recordMap.get(varName);
|
||||
if (h == null) {
|
||||
h = (float) siteConfig.antennaHeight;
|
||||
}
|
||||
Array[] rr = Transform.cartesianToAntennaElevation(xa, ya, record.fixedElevation.get(scanIdx), h);
|
||||
Array azimuth = rr[0];
|
||||
Array ranges = rr[1];
|
||||
Array data = Array.factory(DataType.FLOAT, xa.getShape());
|
||||
IndexIterator iterA = azimuth.getIndexIterator();
|
||||
IndexIterator iterR = ranges.getIndexIterator();
|
||||
IndexIterator iterData = data.getIndexIterator();
|
||||
float v;
|
||||
while (iterData.hasNext()) {
|
||||
v = record.interpolateValue(scanIdx, iterA.getFloatNext(), iterR.getFloatNext());
|
||||
iterData.setFloatNext(v);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read CR data
|
||||
* @param varName Variable name
|
||||
* @param xa X coordinates array - 2D
|
||||
* @param ya Y coordinates array - 2D
|
||||
* @param h Radar height
|
||||
* @return CR data
|
||||
*/
|
||||
public Array getCRData(String varName, Array xa, Array ya, Float h) {
|
||||
RadialRecord record = this.recordMap.get(varName);
|
||||
int nScan = record.getScanNumber();
|
||||
if (h == null) {
|
||||
h = (float) siteConfig.antennaHeight;
|
||||
}
|
||||
|
||||
int[] shape = xa.getShape();
|
||||
int ny = shape[0];
|
||||
int nx = shape[1];
|
||||
Array data = Array.factory(DataType.FLOAT, shape);
|
||||
Index2D index2D = (Index2D) data.getIndex();
|
||||
float v;
|
||||
for (int s = 0; s < nScan; s++) {
|
||||
Array[] rr = Transform.cartesianToAntennaElevation(xa, ya, record.fixedElevation.get(s), h);
|
||||
Array azimuth = rr[0];
|
||||
Array ranges = rr[1];
|
||||
IndexIterator iterA = azimuth.getIndexIterator();
|
||||
IndexIterator iterR = ranges.getIndexIterator();
|
||||
if (s == 0) {
|
||||
for (int i = 0; i < ny; i++) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
v = record.interpolateValue(s, iterA.getFloatNext(), iterR.getFloatNext());
|
||||
data.setFloat(index2D.set(i, j), v);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
float v1;
|
||||
for (int i = 0; i < ny; i++) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
v = record.interpolateValue(s, iterA.getFloatNext(), iterR.getFloatNext());
|
||||
index2D.set(i, j);
|
||||
v1 = data.getFloat(index2D);
|
||||
if (Float.isNaN(v1) || (v > v1))
|
||||
data.setFloat(index2D, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read CAPPI data
|
||||
* @param varName Variable name
|
||||
* @param xa X coordinates array
|
||||
* @param ya Y coordinates array
|
||||
* @param z Z coordinates value
|
||||
* @param h Radar height
|
||||
* @return Grid ppi data
|
||||
*/
|
||||
public Array getCAPPIData(String varName, Array xa, Array ya, float z, Float h) {
|
||||
RadialRecord record = this.recordMap.get(varName);
|
||||
if (h == null) {
|
||||
h = (float) siteConfig.antennaHeight;
|
||||
}
|
||||
Array[] rr = Transform.cartesianToAntenna(xa, ya, z, h);
|
||||
Array azimuth = rr[0];
|
||||
Array ranges = rr[1];
|
||||
Array elevation = rr[2];
|
||||
Array data = Array.factory(DataType.FLOAT, xa.getShape());
|
||||
IndexIterator iterA = azimuth.getIndexIterator();
|
||||
IndexIterator iterR = ranges.getIndexIterator();
|
||||
IndexIterator iterE = elevation.getIndexIterator();
|
||||
IndexIterator iterData = data.getIndexIterator();
|
||||
float v;
|
||||
while (iterData.hasNext()) {
|
||||
v = record.interpolateValue(iterE.getFloatNext(), iterA.getFloatNext(), iterR.getFloatNext());
|
||||
iterData.setFloatNext(v);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read grid 3d data
|
||||
* @param varName Variable name
|
||||
* @param xa X coordinates array
|
||||
* @param ya Y coordinates array
|
||||
* @param z Z coordinates array
|
||||
* @param h Radar height
|
||||
* @return Grid ppi data
|
||||
*/
|
||||
public Array getGrid3DData(String varName, Array xa, Array ya, Array za, Float h) {
|
||||
RadialRecord record = this.recordMap.get(varName);
|
||||
if (h == null) {
|
||||
h = (float) siteConfig.antennaHeight;
|
||||
}
|
||||
|
||||
int nz = (int) za.getSize();
|
||||
int[] shape2D = xa.getShape();
|
||||
int[] shape3D = new int[]{nz, shape2D[0], shape2D[1]};
|
||||
Array data = Array.factory(DataType.FLOAT, shape3D);
|
||||
IndexIterator iterData = data.getIndexIterator();
|
||||
IndexIterator iterZ = za.getIndexIterator();
|
||||
while(iterZ.hasNext()) {
|
||||
float z = iterZ.getFloatNext();
|
||||
Array[] rr = Transform.cartesianToAntenna(xa, ya, z, h);
|
||||
Array azimuth = rr[0];
|
||||
Array ranges = rr[1];
|
||||
Array elevation = rr[2];
|
||||
IndexIterator iterA = azimuth.getIndexIterator();
|
||||
IndexIterator iterR = ranges.getIndexIterator();
|
||||
IndexIterator iterE = elevation.getIndexIterator();
|
||||
float v;
|
||||
while (iterA.hasNext()) {
|
||||
v = record.interpolateValue(iterE.getFloatNext(), iterA.getFloatNext(), iterR.getFloatNext());
|
||||
iterData.setFloatNext(v);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get VCS data
|
||||
* @param varName Variable name
|
||||
|
||||
@ -18,6 +18,7 @@ public class RadialRecord {
|
||||
public String product;
|
||||
private int binLength;
|
||||
private DataType dataType;
|
||||
private int fillValue;
|
||||
public int scale;
|
||||
public int offset;
|
||||
public List<Float> fixedElevation = new ArrayList<>();
|
||||
@ -43,7 +44,7 @@ public class RadialRecord {
|
||||
public void setBinLength(int value) {
|
||||
this.binLength = value;
|
||||
this.dataType = this.binLength == 1 ? DataType.UBYTE : DataType.USHORT;
|
||||
//this.dataType = DataType.FLOAT;
|
||||
this.fillValue = this.dataType == DataType.UBYTE ? 0 : Short.MIN_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -300,6 +301,25 @@ public class RadialRecord {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sorted azimuth list
|
||||
* @param scanIndex Scan index
|
||||
* @return Sorted azimuth list
|
||||
*/
|
||||
public List<Float> getSortedAzimuth(int scanIndex) {
|
||||
int sIdx = this.azimuthMinIndex.get(scanIndex);
|
||||
if (sIdx == 0) {
|
||||
return this.azimuth.get(scanIndex);
|
||||
}
|
||||
|
||||
List<Float> azs = this.azimuth.get(scanIndex);
|
||||
List<Float> sortedAzimuth = new ArrayList<>();
|
||||
sortedAzimuth.addAll(azs.subList(sIdx, azs.size()));
|
||||
sortedAzimuth.addAll(azs.subList(0, sIdx));
|
||||
|
||||
return sortedAzimuth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get azimuth value index
|
||||
* @param ei Scan index
|
||||
@ -353,7 +373,80 @@ public class RadialRecord {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value by elevation, azimuth and distance
|
||||
* Get azimuth value indices
|
||||
* @param ei Scan index
|
||||
* @param a Azimuth value
|
||||
* @return Azimuth value indices - 2 elements
|
||||
*/
|
||||
public int[] getAzimuthIndices(int ei, float a) {
|
||||
List<Float> azs = this.azimuth.get(ei);
|
||||
int n = azs.size();
|
||||
int sIdx = this.azimuthMinIndex.get(ei);
|
||||
int eIdx = sIdx - 1;
|
||||
if (eIdx < 0) {
|
||||
eIdx = n - 1;
|
||||
}
|
||||
|
||||
int i1 = -1, i2 = -1;
|
||||
if (a < azs.get(sIdx) || a > azs.get(eIdx)) {
|
||||
i1 = eIdx;
|
||||
i2 = sIdx;
|
||||
} else {
|
||||
for (int i = sIdx + 1; i < n; i++) {
|
||||
if (a == azs.get(i)) {
|
||||
return new int[]{i, i};
|
||||
} else if (a < azs.get(i)) {
|
||||
i1 = i - 1;
|
||||
i2 = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i1 < 0) {
|
||||
for (int i = 0; i <= eIdx; i++) {
|
||||
if (a == azs.get(i)) {
|
||||
return new int[]{i, i};
|
||||
} else if (a < azs.get(i)) {
|
||||
i1 = i - 1;
|
||||
i2 = i;
|
||||
if (i1 < 0) {
|
||||
i1 = n - 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new int[]{i1, i2};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scan indices
|
||||
*
|
||||
* @param e Elevation value
|
||||
* @return Scan indices - 2 elements
|
||||
*/
|
||||
public int[] getScanIndices(float e) {
|
||||
if (e < fixedElevation.get(0) || e > fixedElevation.get(fixedElevation.size() - 1)) {
|
||||
return new int[]{-1, -1};
|
||||
} else if (e == fixedElevation.get(0)) {
|
||||
return new int[]{0, 0};
|
||||
} else if (e == fixedElevation.get(fixedElevation.size() - 1)) {
|
||||
return new int[]{fixedElevation.size() - 1, fixedElevation.size() - 1};
|
||||
}
|
||||
|
||||
for (int i = 1; i < fixedElevation.size(); i++) {
|
||||
if (e <= fixedElevation.get(i)) {
|
||||
return new int[]{i - 1, i};
|
||||
}
|
||||
}
|
||||
|
||||
return new int[]{-1, -1};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value by elevation index, azimuth and distance
|
||||
*
|
||||
* @param ei Elevation index
|
||||
* @param a Azimuth value
|
||||
* @param r Distance value
|
||||
@ -364,7 +457,7 @@ public class RadialRecord {
|
||||
int aziIdx = getAzimuthIndex(ei, a);
|
||||
int disRes = this.disResolution.get(ei);
|
||||
int disIdx = (int) (r / disRes);
|
||||
Array rData = this.data.get(ei).get(aziIdx);
|
||||
Array rData = sData.get(aziIdx);
|
||||
float v;
|
||||
if (disIdx < rData.getSize()) {
|
||||
v = rData.getFloat(disIdx);
|
||||
@ -375,4 +468,116 @@ public class RadialRecord {
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate value by elevation index, azimuth index and distance
|
||||
*
|
||||
* @param ei Elevation index
|
||||
* @param ai Azimuth index
|
||||
* @param r Distance value
|
||||
* @return Data value
|
||||
*/
|
||||
public float interpolateValue(int ei, int ai, float r) {
|
||||
List<Array> sData = this.data.get(ei);
|
||||
int disRes = this.disResolution.get(ei);
|
||||
float v;
|
||||
Array rData = sData.get(ai);
|
||||
float disIdx = r / disRes;
|
||||
int di1 = (int) Math.floor(disIdx);
|
||||
int di2 = (int) Math.ceil(disIdx);
|
||||
if (di1 < rData.getSize()) {
|
||||
v = rData.getFloat(di1);
|
||||
if (v == this.fillValue) {
|
||||
v = Float.NaN;
|
||||
}
|
||||
} else {
|
||||
v = Float.NaN;
|
||||
}
|
||||
if (di1 != di2) {
|
||||
float v2;
|
||||
if (di2 < rData.getSize()) {
|
||||
v2 = rData.getFloat(di2);
|
||||
if (v2 == this.fillValue) {
|
||||
v2 = Float.NaN;
|
||||
}
|
||||
} else {
|
||||
v2 = Float.NaN;
|
||||
}
|
||||
|
||||
if (Float.isNaN(v)) {
|
||||
v = v2;
|
||||
} else {
|
||||
if (!Float.isNaN(v2)) {
|
||||
Array dis = this.distance.get(ei);
|
||||
v = v + (v2 - v) * (r - dis.getFloat(di1)) / (dis.getFloat(di2) - dis.getFloat(di1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate value by elevation index, azimuth and distance
|
||||
*
|
||||
* @param ei Elevation index
|
||||
* @param a Azimuth value
|
||||
* @param r Distance value
|
||||
* @return Data value
|
||||
*/
|
||||
public float interpolateValue(int ei, float a, float r) {
|
||||
List<Array> sData = this.data.get(ei);
|
||||
int[] aziIndices = getAzimuthIndices(ei, a);
|
||||
int ai1 = aziIndices[0];
|
||||
int ai2 = aziIndices[1];
|
||||
float v = interpolateValue(ei, ai1, r);
|
||||
if (ai2 != ai1) {
|
||||
float v2 = interpolateValue(ei, ai2, r);
|
||||
if (Float.isNaN(v)) {
|
||||
v = v2;
|
||||
} else {
|
||||
if (!Float.isNaN(v2)) {
|
||||
List<Float> azi = this.azimuth.get(ei);
|
||||
v = v + (v2 - v) * (a - azi.get(ai1)) / (azi.get(ai2) - azi.get(ai1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Float.isNaN(v))
|
||||
v = (v - this.offset) / this.scale;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate value by elevation, azimuth and distance - linear interpolate
|
||||
*
|
||||
* @param e Elevation value
|
||||
* @param a Azimuth value
|
||||
* @param r Distance value
|
||||
* @return Data value
|
||||
*/
|
||||
public float interpolateValue(float e, float a, float r) {
|
||||
int[] scanIdx = getScanIndices(e);
|
||||
if (scanIdx[0] < 0) {
|
||||
return Float.NaN;
|
||||
}
|
||||
|
||||
int ei1 = scanIdx[0];
|
||||
int ei2 = scanIdx[1];
|
||||
float v = interpolateValue(ei1, a, r);
|
||||
if (ei2 != ei1) {
|
||||
float v2 = interpolateValue(ei2, a, r);
|
||||
if (Float.isNaN(v)) {
|
||||
v = v2;
|
||||
} else {
|
||||
if (!Float.isNaN(v2)) {
|
||||
v = v + (v2 - v) * (e - fixedElevation.get(ei1)) / (fixedElevation.get(ei2) -
|
||||
fixedElevation.get(ei1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,8 +207,10 @@ public class Transform {
|
||||
public static double[] cartesianToAntenna(float x, float y, float z, float h) {
|
||||
double ranges = Math.sqrt(Math.pow(R + h, 2) + Math.pow(R + z, 2) - 2 * (R + h) * (R + z) *
|
||||
Math.cos(Math.sqrt(x * x + y * y) / R));
|
||||
double elevation = Math.acos((R + z) * Math.sin(Math.sqrt(x * x + y * y) / R) / ranges) *
|
||||
180. / Math.PI;
|
||||
//double elevation = Math.acos((R + z) * Math.sin(Math.sqrt(x * x + y * y) / R) / ranges) *
|
||||
// 180. / Math.PI;
|
||||
double elevation = (Math.acos(((R + h) * (R + h) + ranges * ranges - (R + z) * (R + z)) /
|
||||
(2 * (R + h) * ranges)) - Math.PI / 2) * 180. / Math.PI;
|
||||
double azimuth = xyToAzimuth(x, y);
|
||||
|
||||
return new double[]{azimuth, ranges, elevation};
|
||||
@ -244,4 +246,79 @@ public class Transform {
|
||||
|
||||
return new Array[]{azimuth, ranges, elevation};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert cartesian coordinate to antenna coordinate
|
||||
* @param xa x coordinate array in meters
|
||||
* @param ya y coordinate array in meters
|
||||
* @param z z coordinate value in meters
|
||||
* @param h Altitude of the instrument, above sea level, units:m
|
||||
* @return Antenna coordinate from the radar
|
||||
*/
|
||||
public static Array[] cartesianToAntenna(Array xa, Array ya, float z, float h) {
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
|
||||
Array ranges = Array.factory(DataType.DOUBLE, xa.getShape());
|
||||
Array azimuth = Array.factory(DataType.DOUBLE, xa.getShape());
|
||||
Array elevation = Array.factory(DataType.DOUBLE, xa.getShape());
|
||||
float x, y;
|
||||
|
||||
for (int i = 0; i < xa.getSize(); i++) {
|
||||
x = xa.getFloat(i);
|
||||
y = ya.getFloat(i);
|
||||
double[] rr = cartesianToAntenna(x, y, z, h);
|
||||
azimuth.setDouble(i, rr[0]);
|
||||
ranges.setDouble(i, rr[1]);
|
||||
elevation.setDouble(i, rr[2]);
|
||||
}
|
||||
|
||||
return new Array[]{azimuth, ranges, elevation};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert cartesian coordinate to antenna coordinate
|
||||
* @param x x coordinate in meters
|
||||
* @param y y coordinate in meters
|
||||
* @param e Elevation angle of the radar in radians
|
||||
* @param h Altitude of the instrument, above sea level, units:m
|
||||
* @return Antenna coordinate from the radar - azimuth, range and z
|
||||
*/
|
||||
public static double[] cartesianToAntennaElevation(float x, float y, float e, float h) {
|
||||
double s = Math.sqrt(x * x + y * y);
|
||||
double range = Math.tan(s / R) * (R + h) * Math.cosh(e);
|
||||
double z = (R + h) / Math.cos(e + s/R) * Math.cos(e) - R;
|
||||
double azimuth = xyToAzimuth(x, y);
|
||||
|
||||
return new double[]{azimuth, range, z};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert cartesian coordinate to antenna coordinate
|
||||
* @param xa x coordinate array in meters
|
||||
* @param ya y coordinate array in meters
|
||||
* @param e Elevation angle of the radar in radians
|
||||
* @param h Altitude of the instrument, above sea level, units:m
|
||||
* @return Antenna coordinate from the radar - azimuth, range and z
|
||||
*/
|
||||
public static Array[] cartesianToAntennaElevation(Array xa, Array ya, float e, float h) {
|
||||
xa = xa.copyIfView();
|
||||
ya = ya.copyIfView();
|
||||
|
||||
Array ranges = Array.factory(DataType.DOUBLE, xa.getShape());
|
||||
Array azimuth = Array.factory(DataType.DOUBLE, xa.getShape());
|
||||
Array za = Array.factory(DataType.DOUBLE, xa.getShape());
|
||||
float x, y, z;
|
||||
|
||||
for (int i = 0; i < xa.getSize(); i++) {
|
||||
x = xa.getFloat(i);
|
||||
y = ya.getFloat(i);
|
||||
double[] rr = cartesianToAntennaElevation(x, y, e, h);
|
||||
azimuth.setDouble(i, rr[0]);
|
||||
ranges.setDouble(i, rr[1]);
|
||||
za.setDouble(i, rr[2]);
|
||||
}
|
||||
|
||||
return new Array[]{azimuth, ranges, za};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,36 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\array">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW\ZhengZhou"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\radar">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\savefig"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\no_opengl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array\complex"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
|
||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_bz2_3d.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\array\stack_1.py"/>
|
||||
<OpenedFile File=""/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
|
||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_bz2_3d.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\array\stack_1.py"/>
|
||||
<RecentFile File=""/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -38,5 +34,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1359,786"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1387,825"/>
|
||||
</MeteoInfo>
|
||||
|
||||
@ -30,6 +30,76 @@ class RadarDataFile(DimDataFile):
|
||||
else:
|
||||
return np.array(self.datainfo.getElevations(product))
|
||||
|
||||
def get_grid_ppi(self, product, scan, x, y, h=None):
|
||||
"""
|
||||
Get grid ppi data.
|
||||
|
||||
:param product: (*str*) Product name.
|
||||
:param scan: (*int*) Scan index.
|
||||
:param x: (*array*) X coordinates with meters units.
|
||||
:param y: (*array*) Y coordinates with meters units.
|
||||
:param h: (*float*) Radar height with meters units.
|
||||
|
||||
:return: (*array*) Grid ppi data.
|
||||
"""
|
||||
if (x.ndim == 1):
|
||||
x, y = np.meshgrid(x, y)
|
||||
|
||||
r = self.datainfo.readGridData(product, scan, x._array, y._array, h)
|
||||
return np.array(r)
|
||||
|
||||
def get_cr_data(self, product, x, y, h=None):
|
||||
"""
|
||||
Get grid cr data.
|
||||
|
||||
:param product: (*str*) Product name.
|
||||
:param x: (*array*) X coordinates with meters units.
|
||||
:param y: (*array*) Y coordinates with meters units.
|
||||
:param h: (*float*) Radar height with meters units.
|
||||
|
||||
:return: (*array*) Grid cr data.
|
||||
"""
|
||||
if (x.ndim == 1):
|
||||
x, y = np.meshgrid(x, y)
|
||||
|
||||
r = self.datainfo.getCRData(product, x._array, y._array, h)
|
||||
return np.array(r)
|
||||
|
||||
def get_cappi_data(self, product, x, y, z, h=None):
|
||||
"""
|
||||
Get cappi grid data.
|
||||
|
||||
:param product: (*str*) Product name.
|
||||
:param x: (*array*) X coordinates with meters units.
|
||||
:param y: (*array*) Y coordinates with meters units.
|
||||
:param z: (*float*) Z coordinates value with meters units.
|
||||
:param h: (*float*) Radar height with meters units.
|
||||
|
||||
:return: (*array*) cappi data.
|
||||
"""
|
||||
if (x.ndim == 1):
|
||||
x, y = np.meshgrid(x, y)
|
||||
|
||||
r = self.datainfo.getCAPPIData(product, x._array, y._array, z, h)
|
||||
return np.array(r)
|
||||
|
||||
def get_grid_3d_data(self, product, x, y, z, h=None):
|
||||
"""
|
||||
Get grid 3d data.
|
||||
|
||||
:param product: (*str*) Product name.
|
||||
:param x: (*array*) X coordinates with meters units - 1D.
|
||||
:param y: (*array*) Y coordinates with meters units - 1D.
|
||||
:param z: (*array*) Z coordinates with meters units - 1D.
|
||||
:param h: (*float*) Radar height with meters units.
|
||||
|
||||
:return: (*array*) Grid 3d data.
|
||||
"""
|
||||
xg, yg = np.meshgrid(x, y)
|
||||
|
||||
r = self.datainfo.getGrid3DData(product, xg._array, yg._array, z._array, h)
|
||||
return np.array(r)
|
||||
|
||||
def get_vcs_data(self, product, start_point, end_point):
|
||||
"""
|
||||
Get VCS data.
|
||||
|
||||
@ -41,7 +41,7 @@ def antenna_to_cartesian(distance, azimuth, elevation, h=None):
|
||||
z = np.empty((ns,na,nd))
|
||||
for i in range(ns):
|
||||
dis, azi = np.meshgrid(distance, azimuth[i])
|
||||
if elevation.ndim == 1:
|
||||
if elevation.ndim == 1:
|
||||
ele = elevation[i]
|
||||
else:
|
||||
ele = elevation[i].reshape(na, 1).copy()
|
||||
|
||||
@ -29,7 +29,7 @@ def stack(arrays, axis=0):
|
||||
See Also
|
||||
--------
|
||||
concatenate : Join a sequence of arrays along an existing axis.
|
||||
block : Assemble an nd-array from nested lists of blocks.
|
||||
block : Assemble a nd-array from nested lists of blocks.
|
||||
split : Split array into a list of multiple sub-arrays of equal size.
|
||||
|
||||
Examples
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user