File: __init__.py

package info (click to toggle)
scikit-rf 1.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 82,128 kB
  • sloc: python: 33,328; makefile: 130; sh: 19
file content (102 lines) | stat: -rw-r--r-- 2,088 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""
skrf is an object-oriented approach to microwave engineering,
implemented in Python.
"""

__version__ = '1.10.0'
## Import all  module names for coherent reference of name-space
#import io


from . import (
    calibration,
    circuit,
    constants,
    frequency,
    instances,
    io,
    mathFunctions,
    media,
    network,
    networkSet,
    qfactor,
    taper,
    tlineFunctions,
    util,
    vectorFitting,
)
from .calibration import *
from .circuit import *
from .constants import *

# Import contents into current namespace for ease of calling
from .frequency import *
from .instances import *
from .io import *
from .mathFunctions import *
from .network import *
from .networkSet import *
from .qfactor import *
from .taper import *
from .tlineFunctions import *
from .util import *
from .vectorFitting import *

# Try to import vi, but if except if pyvisa not installed
try:
    import vi
    from vi import *
except ImportError:
    pass

# try to import data but if it fails whatever. it fails if some pickles
# dont unpickle. but its not important
try:
    from . import data
except Exception:
    pass

def __getattr__(name: str):
    return getattr(instances._instances, name)

## built-in imports
from copy import deepcopy as copy

## Shorthand Names
F = Frequency
N = Network
NS = NetworkSet
C = Circuit
lat = load_all_touchstones
# saf  = save_all_figs
saf = None
stylely = None


def setup_pylab() -> bool:
    try:
        import matplotlib
    except ImportError:
        print("matplotlib not found while setting up plotting")
        return False

    from . import plotting

    global saf, stylely
    saf = plotting.save_all_figs
    stylely = plotting.stylely
    return True


def setup_plotting():
    plotting_environment = os.environ.get('SKRF_PLOT_ENV', "pylab").lower()

    if plotting_environment == "pylab":
        setup_pylab()
    elif plotting_environment == "pylab-skrf-style":
        if setup_pylab():
            stylely()
    # elif some different plotting environment
        # set that up

plotting_available = setup_plotting()