Commit 37f2715a authored by Daniel Brown's avatar Daniel Brown
Browse files

Adding EI read function, adding better warning for ROM vs map size...

Adding EI read function, adding better warning for ROM vs map size differences. Making error printouts more readable
parent 700b2620
Pipeline #1005 failed with stage
......@@ -3,7 +3,7 @@ from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
__version__ = "1.0.4"
__version__ = "1.0.6"
# This flag is used to switch on the gui features in pkat at import time
USE_GUI = False
......
......@@ -9,15 +9,22 @@ if six.PY2:
import os, sys
def PrintError(message, exception):
size = 60
size = 62
print("\033[91m")
try:
from textwrap import wrap, fill
print ("-" * size)
for a in wrap(message, size): print(a)
for a in wrap(str(exception.msg), size): print(a)
for a in wrap(message, size):
print(a)
for a in wrap(str(exception.msg), size):
a = a.replace("*** ", "\n")
a = a.replace("** ", "\n")
print(a)
print ("-" * size)
finally:
print ("\033[0m")
......
......@@ -20,11 +20,34 @@ from pykat.maths.hermite import *
from pykat.maths import newton_weights
from scipy.integrate import newton_cotes
from multiprocessing import Process, Queue, Array, Value, Event
from pykat.exceptions import BasePyKatException
EmpiricalInterpolant = collections.namedtuple('EmpiricalInterpolant', 'B nodes node_indices limits x worst_error')
ReducedBasis = collections.namedtuple('ReducedBasis', 'RB limits x')
ROMLimits = collections.namedtuple('ROMLimits', 'zmin zmax w0min w0max R mapSamples max_order')
def read_EI(filename, verbose=True):
import pickle
with open(filename, "rb") as file:
ei = pickle.load(file)
if verbose:
print("Map data this ROM was made for in one dimension:")
print(" Map separation dx = " + str(ei.x[1]-ei.x[0]))
print(" x range = -{0}m to {0}m".format(max(abs(ei.x))))
print(" Data points = " + str(ei.x.size * 2))
print("")
print("Parameter limits:")
print(" w0 = {0}m to {1}m".format(ei.limits.w0min, ei.limits.w0max))
print(" z = {0}m to {1}m".format(ei.limits.zmin, ei.limits.zmax))
print(" max order = {0}".format(ei.limits.max_order))
print("")
print("ROM contains {0} basis modes".format(ei.nodes.shape[0]))
return ei
class ROMWeights:
def __init__(self, w_ij_Q1, w_ij_Q2, w_ij_Q3, w_ij_Q4, EIx, EIy, nr1=1, nr2=1, direction="reflection_front"):
......@@ -566,6 +589,12 @@ def makeWeightsNew(smap, EIxFilename, EIyFilename=None, verbose=True, newtonCote
wy[ym == 0] = 0.5
W = np.outer(wx, wy)
if A_xy_Q1.shape != W.shape or \
A_xy_Q2.shape != W.shape or \
A_xy_Q3.shape != W.shape or \
A_xy_Q4.shape != W.shape:
raise BasePyKatException("Map data points do not overlap exactly with data points this EI was made for. Consider using the `intepolate=True` option.")
# make integration weights
Bx = EIx.B
By = EIy.B[:,::-1]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment