[med-svn] [pycorrfit] 03/07: New upstream version 1.0.1+dfsg

Alex Mestiashvili malex-guest at moszumanska.debian.org
Wed Sep 6 12:40:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

malex-guest pushed a commit to branch master
in repository pycorrfit.

commit 4a11754a3bb83f1befacb775d7e4d65f31ac90cd
Author: Alexandre Mestiashvili <alex at biotec.tu-dresden.de>
Date:   Wed Sep 6 09:20:06 2017 +0200

    New upstream version 1.0.1+dfsg
---
 .travis/linux_build-wheels.sh                      |  22 ---
 .travis/linux_dist.sh                              |  12 --
 .travis/linux_install.sh                           |  14 --
 .travis/osx_dist.sh                                | 117 ---------------
 .travis/osx_install.sh                             |  56 -------
 .travis/osx_install_dmg.sh                         |  36 -----
 .travis/osx_pyinstaller.spec                       |  43 ------
 .travis/osx_requirements.txt                       |   8 -
 .travis/osx_wxPython-3.0.2.0-plot.patch            |  91 ------------
 .travis/test.sh                                    |   8 -
 ChangeLog.txt                                      |   7 +
 README.rst                                         |   4 +-
 pycorrfit/__init__.py                              |   5 +-
 pycorrfit/_version.py                              | 133 +++++++++++++++++
 pycorrfit/gui/doc.py                               |   1 -
 pycorrfit/gui/frontend.py                          |  34 ++---
 pycorrfit/gui/misc.py                              | 140 +-----------------
 pycorrfit/gui/update.py                            | 143 ++++++++++++++++++
 pycorrfit/meta.py                                  |  17 ---
 pycorrfit/openfile.py                              |   3 +-
 pycorrfit/readfiles/read_ASC_ALV.py                | 162 +++++++++++++++------
 pycorrfit/readfiles/read_FCS_Confocor3.py          |   4 +-
 pycorrfit/readfiles/read_pt3_scripts/README        |   8 +-
 .../read_pt3_scripts/correlation_methods.py        |  12 +-
 setup.py                                           |  22 +--
 tests/data_file_dl.py                              |  25 ++--
 tests/test_constraints.py                          |   5 +-
 tests/test_file_formats.py                         | 139 ++++++++++++++++--
 28 files changed, 588 insertions(+), 683 deletions(-)

diff --git a/.travis/linux_build-wheels.sh b/.travis/linux_build-wheels.sh
deleted file mode 100755
index 4aee3da..0000000
--- a/.travis/linux_build-wheels.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-set -e -x
-
-cd /io
-
-for PYBIN in /opt/python/cp${TRAVIS_PYTHON_VERSION//./}*/bin/; do
-    # Install
-    "${PYBIN}/pip" install -e .
-    "${PYBIN}/python" setup.py build_ext --inplace --force
-    # Test
-    "${PYBIN}/python" setup.py test
-    # Wheels
-    "${PYBIN}/pip" wheel /io/ -w wheelhouse/ --no-deps
-    rm -rf .eggs
-done
-
-# Bundle external shared libraries into the wheels
-for whl in /io/wheelhouse/*.whl; do
-    auditwheel repair "$whl" -w /io/dist/
-done
-
-
diff --git a/.travis/linux_dist.sh b/.travis/linux_dist.sh
deleted file mode 100755
index 7e7dbf5..0000000
--- a/.travis/linux_dist.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-# Call this script from the parent directory
-# This will produce wheels using docker
-set -e
-# remove all .pyc files to prevent error:
-# - import file mismatch / unique basename
-find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
-docker pull $DOCKER_IMAGE
-mkdir -p dist
-docker run -e TRAVIS_PYTHON_VERSION --rm -v `pwd`:/io $DOCKER_IMAGE $PRE_CMD /io/.travis/${TRAVIS_OS_NAME}_build-wheels.sh
-python setup.py sdist
-ls -l dist/
diff --git a/.travis/linux_install.sh b/.travis/linux_install.sh
deleted file mode 100755
index 70184c0..0000000
--- a/.travis/linux_install.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-set -e
-deactivate
-sudo apt-get update -qq
-# Fixes the error:
-# - ImportError: No module named _tkinter, please install the python-tk package
-sudo apt-get install -qq python-pip python-tk
-sudo pip install virtualenv
-# use separate virtual environment
-virtualenv --system-site-packages ~/env
-source ~/env/bin/activate
-pip install --upgrade pip
-pip install cython matplotlib lmfit numpy scipy sympy
-
diff --git a/.travis/osx_dist.sh b/.travis/osx_dist.sh
deleted file mode 100755
index 654eca1..0000000
--- a/.travis/osx_dist.sh
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/bash
-set -e
-
-## Python Wheels
-# Create wheels
-pip install wheel
-pip wheel ./ -w wheelhouse/ --no-deps
-# Check for external dependencies
-pip install delocate
-# display dependencies
-delocate-listdeps wheelhouse/*.whl
-mkdir -p dist
-# repair wheels
-delocate-wheel -w dist wheelhouse/*.whl
-# check fixed wheels
-delocate-listdeps --all dist/*.whl
-ls -l dist
-
-# Stop here (OSx, WxPython, Pyinstaller will not work nicely together)
-exit 0
-
-## Pyinstaller
-pip install pyinstaller
-export PATH=/usr/local/bin:$PATH
-#export VERSIONER_PYTHON_PREFER_32_BIT=yes
-#defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
-
-Progname="PyCorrFit"
-# Go to base dir of repo
-BASEDIR=$(dirname $0)
-cd $BASEDIR
-BASEDIR=$(pwd)
-cd "../"
-StartDir=$(pwd)"/"
-Progdir=${StartDir}"/"
-# We require a Progname_doc.tex in the source-doc directory
-DocDir=${StartDir}"/doc/"
-Docname=${DocDir}${Progname}"_doc.pdf"
-Changelogname="ChangeLog.txt"
-Specfile=${BASEDIR}"/"${Progname}"_mac.spec"
-codename="MacOSx"
-distrib=$(sw_vers -productVersion )
-version=$(head -n1 ./ChangeLog.txt | tr -d "\r\n")
-appn="./dist/${Progname}.app"
-StarterScript="./.travs/macOSx_script_starter.sh"
-Zipname=${Progname}_${version}_${codename}_${distrib}"_app.zip"
-DMGname=${Progname}_${version}_${codename}_${distrib}".dmg"
-
-echo $Specfile
-
-cd $StartDir
-
-
-echo "###################"
-echo "Building Extensions"
-echo "###################"
-rm -f $Docname
-python setup.py build_ext --inplace
-if [ $? -ne 0 ]; then
-    echo "Error - Aborting"
-    exit
-fi
-
-
-echo "############################"
-echo "Removing old build directory"
-echo "############################"
-rm -rf build
-if [ $? -ne 0 ]; then
-    echo "Error - Aborting"
-    exit
-fi
-
-
-
-echo "#######################"
-echo "Running Pyinstaller APP"
-echo "#######################"
-
-if [ -e $appn ]; then rm -R $appn; fi
-
-pyinstaller -y -F $Specfile
-if [ $? -ne 0 ]; then
-    echo "Error - Aborting"
-    exit
-fi
-
-
-if [ -e $Zipname ]; then rm $Zipname; fi
-
-
-#echo "############"
-#echo "Creating Zip"
-#echo "############"
-#pushd dist
-#zip -r ${Zipname} ${Progname}".app"
-#popd
-#zip -j "./dist/"${Zipname} ${Docname} ${Changelogname}
-
-
-echo "############"
-echo "Creating DMG"
-echo "############"
-pushd dist
-mkdir dmgsrc
-cp ../doc/*.pdf dmgsrc/
-cp ../ChangeLog.txt dmgsrc/
-cp -r ${Progname}".app" dmgsrc/
-# hdiutil: create failed - error -5341
-# http://stackoverflow.com/questions/18621467/error-creating-disk-image-using-hdutil
-# https://discussions.apple.com/thread/4712306
-touch dmgsrc/.Trash
-rm -rf dmgsrc/.DStore
-ls -la dmgsrc/
-# hdiutil create ${DMGname} -srcfolder dmgsrc/ -ov
-hdiutil create -volname "PyCorrFit_image" -megabytes 314m -format UDZO -imagekey zlib-level=9 -srcfolder dmgsrc -ov ${DMGname}
-popd
diff --git a/.travis/osx_install.sh b/.travis/osx_install.sh
deleted file mode 100644
index 815a755..0000000
--- a/.travis/osx_install.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-set -e
-# a lot of cool formulae for scientific tools
-#- brew tap homebrew/science
-# numpy, scipy, matplotlib, ...
-#- brew tap homebrew/python
-#- brew tap homebrew/dupes
-#- brew update
-#- brew update && brew upgrade
-#- brew install python --universal --framework
-#- brew install wget
-#- which python
-#- python --version
-#- export VERSIONER_PYTHON_PREFER_32_BIT=no
-#- defaults write com.apple.versioner.python Prefer-32-Bit -bool no
-#- brew unlink gcc
-#- brew install gcc --universal
-#- brew install freetype --universal
-##- brew install numpy --universal
-##- brew install scipy --universal
-##- brew install matplotlib --universal
-#
-## https://github.com/Homebrew/homebrew/issues/34470
-##- brew install wxpython --universal
-##- brew install openblas
-##- brew install gfortran
-
-## wxPython
-#- wget http://downloads.sourceforge.net/wxpython/wxPython3.0-osx-3.0.2.0-cocoa-py2.7.dmg
-#sudo ./.travis/osx_install_dmg.sh
-
-MINICONDA=Miniconda2-latest-MacOSX-x86_64.sh
-wget http://repo.continuum.io/miniconda/${MINICONDA} -O miniconda.sh
-chmod +x miniconda.sh
-./miniconda.sh -b -p ${HOME}/miniconda
-export PATH=${HOME}/miniconda/bin:$PATH
-conda update --yes conda
-travis_retry conda install --yes cython matplotlib numpy pip scipy wxpython
-pip install -e .
-
-# Patch wx.lib.plot
-# http://trac.wxwidgets.org/ticket/16767#no1
-#python -c "import wx; print wx.__version__"
-#python -c "import wx; import wx.lib; import wx.lib.plot; print wx.lib.plot.__file__"
-#- patch /usr/local/lib/wxPython-3.0.2.0/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/lib/plot.py ./freeze_travis/wxPython-3.0.2.0-plot.patch
-# wxPython is only available in 64bit version with homebrew
-#- brew install wxpython
-
-#- hdiutil create dist/hw.dmg -srcfolder dist/ -ov
-#./freeze_travis/macOSx_bundle_script.sh
-
-## Fixes
-# matplotlib backend workaround
-mkdir $HOME/.matplotlib
-echo "backend: TkAgg" >> $HOME/.matplotlib/matplotlibrc
-
diff --git a/.travis/osx_install_dmg.sh b/.travis/osx_install_dmg.sh
deleted file mode 100755
index 0e15f65..0000000
--- a/.travis/osx_install_dmg.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-# packages.sh from
-# https://github.com/ayufan/travis-osx-vm-templates/blob/master/scripts/packages.sh
-
-set -eo pipefail
-shopt -s nullglob
-
-install_dmg() {
-    declare dmg="$1" target="${2:-/}"
-    echo "Installing $dmg..."
-    TMPMOUNT=`/usr/bin/mktemp -d /tmp/dmg.XXXX`
-    hdiutil attach "$dmg" -mountpoint "$TMPMOUNT"
-    for app in $TMPMOUNT/*.app; do
-        app_name="$(basename "$app")"
-        echo "Installing application $app_name..."
-        rm -rf "/Applications/$app_name"
-        cp -a "$app" "/Applications/"
-    done
-    find "$TMPMOUNT" -name '*.pkg' -exec installer -target "$target" -pkg "{}" \;
-    hdiutil detach "$TMPMOUNT"
-    rm -rf "$TMPMOUNT"
-    #rm -f "$dmg"
-}
-
-install_dmg_url() {
-    declare url="$1" target="$2"
-    local dmg="${dmg:-$(basename "$url")}"
-    echo "Downloading $url..."
-    curl --retry 3 -o "$dmg" "$url"
-    install_dmg "$dmg" "$target"
-}
-
-# install packages
-for package in ./*.dmg; do
-    install_dmg "$package"
-done
diff --git a/.travis/osx_pyinstaller.spec b/.travis/osx_pyinstaller.spec
deleted file mode 100644
index bae61cc..0000000
--- a/.travis/osx_pyinstaller.spec
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- mode: python -*-
-from os.path import abspath, join
-
-# This is not relative to this file
-repo_dir = abspath("./")
-
-hiddenimports = [
- 		 "scipy.io.matlab.streams",
-		 "scipy.special",
-		 "scipy.special.specfun",
-		 "scipy.io.matlab.streams",
-                 "sympy.assumptions.handlers",
-                 "sympy.assumptions.handlers.common",
-                 "scipy.special._ufuncs_cxx",
-                 "scipy.sparse.csgraph",
-                 "scipy.sparse.csgraph.shortest_path",
-                 "scipy.sparse.csgraph._validation"]
-
-a = Analysis([join(repo_dir, 'pycorrfit/PyCorrFit.py')],
-             hiddenimports=hiddenimports,
-             hookspath=None)
-a.datas += [('doc/ChangeLog.txt', join(repo_dir, 'ChangeLog.txt'), 'DATA'),
-            ('doc/PyCorrFit_doc.pdf', join(repo_dir, 'doc/PyCorrFit_doc.pdf'), 'DATA')]
-pyz = PYZ(a.pure)
-exe = EXE(pyz,
-          a.scripts,
-          exclude_binaries=True,
-          name='PyCorrFit',
-          debug=False,
-          strip=None,
-          upx=True,
-          console=False )
-coll = COLLECT(exe,
-               a.binaries,
-               a.zipfiles,
-               a.datas,
-               strip=None,
-               upx=True,
-               name='PyCorrFit')
-app = BUNDLE(coll,
-             name=join(repo_dir, 'dist/PyCorrFit.app'),
-             icon=join(repo_dir, 'freeze_pyinstaller/PyCorrFit.icns')
-             )
diff --git a/.travis/osx_requirements.txt b/.travis/osx_requirements.txt
deleted file mode 100644
index f34e54d..0000000
--- a/.travis/osx_requirements.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Cython>=0.22
-lmfit
-matplotlib>=1.4.3
-numpy>=1.8.2
-PyYAML==3.11
-scipy>=0.14.0
-sympy>=0.7.6
-wheel
diff --git a/.travis/osx_wxPython-3.0.2.0-plot.patch b/.travis/osx_wxPython-3.0.2.0-plot.patch
deleted file mode 100644
index f56956a..0000000
--- a/.travis/osx_wxPython-3.0.2.0-plot.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-diff -up wxPython-src-3.0.2.0/wxPython/wx/lib/plot.py.plot wxPython-src-3.0.2.0/wxPython/wx/lib/plot.py
---- wxPython-src-3.0.2.0/wxPython/wx/lib/plot.py.plot	2014-10-13 18:37:22.000000000 -0400
-+++ wxPython-src-3.0.2.0/wxPython/wx/lib/plot.py	2015-01-04 20:38:04.645350202 -0500
-@@ -237,7 +237,7 @@ class PolyLine(PolyPoints):
-         :keyword `attr`: keyword attributes, default to:
- 
-          ==========================  ================================
--         'colour'= 'black'           wx.Pen Colour any wx.Colour
-+         'colour'= 'black'           wx.Pen Colour any wx.NamedColour
-          'width'= 1                  Pen width
-          'style'= wx.PENSTYLE_SOLID  wx.Pen style
-          'legend'= ''                Line Legend to display
-@@ -251,7 +251,7 @@ class PolyLine(PolyPoints):
-         width = self.attributes['width'] * printerScale * self._pointSize[0]
-         style = self.attributes['style']
-         if not isinstance(colour, wx.Colour):
--            colour = wx.Colour(colour)
-+            colour = wx.NamedColour(colour)
-         pen = wx.Pen(colour, width, style)
-         pen.SetCap(wx.CAP_BUTT)
-         dc.SetPen(pen)
-@@ -287,7 +287,7 @@ class PolySpline(PolyLine):
-         :keyword `attr`: keyword attributes, default to:
- 
-          ==========================  ================================
--         'colour'= 'black'           wx.Pen Colour any wx.Colour
-+         'colour'= 'black'           wx.Pen Colour any wx.NamedColour
-          'width'= 1                  Pen width
-          'style'= wx.PENSTYLE_SOLID  wx.Pen style
-          'legend'= ''                Line Legend to display
-@@ -301,7 +301,7 @@ class PolySpline(PolyLine):
-         width = self.attributes['width'] * printerScale * self._pointSize[0]
-         style = self.attributes['style']
-         if not isinstance(colour, wx.Colour):
--            colour = wx.Colour(colour)
-+            colour = wx.NamedColour(colour)
-         pen = wx.Pen(colour, width, style)
-         pen.SetCap(wx.CAP_ROUND)
-         dc.SetPen(pen)
-@@ -365,9 +365,9 @@ class PolyMarker(PolyPoints):
-         marker = self.attributes['marker']
- 
-         if colour and not isinstance(colour, wx.Colour):
--            colour = wx.Colour(colour)
-+            colour = wx.NamedColour(colour)
-         if fillcolour and not isinstance(fillcolour, wx.Colour):
--            fillcolour = wx.Colour(fillcolour)
-+            fillcolour = wx.NamedColour(fillcolour)
- 
-         dc.SetPen(wx.Pen(colour, width))
-         if fillcolour:
-@@ -595,9 +595,9 @@ class PlotCanvas(wx.Panel):
- 
-         # set curser as cross-hairs
-         self.canvas.SetCursor(wx.CROSS_CURSOR)
--        self.HandCursor = wx.Cursor(Hand.GetImage())
--        self.GrabHandCursor = wx.Cursor(GrabHand.GetImage())
--        self.MagCursor = wx.Cursor(MagPlus.GetImage())
-+        self.HandCursor = wx.CursorFromImage(Hand.GetImage())
-+        self.GrabHandCursor = wx.CursorFromImage(GrabHand.GetImage())
-+        self.MagCursor = wx.CursorFromImage(MagPlus.GetImage())
- 
-         # Things for printing
-         self._print_data = None
-@@ -681,7 +681,7 @@ class PlotCanvas(wx.Panel):
-         if isinstance(colour, wx.Colour):
-             self._gridColour = colour
-         else:
--            self._gridColour = wx.Colour(colour)
-+            self._gridColour = wx.NamedColour(colour)
- 
-     # SaveFile
-     def SaveFile(self, fileName=''):
-@@ -1513,7 +1513,7 @@ class PlotCanvas(wx.Panel):
-         # Make new offscreen bitmap: this bitmap will always have the
-         # current drawing in it, so it can be used to save the image to
-         # a file, or whatever.
--        self._Buffer = wx.Bitmap(Size.width, Size.height)
-+        self._Buffer = wx.EmptyBitmap(Size.width, Size.height)
-         self._setSize()
- 
-         self.last_PointLabel = None  # reset pointLabel
-@@ -1578,7 +1578,7 @@ class PlotCanvas(wx.Panel):
-         width = self._Buffer.GetWidth()
-         height = self._Buffer.GetHeight()
-         if sys.platform != "darwin":
--            tmp_Buffer = wx.Bitmap(width, height)
-+            tmp_Buffer = wx.EmptyBitmap(width, height)
-             dcs = wx.MemoryDC()
-             dcs.SelectObject(tmp_Buffer)
-             dcs.Clear()
diff --git a/.travis/test.sh b/.travis/test.sh
deleted file mode 100755
index a5310c4..0000000
--- a/.travis/test.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-set -e
-pip install coverage coveralls
-coverage run --source=pycorrfit ./setup.py test
-coverage report -m
-# allow coveralls to fail
-coveralls || exit 0
-
diff --git a/ChangeLog.txt b/ChangeLog.txt
index bd87d74..265932a 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,10 @@
+1.0.1
+- Improved support for ALV ".ASC" file format (#169)
+- NumPy 0.13 support for ".ptu" file reader
+- Code cleanup:
+  - Fetch latest available version from GitHub releases
+  - New dependency for "simplejson" Python package
+  - Move appveyor recipe to separate folder 
 1.0.0
 - New confocal fitting models T+T+2D and T+T+3D
 - Fix regression: .sin files could not be opened (#167)
diff --git a/README.rst b/README.rst
index 71b7b65..33bb825 100644
--- a/README.rst
+++ b/README.rst
@@ -97,5 +97,5 @@ the running time of the build). From there you can download the Windows installe
    :target: https://ci.appveyor.com/project/paulmueller/pycorrfit
 .. |Build Status Travis| image:: https://img.shields.io/travis/FCS-analysis/PyCorrFit/master.svg?label=linux_osx
    :target: https://travis-ci.org/FCS-analysis/PyCorrFit
-.. |Coverage Status| image:: https://img.shields.io/coveralls/FCS-analysis/PyCorrFit.svg
-   :target: https://coveralls.io/r/FCS-analysis/PyCorrFit
+.. |Coverage Status| image:: https://img.shields.io/codecov/c/github/FCS-analysis/PyCorrFit/master.svg
+   :target: https://codecov.io/gh/FCS-analysis/PyCorrFit
\ No newline at end of file
diff --git a/pycorrfit/__init__.py b/pycorrfit/__init__.py
index 84c6a26..92f223f 100644
--- a/pycorrfit/__init__.py
+++ b/pycorrfit/__init__.py
@@ -1,7 +1,8 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 """
-PyCorrFit is a tool to fit correlation curves on a logarithmic scale.
+PyCorrFit is a tool to fit fluorescence correlation spectroscopy
+data on a logarithmic scale.
 """
 
 from . import meta
@@ -12,8 +13,8 @@ from . import readfiles
 from .correlation import Correlation
 from .fit import Fit
 from .trace import Trace
+from ._version import version as __version__
 
-__version__ = meta.get_version()
 __author__ = u"Paul Müller"
 __license__ = "GPL v2"
 
diff --git a/pycorrfit/_version.py b/pycorrfit/_version.py
new file mode 100644
index 0000000..68151fc
--- /dev/null
+++ b/pycorrfit/_version.py
@@ -0,0 +1,133 @@
+#!/usr/bin/env python
+"""
+Determine package version for git repositories.
+
+Each time this file is imported it checks if the ".git" folder is
+present and if so, obtains the version from the git history using
+`git describe`. This information is then stored in the file
+`_version_save.py` which is not versioned by git, but distributed
+along with e.g. pypi.
+"""
+from __future__ import print_function
+
+# Put the entire script into a `True` statement and add the hint
+# `pragma: no cover` to ignore code coverage here.
+if True:  # pragma: no cover
+    import imp
+    import os
+    from os.path import join, abspath, dirname
+    import subprocess
+    import sys
+    import time
+    import traceback
+    import warnings
+
+    def git_describe():
+        """
+        Returns a string describing the version returned by the
+        command `git describe --tags HEAD`.
+        If it is not possible to determine the correct version,
+        then an empty string is returned.
+        """
+        # make sure we are in a directory that belongs to the correct
+        # repository.
+        ourdir = dirname(abspath(__file__))
+
+        def _minimal_ext_cmd(cmd):
+            # construct minimal environment
+            env = {}
+            for k in ['SYSTEMROOT', 'PATH']:
+                v = os.environ.get(k)
+                if v is not None:
+                    env[k] = v
+            # LANGUAGE is used on win32
+            env['LANGUAGE'] = 'C'
+            env['LANG'] = 'C'
+            env['LC_ALL'] = 'C'
+            cmd = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env)
+            out = cmd.communicate()[0]
+            return out
+
+        # change directory
+        olddir = abspath(os.curdir)
+        os.chdir(ourdir)
+
+        try:
+            out = _minimal_ext_cmd(['git', 'describe', '--tags', 'HEAD'])
+            GIT_REVISION = out.strip().decode('ascii')
+        except OSError:
+            GIT_REVISION = ""
+
+        # go back to original directory
+        os.chdir(olddir)
+
+        return GIT_REVISION
+
+    def load_version(versionfile):
+        """ load version from version_save.py
+        """
+        longversion = ""
+        try:
+            _version_save = imp.load_source("_version_save", versionfile)
+            longversion = _version_save.longversion
+        except BaseException:
+            try:
+                from ._version_save import longversion
+            except BaseException:
+                try:
+                    from _version_save import longversion
+                except BaseException:
+                    pass
+
+        return longversion
+
+    def save_version(version, versionfile):
+        """ save version to version_save.py
+        """
+        data = "#!/usr/bin/env python\n" \
+            + "# This file was created automatically\n" \
+            + "longversion='{VERSION}'"
+        try:
+            with open(versionfile, "w") as fd:
+                fd.write(data.format(VERSION=version))
+        except BaseException:
+            msg = "Could not write package version to {}.".format(versionfile)
+            warnings.warn(msg)
+
+    versionfile = join(dirname(abspath(__file__)), "_version_save.py")
+
+    # Determine the accurate version
+    longversion = ""
+
+    # 1. git describe
+    try:
+        # Get the version using `git describe`
+        longversion = git_describe()
+    except BaseException:
+        pass
+
+    # 2. previously created version file
+    if longversion == "":
+        # Either this is this is not a git repository or we are in the
+        # wrong git repository.
+        # Get the version from the previously generated `_version_save.py`
+        longversion = load_version(versionfile)
+
+    # 3. last resort: date
+    if longversion == "":
+        print("Could not determine version. Reason:")
+        print(traceback.format_exc())
+        ctime = os.stat(__file__)[8]
+        longversion = time.strftime("%Y.%m.%d-%H-%M-%S", time.gmtime(ctime))
+        print("Using creation time as version: {}".format(longversion))
+
+    if not hasattr(sys, 'frozen'):
+        # Save the version to `_version_save.py` to allow distribution using
+        # `python setup.py sdist`.
+        # This is only done if the program is not frozen (with e.g.
+        # pyinstaller),
+        if longversion != load_version(versionfile):
+            save_version(longversion, versionfile)
+
+    # PEP 440-conform development version:
+    version = ".dev".join(longversion.split("-")[:2])
diff --git a/pycorrfit/gui/doc.py b/pycorrfit/gui/doc.py
index 37016b2..6f627c9 100755
--- a/pycorrfit/gui/doc.py
+++ b/pycorrfit/gui/doc.py
@@ -28,7 +28,6 @@ with warnings.catch_warnings():
     matplotlib.use('WXAgg') # Tells matplotlib to use WxWidgets for dialogs
 import lmfit
 import numpy
-import os
 import platform
 import scipy
 
diff --git a/pycorrfit/gui/frontend.py b/pycorrfit/gui/frontend.py
index 572ed13..5520c7c 100644
--- a/pycorrfit/gui/frontend.py
+++ b/pycorrfit/gui/frontend.py
@@ -9,40 +9,28 @@ functions and modules are called from here.
 from distutils.version import LooseVersion # For version checking
 import os
 import webbrowser
-import wx.lib.agw.flatnotebook as fnb   # Flatnotebook (Tabs)
+import wx.lib.agw.flatnotebook as fnb
 import wx.py.shell
-import numpy as np                      # NumPy
+import numpy as np
 import platform
-import sys                              # System stuff
-import traceback                        # for Error handling
+import sys
+import traceback
 import warnings
 
-try:
-    # contains e.g. update and icon, but no vital things.
-    import misc
-except ImportError:
-    print " Some modules are not available."
-    print " Update function will not work."
-
-# PyCorrFit modules
-from . import doc                          # Documentation/some texts
-from . import edclasses
-
-try:
-    from . import plotting
-except ImportError:
-    warnings.warn("Submodule `pycorrfit.plotting` will not be "+\
-             "available. Reason: {}.".format(sys.exc_info()[1].message))
-
-
 from pycorrfit import models as mdls
 from pycorrfit import openfile as opf
 from pycorrfit import readfiles
 from pycorrfit import meta
 
 
+# PyCorrFit modules
+from . import doc
+from . import edclasses
+from . import misc
 from . import page
+from . import plotting
 from . import tools
+from . import update
 from . import usermodel
 
 
@@ -1676,7 +1664,7 @@ class MyFrame(wx.Frame):
 
 
     def OnUpdate(self, event):
-        misc.Update(self)
+        update.update(self)
 
 
     def OnWiki(self, e=None):
diff --git a/pycorrfit/gui/misc.py b/pycorrfit/gui/misc.py
index f4e7c3c..7c6b878 100644
--- a/pycorrfit/gui/misc.py
+++ b/pycorrfit/gui/misc.py
@@ -7,69 +7,15 @@ Non-science related code.
 """
 
 import codecs
-from distutils.version import LooseVersion # For version checking
 import numpy as np
-import os
-import tempfile
-import urllib2
-import webbrowser
-import wx.html
-import wx.lib.delayedresult as delayedresult
 
-from . import doc                          # Documentation/some texts
+import wx
+
 # The icon file was created with
 # img2py -i -n Main PyCorrFit_icon.png icon.py
 from . import icon                         # Contains the program icon
 
 
-class UpdateDlg(wx.Frame):
-    def __init__(self, parent, valuedict):
-        
-        description = valuedict["Description"]
-        homepage = valuedict["Homepage"]
-        githome = valuedict["Homepage_GIT"]
-        changelog = valuedict["Changelog"]
-        pos = parent.GetPosition()
-        pos = (pos[0]+100, pos[1]+100)
-        wx.Frame.__init__(self, parent, wx.ID_ANY, title="Update", 
-                          size=(230,240), pos=pos)
-        self.changelog = changelog
-        # Fill html content
-        html = wxHTML(self)
-        string =             '' +\
-            "<b> PyCorrFit <br></b>" +\
-            "Your version: " + description[0]+"<br>" +\
-            "Latest version: " + description[1]+"<br>" +\
-            "(" + description[2]+")<br><p><b>"
-        if len(homepage) != 0:
-            string = string + '<a href="'+homepage+'">Homepage</a><br>'
-        if len(githome) != 0:
-            string = string + '<a href="'+githome+'">Repository</a><br>'
-
-        if len(changelog) != 0:
-            string = string + \
-                     '<a href="'+changelog+'">Change Log</a>'
-        string = string+'</b></p>'
-        html.SetPage(string)
-        self.Bind(wx.EVT_CLOSE, self.Close)
-        # Set window icon
-        ico = getMainIcon()
-        wx.Frame.SetIcon(self, ico)
-
-
-    def Close(self, event):
-        if len(self.changelog) != 0:
-            # Cleanup downloaded file, if it was downloaded
-            if self.changelog != doc.StaticChangeLog:
-                os.remove(self.changelog)
-        self.Destroy()
-
-
-class wxHTML(wx.html.HtmlWindow):
-    def OnLinkClicked(self, link):
-        webbrowser.open(link.GetHref())
-
-
 def parseString2Pagenum(parent, string, nodialog=False):
     """ Parse a string with a list of pagenumbers to an integer list with
         page numbers.
@@ -171,85 +117,3 @@ def getMainIcon(pxlength=32):
     iconICO = wx.IconFromBitmap(iconBMP)
     return iconICO
 
-
-def Update(parent):
-    """ This is a thread for _Update """
-    parent.StatusBar.SetStatusText("Connecting to server...")
-    delayedresult.startWorker(_UpdateConsumer, _UpdateWorker,
-                              wargs=(parent,), cargs=(parent,))
-
-def _UpdateConsumer(delayedresult, parent):
-    results = delayedresult.get()
-    dlg = UpdateDlg(parent, results)
-    dlg.Show()
-    parent.StatusBar.SetStatusText("...update status: "+results["Description"][2])
-
-
-def _UpdateWorker(parent):
-        changelog = ""
-        hpversion = None
-        # I created this TXT record to keep track of the current web presence.
-        try:
-            urlopener = urllib2.urlopen(doc.HomePage, timeout=2)
-            homepage = urlopener.geturl()
-        except:
-            homepage = doc.HomePage
-        try:
-            urlopener2 = urllib2.urlopen(doc.GitHome, timeout=2)
-            githome = urlopener2.geturl()
-        except:
-            githome = ""
-        # Find the changelog file
-        try:
-            responseCL = urllib2.urlopen(homepage+doc.ChangeLog, timeout=2)
-        except:
-            CLfile = doc.GitChLog
-        else:
-            fileresponse = responseCL.read()
-            CLlines = fileresponse.splitlines()
-            # We have a transition between ChangeLog.txt on the homepage
-            # containing the actual changelog or containing a link to
-            # the ChangeLog file.
-            if len(CLlines) == 1:
-                CLfile = CLlines[0]
-            else:
-                hpversion = CLlines[0]
-                CLfile = doc.GitChLog
-        # Continue version comparison if True
-        continuecomp = False
-        try:
-            responseVer = urllib2.urlopen(CLfile, timeout=2)
-        except:
-            if hpversion == None:
-                newversion = "unknown"
-                action = "cannot connect to server"
-            else:
-                newversion = hpversion
-                continuecomp = True
-        else:
-            continuecomp = True
-            changelog = responseVer.read()
-            newversion = changelog.splitlines()[0]
-        if continuecomp:
-            new = LooseVersion(newversion)
-            old = LooseVersion(parent.version)
-            if new > old:
-                action = "update available"
-            elif new < old:
-                action = "whoop you rock!"
-            else:
-                action = "state of the art"
-        description = [parent.version, newversion, action]
-        if len(changelog) != 0:
-            changelogfile = tempfile.mktemp()+"_PyCorrFit_ChangeLog"+".txt"
-            clfile = open(changelogfile, 'wb')
-            clfile.write(changelog)
-            clfile.close()            
-        else:
-            changelogfile=doc.StaticChangeLog
-        results = dict()
-        results["Description"] = description
-        results["Homepage"] = homepage
-        results["Homepage_GIT"] = githome
-        results["Changelog"] = changelogfile
-        return results
diff --git a/pycorrfit/gui/update.py b/pycorrfit/gui/update.py
new file mode 100644
index 0000000..32ce7d3
--- /dev/null
+++ b/pycorrfit/gui/update.py
@@ -0,0 +1,143 @@
+# -*- coding: utf-8 -*-
+"""PyCorrFit - update checking"""
+
+from distutils.version import LooseVersion # For version checking
+import os
+import tempfile
+import traceback
+import urllib2
+import webbrowser
+
+import simplejson
+import wx.html
+import wx.lib.delayedresult as delayedresult
+
+from .. import _version as pcf_version
+
+from . import doc                          # Documentation/some texts
+# The icon file was created with
+# img2py -i -n Main PyCorrFit_icon.png icon.py
+from . import misc
+
+
+
+class UpdateDlg(wx.Frame):
+    def __init__(self, parent, valuedict):
+        
+        description = valuedict["Description"]
+        homepage = valuedict["Homepage"]
+        githome = valuedict["Homepage_GIT"]
+        changelog = valuedict["Changelog"]
+        pos = parent.GetPosition()
+        pos = (pos[0]+100, pos[1]+100)
+        wx.Frame.__init__(self, parent, wx.ID_ANY, title="Update", 
+                          size=(230,240), pos=pos)
+        self.changelog = changelog
+        # Fill html content
+        html = wxHTML(self)
+        string = '' \
+                 + "<b> PyCorrFit <br></b>" \
+                 + "Your version: {}<br>".format(description[0]) \
+                 + "Latest version: {}<br>".format(description[1]) \
+                 + "({})<br><p><b>".format(description[2])
+        if homepage:
+            string = string + '<a href="{}">Homepage</a><br>'.format(homepage)
+        if githome:
+            string = string + '<a href="{}">Repository</a><br>'.format(githome)
+
+        if changelog:
+            string = string + \
+                     '<a href="{}">Change Log</a>'.format(changelog)
+        string += '</b></p>'
+        html.SetPage(string)
+        self.Bind(wx.EVT_CLOSE, self.Close)
+        # Set window icon
+        ico = misc.getMainIcon()
+        wx.Frame.SetIcon(self, ico)
+
+
+    def Close(self, event):
+        if len(self.changelog) != 0:
+            # Cleanup downloaded file, if it was downloaded
+            if self.changelog != doc.StaticChangeLog:
+                os.remove(self.changelog)
+        self.Destroy()
+
+
+class wxHTML(wx.html.HtmlWindow):
+    def OnLinkClicked(self, link):
+        webbrowser.open(link.GetHref())
+
+
+def get_gh_version(ghrepo="user/repo", timeout=20):
+    """ Check GitHub repository for latest release
+    """
+    u = "https://api.github.com/repos/{}/releases/latest".format(ghrepo)
+    try:
+        data = urllib2.urlopen(u, timeout=timeout).read()
+    except:
+        newversion = None
+        try:
+            with open("check_update_error.log", "w") as fe:
+                fe.writelines(str(traceback.format_exc()))
+        except:
+            pass
+    else:
+        j = simplejson.loads(data)
+        newversion = LooseVersion(j["tag_name"])
+
+    return newversion
+    
+
+def update(parent):
+    """ This is a thread for _Update """
+    parent.StatusBar.SetStatusText("Connecting to server...")
+    delayedresult.startWorker(_update_consumer, _update_worker,
+                              wargs=(parent,), cargs=(parent,))
+
+def _update_consumer(delayedresult, parent):
+    results = delayedresult.get()
+    dlg = UpdateDlg(parent, results)
+    dlg.Show()
+    parent.StatusBar.SetStatusText("...update status: "+results["Description"][2])
+
+
+def _update_worker(parent):
+    # Online changelog file
+    cl_file = doc.GitChLog
+    try:
+        responseVer = urllib2.urlopen(cl_file, timeout=2)
+    except:
+        changelog = ""
+    else:
+        changelog = responseVer.read()
+    
+    ghrepo="FCS-analysis/PyCorrFit"
+    if hasattr(pcf_version, "repo_tag"):
+        old = LooseVersion(pcf_version.repo_tag)
+    else:
+        old = LooseVersion(pcf_version.version)
+
+    new = get_gh_version(ghrepo)
+    
+    if new is not None:
+        if new > old:
+            action = "update available"
+        elif new < old:
+            action = "ahead of release"
+        else:
+            action = "state of the art"
+    description = [old, new, action]
+    if changelog:
+        changelogfile = tempfile.mktemp()+"_PyCorrFit_CHANGELOG"+".txt"
+        clfile = open(changelogfile, 'wb')
+        clfile.write(changelog)
+        clfile.close()            
+    else:
+        changelogfile=doc.StaticChangeLog
+    results = dict()
+    results["Description"] = description
+    results["Homepage"] = doc.HomePage
+    results["Homepage_GIT"] = doc.GitHome
+    results["Changelog"] = changelogfile
+    return results
diff --git a/pycorrfit/meta.py b/pycorrfit/meta.py
index 210455a..3ea6845 100644
--- a/pycorrfit/meta.py
+++ b/pycorrfit/meta.py
@@ -55,20 +55,3 @@ def get_file_location(filename):
     # if this does not work:
     return None
 
-
-def get_version():
-    """
-    Get the version.
-    """
-    StaticChangeLog = get_file_location("ChangeLog.txt")
-
-    # Check if we can extract the version
-    try:
-        clfile = open(StaticChangeLog, 'r')
-        version = clfile.readline().strip()
-        clfile.close()     
-    except:
-        version = "0.0.0-unknown"
-        
-        
-    return version
\ No newline at end of file
diff --git a/pycorrfit/openfile.py b/pycorrfit/openfile.py
index 47033b4..5601537 100644
--- a/pycorrfit/openfile.py
+++ b/pycorrfit/openfile.py
@@ -20,9 +20,8 @@ import warnings
 from .readfiles import Filetypes  # @UnusedImport
 from .readfiles import BGFiletypes  # @UnusedImport
 from .trace import Trace
-from . import meta
 
-__version__ = meta.get_version()
+from ._version import version as __version__
 
 
 def LoadSessionData(sessionfile, parameters_only=False):
diff --git a/pycorrfit/readfiles/read_ASC_ALV.py b/pycorrfit/readfiles/read_ASC_ALV.py
index c2fc80b..de00519 100644
--- a/pycorrfit/readfiles/read_ASC_ALV.py
+++ b/pycorrfit/readfiles/read_ASC_ALV.py
@@ -19,8 +19,8 @@ def openASC(dirname, filename):
     
     # Open special format?
     filetype = Alldata[0].strip() 
-    if filetype in ["ALV-7004/USB"]:
-        return openASC_ALV_7004_USB(path)
+    if filetype.count("ALV-7004"):
+        return openASC_ALV_7004(path)
     else:
         # last resort
         return openASC_old(path)
@@ -336,7 +336,7 @@ def openASC_old(path):
     return dictionary
 
 
-def openASC_ALV_7004_USB(path):
+def openASC_ALV_7004(path):
     """
     Opens ALV file format with header information "ALV-7004/USB" 
     
@@ -381,61 +381,137 @@ def openASC_ALV_7004_USB(path):
     # Find the different arrays
     # correlation array: "  "
     # trace array: "       "
-    Allcorr = list()
-    Alltrac = list()
+    allcorr = []
+    alltrac = []
     i=0
     intrace = False
+    mode = False
     for item in Alldata:
-        if item.lower().strip().strip('"').replace(" ", "") == "countrate":
+        if item.lower().strip().strip('"') == "count rate":
             intrace = True
+            continue
+        elif item.count("Mode"):
+            mode = item.split(":")[1].strip().strip('" ').lower()
         i += 1
         if item.count("\t") == 4: 
             if intrace:
                 it = item.split("\t")
                 it = [ float(t.strip()) for t in it ]
-                Alltrac.append(it)
+                alltrac.append(it)
             else:
                 ic = item.split("\t")
                 ic = [ float(c.strip()) for c in ic ]
-                Allcorr.append(ic)
-    Allcorr = np.array(Allcorr)
-    Alltrac = np.array(Alltrac)
-    
-    # Allcorr: lag time, ac1, ac2, cc12, cc21
-    # Alltrac: time, trace1, trace2, trace1, trace2
-    assert np.allclose(Alltrac[:,1], Alltrac[:,3], rtol=.01), "unknown ALV file format"
-    assert np.allclose(Alltrac[:,2], Alltrac[:,4], rtol=.01), "unknown ALV file format"
-    
-    guesstypelist = ["AC1", "AC2", "CC12", "CC21"]
-    typelist = list()
-    corrlist = list()
-    tracelist = list()
-    filelist = list()
+                allcorr.append(ic)
+    allcorr = np.array(allcorr)
+    alltrac = np.array(alltrac)
+
+    tau = allcorr[:,0]
+    time = alltrac[:,0] * 1000
+    lenc = allcorr.shape[0]
+    lent = alltrac.shape[0]
+
+    # Traces
+    trace1 = np.zeros((lent, 2), dtype=np.float_)
+    trace1[:,0] = time
+    trace1[:,1] = alltrac[:,1]
+    trace2 = trace1.copy()
+    trace2[:,1] = alltrac[:,2]
+    trace3 = trace1.copy()
+    trace3[:,1] = alltrac[:,3]
+    trace4 = trace1.copy()
+    trace4[:,1] = alltrac[:,4]
+
+    # Correlations
+    corr1 = np.zeros((lenc, 2), dtype=np.float_)
+    corr1[:,0] = tau
+    corr1[:,1] = allcorr[:,1]
+    corr2 = corr1.copy()
+    corr2[:,1] = allcorr[:,2]
+    corr3 = corr1.copy()
+    corr3[:,1] = allcorr[:,3]
+    corr4 = corr1.copy()
+    corr4[:,1] = allcorr[:,4]
+
+    typelist = []
+    corrlist = []
+    tracelist = []
+    filelist = []
     
-    lagtime = Allcorr[:,0]
-    time = Alltrac[:,0]*1000
-    trace1 = np.dstack((time, Alltrac[:,1]))[0]
-    trace2 = np.dstack((time, Alltrac[:,2]))[0]
+    assert mode, "Could not determine ALV file mode: {}".format(path)
     
-    for i, typ in enumerate(guesstypelist):
-        corr = np.dstack((lagtime, Allcorr[:,i+1]))[0]
-        
-        if not np.allclose(corr[:,1], np.zeros_like(lagtime)):
-            # type
-            typelist.append(typ)
-            # correlation
-            corrlist.append(corr)
-            # trace
-            if typ.count("CC"):
-                tracelist.append([trace1, trace2])
-            elif typ.count("AC1"):
-                tracelist.append([trace1])
-            elif typ.count("AC2"):
-                tracelist.append([trace2])
-            else:
-                raise ValueError("Unknown ALV file format")
-            # filename
+    # Go through all modes
+    if mode == "a-ch0+1  c-ch0/1+1/0":
+        # For some reason, the traces columns show the values
+        # of channel 1 and 2 in channels 3 and 4.
+        assert np.allclose(trace1, trace3, rtol=.01)
+        assert np.allclose(trace2, trace4, rtol=.01)
+        if not np.allclose(corr1[:,1], 0):
+            corrlist.append(corr1)
+            filelist.append(filename)
+            tracelist.append(trace1)
+            typelist.append("AC1")
+        if not np.allclose(corr2[:,1], 0):
+            corrlist.append(corr2)
+            filelist.append(filename)
+            tracelist.append(trace2)
+            typelist.append("AC2")
+        if not np.allclose(corr3[:,1], 0):
+            corrlist.append(corr3)
+            filelist.append(filename)
+            tracelist.append([trace1, trace2])
+            typelist.append("CC12")
+        if not np.allclose(corr4[:,1], 0):
+            corrlist.append(corr4)
             filelist.append(filename)
+            tracelist.append([trace1, trace2])
+            typelist.append("CC21")
+    elif mode in ["a-ch0", "a-ch0 a-"]:
+        assert np.allclose(trace2[:,1], 0)
+        assert np.allclose(trace3[:,1], 0)
+        assert np.allclose(trace4[:,1], 0)
+        assert np.allclose(corr2[:,1], 0)
+        assert np.allclose(corr3[:,1], 0)
+        assert np.allclose(corr4[:,1], 0)
+        corrlist.append(corr1)
+        filelist.append(filename)
+        tracelist.append(trace1)
+        typelist.append("AC")
+    elif mode in ["a-ch1", "a-ch1 a-"]:
+        assert np.allclose(trace1[:,1], 0)
+        assert np.allclose(trace3[:,1], 0)
+        assert np.allclose(trace4[:,1], 0)
+        assert np.allclose(corr1[:,1], 0)
+        assert np.allclose(corr3[:,1], 0)
+        assert np.allclose(corr4[:,1], 0)
+        corrlist.append(corr2)
+        filelist.append(filename)
+        tracelist.append(trace2)
+        typelist.append("AC")
+    elif mode in ["a-ch2", "a- a-ch2"]:
+        assert np.allclose(trace1[:,1], 0)
+        assert np.allclose(trace2[:,1], 0)
+        assert np.allclose(trace4[:,1], 0)
+        assert np.allclose(corr1[:,1], 0)
+        assert np.allclose(corr2[:,1], 0)
+        assert np.allclose(corr4[:,1], 0)
+        corrlist.append(corr3)
+        filelist.append(filename)
+        tracelist.append(trace3)
+        typelist.append("AC")
+    elif mode in ["a-ch3", "a- a-ch3"]:
+        assert np.allclose(trace1[:,1], 0)
+        assert np.allclose(trace2[:,1], 0)
+        assert np.allclose(trace3[:,1], 0)
+        assert np.allclose(corr1[:,1], 0)
+        assert np.allclose(corr2[:,1], 0)
+        assert np.allclose(corr3[:,1], 0)
+        corrlist.append(corr4)
+        filelist.append(filename)
+        tracelist.append(trace4)
+        typelist.append("AC")
+    else:
+        msg = "ALV mode '{}' not implemented yet.".format(mode)
+        raise NotImplementedError(msg)
 
     dictionary = dict()
     dictionary["Correlation"] = corrlist
diff --git a/pycorrfit/readfiles/read_FCS_Confocor3.py b/pycorrfit/readfiles/read_FCS_Confocor3.py
index 3e5658e..6bb401b 100644
--- a/pycorrfit/readfiles/read_FCS_Confocor3.py
+++ b/pycorrfit/readfiles/read_FCS_Confocor3.py
@@ -301,6 +301,7 @@ def openFCS_Single(dirname, filename):
     """
     openfile = open(os.path.join(dirname, filename), 'r')
     Alldata = openfile.readlines()
+    openfile.close()
     # Start progressing through the file. i is the line index.
     # We are searching for "FcsDataSet" sections that contain
     # all the information we want.
@@ -366,8 +367,7 @@ def openFCS_Single(dirname, filename):
     # on mac OSx and potentially affects fitting.
     if corr[0][0] == 0:
         corr = corr[1:]
-    openfile.close()
-    dictionary = dict()
+    dictionary = {}
     dictionary["Correlation"] = [corr]
     dictionary["Trace"] = [newtrace]
     dictionary["Type"] = [""]
diff --git a/pycorrfit/readfiles/read_pt3_scripts/README b/pycorrfit/readfiles/read_pt3_scripts/README
index a09248a..ca94132 100644
--- a/pycorrfit/readfiles/read_pt3_scripts/README
+++ b/pycorrfit/readfiles/read_pt3_scripts/README
@@ -7,8 +7,12 @@ https://github.com/dwaithe/FCS_point_correlator
 - import_methods.py
 
 The following changes were performed:
-- fib4.pyx
+- `fib4.pyx`
   A doc string was inserted.
-- correlation_objects.py
+- `correlation_objects.py`
   Line 7 was commented out:
   #from lmfit import minimize, Parameters,report_fit,report_errors, fit_report
+- `correlation_methods.py`
+  Support for NumPy 0.13 was added:
+  - https://github.com/FCS-analysis/PyCorrFit/commit/132991c7a2950c0c380c6df6edf433f61911a6db
+  - https://github.com/dwaithe/FCS_point_correlator/issues/2
\ No newline at end of file
diff --git a/pycorrfit/readfiles/read_pt3_scripts/correlation_methods.py b/pycorrfit/readfiles/read_pt3_scripts/correlation_methods.py
index a905526..4f6016f 100644
--- a/pycorrfit/readfiles/read_pt3_scripts/correlation_methods.py
+++ b/pycorrfit/readfiles/read_pt3_scripts/correlation_methods.py
@@ -89,12 +89,13 @@ def tttr2xfcs (y,num,NcascStart,NcascEnd, Nsub):
                 i1,i2 = fib4.dividAndConquer(y, y+lag,y.shape[0])
 
                 #If the weights (num) are one as in the first Ncasc round, then the correlation is equal to np.sum(i1)
-                i1 = i1.astype(np.bool);
-                i2 = i2.astype(np.bool);
+                i1 = np.where(i1.astype(np.bool))[0]
+                i2 = np.where(i2.astype(np.bool))[0]
 
                 #Now we want to weight each photon corectly.
                 #Faster dot product method, faster than converting to matrix.
-                auto[(k+(j)*Nsub),:,:] = np.dot((num[i1,:]).T,num[i2,:])/delta    
+                if i1.size and i2.size:
+                    auto[(k+(j)*Nsub),:,:] = np.dot((num[i1,:]).T,num[i2,:])/delta    
             
             autotime[k+(j)*Nsub] =shift;
         
@@ -108,8 +109,9 @@ def tttr2xfcs (y,num,NcascStart,NcascEnd, Nsub):
 
 
     #Removes the trailing zeros.
-    autotime = autotime[autotime != 0]
-    auto = auto[autotime != 0,:,:]
+    idauto = np.where(autotime != 0)[0]
+    autotime = autotime[idauto]
+    auto = auto[idauto,:,:]
     return auto, autotime
 
 
diff --git a/setup.py b/setup.py
index 5f94a58..5be9a6e 100644
--- a/setup.py
+++ b/setup.py
@@ -51,16 +51,6 @@ else:
         except:
             print("Failed to download documentation.")
     
-# Get the version of PyCorrFit from the Changelog.txt
-StaticChangeLog = join(dirname(realpath(__file__)), "ChangeLog.txt")
-try:
-    clfile = open(StaticChangeLog, 'r')
-    version = clfile.readline().strip()
-    clfile.close()     
-except:
-    warn("Could not find 'ChangeLog.txt'. PyCorrFit version is unknown.")
-    version = "0.0.0-unknown"
-
 # Parameters
 author = u"Paul Müller"
 authors = [author]
@@ -68,6 +58,12 @@ description = 'Scientific tool for fitting correlation curves on a logarithmic p
 name = 'pycorrfit'
 year = "2014"
 
+sys.path.insert(0, realpath(dirname(__file__))+"/"+name)
+try:
+    from _version import version
+except:
+    version = "unknown"
+
 setup(
     
     author=author,
@@ -110,7 +106,11 @@ setup(
         # If you need the GUI of this project in your project, add
         # "thisproject[GUI]" to your install_requires
         # Graphical User Interface
-        'GUI':  ["wxPython", "matplotlib >= 1.1.0", "sympy >= 0.7.2"],
+        'GUI':  ["wxPython",
+                 "matplotlib >= 1.1.0",
+                 "sympy >= 0.7.2",
+                 "simplejson", # for updates
+                 ],
         },
     install_requires=[
         "NumPy >= 1.5.1",
diff --git a/tests/data_file_dl.py b/tests/data_file_dl.py
index 2e697e7..8cfe00f 100644
--- a/tests/data_file_dl.py
+++ b/tests/data_file_dl.py
@@ -25,6 +25,7 @@ pool_manager = urllib3.PoolManager()
 
 _fcs_data_tree = None
 
+
 def dl_file(url, dest, chunk_size=6553,
             http=pool_manager):
     """
@@ -60,18 +61,22 @@ def get_data_file(filename, dldir=dldir, pool_manager=pool_manager,
     """
     _f, ext = os.path.splitext(filename)
     assert ext != "", "filename has no extension!"
-    files = get_data_files_ext(extension=ext, dldir=dldir,
-                               pool_manager=pool_manager,
-                               api_origin=api_origin,
-                               raw_origin=raw_origin)
+    extp = ext.strip(".").lower()
     
-    files = [ f for f in files if f.count(filename) ]
-    assert len(files) != 0, "filename not found"
-    return files[0]
+    fbase = filename
+    fdir = os.path.join(dldir, extp)
+    fpath = os.path.join(fdir, fbase)
+
+    if not os.path.exists(fpath):
+        # download file if it does not exist
+        url = raw_origin+extp+"/"+fbase
+        dl_file(url, fpath)
+
+    return fpath
 
 
 def get_data_files_ext(extension, dldir=dldir, pool_manager=pool_manager,
-                      api_origin=api_origin, raw_origin=raw_origin):
+                       api_origin=api_origin, raw_origin=raw_origin):
     """
     Get all files in the repository `origin` that are
     in the folder `extension` and have a file-ending
@@ -122,9 +127,9 @@ def get_data_files_ext(extension, dldir=dldir, pool_manager=pool_manager,
                 dl_file(join(raw_origin, f), dest)
             dl_files.append(dest)
             
-    except urllib3.exceptions.MaxRetryError:
+    except (urllib3.exceptions.MaxRetryError, KeyError):
         # e.g. no internet connection
-        warnings.warn("Non connection, using previuously downloaded files only.")
+        warnings.warn("No connection, using previuously downloaded files only.")
         files = get_data_tree_local(dldir=dldir)
         dl_files = [ f for f in files if f.lower().endswith(ext)]
 
diff --git a/tests/test_constraints.py b/tests/test_constraints.py
index 24f2f62..db889b0 100644
--- a/tests/test_constraints.py
+++ b/tests/test_constraints.py
@@ -19,12 +19,13 @@ import pycorrfit as pcf
 
 NOAPITOKEN = "GITHUB_API_TOKEN" not in os.environ
 
+examplefile = "Zeiss_Confocor3_LSM780_FCCS_HeLa_2015/019_cp_KIND+BFA.fcs"
 
 @pytest.mark.xfail(NOAPITOKEN, reason="Restrictions to GitHub API")
 def test_fit_constraint_simple_inequality():
     """ Check "smaller than" relation during fitting.
     """
-    dfile = data_file_dl.get_data_file("019_cp_KIND+BFA.fcs")
+    dfile = data_file_dl.get_data_file(examplefile)
     data = pcf.readfiles.openAny(dfile)
     corr = pcf.Correlation(correlation=data["Correlation"][0],
                            traces=data["Trace"][0],
@@ -55,7 +56,7 @@ def test_fit_constraint_simple_inequality():
 def test_fit_constraint_sum_smaller_one():
     """ Check "a+b<c" relation during fitting.
     """
-    dfile = data_file_dl.get_data_file("019_cp_KIND+BFA.fcs")
+    dfile = data_file_dl.get_data_file(examplefile)
     data = pcf.readfiles.openAny(dfile)
     corr = pcf.Correlation(correlation=data["Correlation"][0],
                            traces=data["Trace"][0],
diff --git a/tests/test_file_formats.py b/tests/test_file_formats.py
index 59b9602..0ded8c6 100644
--- a/tests/test_file_formats.py
+++ b/tests/test_file_formats.py
@@ -1,8 +1,6 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-"""
-Test if pycorrfit can open all file formats.
-"""
+"""Test support for FCS file formats"""
 from __future__ import division, print_function
 
 import numpy as np
@@ -23,20 +21,129 @@ NOAPITOKEN = "GITHUB_API_TOKEN" not in os.environ
 
 
 @pytest.mark.xfail(NOAPITOKEN, reason="Restrictions to GitHub API")
-def test_open():
-    """
-    Try to open all files supported files
-    """
+def test_asc_all_open():
     # get list of supported file extensions
-    for ext in pycorrfit.readfiles.get_supported_extensions():
-        files = data_file_dl.get_data_files_ext(ext)
-        for f in files:
-            if len([ex for ex in exclude if f.endswith(ex) ]):
-                continue
-            print(f)
-            dn, fn = split(f)
-            data = pycorrfit.readfiles.openAny(dn, fn)
-            assert len(data)
+    ext = "alv"
+    files = data_file_dl.get_data_files_ext(ext)
+    for f in files:
+        if len([ex for ex in exclude if f.endswith(ex) ]):
+            continue
+        dn, fn = split(f)
+        data = pycorrfit.readfiles.openAny(dn, fn)
+        assert len(data)
+
+
+ at pytest.mark.xfail(NOAPITOKEN, reason="Restrictions to GitHub API")
+def test_asc_alv7004usb():
+    """Test alv7004/USB format"""
+    f1 = data_file_dl.get_data_file("ALV-7004USB_ac01_cc01_10.ASC")
+    data = pycorrfit.readfiles.openAny(f1)
+    assert data["Type"] == ["AC1", "AC2", "CC12", "CC21"]
+    assert np.allclose(data["Correlation"][0][10], np.array([0.000275, 0.11208]))
+    assert np.allclose(data["Correlation"][1][12], np.array([0.000325, 0.0900233]))
+    assert np.allclose(data["Correlation"][2][18], np.array([0.00055, 0.0582773]))
+    assert np.allclose(data["Correlation"][3][120], np.array([3.6864, 0.0224212]))
+    assert len(data["Trace"][0]) == 253
+    assert len(data["Trace"][1]) == 253
+    assert len(data["Trace"][2]) == 2
+    assert len(data["Trace"][3]) == 2
+    assert np.all(data["Trace"][0] == data["Trace"][2][0])
+    assert np.all(data["Trace"][1] == data["Trace"][2][1])
+    assert np.all(data["Trace"][0] == data["Trace"][3][0])
+    assert np.all(data["Trace"][1] == data["Trace"][3][1])
+    assert np.allclose(data["Trace"][0][10], np.array([1289.06, 140.20404]))
+    assert np.allclose(data["Trace"][1][100], np.array([11835.94, 94.68225]))
+
+    f2 = data_file_dl.get_data_file("ALV-7004USB_dia10_cen10_0001.ASC")
+    data2 = pycorrfit.readfiles.openAny(f2)
+    # There are empty AC2 and CC12/CC21 curves in this file that should be removed
+    # by pycorrfit.
+    assert data2["Type"] == ["AC1"]
+    assert np.allclose(data2["Correlation"][0][56], np.array([0.0144, 0.0513857]))
+    assert len(data2["Trace"][0]) == 254
+    assert np.allclose(data2["Trace"][0][210], np.array([49453.13, 165.41434]))
+
+    f3 = data_file_dl.get_data_file("ALV-7004.ASC")
+    data3 = pycorrfit.readfiles.openAny(f3)
+    assert len(data3["Type"]) == 1
+    assert len(data3["Trace"][0]) == 66
+    assert data3["Type"][0] == "AC"
+    assert np.allclose(data3["Correlation"][0][56], np.array([0.0144, 0.38757]))
+    assert np.allclose(data3["Trace"][0][60], np.array([1.21523440e5, 5.11968700e1]))
+
+    f4 = data_file_dl.get_data_file("ALV-7004USB_ac3.ASC")
+    data4 = pycorrfit.readfiles.openAny(f4)
+    assert len(data4["Type"]) == 1
+    assert data4["Type"][0] == "AC"
+    assert len(data4["Trace"][0]) == 254
+
+
+ at pytest.mark.xfail(NOAPITOKEN, reason="Restrictions to GitHub API")
+def test_csv_all_open():
+    # get list of supported file extensions
+    ext = "csv"
+    files = data_file_dl.get_data_files_ext(ext)
+    for f in files:
+        if len([ex for ex in exclude if f.endswith(ex) ]):
+            continue
+        dn, fn = split(f)
+        data = pycorrfit.readfiles.openAny(dn, fn)
+        assert len(data)
+
+
+ at pytest.mark.xfail(NOAPITOKEN, reason="Restrictions to GitHub API")
+def test_fcs_all_open():
+    # get list of supported file extensions
+    ext = "fcs"
+    files = data_file_dl.get_data_files_ext(ext)
+    for f in files:
+        if len([ex for ex in exclude if f.endswith(ex) ]):
+            continue
+        dn, fn = split(f)
+        data = pycorrfit.readfiles.openAny(dn, fn)
+        assert len(data)
+
+
+ at pytest.mark.xfail(NOAPITOKEN, reason="Restrictions to GitHub API")
+def test_pt3_all_open():
+    # get list of supported file extensions
+    ext = "pt3"
+    files = data_file_dl.get_data_files_ext(ext)
+    for f in files:
+        if len([ex for ex in exclude if f.endswith(ex) ]):
+            continue
+        dn, fn = split(f)
+        data = pycorrfit.readfiles.openAny(dn, fn)
+        assert len(data)
+
+
+ at pytest.mark.xfail(NOAPITOKEN, reason="Restrictions to GitHub API")
+def test_pt3_basic():
+    f1 = data_file_dl.get_data_file("PicoQuant_SymphoTime32_A42F-4jul2014/Point_1.pt3")
+    data = pycorrfit.readfiles.openAny(f1)
+    
+    trace = data["Trace"][0][0]
+    assert trace.shape == (600, 2)
+    assert np.allclose(trace[40], np.array([2037, 6.48]))
+    
+    corr = data["Correlation"][0]
+    assert corr.shape == (150, 2)
+    assert np.allclose(corr[40], np.array([0.000698, 0.58007174877053136]))
+    assert np.allclose(corr[100], np.array([0.72089, 0.019201608388821567]))
+
+
+ at pytest.mark.xfail(NOAPITOKEN, reason="Restrictions to GitHub API")
+def test_sin_all_open():
+    # get list of supported file extensions
+    ext = "sin"
+    files = data_file_dl.get_data_files_ext(ext)
+    for f in files:
+        if len([ex for ex in exclude if f.endswith(ex) ]):
+            continue
+        dn, fn = split(f)
+        data = pycorrfit.readfiles.openAny(dn, fn)
+        assert len(data)
+
 
 
 if __name__ == "__main__":

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/pycorrfit.git



More information about the debian-med-commit mailing list