smbinterp/lib/baker/tools.py

27 lines
520 B
Python
Raw Normal View History

2009-12-27 09:48:27 -08:00
import numpy as np
class smberror(Exception):
"""
this is a silly little exception subclass
"""
def __init__(self, val):
self.value = val
def __str__(self):
return repr(self.value)
2009-12-27 09:48:27 -08:00
def rms(errors):
"""
root mean square calculation
"""
r = 0.0
for i in errors:
r += np.power(i, 2)
r = np.sqrt(r / len(errors))
return r
def exact_func(x, y):
"""
the exact function used from baker's article (for testing)
"""
return np.power((np.sin(x * np.pi) * np.cos(y * np.pi)), 2)