Skip to content

Commit

Permalink
Added extra dummy checks to Profile object
Browse files Browse the repository at this point in the history
  • Loading branch information
wblumberg committed Sep 13, 2019
1 parent c6ac43a commit e382bac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sharppy/sharptab/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ def __init__(self, **kwargs):
self.tmpc = ma.asanyarray(kwargs.get('tmpc'), dtype=float)
self.dwpc = ma.asanyarray(kwargs.get('dwpc'), dtype=float)

assert self.pres.ndim == 1 and self.hght.ndim == 1 and self.tmpc.ndim == 1 and self.dwpc.ndim == 1,\
"The dimensions of the pres, hght, tmpc, and dwpc arrays passed to the Profile object constructor are not all one dimensional."

assert len(self.pres) > 1 and len(self.hght) > 1 and len(self.tmpc) > 1 and len(self.dwpc) > 1,\
"The length of the data arrays passed to Profile object constructor must all have a length greater than 1."
"The length of the pres, hght, tmpc, and dwpc arrays passed to Profile object constructor must all have a length greater than 1."

assert len(self.pres) == len(self.hght) == len(self.tmpc) == len(self.dwpc),\
"The pres, hght, tmpc, or dwpc arrays passed to the Profile object constructor must all have the same length."
Expand All @@ -121,6 +124,7 @@ def __init__(self, **kwargs):
self.wdir = ma.asanyarray(kwargs.get('wdir'), dtype=float)
self.wspd = ma.asanyarray(kwargs.get('wspd'), dtype=float)
assert len(self.wdir) == len(self.wspd) == len(self.pres), "The wdir and wspd arrays passed to the Profile constructor must have the same length as the pres array."
assert self.wdir.ndim == 1 and self.wspd.ndim == 1, "The wdir and wspd arrays passed to the Profile constructor are not one dimensional."
#self.u, self.v = utils.vec2comp(self.wdir, self.wspd)
self.u = None
self.v = None
Expand All @@ -130,7 +134,7 @@ def __init__(self, **kwargs):
self.u = ma.asanyarray(kwargs.get('u'), dtype=float)
self.v = ma.asanyarray(kwargs.get('v'), dtype=float)
assert len(self.u) == len(self.v) == len(self.pres), "The u and v arrays passed to the Profile constructor must have the same length as the pres array."

assert self.u.ndim == 1 and self.v.ndim == 1, "The wdir and wspd arrays passed to the Profile constructor are not one dimensional."
#self.wdir, self.wspd = utils.comp2vec(self.u, self.v)
self.wdir = None
self.wspd = None
Expand All @@ -149,6 +153,8 @@ def __init__(self, **kwargs):
## get the omega data and turn into arrays
self.omeg = ma.asanyarray(kwargs.get('omeg'))
assert len(self.omeg) == len(self.pres), "Length of omeg array passed to constructor is not the same length as the pres array."
assert self.omeg.ndim == 1, "omeg array is not one dimensional."
assert len(self.omeg) > 1, "omeg array length must have a length greater than 1."
else:
self.omeg = None

Expand Down

0 comments on commit e382bac

Please sign in to comment.