mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
update contour and contourf functions for supporting 2d x/y coordinate array
This commit is contained in:
parent
66793e635d
commit
01fd2f7de6
12
MeteoInfo.iml
Normal file
12
MeteoInfo.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@ -3034,6 +3034,97 @@ public class GraphicFactory {
|
||||
return graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contour lines
|
||||
*
|
||||
* @param xa X coordinate array - one dimension
|
||||
* @param ya Y coordinate array - one dimension
|
||||
* @param va Data array - two dimension
|
||||
* @param ls Legend scheme
|
||||
* @param isSmooth Is smooth or not
|
||||
* @return Contour lines
|
||||
*/
|
||||
public static GraphicCollection createContourLines(Array xa, Array ya, Array va, LegendScheme ls, boolean isSmooth) {
|
||||
ls = ls.convertTo(ShapeTypes.Polyline);
|
||||
Object[] ccs = LegendManage.getContoursAndColors(ls);
|
||||
double[] cValues = (double[]) ccs[0];
|
||||
|
||||
int[] shape = va.getShape();
|
||||
int[][] S1 = new int[shape[0]][shape[1]];
|
||||
double[] x = (double[])ArrayUtil.copyToNDJavaArray_Double(xa);
|
||||
double[] y = (double[])ArrayUtil.copyToNDJavaArray_Double(ya);
|
||||
double missingValue = -9999.0;
|
||||
double[][] data = (double[][]) ArrayUtil.copyToNDJavaArray_Double(va, missingValue);
|
||||
if (x[1] - x[0] < 0)
|
||||
ArrayUtils.reverse(x);
|
||||
if (y[1] - y[0] < 0)
|
||||
ArrayUtils.reverse(y);
|
||||
Object[] cbs = ContourDraw.tracingContourLines(data,
|
||||
cValues, x, y, missingValue, S1);
|
||||
List<PolyLine> ContourLines = (List<PolyLine>) cbs[0];
|
||||
|
||||
if (ContourLines.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isSmooth) {
|
||||
ContourLines = Contour.smoothLines(ContourLines);
|
||||
}
|
||||
|
||||
PolyLine aLine;
|
||||
double v;
|
||||
ColorBreak cbb = ls.findLegendBreak(0);
|
||||
GraphicCollection graphics = new GraphicCollection();
|
||||
for (int i = 0; i < ContourLines.size(); i++) {
|
||||
aLine = ContourLines.get(i);
|
||||
v = aLine.Value;
|
||||
|
||||
PolylineShape aPolyline = new PolylineShape();
|
||||
PointD aPoint;
|
||||
List<PointD> pList = new ArrayList<>();
|
||||
for (int j = 0; j < aLine.PointList.size(); j++) {
|
||||
aPoint = new PointD();
|
||||
aPoint.X = aLine.PointList.get(j).X;
|
||||
aPoint.Y = aLine.PointList.get(j).Y;
|
||||
pList.add(aPoint);
|
||||
}
|
||||
aPolyline.setPoints(pList);
|
||||
aPolyline.setValue(v);
|
||||
aPolyline.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||
|
||||
switch (ls.getLegendType()) {
|
||||
case UniqueValue:
|
||||
for (int j = 0; j < ls.getBreakNum(); j++) {
|
||||
ColorBreak cb = ls.getLegendBreaks().get(j);
|
||||
if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString()))) {
|
||||
cbb = cb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GraduatedColor:
|
||||
int blNum = 0;
|
||||
for (int j = 0; j < ls.getBreakNum(); j++) {
|
||||
ColorBreak cb = ls.getLegendBreaks().get(j);
|
||||
blNum += 1;
|
||||
if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString()))
|
||||
|| (v > Double.parseDouble(cb.getStartValue().toString())
|
||||
&& v < Double.parseDouble(cb.getEndValue().toString()))
|
||||
|| (blNum == ls.getBreakNum() && v == Double.parseDouble(cb.getEndValue().toString()))) {
|
||||
cbb = cb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
graphics.add(new Graphic(aPolyline, cbb));
|
||||
}
|
||||
graphics.setSingleLegend(false);
|
||||
graphics.setLegendScheme(ls);
|
||||
|
||||
return graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contour lines
|
||||
*
|
||||
@ -3453,6 +3544,131 @@ public class GraphicFactory {
|
||||
return graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contour polygons
|
||||
*
|
||||
* @param xa X coordinate array - one dimension
|
||||
* @param ya Y coordinate array - one dimension
|
||||
* @param va Data array - two dimension
|
||||
* @param ls Legend scheme
|
||||
* @param isSmooth Is smooth or not
|
||||
* @return Contour polygons
|
||||
*/
|
||||
public static GraphicCollection createContourPolygons(Array xa, Array ya, Array va, LegendScheme ls, boolean isSmooth) {
|
||||
ls = ls.convertTo(ShapeTypes.Polygon);
|
||||
Object[] ccs = LegendManage.getContoursAndColors(ls);
|
||||
double[] cValues = (double[]) ccs[0];
|
||||
|
||||
double minData = ArrayMath.min(va).doubleValue();
|
||||
double maxData = ArrayMath.max(va).doubleValue();
|
||||
|
||||
int[] shape = va.getShape();
|
||||
int[][] S1 = new int[shape[0]][shape[1]];
|
||||
double[] x = (double[])ArrayUtil.copyToNDJavaArray_Double(xa);
|
||||
double[] y = (double[])ArrayUtil.copyToNDJavaArray_Double(ya);
|
||||
double missingValue = -9999.0;
|
||||
double[][] data = (double[][]) ArrayUtil.copyToNDJavaArray_Double(va, missingValue);
|
||||
if (x[1] - x[0] < 0)
|
||||
ArrayUtils.reverse(x);
|
||||
if (y[1] - y[0] < 0)
|
||||
ArrayUtils.reverse(y);
|
||||
Object[] cbs = ContourDraw.tracingContourLines(data,
|
||||
cValues, x, y, missingValue, S1);
|
||||
List<PolyLine> contourLines = (List<PolyLine>) cbs[0];
|
||||
List<wcontour.global.Border> borders = (List<wcontour.global.Border>) cbs[1];
|
||||
|
||||
if (isSmooth) {
|
||||
contourLines = Contour.smoothLines(contourLines);
|
||||
}
|
||||
List<wcontour.global.Polygon> contourPolygons = ContourDraw.tracingPolygons(data, contourLines, borders, cValues);
|
||||
|
||||
double v;
|
||||
ColorBreak cbb = ls.findLegendBreak(0);
|
||||
GraphicCollection graphics = new GraphicCollection();
|
||||
for (int i = 0; i < contourPolygons.size(); i++) {
|
||||
wcontour.global.Polygon poly = contourPolygons.get(i);
|
||||
v = poly.LowValue;
|
||||
PointD aPoint;
|
||||
List<PointD> pList = new ArrayList<>();
|
||||
for (wcontour.global.PointD pointList : poly.OutLine.PointList) {
|
||||
aPoint = new PointD();
|
||||
aPoint.X = pointList.X;
|
||||
aPoint.Y = pointList.Y;
|
||||
pList.add(aPoint);
|
||||
}
|
||||
if (!GeoComputation.isClockwise(pList)) {
|
||||
Collections.reverse(pList);
|
||||
}
|
||||
PolygonShape aPolygonShape = new PolygonShape();
|
||||
aPolygonShape.setPoints(pList);
|
||||
aPolygonShape.setExtent(GeometryUtil.getPointsExtent(pList));
|
||||
aPolygonShape.lowValue = v;
|
||||
if (poly.HasHoles()) {
|
||||
for (PolyLine holeLine : poly.HoleLines) {
|
||||
pList = new ArrayList<>();
|
||||
for (wcontour.global.PointD pointList : holeLine.PointList) {
|
||||
aPoint = new PointD();
|
||||
aPoint.X = pointList.X;
|
||||
aPoint.Y = pointList.Y;
|
||||
pList.add(aPoint);
|
||||
}
|
||||
aPolygonShape.addHole(pList, 0);
|
||||
}
|
||||
}
|
||||
int valueIdx = Arrays.binarySearch(cValues, v);
|
||||
if (valueIdx < 0) {
|
||||
valueIdx = -valueIdx;
|
||||
}
|
||||
|
||||
if (valueIdx == cValues.length - 1) {
|
||||
aPolygonShape.highValue = maxData;
|
||||
} else {
|
||||
aPolygonShape.highValue = cValues[valueIdx + 1];
|
||||
}
|
||||
|
||||
if (!poly.IsHighCenter && poly.HighValue == poly.LowValue) {
|
||||
aPolygonShape.highValue = v;
|
||||
if (valueIdx == 0) {
|
||||
aPolygonShape.lowValue = minData;
|
||||
} else {
|
||||
aPolygonShape.lowValue = cValues[valueIdx - 1];
|
||||
}
|
||||
}
|
||||
|
||||
v = aPolygonShape.lowValue;
|
||||
switch (ls.getLegendType()) {
|
||||
case UniqueValue:
|
||||
for (int j = 0; j < ls.getBreakNum(); j++) {
|
||||
ColorBreak cb = ls.getLegendBreaks().get(j);
|
||||
if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString()))) {
|
||||
cbb = cb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GraduatedColor:
|
||||
int blNum = 0;
|
||||
for (int j = 0; j < ls.getBreakNum(); j++) {
|
||||
ColorBreak cb = ls.getLegendBreaks().get(j);
|
||||
blNum += 1;
|
||||
if (MIMath.doubleEquals(v, Double.parseDouble(cb.getStartValue().toString()))
|
||||
|| (v > Double.parseDouble(cb.getStartValue().toString())
|
||||
&& v < Double.parseDouble(cb.getEndValue().toString()))
|
||||
|| (blNum == ls.getBreakNum() && v == Double.parseDouble(cb.getEndValue().toString()))) {
|
||||
cbb = cb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
graphics.add(new Graphic(aPolygonShape, cbb));
|
||||
}
|
||||
graphics.setSingleLegend(false);
|
||||
graphics.setLegendScheme(ls);
|
||||
|
||||
return graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D contour polygons
|
||||
*
|
||||
|
||||
@ -13,9 +13,6 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="meteoinfo-math" />
|
||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
<orderEntry type="module" module-name="meteoinfo-math" />
|
||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
|
||||
@ -21,11 +21,6 @@
|
||||
<jarDirectory url="file://$MODULE_DIR$/../../toolbox/miml_dev/miml/lib" recursive="false" />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="meteoinfo-math" />
|
||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||
<orderEntry type="module" module-name="meteoinfo-table" />
|
||||
<orderEntry type="module" module-name="meteoinfo-image" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
<orderEntry type="module" module-name="meteoinfo-chart" />
|
||||
<orderEntry type="module" module-name="meteoinfo-geo" />
|
||||
<orderEntry type="module" module-name="meteoinfo-math" />
|
||||
|
||||
@ -1,32 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\classification">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\image"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\projection"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\topology"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\geotiff"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\contour">
|
||||
<RecentFolder Folder="D:\MyProgram\Distribution\Java\MeteoInfo3\MeteoInfo\script\numeric\linalg"/>
|
||||
<RecentFolder Folder="D:\MyProgram\Distribution\Java\MeteoInfo3\MeteoInfo\script\numeric\random"/>
|
||||
<RecentFolder Folder="D:\MyProgram\Distribution\Java\MeteoInfo3\MeteoInfo\script\numeric\stats"/>
|
||||
<RecentFolder Folder="D:\MyProgram\Distribution\Java\MeteoInfo3\MeteoInfo\script\numeric"/>
|
||||
<RecentFolder Folder="D:\MyProgram\Distribution\Java\MeteoInfo3\MeteoInfo\script"/>
|
||||
<RecentFolder Folder="D:\MyProgram\Distribution\Java\MeteoInfo3\MeteoInfo\script\plot\wind"/>
|
||||
<RecentFolder Folder="D:\MyProgram\Distribution\Java\MeteoInfo3\MeteoInfo\script\plot"/>
|
||||
<RecentFolder Folder="D:\MyProgram\Distribution\Java\MeteoInfo3\MeteoInfo\script\plot\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\netcdf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\wind"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\verification"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\classification"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\classification"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot_cuace_3d_particles_relief.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\image\gray_scale.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\netcdf\lonlat_2d_contour.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\contour_1.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot_cuace_3d_particles_relief.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\image\gray_scale.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\netcdf\lonlat_2d_contour.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\contour_1.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -34,5 +34,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="0,0" MainFormSize="1280,680"/>
|
||||
<Startup MainFormLocation="0,0" MainFormSize="1357,782"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -1627,7 +1627,7 @@ def nonzero(a):
|
||||
'''
|
||||
if isinstance(a, list):
|
||||
a = array(a)
|
||||
ra = ArrayMath.nonzero(a.asarray())
|
||||
ra = ArrayUtil.nonzero(a.asarray())
|
||||
if ra is None:
|
||||
return None
|
||||
|
||||
@ -1646,7 +1646,7 @@ def flatnonzero(a):
|
||||
'''
|
||||
if isinstance(a, list):
|
||||
a = array(a)
|
||||
r = ArrayMath.flatNonZero(a.asarray())
|
||||
r = ArrayUtil.flatNonZero(a.asarray())
|
||||
|
||||
return NDArray(r)
|
||||
|
||||
|
||||
Binary file not shown.
@ -2085,38 +2085,45 @@ class Axes(object):
|
||||
fill_value = kwargs.pop('fill_value', -9999.0)
|
||||
xaxistype = None
|
||||
if n <= 2:
|
||||
gdata = np.asgriddata(args[0])
|
||||
if isinstance(args[0], DimArray):
|
||||
a = args[0]
|
||||
if isinstance(a, DimArray):
|
||||
y = a.dimvalue(0)
|
||||
x = a.dimvalue(1)
|
||||
if args[0].islondim(1):
|
||||
xaxistype = 'lon'
|
||||
elif args[0].islatdim(1):
|
||||
xaxistype = 'lat'
|
||||
elif args[0].istimedim(1):
|
||||
xaxistype = 'time'
|
||||
else:
|
||||
x = np.arange(a.shape[1])
|
||||
y = np.arange(a.shape[0])
|
||||
args = args[1:]
|
||||
elif n <=4:
|
||||
x = args[0]
|
||||
y = args[1]
|
||||
a = args[2]
|
||||
gdata = np.asgriddata(a, x, y, fill_value)
|
||||
args = args[3:]
|
||||
if ls is None:
|
||||
if len(args) > 0:
|
||||
level_arg = args[0]
|
||||
if isinstance(level_arg, int):
|
||||
cn = level_arg
|
||||
ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cn, cmap)
|
||||
ls = LegendManage.createLegendScheme(a.min(), a.max(), cn, cmap)
|
||||
else:
|
||||
if isinstance(level_arg, NDArray):
|
||||
level_arg = level_arg.aslist()
|
||||
ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), level_arg, cmap)
|
||||
ls = LegendManage.createLegendScheme(a.min(), a.max(), level_arg, cmap)
|
||||
else:
|
||||
ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cmap)
|
||||
ls = LegendManage.createLegendScheme(a.min(), a.max(), cmap)
|
||||
ls = ls.convertTo(ShapeTypes.Polyline)
|
||||
plotutil.setlegendscheme(ls, **kwargs)
|
||||
|
||||
smooth = kwargs.pop('smooth', True)
|
||||
igraphic = GraphicFactory.createContourLines(gdata.data, ls, smooth)
|
||||
if x.ndim == 2 and y.ndim == 2:
|
||||
griddata_props = kwargs.pop('griddata_props', dict(method='idw', pointnum=5, convexhull=True))
|
||||
a, x, y = np.griddata((x,y), a, **griddata_props)
|
||||
igraphic = GraphicFactory.createContourLines(x.asarray(), y.asarray(), a.asarray(), ls, smooth)
|
||||
|
||||
if not xaxistype is None:
|
||||
self.set_xaxis_type(xaxistype)
|
||||
@ -2210,39 +2217,47 @@ class Axes(object):
|
||||
fill_value = kwargs.pop('fill_value', -9999.0)
|
||||
xaxistype = None
|
||||
if n <= 2:
|
||||
gdata = np.asgriddata(args[0])
|
||||
if isinstance(args[0], DimArray):
|
||||
a = args[0]
|
||||
if isinstance(a, DimArray):
|
||||
y = a.dimvalue(0)
|
||||
x = a.dimvalue(1)
|
||||
if args[0].islondim(1):
|
||||
xaxistype = 'lon'
|
||||
elif args[0].islatdim(1):
|
||||
xaxistype = 'lat'
|
||||
elif args[0].istimedim(1):
|
||||
xaxistype = 'time'
|
||||
else:
|
||||
x = np.arange(a.shape[1])
|
||||
y = np.arange(a.shape[0])
|
||||
args = args[1:]
|
||||
elif n <=4:
|
||||
x = args[0]
|
||||
y = args[1]
|
||||
a = args[2]
|
||||
gdata = np.asgriddata(a, x, y, fill_value)
|
||||
#gdata = np.asgriddata(a, x, y, fill_value)
|
||||
args = args[3:]
|
||||
if ls is None:
|
||||
if len(args) > 0:
|
||||
level_arg = args[0]
|
||||
if isinstance(level_arg, int):
|
||||
cn = level_arg
|
||||
ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cn, cmap)
|
||||
ls = LegendManage.createLegendScheme(a.min(), a.max(), cn, cmap)
|
||||
else:
|
||||
if isinstance(level_arg, NDArray):
|
||||
level_arg = level_arg.aslist()
|
||||
ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), level_arg, cmap)
|
||||
ls = LegendManage.createLegendScheme(a.min(), a.max(), level_arg, cmap)
|
||||
else:
|
||||
ls = LegendManage.createLegendScheme(gdata.min(), gdata.max(), cmap)
|
||||
ls = LegendManage.createLegendScheme(a.min(), a.max(), cmap)
|
||||
ls = ls.convertTo(ShapeTypes.Polygon)
|
||||
if not kwargs.has_key('edgecolor'):
|
||||
kwargs['edgecolor'] = None
|
||||
plotutil.setlegendscheme(ls, **kwargs)
|
||||
smooth = kwargs.pop('smooth', True)
|
||||
igraphic = GraphicFactory.createContourPolygons(gdata.data, ls, smooth)
|
||||
if x.ndim == 2 and y.ndim == 2:
|
||||
griddata_props = kwargs.pop('griddata_props', dict(method='idw', pointnum=5, convexhull=True))
|
||||
a, x, y = np.griddata((x,y), a, **griddata_props)
|
||||
igraphic = GraphicFactory.createContourPolygons(x.asarray(), y.asarray(), a.asarray(), ls, smooth)
|
||||
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
|
||||
Binary file not shown.
@ -1071,8 +1071,10 @@ class MapAxes(Axes):
|
||||
ls = plotutil.getlegendscheme(args, a.min(), a.max(), **kwargs)
|
||||
ls = ls.convertTo(ShapeTypes.Polyline)
|
||||
plotutil.setlegendscheme(ls, **kwargs)
|
||||
isadd = kwargs.pop('isadd', True)
|
||||
smooth = kwargs.pop('smooth', True)
|
||||
if x.ndim == 2 and y.ndim == 2:
|
||||
griddata_props = kwargs.pop('griddata_props', dict(method='idw', pointnum=5, convexhull=True))
|
||||
a, x, y = np.griddata((x,y), a, **griddata_props)
|
||||
layer = DrawMeteoData.createContourLayer(a._array, x._array, y._array, ls, 'layer', 'data', smooth)
|
||||
if layer is None:
|
||||
return None
|
||||
@ -1130,8 +1132,10 @@ class MapAxes(Axes):
|
||||
if not kwargs.has_key('edgecolor'):
|
||||
kwargs['edgecolor'] = None
|
||||
plotutil.setlegendscheme(ls, **kwargs)
|
||||
isadd = kwargs.pop('isadd', True)
|
||||
smooth = kwargs.pop('smooth', True)
|
||||
if x.ndim == 2 and y.ndim == 2:
|
||||
griddata_props = kwargs.pop('griddata_props', dict(method='idw', pointnum=5, convexhull=True))
|
||||
a, x, y = np.griddata((x,y), a, **griddata_props)
|
||||
layer = DrawMeteoData.createShadedLayer(a._array, x._array, y._array, ls, 'layer', 'data', smooth)
|
||||
proj = kwargs.pop('proj', None)
|
||||
if not proj is None:
|
||||
|
||||
@ -12,8 +12,6 @@
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:28.0-jre" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||
|
||||
@ -2129,6 +2129,26 @@ public class ArrayUtil {
|
||||
return javaArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert array to N-Dimension double Java array
|
||||
*
|
||||
* @param a Array a
|
||||
* @param missingValue The missing value
|
||||
* @return N-D Java array
|
||||
*/
|
||||
public static Object copyToNDJavaArray_Double(Array a, double missingValue) {
|
||||
Object javaArray;
|
||||
try {
|
||||
javaArray = java.lang.reflect.Array.newInstance(Double.TYPE, a.getShape());
|
||||
} catch (IllegalArgumentException | NegativeArraySizeException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
IndexIterator iter = a.getIndexIterator();
|
||||
reflectArrayCopyOut(javaArray, a, iter, missingValue);
|
||||
|
||||
return javaArray;
|
||||
}
|
||||
|
||||
private static void reflectArrayCopyOut(Object jArray, Array aa, IndexIterator aaIter) {
|
||||
Class cType = jArray.getClass().getComponentType();
|
||||
|
||||
@ -2145,12 +2165,40 @@ public class ArrayUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static void reflectArrayCopyOut(Object jArray, Array aa, IndexIterator aaIter,
|
||||
double missingValue) {
|
||||
Class cType = jArray.getClass().getComponentType();
|
||||
|
||||
if (!cType.isArray()) {
|
||||
if (cType == long.class) {
|
||||
copyTo1DJavaArray_Long(aaIter, jArray);
|
||||
} else {
|
||||
copyTo1DJavaArray(aaIter, jArray, missingValue);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < java.lang.reflect.Array.getLength(jArray); i++) {
|
||||
reflectArrayCopyOut(java.lang.reflect.Array.get(jArray, i), aa, aaIter, missingValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static void copyTo1DJavaArray(IndexIterator iter, Object javaArray) {
|
||||
for (int i = 0; i < java.lang.reflect.Array.getLength(javaArray); i++) {
|
||||
java.lang.reflect.Array.set(javaArray, i, iter.getObjectNext());
|
||||
}
|
||||
}
|
||||
|
||||
protected static void copyTo1DJavaArray(IndexIterator iter, Object javaArray, double missingValue) {
|
||||
double v;
|
||||
for (int i = 0; i < java.lang.reflect.Array.getLength(javaArray); i++) {
|
||||
v = iter.getDoubleNext();
|
||||
if (Double.isNaN(v))
|
||||
java.lang.reflect.Array.set(javaArray, i, missingValue);
|
||||
else
|
||||
java.lang.reflect.Array.set(javaArray, i, v);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void copyTo1DJavaArray_Long(IndexIterator iter, Object javaArray) {
|
||||
long[] ja = (long[]) javaArray;
|
||||
for (int i = 0; i < ja.length; i++) {
|
||||
|
||||
@ -13,8 +13,6 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
<orderEntry type="module" module-name="meteoinfo-ndarray" />
|
||||
<orderEntry type="module" module-name="meteoinfo-common" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:28.0-jre" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user