- skrf.util.dict_2_recarray(d, delim, dtype)¶
Turn a dictionary of structured keys to a record array of objects.
This is useful if you save data-base like meta-data in the form or file-naming conventions, aka ‘the poor-mans database’
- Return type
Given a directory of networks like:
>>> ls a1,0.0,0.0.s1p a1,3.0,3.0.s1p a2,3.0,-3.0.s1p b1,-3.0,3.0.s1p ...
you can sort based on the values or each field, after defining their type with dtype. The values field accesses the objects.
>>> d = rf.read_all_networks('/tmp/') >>> delim = ',' >>> dtype = [('name', object), ('voltage', float), ('current', float)] >>> ra = dict_2_recarray(d=rf.ran(dir), delim=delim, dtype =dtype)
then you can sift like you do with numpy arrays
>>> ra[ra['voltage'] < 3]['values'] array([1-Port Network: 'a2,0.0,-3.0', 450-800 GHz, 101 pts, z0=[ 50.+0.j], 1-Port Network: 'b1,0.0,3.0', 450-800 GHz, 101 pts, z0=[ 50.+0.j], 1-Port Network: 'a1,0.0,-3.0', 450-800 GHz, 101 pts, z0=[ 50.+0.j],