mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add get_dbz function in wrf package
This commit is contained in:
parent
fd22bcb973
commit
ab7c21897f
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.commons:commons-math4-legacy:4.0-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy/4.0-SNAPSHOT/commons-math4-legacy-4.0-20221125.173343-612.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy/4.0-SNAPSHOT/commons-math4-legacy-4.0-SNAPSHOT.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy/4.0-SNAPSHOT/commons-math4-legacy-4.0-20221125.173343-612-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy/4.0-SNAPSHOT/commons-math4-legacy-4.0-SNAPSHOT-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy/4.0-SNAPSHOT/commons-math4-legacy-4.0-20221125.173343-612-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy/4.0-SNAPSHOT/commons-math4-legacy-4.0-SNAPSHOT-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.commons:commons-math4-legacy-core:4.0-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20221125.173343-620.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20221129.175631-636.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20221125.173343-620-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20221129.175631-636-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20221125.173343-620-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-core/4.0-SNAPSHOT/commons-math4-legacy-core-4.0-20221129.175631-636-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.commons:commons-math4-legacy-exception:4.0-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-exception/4.0-SNAPSHOT/commons-math4-legacy-exception-4.0-20221125.173343-631.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-exception/4.0-SNAPSHOT/commons-math4-legacy-exception-4.0-20221129.175631-647.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-exception/4.0-SNAPSHOT/commons-math4-legacy-exception-4.0-20221125.173343-631-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-exception/4.0-SNAPSHOT/commons-math4-legacy-exception-4.0-20221129.175631-647-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-exception/4.0-SNAPSHOT/commons-math4-legacy-exception-4.0-20221125.173343-631-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math4-legacy-exception/4.0-SNAPSHOT/commons-math4-legacy-exception-4.0-20221129.175631-647-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.commons:commons-statistics-distribution:1.0-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-statistics-distribution/1.0-SNAPSHOT/commons-statistics-distribution-1.0-20221125.172748-293.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-statistics-distribution/1.0-SNAPSHOT/commons-statistics-distribution-1.0-20221129.174013-299.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-statistics-distribution/1.0-SNAPSHOT/commons-statistics-distribution-1.0-20221125.172748-293-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-statistics-distribution/1.0-SNAPSHOT/commons-statistics-distribution-1.0-20221129.174013-299-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-statistics-distribution/1.0-SNAPSHOT/commons-statistics-distribution-1.0-20221125.172748-293-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-statistics-distribution/1.0-SNAPSHOT/commons-statistics-distribution-1.0-20221129.174013-299-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.locationtech.proj4j:proj4j:1.1.6-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.6-SNAPSHOT/proj4j-1.1.6-SNAPSHOT.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.6-SNAPSHOT/proj4j-1.1.6-20221129.022824-2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.6-SNAPSHOT/proj4j-1.1.6-SNAPSHOT-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.6-SNAPSHOT/proj4j-1.1.6-20221129.022824-2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.6-SNAPSHOT/proj4j-1.1.6-SNAPSHOT-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/locationtech/proj4j/proj4j/1.1.6-SNAPSHOT/proj4j-1.1.6-20221129.022824-2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -2499,13 +2499,17 @@ public class GLPlot extends Plot {
|
||||
} else {
|
||||
boolean isDraw = true;
|
||||
if (graphic instanceof GraphicCollection3D) {
|
||||
GraphicCollection3D gg = (GraphicCollection3D) graphic;
|
||||
if (gg.isAllQuads()) {
|
||||
this.drawQuadsPolygons(gl, gg);
|
||||
isDraw = false;
|
||||
} else if (gg.isAllTriangle()) {
|
||||
this.drawTrianglePolygons(gl, gg);
|
||||
if (graphic.getNumGraphics() == 0) {
|
||||
isDraw = false;
|
||||
} else {
|
||||
GraphicCollection3D gg = (GraphicCollection3D) graphic;
|
||||
if (gg.isAllQuads()) {
|
||||
this.drawQuadsPolygons(gl, gg);
|
||||
isDraw = false;
|
||||
} else if (gg.isAllTriangle()) {
|
||||
this.drawTrianglePolygons(gl, gg);
|
||||
isDraw = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isDraw) {
|
||||
|
||||
@ -3,6 +3,7 @@ package org.meteoinfo.chart.jogl;
|
||||
import com.jogamp.opengl.GL;
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.meteoinfo.chart.ChartText;
|
||||
import org.meteoinfo.chart.graphic.GraphicCollection3D;
|
||||
import org.meteoinfo.chart.graphic.GraphicProjectionUtil;
|
||||
import org.meteoinfo.chart.plot.MapGridLine;
|
||||
import org.meteoinfo.chart.plot.MapGridLine3D;
|
||||
@ -64,6 +65,9 @@ public class MapGLPlot extends GLPlot {
|
||||
super.addGraphic(graphic);
|
||||
} else {
|
||||
Graphic nGraphic = GraphicProjectionUtil.projectClipGraphic(graphic, proj, this.projInfo);
|
||||
if (nGraphic instanceof GraphicCollection3D) {
|
||||
((GraphicCollection3D) nGraphic).setUsingLight(((GraphicCollection3D) graphic).isUsingLight());
|
||||
}
|
||||
super.addGraphic(nGraphic);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7848,9 +7848,6 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
this._scaleX = scale;
|
||||
this._scaleY = scale;
|
||||
PointD center = (PointD)this._drawExtent.getCenterPoint().clone();
|
||||
//PointD center = (PointD) this._viewExtent.getCenterPoint().clone();
|
||||
//center.X -= g.getTransform().getTranslateX();
|
||||
//center.Y -= g.getTransform().getTranslateY();
|
||||
double xlen = width / scale * 0.5;
|
||||
double ylen = height / scale * 0.5;
|
||||
this._drawExtent.minX = center.X - xlen;
|
||||
|
||||
@ -1,33 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\micaps">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\text"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\webmap"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\meteo\wrf">
|
||||
<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\plot_types\3d\jogl\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\taylor"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\projection"/>
|
||||
<RecentFolder Folder="D:\Temp\test"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW\airship"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\micaps"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\LaSW\airship\sounding.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\linalg\norm_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_3.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_3-2.py"/>
|
||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\LaSW\airship\typhoon_windspeed.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\wrf\wrf_get_dbz_cross.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\LaSW\airship\sounding.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\linalg\norm_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_3.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\micaps\micaps_3-2.py"/>
|
||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\LaSW\airship\typhoon_windspeed.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\wrf\wrf_get_dbz_cross.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
@ -3,9 +3,11 @@ from g_slp import *
|
||||
from g_rh import *
|
||||
from g_pressure import *
|
||||
from g_geoht import *
|
||||
from g_dbz import *
|
||||
|
||||
__all__ = destag.__all__
|
||||
__all__ += g_slp.__all__
|
||||
__all__ += g_rh.__all__
|
||||
__all__ += g_pressure.__all__
|
||||
__all__ += g_geoht.__all__
|
||||
__all__ += g_geoht.__all__
|
||||
__all__ += g_dbz.__all__
|
||||
66
meteoinfo-lab/pylib/mipylib/meteolib/wrf/g_dbz.py
Normal file
66
meteoinfo-lab/pylib/mipylib/meteolib/wrf/g_dbz.py
Normal file
@ -0,0 +1,66 @@
|
||||
from org.meteoinfo.math.meteo import WRF
|
||||
import mipylib.numeric as np
|
||||
from .. import constants
|
||||
from ..calc.thermo import temperature_from_potential_temperature
|
||||
|
||||
__all__ = ['get_dbz']
|
||||
|
||||
def get_dbz(wrfin, timeidx=0, use_varint=False, use_liqskin=False):
|
||||
"""Return the simulated radar reflectivity.
|
||||
This functions extracts the necessary variables from the NetCDF file
|
||||
object in order to perform the calculation.
|
||||
Args:
|
||||
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \
|
||||
iterable): WRF-ARW NetCDF
|
||||
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile`
|
||||
or an iterable sequence of the aforementioned types.
|
||||
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The
|
||||
desired time index. This value can be a positive integer,
|
||||
negative integer, or
|
||||
:data:`wrf.ALL_TIMES` (an alias for None) to return
|
||||
all times in the file or sequence. The default is 0.
|
||||
use_varint (:obj:`bool`, optional): When set to False,
|
||||
the intercept parameters are assumed constant
|
||||
(as in MM5's Reisner-2 bulk microphysical scheme).
|
||||
When set to True, the variable intercept
|
||||
parameters are used as in the more recent version of Reisner-2
|
||||
(based on Thompson, Rasmussen, and Manning, 2004, Monthly weather
|
||||
Review, Vol. 132, No. 2, pp. 519-542.).
|
||||
use_liqskin (:obj:`bool`, optional): When set to True, frozen particles
|
||||
that are at a temperature above freezing are assumed to scatter
|
||||
as a liquid particle. Set to False to disable.
|
||||
Returns:
|
||||
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The simulated
|
||||
radar reflectivity.
|
||||
If xarray is enabled and the *meta* parameter is True, then the result
|
||||
will be a :class:`xarray.DataArray` object. Otherwise, the result will
|
||||
be a :class:`numpy.ndarray` object with no metadata.
|
||||
"""
|
||||
t = wrfin["T"][timeidx]
|
||||
p = wrfin["P"][timeidx]
|
||||
pb = wrfin["PB"][timeidx]
|
||||
qv = wrfin["QVAPOR"][timeidx]
|
||||
qr = wrfin["QRAIN"][timeidx]
|
||||
|
||||
if wrfin.varnames.contains("QSNOW"):
|
||||
qs = wrfin["QSNOW"][timeidx]
|
||||
else:
|
||||
qs = np.zeros(qv.shape, qv.dtype)
|
||||
|
||||
if wrfin.varnames.contains("QGRAUP"):
|
||||
qg = wrfin["QGRAUP"][timeidx]
|
||||
else:
|
||||
qg = np.zeros(qv.shape, qv.dtype)
|
||||
|
||||
full_t = t + constants.T_BASE
|
||||
full_p = p + pb
|
||||
tk = temperature_from_potential_temperature(full_p * 0.01, full_t)
|
||||
|
||||
# If qsnow is not all 0, set sn0 to 1
|
||||
sn0 = 1 if qs.any() else 0
|
||||
ivarint = 1 if use_varint else 0
|
||||
iliqskin = 1 if use_liqskin else 0
|
||||
|
||||
dbz = WRF.calcDBZ(full_p._array, tk._array, qv._array, qr._array, qs._array, qg._array,
|
||||
sn0, ivarint, iliqskin)
|
||||
return np.DimArray(dbz, dims=t.dims)
|
||||
@ -574,6 +574,23 @@ class NDArray(object):
|
||||
r = NDArray(ArrayMath.inValues(self._array, other))
|
||||
return r
|
||||
|
||||
def any(self, axis=None):
|
||||
"""
|
||||
Test whether any array element along a given axis evaluates to True.
|
||||
|
||||
:param axis: (*int*) Axis along which a logical OR reduction is performed.
|
||||
The default (axis = None) is to perform a logical OR over all the
|
||||
dimensions of the input array.
|
||||
|
||||
:returns: (*array_like*) Any result
|
||||
"""
|
||||
if axis is None:
|
||||
return ArrayMath.any(self._array)
|
||||
else:
|
||||
if axis < 0:
|
||||
axis += self.ndim
|
||||
return NDArray(ArrayMath.any(self._array, axis))
|
||||
|
||||
def contains_nan(self):
|
||||
"""
|
||||
Check if the array contains nan value.
|
||||
|
||||
Binary file not shown.
@ -1166,12 +1166,7 @@ def any(x, axis=None):
|
||||
if isinstance(x, list):
|
||||
x = array(x)
|
||||
|
||||
if axis is None:
|
||||
return ArrayMath.any(x._array)
|
||||
else:
|
||||
if axis < 0:
|
||||
axis += x.ndim
|
||||
return NDArray(ArrayMath.any(x._array, axis))
|
||||
return x.any(axis)
|
||||
|
||||
def all(x, axis=None):
|
||||
"""
|
||||
|
||||
Binary file not shown.
@ -10,7 +10,7 @@ from org.meteoinfo.math.stats import StatsUtil
|
||||
from org.meteoinfo.ndarray.math import ArrayMath
|
||||
from org.meteoinfo.ndarray import Array
|
||||
|
||||
from ..core import numeric as np
|
||||
from .. import core as np
|
||||
from collections import namedtuple
|
||||
import warnings
|
||||
|
||||
|
||||
Binary file not shown.
@ -504,7 +504,7 @@ class Figure(GLChartPanel):
|
||||
"""
|
||||
Set MouseMode.
|
||||
|
||||
:param mm: (*string*) MouseMode string [zoom_in | zoom_out | pan | identifer
|
||||
:param mm: (*string*) MouseMode string [zoom_in | zoom_out | pan | identifier
|
||||
| rotate | select].
|
||||
"""
|
||||
mm = MouseMode.valueOf(mm.upper())
|
||||
|
||||
Binary file not shown.
@ -846,7 +846,7 @@ def axes3dgl(*args, **kwargs):
|
||||
|
||||
def axes3d_map(*args, **kwargs):
|
||||
"""
|
||||
Add an map 3d axes with JOGL to the figure.
|
||||
Add a map 3d axes with JOGL to the figure.
|
||||
|
||||
:returns: The axes.
|
||||
"""
|
||||
|
||||
@ -8,6 +8,8 @@ import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@ -204,9 +206,12 @@ public class FrmAppsManager extends javax.swing.JDialog {
|
||||
File fs[] = f.listFiles();
|
||||
for (File ff : fs) {
|
||||
if (ff.isDirectory()) {
|
||||
Application plugin = this.readPyApp(ff.getName(), "loadApp.py");
|
||||
if (plugin != null) {
|
||||
plugins.add(plugin);
|
||||
Path loadApp = Paths.get(ff.getPath(), "loadApp.py");
|
||||
if (loadApp.toFile().isFile()) {
|
||||
Application plugin = this.readPyApp(ff.getName(), "loadApp.py");
|
||||
if (plugin != null) {
|
||||
plugins.add(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,8 +157,12 @@ public class FrmMain extends javax.swing.JFrame implements IApplication {
|
||||
if (this.startupPath.endsWith("meteoinfo-lab")) {
|
||||
Path path = new File(this.startupPath).toPath();
|
||||
path = path.getParent();
|
||||
path = path.resolve(Paths.get("auxdata", "toolbox"));
|
||||
toolboxPath = path.toString();
|
||||
Path toolPath = path.getParent();
|
||||
toolPath = toolPath.resolve(Paths.get("toolbox"));
|
||||
if (!toolPath.toFile().isDirectory()) {
|
||||
toolPath = path.resolve(Paths.get("auxdata", "toolbox"));
|
||||
}
|
||||
toolboxPath = toolPath.toString();
|
||||
}
|
||||
String appConfFn = toolboxPath + File.separator + "apps.xml";
|
||||
if (new File(appConfFn).exists()) {
|
||||
|
||||
163
meteoinfo-math/src/main/java/org/meteoinfo/math/meteo/WRF.java
Normal file
163
meteoinfo-math/src/main/java/org/meteoinfo/math/meteo/WRF.java
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Calculation algorithm for WRF model output
|
||||
*/
|
||||
package org.meteoinfo.math.meteo;
|
||||
|
||||
import org.meteoinfo.ndarray.Array;
|
||||
import org.meteoinfo.ndarray.Index3D;
|
||||
|
||||
public class WRF {
|
||||
//constants
|
||||
public static final double GAMMA_SEVEN = 720.;
|
||||
public static final double RHOWAT = 1000.;
|
||||
public static final double RHO_R = RHOWAT;
|
||||
public static final double RHO_S = 100.;
|
||||
public static final double RHO_G = 400.;
|
||||
public static final double ALPHA = 0.224;
|
||||
public static final double CELKEL = 273.15;
|
||||
public static final double PI = 3.141592653589793;
|
||||
public static final double RD = 287.04;
|
||||
|
||||
/**
|
||||
* Computes equivalent reflectivity factor (in dBZ) at
|
||||
* each model grid point.
|
||||
*
|
||||
* @param prs Pressure
|
||||
* @param tmk Temperature
|
||||
* @param qvp Water vapor mixing ratio
|
||||
* @param qra Rain water mixing ratio
|
||||
* @param qsn Snow mixing ratio
|
||||
* @param qgr Graupel mixing ratio
|
||||
* @param sn0 Whether snow mixing ratio is not all 0
|
||||
* @param ivarint The variable intercept parameter
|
||||
* @param iliqskin The frozen particles parameter
|
||||
* @return Calculated dBZ array
|
||||
*/
|
||||
public static Array calcDBZ(Array prs, Array tmk, Array qvp, Array qra, Array qsn, Array qgr,
|
||||
int sn0, int ivarint, int iliqskin) {
|
||||
int[] shape = prs.getShape();
|
||||
int nz = shape[0]; int ny = shape[1]; int nx = shape[2];
|
||||
int i, j, k;
|
||||
double temp_c, virtual_t, gonv, ronv, sonv, factor_g, factor_r, factor_s,
|
||||
factorb_g, factorb_s, rhoair, z_e;
|
||||
|
||||
//Constants used to calculate variable intercepts
|
||||
double R1 = 1.E-15;
|
||||
double RON = 8.E6;
|
||||
double RON2 = 1.E10;
|
||||
double SON = 2.E7;
|
||||
double GON = 5.E7;
|
||||
double RON_MIN = 8.E6;
|
||||
double RON_QR0 = 0.00010;
|
||||
double RON_DELQR0 = 0.25 * RON_QR0;
|
||||
double RON_CONST1R = (RON2-RON_MIN)*0.5;
|
||||
double RON_CONST2R = (RON2+RON_MIN)*0.5;
|
||||
|
||||
//Constant intercepts
|
||||
double RN0_R = 8.E6;
|
||||
double RN0_S = 2.E7;
|
||||
double RN0_G = 4.E6;
|
||||
|
||||
//Force all Q arrays to be 0.0 or greater.
|
||||
Index3D index = (Index3D) Index3D.factory(shape);
|
||||
for (k = 0; k < nz; k++) {
|
||||
for (j = 0; j < ny; j++) {
|
||||
for (i = 0; i < nx; i++) {
|
||||
index.set(k, j, i);
|
||||
if (qvp.getDouble(index) < 0.0) {
|
||||
qvp.setDouble(index, 0.0);
|
||||
}
|
||||
if (qra.getDouble(index) < 0.0) {
|
||||
qra.setDouble(index, 0.0);
|
||||
}
|
||||
if (qsn.getDouble(index) < 0.0) {
|
||||
qsn.setDouble(index, 0.0);
|
||||
}
|
||||
if (qgr.getDouble(index) < 0.0) {
|
||||
qgr.setDouble(index, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Input pressure is Pa, but we need hPa in calculations
|
||||
if (sn0 == 0) {
|
||||
for (k = 0; k < nz; k++) {
|
||||
for (j = 0; j < ny; j++) {
|
||||
for (i = 0; i < nx; i++) {
|
||||
index.set(k, j, i);
|
||||
if (tmk.getDouble(index) < CELKEL) {
|
||||
qsn.setDouble(index, qra.getDouble(index));
|
||||
qra.setDouble(index, 0.);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
factor_r = GAMMA_SEVEN * 1.E18 * Math.pow((1.0 / (PI * RHO_R)), 1.75);
|
||||
factor_s = GAMMA_SEVEN * 1.E18 * Math.pow((1.0 / (PI * RHO_S)), 1.75) *
|
||||
Math.pow((RHO_S / RHOWAT), 2) * ALPHA;
|
||||
factor_g = GAMMA_SEVEN * 1.E18 * Math.pow((1.0 / (PI * RHO_G)), 1.75) *
|
||||
Math.pow((RHO_G / RHOWAT), 2) * ALPHA;
|
||||
|
||||
Array dbz = Array.factory(prs.getDataType(), shape);
|
||||
for (k = 0; k < nz; k++) {
|
||||
for (j = 0; j < ny; j++) {
|
||||
for (i = 0; i < nx; i++) {
|
||||
index.set(k, j, i);
|
||||
virtual_t = tmk.getDouble(index) * (0.622 + qvp.getDouble(index)) /
|
||||
(0.622 * (1. + qvp.getDouble(index)));
|
||||
rhoair = prs.getDouble(index) / (RD * virtual_t);
|
||||
|
||||
//Adjust factor for brightband, where snow or graupel particle
|
||||
//scatters like liquid water (alpha=1.0) because it is assumed to
|
||||
//have a liquid skin.
|
||||
if (iliqskin == 1 && tmk.getDouble(index) > CELKEL) {
|
||||
factorb_s = factor_s / ALPHA;
|
||||
factorb_g = factor_g / ALPHA;
|
||||
} else {
|
||||
factorb_s = factor_s;
|
||||
factorb_g = factor_g;
|
||||
}
|
||||
|
||||
//Calculate variable intercept parameters
|
||||
if (ivarint == 1) {
|
||||
temp_c = Math.min(-0.001, tmk.getDouble(index) - CELKEL);
|
||||
sonv = Math.min(2.0E8, 2.0E6 * Math.exp(-0.12 * temp_c));
|
||||
|
||||
gonv = GON;
|
||||
if (qgr.getDouble(index) > R1) {
|
||||
gonv = 2.38 * Math.pow(PI * RHO_G / (rhoair * qgr.getDouble(index)), 0.92);
|
||||
gonv = Math.max(1.E4, Math.min(gonv, GON));
|
||||
}
|
||||
|
||||
ronv = RON2;
|
||||
if (qra.getDouble(index) > R1) {
|
||||
ronv = RON_CONST1R * Math.tanh((RON_QR0 - qra.getDouble(index)) / RON_DELQR0) + RON_CONST2R;
|
||||
}
|
||||
|
||||
} else {
|
||||
ronv = RN0_R;
|
||||
sonv = RN0_S;
|
||||
gonv = RN0_G;
|
||||
}
|
||||
|
||||
//Total equivalent reflectivity factor (z_e, in mm^6 m^-3) is
|
||||
//the sum of z_e for each hydrometeor species:
|
||||
z_e = factor_r * Math.pow(rhoair * qra.getDouble(index), 1.75) / Math.pow(ronv, .75) +
|
||||
factorb_s * Math.pow(rhoair * qsn.getDouble(index), 1.75) / Math.pow(sonv, .75) +
|
||||
factorb_g * Math.pow(rhoair * qgr.getDouble(index), 1.75) / Math.pow(gonv, .75);
|
||||
|
||||
//Adjust small values of Z_e so that dBZ is no lower than -30
|
||||
z_e = Math.max(z_e, .001);
|
||||
|
||||
//Convert to dBZ
|
||||
dbz.setDouble(index, 10. * Math.log10(z_e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dbz;
|
||||
}
|
||||
}
|
||||
@ -228,14 +228,14 @@ public class ArrayDouble extends Array {
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public boolean getBoolean(Index i) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storageD[i.currentElement()] != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public void setBoolean(Index i, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storageD[i.currentElement()] = value ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -336,11 +336,11 @@ public class ArrayDouble extends Array {
|
||||
}
|
||||
|
||||
public boolean getBoolean(int index) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storageD[index] != 0;
|
||||
}
|
||||
|
||||
public void setBoolean(int index, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storageD[index] = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public String getString(int index) {
|
||||
|
||||
@ -233,14 +233,14 @@ public class ArrayFloat extends Array {
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public boolean getBoolean(Index i) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storage[i.currentElement()] != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public void setBoolean(Index i, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storage[i.currentElement()] = value ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -341,11 +341,11 @@ public class ArrayFloat extends Array {
|
||||
}
|
||||
|
||||
public boolean getBoolean(int index) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storage[index] != 0;
|
||||
}
|
||||
|
||||
public void setBoolean(int index, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storage[index] = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public String getString(int index) {
|
||||
|
||||
@ -248,14 +248,14 @@ public class ArrayInt extends Array {
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public boolean getBoolean(Index i) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storage[i.currentElement()] != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public void setBoolean(Index i, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storage[i.currentElement()] = value ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -238,14 +238,14 @@ public class ArrayLong extends Array {
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public boolean getBoolean(Index i) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storage[i.currentElement()] != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public void setBoolean(Index i, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storage[i.currentElement()] = value ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -348,11 +348,11 @@ public class ArrayLong extends Array {
|
||||
}
|
||||
|
||||
public boolean getBoolean(int index) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storage[index] != 0;
|
||||
}
|
||||
|
||||
public void setBoolean(int index, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storage[index] = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public String getString(int index) {
|
||||
|
||||
@ -243,18 +243,12 @@ public class ArrayShort extends Array {
|
||||
storage[i.currentElement()] = (short) value;
|
||||
}
|
||||
|
||||
/**
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public boolean getBoolean(Index i) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storage[i.currentElement()] != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* not legal, throw ForbiddenConversionException
|
||||
*/
|
||||
public void setBoolean(Index i, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storage[i.currentElement()] = value ? (short) 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -362,11 +356,11 @@ public class ArrayShort extends Array {
|
||||
}
|
||||
|
||||
public boolean getBoolean(int index) {
|
||||
throw new ForbiddenConversionException();
|
||||
return storage[index] != 0;
|
||||
}
|
||||
|
||||
public void setBoolean(int index, boolean value) {
|
||||
throw new ForbiddenConversionException();
|
||||
storage[index] = value ? (short)1 : 0;
|
||||
}
|
||||
|
||||
public String getString(int index) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user