|
190 | 190 | 'E_theta_mag', 'E_theta_phase_deg', 'E_phi_mag', 'E_phi_phase_deg' |
191 | 191 | ] |
192 | 192 |
|
| 193 | + n_theta, n_phi, theta_step, phi_step = _extract_pattern_grid_info(pattern) |
| 194 | + print(n_theta, n_phi, theta_step, phi_step ) |
| 195 | + |
193 | 196 | with open(file_path, "w") as f: |
| 197 | + f.write(f" ***** DATA CARD NO. 5 RP 0 {n_theta} {n_phi} 1003 0 0 {theta_step:.1f} {phi_step:.1f} 0.0 0.0\n\n") |
194 | 198 | f.write(" - - - RADIATION PATTERNS - - -\n") |
195 | 199 | f.write("\n") |
196 | 200 | f.write(" - - ANGLES - - - POWER GAINS - - - - POLARIZATION - - - - - - E(THETA) - - - - - - E(PHI) - - -\n") |
|
208 | 212 | line += f"{val:{fmt}}" |
209 | 213 | f.write(line.rstrip() + "\n") |
210 | 214 |
|
211 | | - |
| 215 | + f.write("\n RUN TIME = 0\n") |
212 | 216 |
|
213 | 217 |
|
214 | 218 | </pre> |
|
297 | 301 |
|
298 | 302 | # Total field magnitude squared |
299 | 303 | total_power = abs(E_theta)**2 + abs(E_phi)**2 |
300 | | - total_gain_dBi = 10 * math.log10(total_power) if total_power > 0 else -math.inf |
| 304 | + total_gain_dBi = 10 * math.log10(total_power) if total_power > 0 else -999 |
301 | 305 |
|
302 | 306 | # RHCP and LHCP components |
303 | 307 | E_rhcp = (E_theta - 1j * E_phi) / math.sqrt(2) |
|
306 | 310 | rhcp_power = abs(E_rhcp)**2 |
307 | 311 | lhcp_power = abs(E_lhcp)**2 |
308 | 312 |
|
309 | | - rhcp_gain_dBi = 10 * math.log10(rhcp_power) if rhcp_power > 0 else -math.inf |
310 | | - lhcp_gain_dBi = 10 * math.log10(lhcp_power) if lhcp_power > 0 else -math.inf |
| 313 | + rhcp_gain_dBi = 10 * math.log10(rhcp_power) if rhcp_power > 0 else -999 |
| 314 | + lhcp_gain_dBi = 10 * math.log10(lhcp_power) if lhcp_power > 0 else -999 |
311 | 315 |
|
312 | 316 | # Axial ratio in dB |
313 | 317 | max_pol_power = max(rhcp_power, lhcp_power) |
314 | 318 | min_pol_power = min(rhcp_power, lhcp_power) |
315 | 319 | if min_pol_power == 0: |
316 | | - axial_ratio_dB = float('inf') |
| 320 | + axial_ratio_dB = 999 |
317 | 321 | else: |
318 | 322 | axial_ratio_dB = 10 * math.log10(max_pol_power / min_pol_power) |
319 | 323 |
|
320 | 324 | # Polarization sense |
321 | | - if axial_ratio_dB == float('inf'): |
| 325 | + if axial_ratio_dB == 999: |
322 | 326 | polarization_sense = "Linear" |
323 | 327 | elif rhcp_power > lhcp_power: |
324 | 328 | polarization_sense = "RHCP" |
|
344 | 348 | vert_power = abs(E_theta)**2 |
345 | 349 | horiz_power = abs(E_phi)**2 |
346 | 350 |
|
347 | | - vert_gain_dBi = 10 * math.log10(vert_power) if vert_power > 0 else -math.inf |
348 | | - horiz_gain_dBi = 10 * math.log10(horiz_power) if horiz_power > 0 else -math.inf |
| 351 | + vert_gain_dBi = 10 * math.log10(vert_power) if vert_power > 0 else -999 |
| 352 | + horiz_gain_dBi = 10 * math.log10(horiz_power) if horiz_power > 0 else -999 |
349 | 353 |
|
350 | 354 | return { |
351 | 355 | 'vert_gain_dBi': vert_gain_dBi, |
|
363 | 367 | } |
364 | 368 |
|
365 | 369 |
|
| 370 | +</pre> |
| 371 | +</details> |
| 372 | +<details><summary><span class ='def signature'> def _extract_pattern_grid_info(pattern):</span></summary> |
| 373 | +<pre class ='def content'> # Compute theta and phi for each entry |
| 374 | + for entry in pattern: |
| 375 | + entry['theta_deg'] = 90.0 - entry['elevation_deg'] |
| 376 | + entry['phi_deg'] = entry['azimuth_deg'] |
| 377 | + |
| 378 | + # Extract sorted unique theta and phi values |
| 379 | + theta_vals = sorted(set(round(e['theta_deg'], 5) for e in pattern)) |
| 380 | + phi_vals = sorted(set(round(e['phi_deg'], 5) for e in pattern)) |
| 381 | + |
| 382 | + # Determine steps (assuming uniform grid) |
| 383 | + if len(theta_vals) > 1: |
| 384 | + theta_step = round(theta_vals[1] - theta_vals[0], 5) |
| 385 | + else: |
| 386 | + theta_step = 0.0 |
| 387 | + |
| 388 | + if len(phi_vals) > 1: |
| 389 | + phi_step = round(phi_vals[1] - phi_vals[0], 5) |
| 390 | + else: |
| 391 | + phi_step = 0.0 |
| 392 | + |
| 393 | + n_theta = len(theta_vals) |
| 394 | + n_phi = len(phi_vals) |
| 395 | + |
| 396 | + return n_theta, n_phi, theta_step, phi_step |
| 397 | + |
| 398 | + |
| 399 | + |
366 | 400 | </pre> |
367 | 401 | </details> |
368 | 402 | <details><summary><span class ='def signature'> def _get_available_results(model):</span></summary> |
|
629 | 663 | LDTAG = LD['iTag'] |
630 | 664 | R_Ohms, L_uH , C_pF = LD['RoLuCp'] |
631 | 665 | # these strings are set programatically so shouldn't need an error trap |
632 | | - f.write(f"LD {LDTYP} {LDTAG} 0 0 {R_Ohms} {L_uH * 1e-6} {C_pF * 1e-12}\n") |
| 666 | + f.write(f"LD {LDTYP} {LDTAG} 0 0 {R_Ohms:8.4e} {L_uH * 1e-6:8.4e} {C_pF * 1e-12:8.4e}\n") |
633 | 667 |
|
634 | 668 | # Feed |
635 | 669 | f.write(f"EX 0 {self.EX_tag} 1 0 1 0\n") |
|
0 commit comments