<jupyter_start><jupyter_text>The *new* **Network** Class  Intro This notebook demonstrates the new design of skrf's **Network** Class. The new class utilizes a more object-oriented approach which is cleaner and more scalable. The draw-back is that it breaks backward compatibility. Creating a *new style* **Network** from an old<jupyter_code>import skrf as rf 
%matplotlib inline
from pylab import * 
rf.stylely()

from skrf import network2

a = network2.Network.from_ntwkv1(rf.data.ring_slot)<jupyter_output><empty_output><jupyter_text>The new **Network** class employs nested objects, which makes for a cleaner and more logical namespace. The basic structure is:* **Network**    * **Frequency ** (same as before)    * **Parameter** (s,z,y,etc)        * **Projection** ( db10, db20, deg, mag,etc)    Network Parameters Accessing a Network's parameters like `s`,`z`,or `y` returns a  **Parameters** object,<jupyter_code>type(a.s)<jupyter_output><empty_output><jupyter_text>You can get at the array by accessing the property `val`.<jupyter_code>a.s.val[:3]<jupyter_output><empty_output><jupyter_text>You can also slice the parameter directly. This can be used as an alternative way to access the values.<jupyter_code>a.s[:2]<jupyter_output><empty_output><jupyter_text>This nested-object desgin allows for more concise function calls. For example, plot functions become members of the parameters, which behave like you expect<jupyter_code>a.s.plot()
a.z.plot()
axis('equal')<jupyter_output><empty_output><jupyter_text>Projections Each parameter has members for various scalar projections.<jupyter_code>type(a.s.db)
type(a.s.deg)<jupyter_output><empty_output><jupyter_text>Their numerical values may be accessed through `val` attribute or by direct slicing, just like a **Parameter**<jupyter_code>a.s.db[:2]<jupyter_output><empty_output><jupyter_text>Projections also `plot()` as you expect<jupyter_code>a.s.db.plot();
a.s.deg.plot(1,0);<jupyter_output><empty_output><jupyter_text>Ipython Notebook display system One interesting advantage of using an object-oriented model for parameters and projections is that we can create [custom display logic](http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/notebooks/Custom%20Display%20Logic.ipynb) for the ipython notebook.  This allows us to define graphical  representations for an object, removing the need to call any plot method.<jupyter_code>a.s.db
a.z.im<jupyter_output><empty_output><jupyter_text>Accessing numpy array properties Numpy ndarray properties are accessable on both **Parameters** and **Projections **. These are implemented using python `__getattr__()` operator so they wont tab out, but you can still use em.<jupyter_code>a.s.db.plot()
axhline(a.s.db.min(),color='k')
axhline(a.s.db.max(),color='k')<jupyter_output><empty_output><jupyter_text>Frequency Band Selection Networks can sliced by an index on the frequency axis or by a human readable frequency selections,<jupyter_code>a[40:100] #slice by frequency index
a['82-92ghz'] # slice by a human readable string
a['82-92ghz'].s.db<jupyter_output><empty_output><jupyter_text>Subnetworks Individual s-parameters  can be accessed by calling a **Network** with the desired port indecies (*index starting from 0*)<jupyter_code>s11 = a(0,0) # s11
s22 = a(1,1) # s22
s12 = a(0,1) # s12
s21 = a(1,1) # s21

s11<jupyter_output><empty_output><jupyter_text>Time domain Time domain transform is implemented as a Parameter named `s_time`. Note that accessing this parameter implicitly  windows the s-parameters before taking the FFT. For finer control over the transform, use the functions `s2time`  and `windowed`.<jupyter_code>b = network2.Network.from_ntwkv1(rf.data.ring_slot_meas)
b.s_time.db<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10717142095441215, 'fraction_numerical': 0.01572913889629432, 'mean_word_length': 6.5951417004048585, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '144796', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1198, 'n_words': 365, 'path': 'doc/source/examples/internals/Network2.ipynb', 'repo_name': 'hohe/scikit-rf', 'size': '3751'}