mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add square function
This commit is contained in:
parent
c1753709bd
commit
bf327b923c
@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\satellite\calipso">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\wind">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\fill_between"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\legend"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
@ -16,24 +13,27 @@
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\text"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\ascii"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\bar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\wind"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\traj_4.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\classifer_linear_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\satellite\calipso\CALIPSO_aerosol_type-1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\wind\quiverm_2-1.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\traj_4.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\classifer_linear_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\satellite\calipso\CALIPSO_aerosol_type-1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\wind\quiverm_2-1.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
<TextFont FontName="YaHei Consolas Hybrid" FontSize="14"/>
|
||||
</Font>
|
||||
<LookFeel Name="Darcula"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,693"/>
|
||||
<Startup MainFormLocation="-7,4" MainFormSize="1389,805"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -797,4 +797,47 @@ def varimax(x, normalize=False, tol=1e-10, it_max=1000):
|
||||
|
||||
# Final matrix.
|
||||
r = np.dot(x, TT)
|
||||
return r, TT
|
||||
return r, TT
|
||||
|
||||
def centered_rms_dev(predicted,reference):
|
||||
'''
|
||||
Calculates the centered root-mean-square (RMS) difference between
|
||||
two variables PREDICTED and REFERENCE (E'). The latter is calculated
|
||||
using the formula:
|
||||
(E')^2 = sum_(n=1)^N [(p_n - mean(p))(r_n - mean(r))]^2/N
|
||||
where p is the predicted values, r is the reference values, and
|
||||
N is the total number of values in p & r. Note that p & r must
|
||||
have the same number of values.
|
||||
Input:
|
||||
PREDICTED : predicted field
|
||||
REFERENCE : reference field
|
||||
Output:
|
||||
CRMSDIFF : centered root-mean-square (RMS) difference (E')^2
|
||||
Author: Peter A. Rochford
|
||||
Symplectic, LLC
|
||||
www.thesymplectic.com
|
||||
prochford@thesymplectic.com
|
||||
Created on Nov 24, 2016
|
||||
'''
|
||||
|
||||
# Check that dimensions of predicted and reference fields match
|
||||
pdims= predicted.shape
|
||||
rdims= reference.shape
|
||||
if not np.array_equal(pdims,rdims):
|
||||
message = 'predicted and reference field dimensions do not' + \
|
||||
' match.\n' + \
|
||||
'shape(predicted)= ' + str(pdims) + ', ' + \
|
||||
'shape(reference)= ' + str(rdims) + \
|
||||
'\npredicted type: ' + str(type(predicted))
|
||||
raise ValueError(message)
|
||||
|
||||
# Calculate means
|
||||
pmean = np.mean(predicted)
|
||||
rmean = np.mean(reference)
|
||||
|
||||
# Calculate (E')^2
|
||||
crmsd = np.square((predicted - pmean) - (reference - rmean))
|
||||
crmsd = np.sum(crmsd)/predicted.size
|
||||
crmsd = np.sqrt(crmsd)
|
||||
|
||||
return crmsd
|
||||
Binary file not shown.
@ -670,7 +670,10 @@ class NDArray(object):
|
||||
else:
|
||||
r = ArrayMath.std(self._array, axis)
|
||||
return NDArray(r)
|
||||
|
||||
|
||||
def square(self):
|
||||
return self.__mul__(self)
|
||||
|
||||
def sqrt(self):
|
||||
return NDArray(ArrayMath.sqrt(self._array))
|
||||
|
||||
|
||||
Binary file not shown.
@ -44,7 +44,7 @@ __all__ = [
|
||||
'logspace','magnitude','max','maximum','mean','median','meshgrid','min','minimum','monthname',
|
||||
'newaxis','nonzero','ones','ones_like','pol2cart','polyval','power',
|
||||
'radians','ravel','reshape','repeat',
|
||||
'rolling_mean','rot90','sin','smooth5','smooth9','sort','squeeze','argsort','sqrt','std','sum','swapaxes','tan',
|
||||
'rolling_mean','rot90','sin','smooth5','smooth9','sort','squeeze','argsort','sqrt','square','std','sum','swapaxes','tan',
|
||||
'tile','transpose','trapz','vdot','unique','unravel_index','var','vstack',
|
||||
'where','zeros','zeros_like'
|
||||
]
|
||||
@ -550,6 +550,21 @@ def absolute(x):
|
||||
return x.abs()
|
||||
else:
|
||||
return abs(x)
|
||||
|
||||
def square(x):
|
||||
"""
|
||||
Return the element-wise square of the input.
|
||||
|
||||
:param x: (*array_like*) Input data.
|
||||
|
||||
:returns: Element-wise x*x, of the same shape and dtype as x. This is a scalar if x is a scalar.
|
||||
"""
|
||||
if isinstance(x, list):
|
||||
return array(x).square()
|
||||
elif isinstance(x, NDArray):
|
||||
return x.square()
|
||||
else:
|
||||
return x * x
|
||||
|
||||
def sqrt(x):
|
||||
"""
|
||||
@ -557,7 +572,7 @@ def sqrt(x):
|
||||
|
||||
:param x: (*array_like*) The values whose square-roots are required.
|
||||
|
||||
:returns y: (*array_like*) An array of the same shape as *x*, containing the positive
|
||||
:returns: (*array_like*) An array of the same shape as *x*, containing the positive
|
||||
square-root of each element in *x*.
|
||||
|
||||
Examples::
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user