scikit-rf / scikit-rf Goto Github PK
View Code? Open in Web Editor NEWRF and Microwave Engineering Scikit
Home Page: http://scikit-rf.org
License: BSD 3-Clause "New" or "Revised" License
RF and Microwave Engineering Scikit
Home Page: http://scikit-rf.org
License: BSD 3-Clause "New" or "Revised" License
Causes the following error:
Traceback (most recent call last):
File "P:\Test\skrftest.py", line 6, in
zin = tl.zl_2_zin(z0, zl, m.pi/4)
File "C:\Python27\lib\site-packages\scikit_rf-0.13-py2.7.egg\skrf\tlineFunctio
ns.py", line 452, in input_impedance_at_theta
Gamma_in = reflection_coefficient_at_theta(Gamma=Gamma, theta=theta)
TypeError: reflection_coefficient_at_theta() got an unexpected keyword argument
'Gamma'
On my system I implemented the following fix:
Rename the variable 'Gamma' in function 'input_impedance_at_theta' (lines 451, 452) to 'Gamma0'.
Hi!
Unfortunatly, the ylabel generated by NetworkSet.plot_uncertainty_bounds_s_db() is "Magnitude" instead of "Magnitude (dB)".
Most likely the overwritten attribute "s_mag" in line https://github.com/scikit-rf/scikit-rf/blob/master/skrf/networkSet.py#L910 is the reason. Have no idea how to fix that quickly.
Could we require numpy version >= 1.6? I'd like to use numpy.linalg.einsum, which is new in numpy 1.6.
Since commit 29387cb "Moving Network Plotting Methods ..." I need to use
import skrf
import skrf.plotting
skrf.plotting.setup_matplotlib_plotting()
instead of
import skrf
to my plotting python scripts. Is this the way I shall use the new plotting features? Is this documented somewhere?
I'm asking, because the examples are not working any more and I had to search some time for this solution.
When concatenating like this networkA**networkB, the resulting network seems to inherit the name from networkA. Would it be useful to set its name to networkA.name + " <=> " + networkB.name by default?
Using the 07149 revision and Python 2.6.5, I can't seem to deepcopy a loaded 1-port Network. I don't have the time now to set up a test that detects the bug and then fix it. Furthermore, I have a problem configuring git for our corporate proxy, so you will need to wait for my commits.
This bug is rather serious, because Calibration invokes a deepcopy on the provided measurements and ideals.
Do you succeed in reproducing the bug?
import skrf
import copy
loadedNetwork = skrf.Network('Y:\ADS\SOIC8_Fixture_Test_prj\misc\short_sma_calibration.s1p')
copiedNetwork = copy.deepcopy(loadedNetwork)
Traceback (most recent call last):
File "<tmp 2>", line 5, in
copiedNetwork = copy.deepcopy(loadedNetwork)
File "C:\Python26\lib\copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python26\lib\copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python26\lib\copy.py", line 162, in deepcopy
y = copier(x, memo)
File "C:\Python26\lib\copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python26\lib\copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python26\lib\copy.py", line 323, in _reconstruct
y = callable(*args)
File "C:\Python26\lib\copy_reg.py", line 93, in newobj
return cls.new(cls, *args)
TypeError: instancemethod expected at least 2 arguments, got 0
Here is the error I get:
UnsatisfiableError:
The following specifications were found to be in conflict:
Hi,
as stated, skrf.Network fail to read version 2.0 touchstone file.
the s4p file to be read
! Touchstone data file
[Version] 2.0
# Hz S MA R 50
[Number of Ports] 4
[Number of Frequencies] 3501
[Network Data]
! freq S11mag S11ang S12mag S12ang S13mag S13ang S14mag S14ang
! S21mag S21ang S22mag S22ang S23mag S23ang S24mag S24ang
the error I got
C:\Anaconda3\lib\site-packages\skrf\io\touchstone.py in load_file(self, fid)
180 # collect all values without taking care of there meaning
181 # we're seperating them later
--> 182 values.extend([ float(v) for v in line.split() ])
183
184 # let's do some post-processing to the read values
C:\Anaconda3\lib\site-packages\skrf\io\touchstone.py in <listcomp>(.0)
180 # collect all values without taking care of there meaning
181 # we're seperating them later
--> 182 values.extend([ float(v) for v in line.split() ])
183
184 # let's do some post-processing to the read values
ValueError: could not convert string to float: '[number'
would be nice to execute all the doc notebooks during a test suite execution to increase our coverage.
Hi there,
A bit of a python newb here. Not sure how to use the lingo. So bear with me a bit.
I ran through examples from here, scikit-rf.readthedocs; and it appears that it is not working as intended.
Example Objective: to match line1 to line number of frequency points.
Over at the example the author used .resample for line1 to interpolate the frequency points of object line1 from 101 points to 201 points.
At the 2nd example, the author mentioned that .interpolate_from_f can be used too.
But it fails to work as intended.
Here is my example code
# To show example S-Parameter interpolation
import skrf as rf
from pylab import *
from matplotlib import pyplot as plt
#plots generated will have grids styled like RF plots
rf.stylely()
#import example data
from skrf.data import wr2p2_line1 as line1
line = rf.data.wr2p2_line
print 'line:'
print line
print '\norig line1 :'
print line1
#intepolate line1 here from 101 points to 201 points using .resample
line1.resample(201)
print '\nline1 via ' +"\x1b[32m\".resample\"\x1b[0m"
print line1
#intepolate line1 here from 101 points to 201 points using .resample
line1.resample(501)
print '\norig line1 again via ' +"\x1b[32m\".resample\"\x1b[0m"
print line1
#intepolate line1 here from 101 points to 201 points using .interpolate_from_f
line1.interpolate_from_f(line.frequency)
print '\nline1 again via ' +"\x1b[31m\".interpolate_from_f\"\x1b[0m"
print line1
and here's the output
line:
2-Port Network: 'wr2p2,line', 330-500 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]
orig line1 :
2-Port Network: 'wr2p2,line1', 330-500 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]
line1 via ".resample"
2-Port Network: 'wr2p2,line1', 330-500 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]
orig line1 again via ".resample"
2-Port Network: 'wr2p2,line1', 330-500 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]
line1 again via ".interpolate_from_f"
2-Port Network: 'wr2p2,line1', 330-500 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]
I hope I am not wrong when I open up this issue. Please let me know if I am .. :)
I am using HP8753D, which seems to be compatible to 8720. If I setup VNA for log sweep, skrf ignores exact frequency data, using start-stop-points and linear distribution instead.
I have a patch, fixing the issue. Works for me, according to docs should work for 8720 as well. Now, how can I upload a file here?
The class of EightTerm calibrations should allow for isolation correction terms.
Obviously, this would make the class more appropriately named TenTerm
!, but i think leaving it as EightTerm is ok, even though it's misleading.
see #122,
Firstly - thank you for this software
Secondly - I'm a complete noob to this scikit-rf/python and github so please be kind
If I issue the command
network.f=network.f
The frequencies of the network will be multiplied by the current unit (e.g. 10 ^ 9)
To have no effect you need to type
network.f=network.frequency.f_scaled
Obviously this is a contrived example but I was trying to populate the frequency array my changing entries in the original and kept getting them multiplied by Power[10,9].
the docs at readthedocs dont build due to an arbitrary timeout.
would be nice to fix this.
would be nice to have a easy way to install ALL skrf deps in one line , like a conda meta-package
I saw that you started implementing conversion functions between single-ended and mixed-mode S-parameters. How far have you come and are you going to follow up on that enhancement?
I've stumbled over "Generalized Mixed-Mode S-Parameters" and consider to implement that in the not to far future.
Any thoughts?
When asked to plot the uncertainty bounds of a network set, the function only prints the S11 bounds. I believe it should print all by default and allow you to specify if you want. This behavior should be similar to plot_s_db().
Sample code to illustrate:
import skrf as rf
rf.stylely()
ring_slot = rf.Network(rf.data.pwd+'/ring slot.s2p')
ring_slot.plot_s_db()
figure()
noise1 = rf.Network(rf.data.pwd+'/ring slot.s2p')
noise2 = rf.Network(rf.data.pwd+'/ring slot.s2p')
noise3 = rf.Network(rf.data.pwd+'/ring slot.s2p')
noise1.name = 'noise1'
noise2.name = 'noise2'
noise3.name = 'noise3'
noise1.add_noise_polar(.003,.01)
noise2.add_noise_polar(.001,.03)
noise3.add_noise_polar(.005,.001)
for i in (noise1, noise2, noise3):
i.plot_s_db()
figure()
noiseSet = rf.NetworkSet([noise1, noise2, noise3])
noiseSet.plot_s_db()
figure()
noiseSet.plot_uncertainty_bounds_s_db()
Any reason std_s_deg is not in the API list in the scikit-rf documentation?
Tested in my code that it exist, but not much description of it. (As indicated here)
I am just assuming that it behaves like std_s_db but I did not verify it yet.
Thoughts?
Hi,
I am wondering whether there is a typo in the line of 735 in media.py.
Is "s21 = npy.exp(-1_theta)" supposed to be "s21 = npy.exp(-1j_theta)"?
Also, as someone pointed out, it is a good idea to add unit of 's' for definition of calkit.
Thank you.
Currently, the Media.line() function supports degrees, radians and meters as delay value. I would like to use this function to define calibration standards, that are specified with picoseconds of delay by the manufacturer.
Would you agree that I add a 's' format value to this function?
Due to recent plotting changes it looks like that the all the examples in documentation that had plots are now failing.
This came up as I was fiddling with an Agilent PNA calibration. Performing a standard TRL calibration resulted in the following error terms being set on the VNA:
in the convert_8term_2_12term function, only terms 1-5 are return.
Also, internally skrf calls term 6 "isolation" instead of "crosstalk".
Can we just add in the following two lines at the end of convert_8term_2_12term:
coefs_12term['forward isolation'] = npy.zeros_like(Elf)
coefs_12term['reverse isolation'] = npy.zeros_like(Elf)
or would this cause any problems?
In the skrf.calibration.determine_reflect function there is a bug on line 4017
if reflect_approx is None:
reflect_approx = reflect.copy()
reflect_approx.s[:,0,0]=-1
there is no available reference to reflect
in the function. Currently all calling functions specify a value for reflect_approx
so this code block is never entered. The function should be re-written to either require an input value for reflect, or to simply require an input for reflect_approx instead of making it an optional None.
Also the docstring parameters don't match the function signature. It may be that reflect
is supposed to be pulled from reflect_m
fix the many warnings produced by skrf, as seen in docs.
In network.connect and same functions, all the connected ports are removed at first pass although only one connection has been made and iteration is called just after.
The lines 2572 to 2574 (scikit-rf 0.14)
# combine z0 arrays and remove ports which were connected
ntwkC.z0 = npy.hstack(
(npy.delete(ntwkA.z0, range(k,k+num), 1), npy.delete(ntwkB.z0, range(l,l+num), 1)))
should become e.g.
# combine z0 arrays and remove ports which were connected
ntwkC.z0 = npy.hstack(
(npy.delete(ntwkA.z0, range(k,k+1), 1), npy.delete(ntwkB.z0, range(l,l+1), 1)))
only deleting one port (code optimization to be done)
Thank you for scikit-rf, very useful!
When importing log-sampled Touchstone files or resampling linear Touchstone files to a log scale by setting the frequencies attribute, the sweep_type is "lin" all the time.
I am sorry not to take the time to integrate this into the repository and to write the necessary tests, but this MWE seems to demonstrate the root cause:
>>> import skrf as rf
>>> import numpy as np
>>> rf.Frequency.from_f(np.linspace(1e9,1e10)).sweep_type
'lin'
>>> rf.Frequency.from_f(np.logspace(9,10)).sweep_type
'lin'
I think this could be solved by detecting the sweep type at creation of a Frequency object, but I am not sure if that also solves the resampled case (when we resample linear data with log frequencies). Anyhow, this piece of code allows detecting log or lin.
import numpy as npy
def _logOrLin(f):
incrementFactors = f[1:]/f[:-1] - 1
averageFactor = npy.average(incrementFactors)
incrementTerms = f[1:]-f[:-1]
averageTerm = npy.average(incrementTerms)
factorDeviation = npy.max(npy.abs(incrementFactors/averageFactor)) - 1
termDeviation = npy.max(npy.abs(incrementTerms/averageTerm)) - 1
return ('lin' if termDeviation < factorDeviation else 'log')
if __name__ == '__main__':
print _logOrLin(npy.logspace(9,10))
print _logOrLin(npy.linspace(1e9,1e10))
Latest release on pypi was may 2015. We could really use a new release uploaded to capture the last few pull requests please!
I am not sure why there are .pyc under version control in the skrf/pythonicsInstruments folder. Moreover the source files are not present.
Dear all,
It's a long time since I've used skrf, so I wonder if the following is a problem or a misuse.
I've got a Touchstone file of an 8-ports device(*) which has been exported from HFSS in the Magnitude/Angle format. One file has been exported with the 50Ohm renormalization while not the other (remove the .txt extension):
HFSS_S_MA_example_50Ohm.s8p.txt
HFSS_S_MA_example.s8p.txt
It is a detail, but the network frequency display is rounded. Is it intended?
nwk = rf.Network('HFSS_S_MA_example.s8p')
nwk_50Ohm = rf.Network('HFSS_S_MA_example_50Ohm.s8p')
nwk.frequency.f
Out[125]: array([ 3.70000000e+09])
nwk.frequency
Out[124]: 3-3 GHz, 1 pts
In HFSS, when exporting the Touchstone file, there is the possibility (now by default) to add the gamma and port impedances (for each ports) in the comments, which I think is great since it is always a source of confusion when analyzing some files. Presently these informations are not parsed (since I guess such additional info are not standard in touchstone files):
nwk.z0
Out[177]:
array([[ 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j]])
nwk_50Ohm.z0
Out[178]:
array([[ 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j, 50.+0.j]])
while for the former case, one would expect z0=445.259695889026+1.51087559077766j
, as it is written in the Touchstone file. As a direct consequence, skrf renormalize the S parameters to 50hm, which is not the correct value here, so the S param are not as expected.
Tricky: in the HFSS touchstone file, the port impedances are written in real/imaginary, whatever the format used for the scattering parameters (MA, DB, RI)
Which brings me to the following : since I guess the way HFSS is formatting the Touchstone file is certainly not standard, the rf.hfss_touchstone_2_network()
is definetly of interest. However presently it does not work with such files (returns a ValueError: could not convert string to float: '!'
).
Before trying to patch the code myself, I would like to discuss if the present behavior is normal/expected.
(*) : all 8 ports are rectangular waveguides and thus setup as "Z_wave" ports in the HFSS terminology.
Dear all,
as there was a lot of time invested into skrf over the last years, I'm wondering on how to acknowledge the beautiful work of all involved in an efficient manner in a scientific context. E.g. the Astropy community is going a way documented at Astropy: About. Are there any opinions?
Cheers,
Jens
Documentation Requirements state python (>=2.6), but scikit-rf fails to install on python 3.3 (Windows). Please update documentation to explicitly state Python 2 only if Python 3 is not intended to be supported.
Hello everyone,
I am a newbie to python and to scikit-rf. I have been forced to work on a windows environment and so I installed cygwin to get some of the good 'ol unix functionality. I successfully managed to install all the required packages:
numpy-1.6.2, scipy-0.11.0, ipython-0.13.1, nose-1.2.1, pandas-0.10.1, sympy,matplotlib-1.2.0 and nose-1.2.1
On the default python install (v. 2.6.8) that comes with cygwin and confirmed the general plotting capability on the x-windows environment. The installation of Matplotlib was not a straight-forward task and was installed according to http://berlinbrowndev.blogspot.com/2012/01/python-matplotlib-plotting-setup-for.html.
I also managed to install the scikit-rf-0.13 package, but when I try to import it to the ipython/pylab environment, I get the following:
$ ipython --pylab
Python 2.6.8 (unknown, Jun 9 2012, 11:30:32)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
Welcome to pylab, a matplotlib-based Python environment [backend: TkAgg].
For more information, type 'help(pylab)'.
In [1]: import skrf as rf
File "/usr/lib/python2.6/site-packages/scikit_rf-0.13-py2.6.egg/skrf/media/rectangularWaveguide.py", line 128
return {k: self.dict[k] for k in
^
SyntaxError: invalid syntax
Using the python/enthought/pylab everything works as it should, but I would really like to get this to work on the cygwin, so I would appreciate any help on the matter.
Thanks!
If two networks with different f_units are plotted in the same plot x-axis of the plot is incorrect.
A simple program with the bug:
import skrf
import matplotlib.pyplot as plt
import numpy as np
skrf.stylely()
net1 = skrf.Network(s=np.random.random(100).reshape(-1,1,1), f=np.linspace(1e9,2e9,100), f_unit='Hz')
net2 = skrf.Network(s=np.random.random(100).reshape(-1,1,1), f=np.linspace(1,2,100), f_unit='GHz')
net1.plot_s_db()
net2.plot_s_db()
plt.show(block=True)
The networks have the same frequencies, but the first network with f_unit=Hz is plotted as if its f_unit was GHz.
The impedance calculation for RectangularWaveguide has an error that results in propagating modes returning imaginary impedances from the Z0() method, and the mismatch between a TE mode and free space giving an insertion loss greater than 1.
Pozar eq. (3.86) gives the impedance of a TE mode as Z_TE = k * eta / beta where beta is real for propagating modes and imaginary for evanescent modes. The source code shows that the RectangularWaveguide impedance is calculated using gamma, which is defined as being imaginary for propagating modes, which in turn gives imaginary impedances for propagating modes.
(EDIT: it seems I'm using 0.14.1 release, and the code has changed since then. However, the comments in the code suggest that this is still the case, with gamma being imaginary for propagating modes and the impedance calculation using gamma. I'm going to try to update the scikit-rf I'm using in Anaconda to confirm this issue in the latest release)
I have a 3-port single-ended network, let's call it a "differential power divider". Ideally, S21 and S31 should be -3 dB and angle(31)-angle(S21) = 180 degrees.
I used se2gmm() to convert this network to mixed-mode parameters where port 1 remains single-ended and ports 2 and 3 become differential mode (100 ohms) and common mode (25 ohms).
se2gmm() seems to work fine (agrees with Microwave Office), but it does appear to be assuming that the ports to be transformed are 1 and 2. I was able to get around this by renumbering the ports. This is probably only an issue when there are an odd number of ports. If nothing else, it probably makes sense to document the behavior of se2gmm() because it wasn't completely clear.
import skrf as rf
ntwk = rf.Network("dpd.s3p")
ntwk.renumber([0,1,2],[2,1,0])
ntwk.se2gmm(p=1)
ntwk.renumber([2,1,0],[0,1,2])
Hello,
My two cents RE instrument drivers:
I think it would be wise if you only used individual drivers to define the SCPI commands and override any necessary methods from the parent class. The commands could be kept in a dictionary with a set of required commands for each instrument type (which can be added to and used in overridden methods). This has two main benefits, being that new drivers are simple to implement by users, and also that any update to the driver functions for speed etc are pushed out to the whole set without thinking about ways to do that through inheritance.
An example pseudocode/python structure would be:
PNA.py:
...
self.commands = {
'reset': 'SYST:PRES',
'setFreqStart': 'SENS:FREQ:STAR {e}',
'setFreqStop': 'SENS:FREQ:STOP {e}'
}
def setFreq(self):
super(PNA, self) #optional
interface.write(vna.command('somethingExtra')
And use:
na.py:
(conditionally load the relevant driver)
interface.write(vna.command('setFreqStart'), [minFreq]);
interface.write(vna.command('setFreqStop'), [maxFreq]);
...
while(!interface.write(vna.command('isReady'))
time.sleep(1);
trace = interface.write(vna.command('getTrace')
The conditional logic for inserting values and building SCPI strings would be put in the instrument class as they shouldn't vary heavily between models. Note the second argument is a list so this could contain strings and numerics. If the particular model needs some extra commands or needs to skip some, then override the relevant method from the instrument class.
Thoughts?
When I import two s2p files, one having frequencies in GHz, another in Hz, I have trouble plotting s-parameters in one figure. It appears, method plot_s_db uses for x-values not dut.f, or dut.frequency.f, but dut.frequency.f_scaled. Tried to find responsible code, but my python skills were not enough for this task.
Could you please fix this, or at least direct me where to look for relevant code?
Desired behaviour would be to use unscaled frequency, possibly with additional switch allowing to choose scaled/unscaled.
Thanks in advance!
This issue goes back to topic I started here:
https://groups.google.com/forum/#!topic/scikit-rf/n_UWZOEMwpQ
Back then I reported that "all works", which was a mistake. Only now I got back to the device, and discovered a problem. Even though there were no errors, the data was all wrong.
The trouble is, in get_data_snp() you assume that PNA returns S-Parameters in real/imaginary format. However, mine returned magnitude/angle by default.
As a temporary workaround I explicitly set output format to RI after PNA instantiation, like that:
my_vna = vna.PNA(address=16, timeout = 10)
my_vna.set_snp_format('ri')
I think fixing the code should be easy. Maybe I'll get around to it when I use PNA next time. Can be in a while though.
Hej hej,
is there any interest to discuss transformations into time domain to approach device behavior from a different perspective. There are many possible ideas on which transform (FFTs, z-Transforms, etc) works better. Even some time domain gating could be interesting to apply to measured real world data. What are your thoughts?
Cheers,
Jens
By using the S2P decoder like "skrf.touchstone.touchstone(filename)", it looks like that the comment line in the s2p file with the column information is not decoded.
In several S2P files, the S12 and S21 columns are sometimes in different order:
1.) Mini-Circuits LFCN-800 Filter
! FREQ dB(S11) PHS(S11) dB(S21) PHS(S21) dB(S12) PHS(S12) dB(S22) PHS(S22)
2.) Mini-Circuits SXBP-640 Filter
!
!FREQMAG(S11)PHS(S11)MAG(S12)PHS(S12)MAG(S21)PHS(S21)MAG(S22)PHS(S22)
As a result of this, the current implementation interpretes sometimes the S21 column as S12 an vice verca.
I tried to plot an S-parameter file that has non-uniform frequency spacing in it's data. For instance, if you have S-parameters with a frequency vector [1, 2, 5]
then try to plot it, you'll see data points at frequencies [1, 2.5, 5]
.
Looking at the code, it seems the frequency data is read from the file, but most of the data is discarded, only using the frequency start, stop, and number of points. Then a new frequency vector is created. Now the data is incorrect.
The frequency object constructor is convenient, but during a network object's initialization should we be discarding most of the frequency data? From network.py:
@f.setter
def f(self,f):
tmpUnit = self.frequency.unit
self._frequency = Frequency(f[0],f[-1],len(f),'hz') # <--------------------
self._frequency.unit = tmpUnit
When performing one-port (short, open, load) calibration, three error terms are estimated: s11 (source match), s22 (directivity) and s12*s21 (reflection tracking). Currently, calibration.error_ntwk returns
[[ s11 s12*s21 ]
[ 1.0 s22 ]]
Would it make sense to suppose the error network to be reciprocal and return this?
[[ s11 sqrt(s12*s21) ]
[ sqrt(s12*s21) s22 ]]
In terms of phase, the two factors will have a 180ΒΊ ambiguity, but at least in terms of magnitude, it looks like the "best guess" to me.
What do others think?
The current code uses mf.complex_2_db which simply does 20_log10(sqrt(real^2 + imaginary^2)). However this should be -20_log10(refl. coeff.) where refl. coeff = sqrt( (Real-Zo)^2 + Imag^2 ) / sqrt( (Real+Zo)^2 + Imag^2).
The current code makes S11 match to the 50Z impedance circle on the smith chart vs. the 50 ohm point on the smith chart (assuming a 50 ohm source impedance). This means that your current S11 parameters dB mag give very wrong numbers.
Similar to #15 for different hardware.
In PNA class frequency vector gets generated using f_start/f_stop/f_npoints, which assumes linear sweep. For log sweeps frequency vector will be wrong.
No fix from me just yet since I don't need log sweep ATM.
An idea for implementation: use first column from CALCulate:DATA:SNP:PORTs? reply, possibly inside get_data_snp()
import skrf
import numpy
lna = skrf.Network('test.s2p')
z = numpy.array([[100, -100], [-100, 100]])
a = z.reshape(1,2,2).repeat(201,0)
imp = skrf.Network(f = lna.f, z0 = lna.z0, z = a, f_unit = 'Hz')
This is not working, because in my case z
is set first. Then z2s
is performed which wants to fix_z0_shape
but it does not work. It seems the default value is set wrong:
Warning: Network has improper 'z0' shape.
Traceback (most recent call last):
File "fail.py", line 9, in <module>
imp = skrf.Network(f = lna.f, z0 = lna.z0, z = a, f_unit = 'Hz')
File "/usr/local/lib/python3.5/site-packages/skrf/network.py", line 387, in __init__
self.__setattr__(attr,kwargs[attr])
File "/usr/local/lib/python3.5/site-packages/skrf/network.py", line 1085, in z
self._s = z2s(value, self.z0)
File "/usr/local/lib/python3.5/site-packages/skrf/network.py", line 3564, in z2s
z0 = fix_z0_shape(z0, nfreqs, nports)
File "/usr/local/lib/python3.5/site-packages/skrf/network.py", line 4220, in fix_z0_shape
elif len(z0) == nports:
TypeError: len() of unsized object
The documentation of Network.f specifies, that the returned frequency is in Hz. However if the unit of the Network is not Hz, changing the .f property results in wrong frequency data.
Example:
import skrf
import numpy
n = 5
sp = numpy.ones((n, 2, 2))
frequency = numpy.linspace(0, 1, n)
z0 = 50 * numpy.ones(n)
nw = skrf.Network(f_unit="GHz")
nw.s, nw.f, nw.z0 = sp, frequency, z0
print(nw.f)
nw.f = nw.f
print(nw.f)
>> [ 0.00000000e+00 2.50000000e+08 5.00000000e+08 7.50000000e+08
1.00000000e+09]
>> [ 0.00000000e+00 2.50000000e+17 5.00000000e+17 7.50000000e+17
1.00000000e+18]
If .f always returns the data in Hz it also should accept only data in Hz.
SCPI is fairly straightforward (SET commands and QUERY commands) so the notion of having 1 proper method defined for each command is sort of self-defining. Furthermore the convention for putting the command tree in a yaml file is also pretty simple:
Each Dict key represents either:
In this way it is possible to write a "compiler" that parses the SCPI command tree in a recursive fashion and generates code that is always consistent in style and naming.
The main issues to decide:
class SCPI():
def set_pep8_scpi_name(kwarg1="", kwarg2=""):
def query_pep8_scpi_name(kwarg1="", kwarg2=""):
class analyzer(SCPI):
so that a call would look something like:
analyzer.set_averaging_mode(cnum=1, mode="sweep")
analyzer.query_averaging_mode(cnum=1)
Is there a better way to be organizing this or it doesn't really matter and we should just get it going?
I'm going to leave this open for a few days before I start refining the idea in the code.
make it work.
https://github.com/scikit-rf/staged-recipes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.