diff --git a/README.rst b/README.rst index 601d7b67dfd221b69ddba2d8b981bbd27023e4ed..37e750d56020b8db74829855e5a657a06fd60e7d 100644 --- a/README.rst +++ b/README.rst @@ -74,6 +74,8 @@ as shown next:: m m2 0.5 0.5 0 n4 n5 s s3 10 1 n5 n6 + pd pd_cav n4 + xaxis m1 phi lin 0 360 360 yaxis abs:deg """ diff --git a/pykat/__init__.py b/pykat/__init__.py index 72d48a7aa0aff95dc0761e54e8d13a8fcf9df2b6..6ba3fae76a35e6cf43d7de58741ec2e188ba5d64 100644 --- a/pykat/__init__.py +++ b/pykat/__init__.py @@ -1,6 +1,5 @@ -__version__ = "0.3.1" +__version__ = "0.4.3" -#__all__ = ['finesse', 'components', 'detectors', 'commands'] import finesse import components import detectors diff --git a/pykat/finesse.py b/pykat/finesse.py index 9eb76d45e7d1a8fe9055ffde045bfe0500fb86b5..423e1e17c239160a82e232a656f34a10f9df650b 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -104,24 +104,14 @@ class katRun(object): def __getitem__(self, value): idx = [i for i in range(len(self.ylabels)) if self.ylabels[i].split()[0] == str(value)] - if len(idx) > 0 and self.y.shape == (): - # In the case we have a noxaxis and just one output... - return float(self.y) - elif len(idx) == 1 and len(self.y.shape) == 1: + + if len(idx) > 0: + out = self.y[:, idx] - # only selecting a single output from a 1D array - if self.y.size == 1: - return self.y + if out.size == 1: + return float(out) else: - return self.y[idx[0]] - - - elif len(idx) > 0 and len(self.y.shape) == 1: - return self.y[idx] - elif len(idx) > 0: - return self.y[:,idx].squeeze() - elif len(idx) >= 1: - return self.y[:,idx].squeeze() + return out.squeeze() else: raise pkex.BasePyKatException("No output by the name '{0}' found in the output".format(str(value))) @@ -897,8 +887,12 @@ class kat(object): hdr = outfile.readline().replace('%','').replace('\n','').split(',') - data = np.loadtxt(filename,comments='%',skiprows=4) - + data = np.loadtxt(filename, comments='%',skiprows=4) + + # convert 1D arrays into 2D ones for simpler selection + if len(data.shape) == 1: + data = np.array([data]) + if hasattr(self, "x2axis"): # need to parse 2D outputs slightly different as they are effectively 2D matrices # written in linear form @@ -913,17 +907,11 @@ class kat(object): else: shape_len = len(data.shape) - if shape_len > 1: - rows,cols = data.shape - x = data[:,0] - y = data[:,1:cols].squeeze() - else: - rows = 1 - cols = data.shape[0] - - x = data[0] - y = data[1:cols].squeeze() + rows,cols = data.shape + x = data[:,0] + y = data[:,1:cols] + return [x, y, hdr] def removeLine(self, fragment) : diff --git a/requirements.txt b/requirements.txt index ec0674770a202357c1fe880cafd5e5c8c590d7d7..fd2476d4abd3185e6ada7f0ef6a85c64620faf27 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ -PyQt >= 4.8.0 numpy >= 1.6.2 flask >= 0.10.1 \ No newline at end of file diff --git a/setup.py b/setup.py index fe6779456789420e8b18c4859783ccbbf6419b2f..c5c4775978100b2c6004446dcd8cd6c02ed33425 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( version=pykat.__version__, author='Daniel Brown', author_email='ddb@star.sr.bham.ac.uk', - packages=['pykat','pykat.gui','pykat.gui.resources','pykat.testing','pykat.testing.web'], + packages=['pykat','pykat.gui','pykat.gui.resources','pykat.testing','pykat.testing.web','pykat.utilities','pykat.utilities.optics'], url='http://pypi.python.org/pypi/PyKat/', license='GPL v2', description='Python interface and tools for FINESSE',