Skip to content

Commit

Permalink
Merge branch 'fmihpc:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
FasilGibdaw authored Feb 28, 2024
2 parents 0cbd2cc + 8758f51 commit 07d378e
Show file tree
Hide file tree
Showing 87 changed files with 5,139 additions and 3,248 deletions.
23 changes: 19 additions & 4 deletions pyCalculations/interpolator_amr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
from scipy.spatial import Delaunay
import numpy as np
from scipy.interpolate import LinearNDInterpolator, RBFInterpolator
from scipy.interpolate import LinearNDInterpolator

import warnings
from variable import get_data

importerror = None

try:
from scipy.interpolate import RBFInterpolator
except Exception as e:
importerror = e
class RBFInterpolator(object):
def __init__(self, pts, vals, **kwargs):
raise importerror #Exception("Module load error")



# With values fi at hexahedral vertices and trilinear basis coordinates ksi,
Expand Down Expand Up @@ -151,7 +162,7 @@ def get_points(self):
def get_interpolator(self, name, operator, coords,
method="RBF",
methodargs={
"RBF":{"neighbors":64},
"RBF":{"neighbors":64}, # Harrison-Stetson number of neighbors
"Delaunay":{"qhull_options":"QJ"}
}):
methodargs["Trilinear"] = {"reader":self.__reader, "var" : name, "op":operator}
Expand All @@ -162,7 +173,11 @@ def get_interpolator(self, name, operator, coords,
self.__Delaunay = Delaunay(self.reader.get_cell_coordinates(self.__cellids),**methodargs[method])
return LinearNDInterpolator(self.__Delaunay, vals)
elif method == "RBF":
return RBFInterpolator(pts, vals, **methodargs[method]) # Harrison-Stetson number of neighbors
try:
return RBFInterpolator(pts, vals, **methodargs[method])
except Exception as e:
warnings.warn("RBFInterpolator could not be imported. SciPy >= 1.7 is required for this class. Falling back to Hexahedral trilinear interpolator. Error given was " + str(e))
return HexahedralTrilinearInterpolator(pts, vals, **methodargs["Trilinear"])
elif method == "Trilinear":
return HexahedralTrilinearInterpolator(pts, vals, **methodargs[method])

6 changes: 2 additions & 4 deletions pyCalculations/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def get_scaled_units(self, vscale=None, env='EarthSpace', manualDict=None):
try:
udict = self.scaleDict[dictKey]
except:
print('No entry in specialist dict for unit "' + self.units+ '"')
if vscale is None:
return 1.0, self.units, self.latexunits
else:
Expand All @@ -177,7 +176,6 @@ def get_scaled_units(self, vscale=None, env='EarthSpace', manualDict=None):
try:
unitScale = udict['defaultScale']
except:
print('No vscale or defaultScale in specialist dict for unit "' + self.units +'"')
return 1.0, self.units, self.latexunits
elif np.isclose(vscale, 1.0):
return 1.0, self.units, self.latexunits
Expand All @@ -192,12 +190,12 @@ def get_scaled_units(self, vscale=None, env='EarthSpace', manualDict=None):
unitScale = [scale for scale in udict.keys() if isinstance(scale, Number) and np.isclose(scale,unitScale)][0]
scaledUnits = udict[unitScale]['scaledUnits']
except KeyError:
print('Missing scaledUnits in specialist dict for' + self.units + ' for unitScale='+str(unitScale))
# print('Missing scaledUnits in specialist dict for' + self.units + ' for unitScale='+str(unitScale))
return 1.0, self.units, self.latexunits
try:
scaledLatexUnits = udict[unitScale]['scaledLatexUnit']
except:
print('Missing scaledLatexUnits in specialist dict for ' + self.units+ ' for unitScale='+str(unitScale))
# print('Missing scaledLatexUnits in specialist dict for ' + self.units+ ' for unitScale='+str(unitScale))
return 1.0, self.units, self.latexunits
else:
if vscale is None or np.isclose(vscale, 1.0):
Expand Down
256 changes: 0 additions & 256 deletions pyPlots/SCM7/acton.txt

This file was deleted.

Loading

0 comments on commit 07d378e

Please sign in to comment.