Exemple #1
0
 def read_file(cls,
               filename,
               make_complex=True,
               property_to_vars=True,
               guess_unit=True,
               normalize=True,
               make_matrix=False,
               merge=True,
               verbose=False,
               multiple_files=True,
               hyper=False,
               encoding="cp1252",
               **kw):
     obj = cls(make_complex=make_complex,
               property_to_vars=property_to_vars,
               guess_unit=guess_unit,
               normalize=normalize,
               make_matrix=make_matrix,
               merge=merge,
               verbose=verbose,
               hyper=hyper,
               **kw)
     obj.filename = filename
     if multiple_files:
         if isinstance(filename, (list, tuple)):
             filenames = []
             for f in filename:
                 filenames.extend(glob(f))
         else:
             filenames = glob(filename)
     else:
         filenames = [filename]
     filenames = [path(f) for f in filenames]
     objs = []
     if not filenames:
         raise IOError("Pattern %r did not match any files" % filename)
     for idx, fname in enumerate(filenames):
         if verbose:
             print("\r%-80s\r" % fname.basename(), end="")
         with io.open(fname, encoding=encoding) as fil:
             res = obj.do_file(fil)
             if multiple_files:
                 #res["FILEINDEX"] = DimPartial("FILEINDEX", [idx])
                 fname = py3.cast_unicode(fname)
                 if "FILENAME" not in res:
                     res["FILENAME"] = hfarray(fname)
             objs.append(res)
     if multiple_files:
         res = obj._merge(objs)
     else:
         res = objs
     if verbose:
         print("\r%80s\r" % "")
     return res
Exemple #2
0
 def setUp(self):
     self.db = db = DataBlock()
     fi = DimSweep("freq", [1e9, 2e9, 3e9, 4e9], unit="Hz")
     db.y = hfarray([1, 2, 3, 4], dims=(fi, ), unit="V")
     db.z = hfarray([1, 2, 3, 4 + 0j], dims=(fi, ), unit="Ohm")
     self.fig = plt.figure(1)
     self.ax = plt.subplot(111, projection=self.proj)
     self.lines = plt.plot(self.db.y)
     self.outpath = p = path(basepath / "savetest")
     if not p.exists():  # pragma: no cover
         p.makedirs()
Exemple #3
0
 def setUp(self):
     self.db = db = DataBlock()
     fi = DimSweep("freq", [1e9, 2e9, 3e9, 4e9], unit="Hz")
     db.y = hfarray([1, 2, 3, 4], dims=(fi, ), unit="V")
     db.z = hfarray([1, 2, 3, 4 + 0j], dims=(fi, ), unit="Ohm")
     self.fig = plt.figure(1)
     self.ax = plt.subplot(111, projection=self.proj)
     self.lines = plt.plot(self.db.y)
     self.outpath = p = path(basepath / "savetest")
     if not p.exists():  # pragma: no cover
         p.makedirs()
 def setUpClass(cls):
     p = path(testpath / "testdata/hdf5/v02/savetest")
     if not p.exists():  # pragma: no cover
         p.makedirs()
 def tearDownClass(cls):
     p = path(testpath / "testdata/hdf5/v02/savetest")
     p.removedirs()
Exemple #6
0
 def tearDownClass(cls):
     p = path(testpath / "testdata/citi/savetest")
     p.removedirs()
Exemple #7
0
 def setUpClass(cls):
     p = path(testpath / "testdata/citi/savetest")
     if not p.exists():  # pragma: no cover
         p.makedirs()
Exemple #8
0
            Figur nummer, None anger aktiv figur.
    """
    if fig is None:
        fig = pylab.get_current_fig_manager()
    else:
        fig = Gcf.figs[fig]
    wm_geom = fig.window.wm_geometry()
    (x, y) = map(int, _reg_split_wm_geometry.split(wm_geom))[2:]
    return x, y


def get_figure_positions():
    """Hamta position for alla figurer

    """
    return [(i, get_current_figure_position(i)) for i in Gcf.figs.keys()]


if __name__ == '__main__':
    from hftools import path
    from hftools.file_formats import read_data
    datapath = (path(hftools.__file__).dirname() / "../data/").normpath()

    fwd = read_data(datapath / "fwd.s2p")
    cold = read_data(datapath / "cold.s2p")
    active = read_data(datapath / "active.s2p")

    plt.clf()
    plt.subplot(111, projection="db")
    plt.plot(fwd.S[..., 0, 0])
Exemple #9
0
#-----------------------------------------------------------------------------
# Copyright (c) 2014, HFTools Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import hftools.file_formats
from hftools import path
from hftools.testing import TestCase
from hftools.file_formats.tests import base_test
from hftools.dataset import DataBlock, hfarray, DimSweep
from hftools.file_formats.common import Comments

testpath = path(__file__).dirname()


class TestInitSPdata_1(base_test.Test_1):
    readfun = [hftools.file_formats.read_data]
    basepath = testpath
    dirname = "sp-data"
    extension = ".txt"
    readpars = dict(verbose=False)


class TestInitSPdata_1b(base_test.Test_1):
    readfun = [hftools.file_formats.read_data]
    basepath = testpath
    dirname = "sp-data"
    extension = ".txt"
    filename = "test1b"
Exemple #10
0
            Figur nummer, None anger aktiv figur.
    """
    if fig is None:
        fig = pylab.get_current_fig_manager()
    else:
        fig = Gcf.figs[fig]
    wm_geom = fig.window.wm_geometry()
    (x, y) = map(int, _reg_split_wm_geometry.split(wm_geom))[2:]
    return x, y


def get_figure_positions():
    """Hamta position for alla figurer

    """
    return [(i, get_current_figure_position(i)) for i in Gcf.figs.keys()]


if __name__ == '__main__':
    from hftools import path
    from hftools.file_formats import read_data
    datapath = (path(hftools.__file__).dirname() / "../data/").normpath()

    fwd = read_data(datapath / "fwd.s2p")
    cold = read_data(datapath / "cold.s2p")
    active = read_data(datapath / "active.s2p")

    plt.clf()
    plt.subplot(111, projection="db")
    plt.plot(fwd.S[..., 0, 0])
Exemple #11
0
 def tearDownClass(cls):
     p = path(basepath / "savetest")
     for f in p.glob("*"):  # pragma: no cover
         f.unlink()
     p.removedirs()
Exemple #12
0
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter, EngFormatter

import hftools
import hftools.utils as utils
import hftools.testing as testing
import hftools.plotting.helper as plthelp
from hftools import path
from hftools.dataset import hfarray, DataBlock, DimSweep
from hftools.testing import TestCase, make_load_tests, expectedFailure
#import warnings
#warnings.filterwarnings(action='error', category=DeprecationWarning)
#utils.reset_hftools_warnings()

#load_tests = make_load_tests(utils)
basepath = path(__file__).dirname()


class Test_db_axes(TestCase):
    proj = "db"

    def setUp(self):
        self.db = db = DataBlock()
        fi = DimSweep("freq", [1e9, 2e9, 3e9, 4e9], unit="Hz")
        db.y = hfarray([1, 2, 3, 4], dims=(fi, ), unit="V")
        db.z = hfarray([1, 2, 3, 4 + 0j], dims=(fi, ), unit="Ohm")
        self.fig = plt.figure(1)
        self.ax = plt.subplot(111, projection=self.proj)
        self.lines = plt.plot(self.db.y)
        self.outpath = p = path(basepath / "savetest")
        if not p.exists():  # pragma: no cover
Exemple #13
0
        d = hftools.file_formats.merge_blocks(out)
    else:
        d = read_single_muwave_matlabdata(filenames[0], drop_empty=drop_empty)

    order = [d.ivardata[dim] for dim in ["freq", "Index", "Index2"] if dim in d.S.dims]

    d.S = d.S.reorder_dimensions(*order)
    if drop_empty:
        for k in d.vardata.keys():
            if np.all("" == d[k]):
                del d[k]
    return d


if __name__ == "__main__":
    p = path("ColdSource-muwave")
    p1 = path("ColdSource-muwave/ColdSource_Vg_m2.mat")
    p2 = path("ColdSource-muwave/ColdSource_Vg_m2_5.mat")

    d = read_muwave_matlabdata(p / "*.mat")

    figure(1)
    clf()
    subplot(221, projection="smith")
    plot(d.S11)
    subplot(224, projection="smith")
    plot(d.S22)

    figure(2)
    clf()
    subplot(111, projection="db")
Exemple #14
0
    order = [
        d.ivardata[dim] for dim in ["freq", "Index", "Index2"]
        if dim in d.S.dims
    ]

    d.S = d.S.reorder_dimensions(*order)
    if drop_empty:
        for k in d.vardata.keys():
            if np.all("" == d[k]):
                del d[k]
    return d


if __name__ == "__main__":
    p = path("ColdSource-muwave")
    p1 = path("ColdSource-muwave/ColdSource_Vg_m2.mat")
    p2 = path("ColdSource-muwave/ColdSource_Vg_m2_5.mat")

    d = read_muwave_matlabdata(p / "*.mat")

    figure(1)
    clf()
    subplot(221, projection="smith")
    plot(d.S11)
    subplot(224, projection="smith")
    plot(d.S22)

    figure(2)
    clf()
    subplot(111, projection="db")
Exemple #15
0
 def tearDownClass(cls):
     p = path(basepath / "savetest")
     for f in p.glob("*"):  # pragma: no cover
         f.unlink()
     p.removedirs()
Exemple #16
0
 def tearDownClass(cls):
     p = path(testpath / "testdata/hdf5/v02/savetest")
     for f in p.glob("*"):  # pragma: no cover
         f.unlink()
     p.removedirs()
Exemple #17
0
 def tearDownClass(cls):
     p = path(testpath / "testdata/hdf5/v02/savetest")
     p.removedirs()
Exemple #18
0
 def tearDownClass(cls):
     p = path(testpath / "testdata/hdf5/v02/savetest")
     for f in p.glob("*"):  # pragma: no cover
         f.unlink()
     p.removedirs()
Exemple #19
0
#-----------------------------------------------------------------------------
# Copyright (c) 2014, HFTools Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import hftools.file_formats
import hftools.file_formats.tests.base_test as base_test
from hftools.file_formats.common import Comments
from hftools import path
from hftools.testing import TestCase
import hftools.file_formats.config as hfconfig
import datetime
testpath = path(__file__).dirname()

datapath = testpath / "testdata/config"


class TestLexical(TestCase):
    def test1(self):
        cfg = hfconfig.LexicalConfig(datapath / "lexical_1.yaml")
        self.assertEqual(cfg["VNA"]["gpib"], 16)
        self.assertEqual(cfg["VNA"]["ifbw"], 100)
        self.assertEqual(cfg["VNA"]["ifbw"].unit, "Hz")
        self.assertEqual(cfg["VNA"]["timespan"], datetime.timedelta(0, 72000))
        self.assertEqual(cfg["VNA"]["date"],
                         datetime.datetime(2010, 10, 10, 8, 30))
        now = datetime.datetime.now()
        tomorrow = datetime.datetime.now() + datetime.timedelta(1, 0)
        self.assertEqual(cfg["VNA"]["datelong"],
Exemple #20
0
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter, EngFormatter

import hftools
import hftools.utils as utils
import hftools.testing as testing
import hftools.plotting.helper as plthelp
from hftools import path
from hftools.dataset import hfarray, DataBlock, DimSweep
from hftools.testing import TestCase, make_load_tests, expectedFailure
#import warnings
#warnings.filterwarnings(action='error', category=DeprecationWarning)
#utils.reset_hftools_warnings()

#load_tests = make_load_tests(utils)
basepath = path(__file__).dirname()


class Test_db_axes(TestCase):
    proj = "db"

    def setUp(self):
        self.db = db = DataBlock()
        fi = DimSweep("freq", [1e9, 2e9, 3e9, 4e9], unit="Hz")
        db.y = hfarray([1, 2, 3, 4], dims=(fi, ), unit="V")
        db.z = hfarray([1, 2, 3, 4 + 0j], dims=(fi, ), unit="Ohm")
        self.fig = plt.figure(1)
        self.ax = plt.subplot(111, projection=self.proj)
        self.lines = plt.plot(self.db.y)
        self.outpath = p = path(basepath / "savetest")
        if not p.exists():  # pragma: no cover