PDL::IO::MDIF - Read and manipulate Measurement Data Interchange Format (MDIF, *.mdf) files.
A simple interface for reading and writing RF MDIF files (also known as MDF or .mdf files). MDIF files contain multiple Touchstone files in a text format; consult the "SEE ALSO" section for more about the MDIFs format and using them to optimize circuits. For example, a single MDIF file could contain the Touchstone RF data for each available value in a line of capacitors (ie, from 10pF to 1000pF) provided by a particular manufacturer.
MDIF files contain Touchstone-formatted data representing multiple components, so PDL::IO::Touchstone is used internally for processing the Touchstone data.
A notable difference between Touchstone files and MDIF files is that MDIF supports variable parameters within the MDIF file itself. For example, an MDIF file containing a set of capacitor data of different values might define the following:
VAR pF = 1000 VAR Vmax = 250
These variables are provided in the return value of rmdif as shown below.
rmdif
use PDL::IO::MDIF; # Read input matrix into an arrayref: $mdif_data = rmdif('input-file.mdf', { units => 'MHz' }); # Write output file: wmdif('output-file.mdf', $mdif_data);
rmdif($filename, $options)
$options is a hashref passed to PDL:IO::Touchstone's rsnp function. The function rmdf is an alias for rmdif.
$options
rsnp
rmdf
# Read input matrix into an arrayref: $mdif_data = rmdif('input-file.mdf');
It returns an arrayref of hashrefs, as follows:
[ # Component 1 { var1 => "val1", var2 => -123, ... _data => [ @rsnp_data ], _comments => [ 'comment line 1', 'comment line 2', ... ] }, # Component 2: { pF => 1000, # component value in pF Vmax => 250, # component maximum voltage ... _data => [ @rsnp_data ] }, ... ]
MDIF Variable (parameter) Names
The example variables and values above (var1, pF, etc) are arbitrary; they are specific to the MDIF file being read.
_data Structure
_data
The _data hash element is an array refernce to exactly that which was returned by PDL::IO::Touchstone's rsnp() function. It is prefixed with an underscore to prevent name collisions with the MDIF file being loaded.
rsnp()
This may deviate from the typical PDL structures in the sense that frequency and S-parameter data is not combined into one big PDL. There are a number of reasons for this, but notably, the frequencies and RF port count in each component contained in the MDF are not required to be identical.
Since they are not guaranteed to be consistent the best we can do is generate a structure containing all of the data and let the user parse what they need. Interpolation using things like PDL::IO::Touchstone's m_interpolate function is possible if the frequencies differ, but we don't want to modify the source data, and that wouldn't address the RF port count issue.
m_interpolate
_comments Structure
_comments
Comments are simply an arrayref of strings, one for each comment line. When written by wsnp, each comment will be written before that component's section on the resulting .mdf text file.
wsnp
wmdif($filename, $mdif_data)
The wmdif function writes the MDIF data in $mdif_data to $filename. The function wmdf is an alias for wmdif.
wmdif
$mdif_data
$filename
wmdf
Internally wmdif uses PDL::IO::Touchstone's wsnp_fh function to write Touchstone data for each component into the MDIF file. To generate an MDIF file from multiple Touchstone files you can read each Touchstone file and merge them as follows:
wsnp_fh
my @cap_100pF = rsnp('100pF.s2p'); my @cap_200pF = rsnp('200pF.s2p'); my @cap_300pF = rsnp('300pF.s2p'); wmdif("my_caps.mdf", [ { pF => 100, _data => \@cap_100pF }, { pF => 200, _data => \@cap_200pF }, { pF => 300, _data => \@cap_300pF }, ]);
Note that pF is just an arbitrary variable that will be stored in the MDIF file for reference when you load it in your EDA software.
pF
You may transform the content of $mdif_data in any way that is suitable to your application before writing the file provided the resulting data is valid. For example, if you convert S paramters to Z parameters using s_to_z then be sure to set $param_type to Y before writing the MDIF output. See PDL::IO::Touchstone for details.
s_to_z
$param_type
Y
PDL::IO::Touchstone
Originally written at eWheeler, Inc. dba Linux Global Eric Wheeler to transform .s2p files and build MDIF files to optimize with Microwave Office for amplifer impedance matches.
Copyright (C) 2022 eWheeler, Inc. https://www.linuxglobal.com/
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this module. If not, see <http://www.gnu.org/licenses/>.
To install PDL::IO::Touchstone, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PDL::IO::Touchstone
CPAN shell
perl -MCPAN -e shell install PDL::IO::Touchstone
For more information on module installation, please visit the detailed CPAN module installation guide.