nec2++ 2.1.1
RadiationInput.h
1/*
2 Copyright (C) 2004-2005 Timothy C.A. Molteno
3 tim@molteno.net
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19#pragma once
20
21#include <vector>
22
23#include "BaseInput.h"
24
26{
27public:
28 vector<double> theta, phi;
29 vector<double> power_v, power_h, power_t;
30 vector<double> pol_axial_ratio, pol_tilt;
31 string pol_sense; // ignore polarization sense
32 vector<double> E_theta_mag, E_phi_mag;
33 vector<double> E_theta_phase, E_phi_phase;
34
35 long n_items;
36
37 RadiationInput(std::string& filename)
38 : BaseInput(filename)
39 {
40 n_items = 0;
41
42 string searchString("RADIATION PATTERNS");
43 while (m_stream.good())
44 {
45 string line = readline();
46
47 if (line.find(searchString,0) != string::npos)
48 {
49
50 while (line.find("VOLTS/M",0) == string::npos)
51 line = readline();
52
53 /*
54 - - ANGLES - - - POWER GAINS - - - - POLARIZATION - - - - - - E(THETA) - - - - - - E(PHI) - - -
55 THETA PHI VERT. HOR. TOTAL AXIAL TILT SENSE MAGNITUDE PHASE MAGNITUDE PHASE
56 DEGREES DEGREES DB DB DB RATIO DEG. VOLTS/M DEGREES VOLTS/M DEGREES
57 .00 .00 -999.99 -3.23 -3.23 .00000 -90.00 LINEAR 0.00000E+00 -81.39 7.35700E-05 -195.64
58 */
59 line = readline();
60
61 while (line != "")
62 {
63 stringstream ss(line);
64
65 theta.push_back(read_fixed(ss));
66 phi.push_back(read_fixed(ss));
67 power_v.push_back(read_fixed(ss));
68 power_h.push_back(read_fixed(ss));
69 power_t.push_back(read_fixed(ss));
70 pol_axial_ratio.push_back(read_fixed(ss));
71 pol_tilt.push_back(read_fixed(ss));
72
73 ss >> pol_sense;
74
75 E_theta_mag.push_back(read_sci(ss));
76 E_theta_phase.push_back(read_fixed(ss));
77
78 E_phi_mag.push_back(read_sci(ss));
79 E_phi_phase.push_back(read_fixed(ss));
80
81 line = readline();
82 n_items++;
83 }
84 cout << "Radiation pattern: " << n_items << " lines" << endl;
85 }
86 }
87 }
88
89 bool equalto(const RadiationInput& ai)
90 {
91 if (difference(ai) > 1e-4)
92 return false;
93
94 return true;
95 }
96
97 double difference(const RadiationInput& ai)
98 {
99 double ret = 0.0;
100 // compart angles
101 if (n_items != ai.n_items)
102 return 1;
103
104 for (long i=0; i < n_items;i++)
105 {
106 if (theta[i] != ai.theta[i])
107 return 1;
108 if (phi[i] != ai.phi[i])
109 return 1;
110
111 try
112 {
113 ret += diff(power_v[i], ai.power_v[i]);
114 ret += diff(power_h[i], ai.power_h[i]);
115 ret += diff(power_t[i], ai.power_t[i]);
116 if (power_v[i] > -999.0)
117 {
118 ret += diff(pol_axial_ratio[i], ai.pol_axial_ratio[i]);
119 ret += diff(pol_tilt[i], ai.pol_tilt[i]);
120
121 ret += diff(deg_polar(E_theta_mag[i],E_theta_phase[i]), deg_polar(ai.E_theta_mag[i],ai.E_theta_phase[i]));
122 ret += diff(deg_polar(E_phi_mag[i],E_phi_phase[i]), deg_polar(ai.E_phi_mag[i],ai.E_phi_phase[i]));
123 }
124 }
125 catch (string message)
126 {
127 cout << "Diff at [" << theta[i] << "," << phi[i] << "] : " << message << endl;
128 }
129 }
130 return ret;
131 };
132};
Definition BaseInput.h:69
Definition RadiationInput.h:26