mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
update cappi and grid 3d data extraction functions to including beam width data
This commit is contained in:
parent
80f1097b51
commit
618c5f1380
@ -2499,7 +2499,6 @@ public class GLPlot extends Plot {
|
||||
protected void drawGraphics(GL2 gl, Graphic graphic) {
|
||||
boolean lightEnabled = this.lighting.isEnable();
|
||||
if (graphic instanceof GraphicCollection3D) {
|
||||
boolean usingLight = lightEnabled && ((GraphicCollection3D)graphic).isUsingLight();
|
||||
if (lightEnabled && !((GraphicCollection3D)graphic).isUsingLight()) {
|
||||
this.lighting.stop(gl);
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ public class Lighting {
|
||||
|
||||
private boolean enable;
|
||||
private int light;
|
||||
private boolean started;
|
||||
float[] ambient;
|
||||
float[] diffuse;
|
||||
float[] specular;
|
||||
@ -42,6 +43,7 @@ public class Lighting {
|
||||
*/
|
||||
public Lighting(boolean far) {
|
||||
this.enable = false;
|
||||
this.started = false;
|
||||
this.light = GL2.GL_LIGHT1;
|
||||
//this.ambient = new float[]{0.f, 0.f, 0.f, 1.f};
|
||||
this.ambient = new float[]{0.2f, 0.2f, 0.2f, 1.f};
|
||||
@ -76,6 +78,15 @@ public class Lighting {
|
||||
this.enable = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lighting is started or not
|
||||
*
|
||||
* @return Lighting is started or not
|
||||
*/
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ambient
|
||||
*
|
||||
@ -437,6 +448,8 @@ public class Lighting {
|
||||
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, materialDiffuse, 0);
|
||||
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, materialSpecular, 0);
|
||||
gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, materialShininess);
|
||||
|
||||
this.started = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -449,5 +462,7 @@ public class Lighting {
|
||||
//gl.glDisable(GL2.GL_AUTO_NORMAL);
|
||||
//gl.glDisable(GLLightingFunc.GL_NORMALIZE);
|
||||
//gl.glPopAttrib();
|
||||
|
||||
this.started = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +130,9 @@ public class MapGLPlot extends GLPlot {
|
||||
this.drawGraphics(gl, mapGridLine.getLatitudeLines());
|
||||
}
|
||||
}
|
||||
if (this.lighting.isStarted()) {
|
||||
this.lighting.stop(gl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ public class MapGridLine3D extends MapGridLine {
|
||||
|
||||
protected void updateLongitudeLines() {
|
||||
this.longitudeLines = new GraphicCollection3D();
|
||||
((GraphicCollection3D) this.longitudeLines).setUsingLight(false);
|
||||
double latMin = this.lonLatExtent.minY;
|
||||
double latMax = this.lonLatExtent.maxY;
|
||||
double delta = this.lonLatExtent.getHeight() / (this.nPoints - 1);
|
||||
@ -50,6 +51,7 @@ public class MapGridLine3D extends MapGridLine {
|
||||
|
||||
protected void updateLatitudeLines() {
|
||||
this.latitudeLines = new GraphicCollection3D();
|
||||
((GraphicCollection3D) this.latitudeLines).setUsingLight(false);
|
||||
double lonMin = this.lonLatExtent.minX;
|
||||
double lonMax = this.lonLatExtent.maxX;
|
||||
if (lonMin < - 170) {
|
||||
|
||||
@ -67,7 +67,7 @@ import java.util.zip.ZipInputStream;
|
||||
public static String getVersion(){
|
||||
String version = GlobalUtil.class.getPackage().getImplementationVersion();
|
||||
if (version == null || version.equals("")) {
|
||||
version = "3.7.0";
|
||||
version = "3.7.1";
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -679,81 +679,6 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public Array read_bak(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
int idx = varName.lastIndexOf("_s");
|
||||
int scanIdx = Integer.parseInt(varName.substring(idx + 2)) - 1;
|
||||
String product = varName.substring(0, idx);
|
||||
boolean isXYZ = product.startsWith("xyz_");
|
||||
if (isXYZ) {
|
||||
product = product.substring(4);
|
||||
}
|
||||
RadialRecord record = this.recordMap.get(product);
|
||||
|
||||
Array dataArray;
|
||||
if (isXYZ) {
|
||||
dataArray = record.getXYZ(scanIdx).section(origin, size, stride).copy();
|
||||
} else {
|
||||
List<Array> arrays = record.getDataArray(scanIdx);
|
||||
Section section = new Section(origin, size, stride);
|
||||
dataArray = Array.factory(record.getDataType(), section.getShape());
|
||||
Range yRange = section.getRange(0);
|
||||
Range xRange = section.getRange(1);
|
||||
IndexIterator iter = dataArray.getIndexIterator();
|
||||
for (int i = yRange.first(); i <= yRange.last(); i += yRange.stride()) {
|
||||
if (i < arrays.size()) {
|
||||
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));
|
||||
else
|
||||
iter.setObjectNext(Float.NaN);
|
||||
}
|
||||
} else {
|
||||
for (int j = xRange.first(); j <= xRange.last(); j += xRange.stride()) {
|
||||
iter.setObjectNext(Float.NaN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Variable variable = this.getVariable(varName);
|
||||
Attribute aoAttr = variable.findAttribute("add_offset");
|
||||
Attribute sfAttr = variable.findAttribute("scale_factor");
|
||||
if (aoAttr != null || sfAttr != null) {
|
||||
Number add_offset = 0.f;
|
||||
Number scale_factor = 1.f;
|
||||
if (aoAttr != null) {
|
||||
switch (aoAttr.getDataType()) {
|
||||
case DOUBLE:
|
||||
add_offset = aoAttr.getValues().getDouble(0);
|
||||
break;
|
||||
case FLOAT:
|
||||
case INT:
|
||||
add_offset = aoAttr.getValues().getFloat(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sfAttr != null) {
|
||||
switch (sfAttr.getDataType()) {
|
||||
case DOUBLE:
|
||||
scale_factor = sfAttr.getValues().getDouble(0);
|
||||
break;
|
||||
case FLOAT:
|
||||
case INT:
|
||||
scale_factor = sfAttr.getValues().getFloat(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
dataArray = ArrayMath.div(ArrayMath.sub(dataArray, add_offset), scale_factor);
|
||||
}
|
||||
}
|
||||
|
||||
return dataArray;
|
||||
} catch (InvalidRangeException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Attribute> getGlobalAttributes() {
|
||||
return this.attributes;
|
||||
@ -864,8 +789,10 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
IndexIterator iterE = elevation.getIndexIterator();
|
||||
IndexIterator iterData = data.getIndexIterator();
|
||||
float v;
|
||||
float halfBeamWidth = this.siteConfig.beamWidthVert / 2;
|
||||
while (iterData.hasNext()) {
|
||||
v = record.interpolateValue(iterE.getFloatNext(), iterA.getFloatNext(), iterR.getFloatNext());
|
||||
v = record.interpolateValue(iterE.getFloatNext(), iterA.getFloatNext(),
|
||||
iterR.getFloatNext(), halfBeamWidth);
|
||||
iterData.setFloatNext(v);
|
||||
}
|
||||
|
||||
@ -893,6 +820,7 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
Array data = Array.factory(DataType.FLOAT, shape3D);
|
||||
IndexIterator iterData = data.getIndexIterator();
|
||||
IndexIterator iterZ = za.getIndexIterator();
|
||||
float halfBeamWidth = this.siteConfig.beamWidthVert / 2;
|
||||
while(iterZ.hasNext()) {
|
||||
float z = iterZ.getFloatNext();
|
||||
Array[] rr = Transform.cartesianToAntenna(xa, ya, z, h);
|
||||
@ -904,7 +832,8 @@ public class CMARadarBaseDataInfo extends DataInfo implements IGridDataInfo {
|
||||
IndexIterator iterE = elevation.getIndexIterator();
|
||||
float v;
|
||||
while (iterA.hasNext()) {
|
||||
v = record.interpolateValue(iterE.getFloatNext(), iterA.getFloatNext(), iterR.getFloatNext());
|
||||
v = record.interpolateValue(iterE.getFloatNext(), iterA.getFloatNext(),
|
||||
iterR.getFloatNext(), halfBeamWidth);
|
||||
iterData.setFloatNext(v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,6 +444,32 @@ public class RadialRecord {
|
||||
return new int[]{-1, -1};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scan indices
|
||||
*
|
||||
* @param e Elevation value
|
||||
* @param halfBeamWidth Half beam width
|
||||
* @return Scan indices - 2 elements
|
||||
*/
|
||||
public int[] getScanIndices(float e, float halfBeamWidth) {
|
||||
if (e < fixedElevation.get(0) - halfBeamWidth || e > fixedElevation.get(fixedElevation.size() - 1) +
|
||||
halfBeamWidth) {
|
||||
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
|
||||
*
|
||||
@ -580,4 +606,37 @@ public class RadialRecord {
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate value by elevation, azimuth and distance - linear interpolate
|
||||
*
|
||||
* @param e Elevation value
|
||||
* @param a Azimuth value
|
||||
* @param r Distance value
|
||||
* @param halfBeamWidth Half beam width
|
||||
* @return Data value
|
||||
*/
|
||||
public float interpolateValue(float e, float a, float r, float halfBeamWidth) {
|
||||
int[] scanIdx = getScanIndices(e, halfBeamWidth);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,30 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\radar">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
||||
<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\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"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox"/>
|
||||
<RecentFolder Folder="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\classification"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\patch"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\bar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\axis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d_geo_to_nc.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\test_plot_grid_3d_nc.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\patch\wind_circle_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_bin_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_bin_4.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d_geo_to_nc.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\test_plot_grid_3d_nc.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\patch\wind_circle_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_bin_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_bin_4.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -32,5 +36,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1365,791"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -1469,7 +1469,7 @@ class Axes(object):
|
||||
:param c: (*Color or array*) Color of the points. Or z values.
|
||||
:param alpha: (*int*) The alpha blending value, between 0 (transparent) and 1 (opaque).
|
||||
:param marker: (*string*) Marker of the points.
|
||||
:param label: (*string*) Label of the points series.
|
||||
:param label: (*string*) Label of the point series.
|
||||
:param levs: (*array_like*) Optional. A list of floating point numbers indicating the level
|
||||
points to draw, in increasing order.
|
||||
|
||||
|
||||
Binary file not shown.
@ -1021,29 +1021,42 @@ class MapAxes(Axes):
|
||||
else:
|
||||
ls = plotutil.getlegendscheme(args, a.min(), a.max(), **kwargs)
|
||||
ls = plotutil.setlegendscheme_point(ls, **kwargs)
|
||||
|
||||
if a.size == ls.getBreakNum() and ls.getLegendType() == LegendType.UNIQUE_VALUE:
|
||||
layer = DrawMeteoData.createSTPointLayer_Unique(a._array, x._array, y._array, ls, 'layer', 'data')
|
||||
else:
|
||||
layer = DrawMeteoData.createSTPointLayer(a._array, x._array, y._array, ls, 'layer', 'data')
|
||||
|
||||
|
||||
proj = kwargs.pop('proj', None)
|
||||
if not proj is None:
|
||||
layer.setProjInfo(proj)
|
||||
avoidcoll = kwargs.pop('avoidcoll', None)
|
||||
if not avoidcoll is None:
|
||||
layer.setAvoidCollision(avoidcoll)
|
||||
|
||||
# Add layer
|
||||
isadd = kwargs.pop('isadd', True)
|
||||
if isadd:
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
select = kwargs.pop('select', True)
|
||||
self.add_layer(layer, zorder, select)
|
||||
self._axes.setDrawExtent(layer.getExtent().clone())
|
||||
self._axes.setExtent(layer.getExtent().clone())
|
||||
|
||||
return MILayer(layer)
|
||||
aslayer = kwargs.pop('aslayer', True)
|
||||
if aslayer:
|
||||
if a.size == ls.getBreakNum() and ls.getLegendType() == LegendType.UNIQUE_VALUE:
|
||||
layer = DrawMeteoData.createSTPointLayer_Unique(a._array, x._array, y._array, ls, 'layer', 'data')
|
||||
else:
|
||||
layer = DrawMeteoData.createSTPointLayer(a._array, x._array, y._array, ls, 'layer', 'data')
|
||||
|
||||
if not proj is None:
|
||||
layer.setProjInfo(proj)
|
||||
avoidcoll = kwargs.pop('avoidcoll', None)
|
||||
if not avoidcoll is None:
|
||||
layer.setAvoidCollision(avoidcoll)
|
||||
|
||||
# Add layer
|
||||
isadd = kwargs.pop('isadd', True)
|
||||
if isadd:
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
select = kwargs.pop('select', True)
|
||||
self.add_layer(layer, zorder, select)
|
||||
self._axes.setDrawExtent(layer.getExtent().clone())
|
||||
self._axes.setExtent(layer.getExtent().clone())
|
||||
|
||||
return MILayer(layer)
|
||||
else:
|
||||
# Create graphics
|
||||
if a.ndim == 0:
|
||||
graphics = GraphicFactory.createPoints(x._array, y._array, ls.getLegendBreak(0))
|
||||
else:
|
||||
graphics = GraphicFactory.createPoints(x._array, y._array, a._array, ls)
|
||||
|
||||
self.add_graphic(graphics, proj)
|
||||
self._axes.setAutoExtent()
|
||||
|
||||
return graphics
|
||||
|
||||
def text(self, x, y, s, **kwargs):
|
||||
"""
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -34,7 +34,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<revision>3.7.0</revision>
|
||||
<revision>3.7.1</revision>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user