rf-touchstone 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,697 @@
1
+ import { Complex } from 'mathjs';
2
+
3
+ /**
4
+ * Class representing frequency data in RF and microwave engineering
5
+ *
6
+ * @remarks
7
+ * The Frequency class manages frequency-related data, including:
8
+ * - Frequency unit management
9
+ * - Storage of frequency points
10
+ * - Unit conversion capabilities
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const freq = new Frequency();
15
+ * freq.unit = 'GHz';
16
+ * freq.f_scale = [1.0, 2.0, 3.0];
17
+ * ```
18
+ */
19
+ declare class Frequency {
20
+ /**
21
+ * Internal storage for frequency unit
22
+ * Defaults to 'Hz' as the base SI unit for frequency
23
+ */
24
+ private _unit;
25
+ /**
26
+ * Sets the frequency unit for the instance
27
+ *
28
+ * @param newUnit - The frequency unit to set
29
+ * @throws {Error} If the provided unit is not one of the supported frequency units
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const freq = new Frequency();
34
+ * freq.unit = 'MHz'; // Sets unit to Megahertz
35
+ * ```
36
+ */
37
+ set unit(newUnit: FrequencyUnit);
38
+ /**
39
+ * Gets the current frequency unit
40
+ *
41
+ * @returns The current frequency unit
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const freq = new Frequency();
46
+ * console.log(freq.unit); // Outputs: 'Hz'
47
+ * ```
48
+ */
49
+ get unit(): FrequencyUnit;
50
+ /**
51
+ * Internal storage for frequency points array
52
+ * Each element represents a frequency point in the specified unit
53
+ * @private
54
+ */
55
+ private _f_scaled;
56
+ /**
57
+ * Array of frequency points in the current frequency unit
58
+ * Each element represents a discrete frequency point for measurement or analysis
59
+ *
60
+ * @param value - Array of frequency points
61
+ * @throws {Error} If the input is not an array
62
+ * @throws {Error} If any element in the array is not a number
63
+ * @throws {Error} If the array contains negative frequencies
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const freq = new Frequency();
68
+ * freq.unit = 'GHz';
69
+ * freq.f_scaled = [1.0, 1.5, 2.0]; // Sets frequency points in GHz
70
+ * ```
71
+ */
72
+ set f_scaled(value: number[]);
73
+ /**
74
+ * Gets the array of frequency points
75
+ * @returns Array of frequency points in the current unit
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const freq = new Frequency();
80
+ * freq.unit = 'MHz';
81
+ * freq.f_scaled = [100, 200, 300];
82
+ * console.log(freq.f_scaled); // Outputs: [100, 200, 300]
83
+ * ```
84
+ */
85
+ get f_scaled(): number[];
86
+ /**
87
+ * Private helper method to get frequency values in a target unit.
88
+ * @param targetUnit - The key of the target frequency unit in FREQUENCY_MULTIPLIERS.
89
+ * @returns Array of frequency points in the target unit.
90
+ */
91
+ private _getFrequencyInTargetUnit;
92
+ /**
93
+ * Private helper method to set frequency values from a source unit.
94
+ * @param values - Array of frequency points in the source unit.
95
+ * @param sourceUnit - The key of the source frequency unit in FREQUENCY_MULTIPLIERS.
96
+ */
97
+ private _setFrequencyFromTargetUnit;
98
+ /**
99
+ * Gets frequency points in Hz
100
+ * @returns Array of frequency points in Hz
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const freq = new Frequency();
105
+ * freq.unit = 'GHz';
106
+ * freq.f_scaled = [1, 2, 3]; // 1 GHz, 2 GHz, 3 GHz
107
+ * console.log(freq.f_Hz); // Outputs: [1e9, 2e9, 3e9]
108
+ * ```
109
+ */
110
+ get f_Hz(): number[];
111
+ /**
112
+ * Sets frequency points assuming input is in Hz
113
+ * @param values - Array of frequency points in Hz
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const freq = new Frequency();
118
+ * freq.unit = 'MHz';
119
+ * freq.f_Hz = [1e9, 2e9, 3e9]; // Sets frequencies as 1 GHz, 2 GHz, 3 GHz
120
+ * console.log(freq.f_scaled); // Outputs: [1000, 2000, 3000] (in MHz)
121
+ * ```
122
+ */
123
+ set f_Hz(values: number[]);
124
+ /**
125
+ * Gets frequency points in kHz
126
+ * @returns Array of frequency points in kHz
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * const freq = new Frequency();
131
+ * freq.unit = 'Hz';
132
+ * freq.f_scaled = [1000, 2000, 3000]; // 1 kHz, 2 kHz, 3 kHz
133
+ * console.log(freq.f_kHz); // Outputs: [1, 2, 3]
134
+ * ```
135
+ */
136
+ get f_kHz(): number[];
137
+ /**
138
+ * Sets frequency points assuming input is in kHz
139
+ * @param values - Array of frequency points in kHz
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const freq = new Frequency();
144
+ * freq.unit = 'Hz';
145
+ * freq.f_kHz = [1, 2, 3]; // Sets frequencies as 1 kHz, 2 kHz, 3 kHz
146
+ * console.log(freq.f_scaled); // Outputs: [1000, 2000, 3000] (in Hz)
147
+ * ```
148
+ */
149
+ set f_kHz(values: number[]);
150
+ /**
151
+ * Gets frequency points in MHz
152
+ * @returns Array of frequency points in MHz
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const freq = new Frequency();
157
+ * freq.unit = 'GHz';
158
+ * freq.f_scaled = [0.1, 0.2, 0.3]; // 0.1 GHz, 0.2 GHz, 0.3 GHz
159
+ * console.log(freq.f_MHz); // Outputs: [100, 200, 300]
160
+ * ```
161
+ */
162
+ get f_MHz(): number[];
163
+ /**
164
+ * Sets frequency points assuming input is in MHz
165
+ * @param values - Array of frequency points in MHz
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * const freq = new Frequency();
170
+ * freq.unit = 'GHz';
171
+ * freq.f_MHz = [100, 200, 300]; // Sets frequencies as 100 MHz, 200 MHz, 300 MHz
172
+ * console.log(freq.f_scaled); // Outputs: [0.1, 0.2, 0.3] (in GHz)
173
+ * ```
174
+ */
175
+ set f_MHz(values: number[]);
176
+ /**
177
+ * Gets frequency points in GHz
178
+ * @returns Array of frequency points in GHz
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * const freq = new Frequency();
183
+ * freq.unit = 'MHz';
184
+ * freq.f_scaled = [1000, 2000, 3000]; // 1000 MHz, 2000 MHz, 3000 MHz
185
+ * console.log(freq.f_GHz); // Outputs: [1, 2, 3]
186
+ * ```
187
+ */
188
+ get f_GHz(): number[];
189
+ /**
190
+ * Sets frequency points assuming input is in GHz
191
+ * @param values - Array of frequency points in GHz
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * const freq = new Frequency();
196
+ * freq.unit = 'MHz';
197
+ * freq.f_GHz = [1, 2, 3]; // Sets frequencies as 1 GHz, 2 GHz, 3 GHz
198
+ * console.log(freq.f_scaled); // Outputs: [1000, 2000, 3000] (in MHz)
199
+ * ```
200
+ */
201
+ set f_GHz(values: number[]);
202
+ /**
203
+ * Gets frequency points in THz
204
+ * @returns Array of frequency points in THz
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const freq = new Frequency();
209
+ * freq.unit = 'GHz';
210
+ * freq.f_scaled = [1000, 2000, 3000]; // 1000 GHz, 2000 GHz, 3000 GHz
211
+ * console.log(freq.f_THz); // Outputs: [1, 2, 3]
212
+ * ```
213
+ */
214
+ get f_THz(): number[];
215
+ /**
216
+ * Sets frequency points assuming input is in THz
217
+ * @param values - Array of frequency points in THz
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const freq = new Frequency();
222
+ * freq.unit = 'GHz';
223
+ * freq.f_THz = [1, 2, 3]; // Sets frequencies as 1 THz, 2 THz, 3 THz
224
+ * console.log(freq.f_scaled); // Outputs: [1000, 2000, 3000] (in GHz)
225
+ * ```
226
+ */
227
+ set f_THz(values: number[]);
228
+ /**
229
+ * Private helper method to get wavelength values in a target unit.
230
+ * @param targetWavelengthUnit - The key of the target wavelength unit in WAVELENGTH_MULTIPLIERS_TO_M.
231
+ * @returns Array of wavelength points in the target unit.
232
+ */
233
+ private _getWavelengthInTargetUnit;
234
+ /**
235
+ * Private helper method to set frequency values from wavelength values in a source unit.
236
+ * @param values - Array of wavelength points in the source unit.
237
+ * @param sourceWavelengthUnit - The key of the source wavelength unit in WAVELENGTH_MULTIPLIERS_TO_M.
238
+ */
239
+ private _setWavelengthFromTargetUnit;
240
+ /**
241
+ * Gets wavelength in meters
242
+ * @returns Array of wavelength values in meters
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * const freq = new Frequency();
247
+ * freq.unit = 'GHz';
248
+ * freq.f_scaled = [1, 2, 3]; // Frequencies in GHz
249
+ * console.log(freq.wavelength_m); // Outputs: Wavelengths in meters
250
+ * ```
251
+ */
252
+ get wavelength_m(): number[];
253
+ /**
254
+ * Sets wavelength in meters. Converts to frequency and stores.
255
+ * @param values - Array of wavelength values in meters
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * const freq = new Frequency();
260
+ * freq.unit = 'GHz';
261
+ * freq.wavelength_m = [0.3, 0.15, 0.1]; // Wavelengths in meters
262
+ * console.log(freq.f_scaled); // Outputs: Frequencies in GHz
263
+ * ```
264
+ */
265
+ set wavelength_m(values: number[]);
266
+ /**
267
+ * Gets wavelength in centimeters
268
+ * @returns Array of wavelength values in centimeters
269
+ *
270
+ * @example
271
+ * ```typescript
272
+ * const freq = new Frequency();
273
+ * freq.unit = 'GHz';
274
+ * freq.f_scaled = [10, 20, 30]; // Frequencies in GHz
275
+ * console.log(freq.wavelength_cm); // Outputs: Wavelengths in centimeters
276
+ * ```
277
+ */
278
+ get wavelength_cm(): number[];
279
+ /**
280
+ * Sets wavelength in centimeters. Converts to frequency and stores.
281
+ * @param values - Array of wavelength values in centimeters
282
+ *
283
+ * @example
284
+ * ```typescript
285
+ * const freq = new Frequency();
286
+ * freq.unit = 'GHz';
287
+ * freq.wavelength_cm = [30, 15, 10]; // Wavelengths in centimeters
288
+ * console.log(freq.f_scaled); // Outputs: Frequencies in GHz
289
+ * ```
290
+ */
291
+ set wavelength_cm(values: number[]);
292
+ /**
293
+ * Gets wavelength in millimeters
294
+ * @returns Array of wavelength values in millimeters
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * const freq = new Frequency();
299
+ * freq.unit = 'GHz';
300
+ * freq.f_scaled = [100, 200, 300]; // Frequencies in GHz
301
+ * console.log(freq.wavelength_mm); // Outputs: Wavelengths in millimeters
302
+ * ```
303
+ */
304
+ get wavelength_mm(): number[];
305
+ /**
306
+ * Sets wavelength in millimeters. Converts to frequency and stores.
307
+ * @param values - Array of wavelength values in millimeters
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * const freq = new Frequency();
312
+ * freq.unit = 'GHz';
313
+ * freq.wavelength_mm = [300, 150, 100]; // Wavelengths in millimeters
314
+ * console.log(freq.f_scaled); // Outputs: Frequencies in GHz
315
+ * ```
316
+ */
317
+ set wavelength_mm(values: number[]);
318
+ /**
319
+ * Gets wavelength in micrometers
320
+ * @returns Array of wavelength values in micrometers
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * const freq = new Frequency();
325
+ * freq.unit = 'GHz';
326
+ * freq.f_scaled = [1000, 2000, 3000]; // Frequencies in GHz
327
+ * console.log(freq.wavelength_um); // Outputs: Wavelengths in micrometers
328
+ * ```
329
+ */
330
+ get wavelength_um(): number[];
331
+ /**
332
+ * Sets wavelength in micrometers. Converts to frequency and stores.
333
+ * @param values - Array of wavelength values in micrometers
334
+ *
335
+ * @example
336
+ * ```typescript
337
+ * const freq = new Frequency();
338
+ * freq.unit = 'GHz';
339
+ * freq.wavelength_um = [300000, 150000, 100000]; // Wavelengths in micrometers
340
+ * console.log(freq.f_scaled); // Outputs: Frequencies in GHz
341
+ * ```
342
+ */
343
+ set wavelength_um(values: number[]);
344
+ /**
345
+ * Gets wavelength in nanometers
346
+ * @returns Array of wavelength values in nanometers
347
+ *
348
+ * @example
349
+ * ```typescript
350
+ * const freq = new Frequency();
351
+ * freq.unit = 'THz';
352
+ * freq.f_scaled = [100, 200, 300]; // Frequencies in THz
353
+ * console.log(freq.wavelength_nm); // Outputs: Wavelengths in nanometers
354
+ * ```
355
+ */
356
+ get wavelength_nm(): number[];
357
+ /**
358
+ * Sets wavelength in nanometers. Converts to frequency and stores.
359
+ * @param values - Array of wavelength values in nanometers
360
+ *
361
+ * @example
362
+ * ```typescript
363
+ * const freq = new Frequency();
364
+ * freq.unit = 'THz';
365
+ * freq.wavelength_nm = [300, 150, 100]; // Wavelengths in nanometers
366
+ * console.log(freq.f_scaled); // Outputs: Frequencies in THz
367
+ * ```
368
+ */
369
+ set wavelength_nm(values: number[]);
370
+ }
371
+
372
+ /**
373
+ * Type definition for frequency units
374
+ * - Hz: Hertz (cycles per second)
375
+ * - kHz: Kilohertz (10³ Hz)
376
+ * - MHz: Megahertz (10⁶ Hz)
377
+ * - GHz: Gigahertz (10⁹ Hz)
378
+ * Touchstone standard doesn't support THz as the frequency unit in Touchstone file
379
+ */
380
+ declare type FrequencyUnit = (typeof FrequencyUnits)[number];
381
+
382
+ /**
383
+ * Frequency units: 'Hz', 'kHz', 'MHz', 'GHz'
384
+ * Touchstone standard doesn't support THz as the frequency unit in Touchstone file
385
+ */
386
+ declare const FrequencyUnits: readonly ["Hz", "kHz", "MHz", "GHz"];
387
+
388
+ /**
389
+ * Touchstone class for reading and writing network parameter data in Touchstone format.
390
+ * Supports both version 1.0 and 1.1 of the Touchstone specification.
391
+ *
392
+ * ## Overview
393
+ *
394
+ * The **Touchstone file format** (also known as `.snp` files) is an industry-standard ASCII text format used to represent the n-port network parameters of electrical circuits. These files are commonly used in RF and microwave engineering to describe the behavior of devices such as filters, amplifiers, and interconnects.
395
+ *
396
+ * A Touchstone file contains data about network parameters (e.g., S-parameters, Y-parameters, Z-parameters) at specific frequencies.
397
+ *
398
+ * ### Key Features:
399
+ * - **File Extensions**: Traditionally, Touchstone files use extensions like `.s1p`, `.s2p`, `.s3p`, etc., where the number indicates the number of ports. For example, `.s2p` represents a 2-port network.
400
+ * - **Case Insensitivity**: Touchstone files are case-insensitive, meaning keywords and values can be written in uppercase or lowercase.
401
+ * - **Versioning**: **Only version 1.0 and 1.1 are supported in this class**
402
+ *
403
+ * ---
404
+ *
405
+ * ## File Structure
406
+ *
407
+ * A Touchstone file consists of several sections, each serving a specific purpose. Below is a breakdown of the structure:
408
+ *
409
+ * ### 1. Header Section
410
+ *
411
+ * - **Comment Lines**: Lines starting with `!` are treated as comments and ignored during parsing.
412
+ * - **Option Line**: Line starting with `#` defines global settings for the file, such as frequency units, parameter type, and data format. Example:
413
+ * ```
414
+ * # GHz S MA R 50
415
+ * ```
416
+ * - `GHz`: Frequency unit (can be `Hz`, `kHz`, `MHz`, or `GHz`).
417
+ * - `S`: Parameter type (`S`, `Y`, `Z`, `H`, or `G`).
418
+ * - `MA`: Data format (`MA` for magnitude-angle, `DB` for decibel-angle, or `RI` for real-imaginary).
419
+ * - `R 50`: Reference resistance in ohms (default is 50 ohms if omitted).
420
+ *
421
+ * ### 2. Network Data
422
+ *
423
+ * The core of the file contains the network parameter data, organized by frequency. Each frequency point is followed by its corresponding parameter values.
424
+ *
425
+ * - **Single-Ended Networks**: Data is arranged in a matrix format. For example, a 2-port network might look like this:
426
+ * ```
427
+ * <frequency> <N11> <N21> <N12> <N22>
428
+ * ```
429
+ *
430
+ * ---
431
+ *
432
+ * ## Examples
433
+ *
434
+ * ### Example 1: Simple 1-Port S-Parameter File
435
+ * ```plaintext
436
+ * ! 1-port S-parameter file
437
+ * # MHz S MA R 50
438
+ * 100 0.99 -4
439
+ * 200 0.80 -22
440
+ * 300 0.707 -45
441
+ * ```
442
+ *
443
+ * ---
444
+ *
445
+ * ## References:
446
+ * - {@link https://ibis.org/touchstone_ver2.1/touchstone_ver2_1.pdf Touchstone(R) File Format Specification (Version 2.1)}
447
+ * - {@link https://books.google.com/books/about/S_Parameters_for_Signal_Integrity.html?id=_dLKDwAAQBAJ S-Parameters for Signal Integrity}
448
+ * - {@link https://github.com/scikit-rf/scikit-rf/blob/master/skrf/io/touchstone.py scikit-rf: Open Source RF Engineering}
449
+ * - {@link https://github.com/Nubis-Communications/SignalIntegrity/blob/master/SignalIntegrity/Lib/SParameters/SParameters.py SignalIntegrity: Signal and Power Integrity Tools}
450
+ */
451
+ export declare class Touchstone {
452
+ /**
453
+ * Comments in the file header with "!" symbol at the beginning of each row
454
+ */
455
+ comments: string[];
456
+ /**
457
+ * Touchstone format: MA, DB, and RI
458
+ */
459
+ private _format;
460
+ /**
461
+ * Set the Touchstone format: MA, DB, RI, or undefined
462
+ * - RI: real and imaginary, i.e. $A + j \cdot B$
463
+ * - MA: magnitude and angle (in degrees), i.e. $A \cdot e^{j \cdot {\pi \over 180} \cdot B }$
464
+ * - DB: decibels and angle (in degrees), i.e. $10^{A \over 20} \cdot e^{j \cdot {\pi \over 180} \cdot B}$
465
+ * @param format
466
+ * @returns
467
+ * @throws Will throw an error if the format is not valid
468
+ */
469
+ set format(format: TouchstoneFormat | undefined | null);
470
+ /**
471
+ * Get the Touchstone format
472
+ * @returns
473
+ */
474
+ get format(): TouchstoneFormat | undefined;
475
+ /**
476
+ * Type of network parameter: 'S' | 'Y' | 'Z' | 'G' | 'H'
477
+ */
478
+ private _parameter;
479
+ /**
480
+ * Set the type of network parameter
481
+ * - S: Scattering parameters
482
+ * - Y: Admittance parameters
483
+ * - Z: Impedance parameters
484
+ * - H: Hybrid-h parameters
485
+ * - G: Hybrid-g parameters
486
+ * @param parameter
487
+ * @returns
488
+ * @throws Will throw an error if the parameter is not valid
489
+ */
490
+ set parameter(parameter: TouchstoneParameter | undefined | null);
491
+ /**
492
+ * Get the type of network parameter
493
+ */
494
+ get parameter(): TouchstoneParameter | undefined | null;
495
+ /**
496
+ * Reference impedance(s) for the network parameters
497
+ * Default: 50Ω
498
+ */
499
+ private _impedance;
500
+ /**
501
+ * Set the Touchstone impedance.
502
+ * Default: 50Ω
503
+ * @param impedance
504
+ * @returns
505
+ * @throws Will throw an error if the impedance is not valid
506
+ */
507
+ set impedance(impedance: TouchstoneImpedance);
508
+ /**
509
+ * Get the Touchstone impedance.
510
+ * Default: 50Ω
511
+ * @returns
512
+ */
513
+ get impedance(): TouchstoneImpedance;
514
+ /**
515
+ * The number of ports in the network
516
+ */
517
+ private _nports;
518
+ /**
519
+ * Set the ports number
520
+ * @param nports
521
+ * @returns
522
+ * @throws Will throw an error if the number of ports is not valid
523
+ */
524
+ set nports(nports: number | undefined | null);
525
+ /**
526
+ * Get the ports number
527
+ */
528
+ get nports(): number | undefined | null;
529
+ /**
530
+ * Frequency points
531
+ */
532
+ frequency: Frequency | undefined;
533
+ /**
534
+ * 3D array to store the network parameter data
535
+ * - The first dimension is the exits (output) port number
536
+ * - The second dimension is the enters (input) port number
537
+ * - The third dimension is the frequency index
538
+ * For example, data[i][j][k] would be the parameter from j+1 port to i+1 port at frequency index k
539
+ */
540
+ private _matrix;
541
+ /**
542
+ * Sets the network parameter matrix.
543
+ *
544
+ * @param matrix - The 3D complex matrix to store, or undefined/null to clear
545
+ * @remarks
546
+ * This setter provides a way to directly assign the network parameter matrix.
547
+ * Setting to undefined or null will clear the existing matrix data.
548
+ */
549
+ set matrix(matrix: TouchstoneMatrix | undefined | null);
550
+ /**
551
+ * Gets the current network parameter matrix (3D array).
552
+ * Represents the S/Y/Z/G/H-parameters of the network.
553
+ *
554
+ * @remarks
555
+ * Matrix Structure:
556
+ * - First dimension [i]: Output (exit) port number (0 to nports-1)
557
+ * - Second dimension [j]: Input (enter) port number (0 to nports-1)
558
+ * - Third dimension [k]: Frequency point index
559
+ *
560
+ * Example:
561
+ * - matrix[i][j][k] represents the parameter from port j+1 to port i+1 at frequency k
562
+ * - For S-parameters: matrix[1][0][5] is S₂₁ at the 6th frequency point
563
+ *
564
+ * Special case for 2-port networks:
565
+ * - Indices are swapped to match traditional Touchstone format
566
+ * - matrix[0][1][k] represents S₁₂ (not S₂₁)
567
+ *
568
+ * @returns The current network parameter matrix, or undefined if not set
569
+ */
570
+ get matrix(): TouchstoneMatrix | undefined | null;
571
+ /**
572
+ * Reads and parses a Touchstone format string into the internal data structure.
573
+ *
574
+ * @param string - The Touchstone format string to parse
575
+ * @param nports - Number of ports in the network
576
+ *
577
+ * @throws {Error} If the option line is missing or invalid
578
+ * @throws {Error} If multiple option lines are found
579
+ * @throws {Error} If the impedance specification is invalid
580
+ * @throws {Error} If the data format is invalid or incomplete
581
+ *
582
+ * @remarks
583
+ * The method performs the following steps:
584
+ * 1. Parses comments and option line
585
+ * 2. Extracts frequency points
586
+ * 3. Converts raw data into complex numbers based on format
587
+ * 4. Stores the results in the matrix property
588
+ */
589
+ readContent(string: string, nports: number): void;
590
+ /**
591
+ * Validates the internal state of the Touchstone instance.
592
+ * Performs comprehensive checks on all required data and matrix dimensions.
593
+ *
594
+ * @throws {Error} If any of the following conditions are met:
595
+ * - Number of ports is undefined
596
+ * - Frequency object is not initialized
597
+ * - Frequency points array is empty
598
+ * - Network parameter type is undefined
599
+ * - Data format is undefined
600
+ * - Network parameter matrix is undefined
601
+ * - Matrix dimensions don't match with nports or frequency points
602
+ *
603
+ * @remarks
604
+ * This method performs two main validation steps:
605
+ * 1. Essential Data Validation:
606
+ * - Checks existence of all required properties
607
+ * - Ensures frequency points are available
608
+ *
609
+ * 2. Matrix Dimension Validation:
610
+ * - Verifies matrix row count matches port number
611
+ * - Ensures each row has correct number of columns
612
+ * - Validates frequency points count in each matrix element
613
+ */
614
+ validate(): void;
615
+ /**
616
+ * Generates a Touchstone format string from the internal data structure.
617
+ *
618
+ * @returns The generated Touchstone format string
619
+ *
620
+ * @throws {Error} If any required data is missing
621
+ * @throws {Error} If the matrix dimensions are invalid
622
+ *
623
+ * @remarks
624
+ * The generated string includes:
625
+ * 1. Comments (if any)
626
+ * 2. Option line with format, parameter type, and impedance
627
+ * 3. Network parameter data in the specified format
628
+ */
629
+ writeContent(): string;
630
+ }
631
+
632
+ /**
633
+ * S-parameter format: MA, DB, and RI
634
+ * - RI: real and imaginary, i.e. $A + j \cdot B$
635
+ * - MA: magnitude and angle (in degrees), i.e. $A \cdot e^{j \cdot {\pi \over 180} \cdot B }$
636
+ * - DB: decibels and angle (in degrees), i.e. $10^{A \over 20} \cdot e^{j \cdot {\pi \over 180} \cdot B}$
637
+ */
638
+ export declare type TouchstoneFormat = (typeof TouchstoneFormats)[number];
639
+
640
+ /**
641
+ * S-parameter format: MA, DB, and RI
642
+ * - RI: real and imaginary, i.e. $A + j \cdot B$
643
+ * - MA: magnitude and angle (in degrees), i.e. $A \cdot e^{j \cdot {\pi \over 180} \cdot B }$
644
+ * - DB: decibels and angle (in degrees), i.e. $10^{A \over 20} \cdot e^{j \cdot {\pi \over 180} \cdot B}$
645
+ */
646
+ export declare const TouchstoneFormats: readonly ["RI", "MA", "DB"];
647
+
648
+ /**
649
+ * The reference resistance(s) for the network parameters.
650
+ * The token "R" (case-insensitive) followed by one or more reference resistance values.
651
+ * Default: 50Ω
652
+ *
653
+ * For Touchstone 1.0, this is a single value for all ports.
654
+ * For Touchstone 1.1, this can be an array of values (one per port)
655
+ */
656
+ export declare type TouchstoneImpedance = number | number[];
657
+
658
+ /**
659
+ * Network parameter matrix stored as complex numbers.
660
+ *
661
+ * @remarks
662
+ * The matrix is a 3D array with the following dimensions:
663
+ * - First dimension: output port index (0 to nports-1)
664
+ * - Second dimension: input port index (0 to nports-1)
665
+ * - Third dimension: frequency point index
666
+ *
667
+ * For example:
668
+ * - matrix[i][j][k] represents the parameter from port j+1 to port i+1 at frequency k
669
+ * - For S-parameters: matrix[1][0][5] is S₂₁ at the 6th frequency point
670
+ *
671
+ * Special case for 2-port networks:
672
+ * - Indices are swapped to match traditional Touchstone format
673
+ * - matrix[0][1][k] represents S₁₂ (not S₂₁)
674
+ */
675
+ export declare type TouchstoneMatrix = Complex[][][];
676
+
677
+ /**
678
+ * Type of network parameters: 'S' | 'Y' | 'Z' | 'G' | 'H'
679
+ * - S: Scattering parameters
680
+ * - Y: Admittance parameters
681
+ * - Z: Impedance parameters
682
+ * - H: Hybrid-h parameters
683
+ * - G: Hybrid-g parameters
684
+ */
685
+ export declare type TouchstoneParameter = (typeof TouchstoneParameters)[number];
686
+
687
+ /**
688
+ * Type of network parameters
689
+ * - S: Scattering parameters
690
+ * - Y: Admittance parameters
691
+ * - Z: Impedance parameters
692
+ * - H: Hybrid-h parameters
693
+ * - G: Hybrid-g parameters
694
+ */
695
+ export declare const TouchstoneParameters: string[];
696
+
697
+ export { }