From e382bacc2166a34d8dec4cc7f82aad93da9db94d Mon Sep 17 00:00:00 2001 From: wblumberg Date: Fri, 13 Sep 2019 18:23:58 -0400 Subject: [PATCH] Added extra dummy checks to Profile object --- sharppy/sharptab/profile.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sharppy/sharptab/profile.py b/sharppy/sharptab/profile.py index 7c6c1548..d6ae14f5 100644 --- a/sharppy/sharptab/profile.py +++ b/sharppy/sharptab/profile.py @@ -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." @@ -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 @@ -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 @@ -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