Hi Eric,
On Sat, Jul 09, 2022 at 12:03:18AM -0700, Eric Wheeler wrote:
> ...
> This could be read into simple PDLs and scalars as follows:
>
> ($freqs, $hz_scale, $matrix, $format, $z0) =
> PDL::IO::Touchstone::read('foo.s2p');
>
> where N is the number of ports:
> - $freqs is a 1xN matrix
I guess you mean 1xM, with M the number of frequencies, or maybe and
M-vector (close but not exactly the same).
> - $matrix is a NxNxM matrix (M is the number of freqs)
> - and the rest are scalar
>
> Assuming PDL::IO::Touchstone::read() turns each record into a
> complex-valued matrix, the "$format" value of how the file was original is
> no longer useful, just noteworthy. Perhaps the user would want to write
> out to the same format or something.
I agree, the user might want to know the original format.
>
> Questions:
>
> 1. In my existing code I've been scaling $freqs to Hz from whatever it
> came so the user can do what they like. If I scale it to Hz _and_
> leave the $hz_scale term available then it could be confusing to the
> user, perhaps thinking they need to scale what I've already scaled.
>
> Should PDL::IO::Touchstone be lower-level than that and just return the
> frequency values verbatim and to let the user scale it based on
> $hz_scale if they wish, or should I scale it to Hz and drop the
> $hz_scale term?
I guess you could use, as suggested by Ed,
use PDL::IO::Touchstone;
($freqs, $matrix, $format, $z0) = rs2p('foo.s2p');
with the ndarrays first and the optional outputs last, but allowing
for options so the user could say
($freqs, $matrix, $format, $z0) = rs2p('foo.s2p', {units=>'MHz'});
to choose his desired units, his desired format, etc., establishing a
reasonable default. Maybe you could also offer in the
package some utility routines to change from one to another format, such as
($magnitudes, $angles)=polar($matrices, {magnitudes=>'dB',
angles=>'degrees'});
Regards,
Luis
--
o
W. Luis Mochán, | tel:(52)(777)329-1734 /<(*)
Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\
Av. Universidad s/n CP 62210 | (*)/\/ \
Cuernavaca, Morelos, México | [email protected] /\_/\__/
GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general