From f25ea454d3a84e0e867668a3781690cc12093072 Mon Sep 17 00:00:00 2001 From: Daniel Brown <ddb@star.sr.bham.ac.uk> Date: Fri, 7 Mar 2014 02:27:45 +0000 Subject: [PATCH] udpdating setup files and requirements. Fixing and simplifying the output select from a kat_run object. Internally it always stores output data as a 2d array, even if noxaxis is used. This simplifies the selection of output data greatly --- README.rst | 2 ++ pykat/__init__.py | 3 +-- pykat/finesse.py | 44 ++++++++++++++++---------------------------- requirements.txt | 1 - setup.py | 2 +- 5 files changed, 20 insertions(+), 32 deletions(-) diff --git a/README.rst b/README.rst index 601d7b6..37e750d 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 72d48a7..6ba3fae 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 9eb76d4..423e1e1 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 ec06747..fd2476d 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 fe67794..c5c4775 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', -- GitLab