Former-commit-id:a4fa438a41
[formerly33bc5fd816
] [formerly83e9157df7
] [formerlya4fa438a41
[formerly33bc5fd816
] [formerly83e9157df7
] [formerly328c6dccad
[formerly83e9157df7
[formerly bd9eec1d4e6fd843c7bb594b8adb882d72edc6cf]]]] Former-commit-id:328c6dccad
Former-commit-id:ce726fadc7
[formerlyd9be4dce21
] [formerly f30d6bb5c391ebffda9767fba913019b2cd7d050 [formerly47cc08ac79
]] Former-commit-id: 281ab815ed143a9ff49cedae7054da06195e3c69 [formerly547c1dedd1
] Former-commit-id:2779f5c6d9
87 lines
3 KiB
Python
87 lines
3 KiB
Python
##
|
|
# This software was developed and / or modified by Raytheon Company,
|
|
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
|
#
|
|
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
|
# This software product contains export-restricted data whose
|
|
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
|
# to non-U.S. persons whether in the United States or abroad requires
|
|
# an export license or other authorization.
|
|
#
|
|
# Contractor Name: Raytheon Company
|
|
# Contractor Address: 6825 Pine Street, Suite 340
|
|
# Mail Stop B8
|
|
# Omaha, NE 68106
|
|
# 402.291.0100
|
|
#
|
|
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
|
# further licensing information.
|
|
##
|
|
from scipy.interpolate import Rbf
|
|
from numpy import zeros, float32, NaN, isnan, array
|
|
|
|
##
|
|
# Designed to replace interp_up and interp_down in design files for point data
|
|
#
|
|
def execute(paramArray, vertArray, numLevels, vertPoints, maxGap=None):
|
|
ret = zeros(numLevels.shape, float32)
|
|
ret.fill(NaN)
|
|
for i in range(len(vertArray)):
|
|
verts = vertArray[i]
|
|
if type(verts) == float32:
|
|
verts = [verts]
|
|
params = paramArray[i]
|
|
# clone verts and params before modifying
|
|
verts = array(verts)
|
|
params = array(params)
|
|
gi = 0
|
|
for ci in range(len(verts)):
|
|
if isnan(verts[ci]) or isnan(params[ci]):
|
|
continue
|
|
verts[gi] = verts[ci]
|
|
params[gi] = params[ci]
|
|
gi += 1
|
|
if(gi == 0):
|
|
ret[i] = NaN
|
|
continue
|
|
verts = verts[:gi]
|
|
params = params[:gi]
|
|
if isinstance(vertPoints, float):
|
|
vertPoint = vertPoints
|
|
elif isinstance(vertPoints, float32):
|
|
vertPoint = vertPoints
|
|
else:
|
|
vertPoint = vertPoints[i]
|
|
if (maxGap != None):
|
|
below = None
|
|
above = None
|
|
gap = None
|
|
match = None
|
|
for point in verts:
|
|
if (point > vertPoint and (above == None or above > point)):
|
|
above = point
|
|
if (point < vertPoint and (below == None or below < point)):
|
|
below = point
|
|
if (point == vertPoint):
|
|
match = point
|
|
if(above == None and below == None):
|
|
continue
|
|
elif(above == None):
|
|
gap = (vertPoint - below)*2
|
|
elif(below == None):
|
|
gap = (above - vertPoint)*2
|
|
else:
|
|
gap = above - below
|
|
if((gap == None or gap > maxGap) and match == None):
|
|
ret[i] = NaN
|
|
continue
|
|
# If withion gap and only 1 value just use it
|
|
if(len(verts) == 1):
|
|
ret[i] = params[0]
|
|
continue
|
|
if(len(verts) == 1):
|
|
ret[i] = NaN
|
|
continue
|
|
rbf = Rbf(verts, params, function="linear")
|
|
ret[i] = rbf(vertPoint)
|
|
return ret
|