File: nec_norm_rx_pattern.py

package info (click to toggle)
necpp 1.2.4%2Bcvs20060601-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,764 kB
  • ctags: 5,989
  • sloc: cpp: 30,174; ansic: 10,162; fortran: 8,333; python: 2,948; makefile: 186; sh: 1
file content (201 lines) | stat: -rw-r--r-- 5,115 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#nec_norm_rx_pattern.py

#header generated by SWIG

import _PyNEC

def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
    if (name == "this"):
        if isinstance(value, class_type):
            self.__dict__[name] = value.this
            if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown
            del value.thisown
            return
    method = class_type.__swig_setmethods__.get(name,None)
    if method: return method(self,value)
    if (not static) or hasattr(self,name) or (name == "thisown"):
        self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)

def _swig_setattr(self,class_type,name,value):
    return _swig_setattr_nondynamic(self,class_type,name,value,0)

def _swig_getattr(self,class_type,name):
    method = class_type.__swig_getmethods__.get(name,None)
    if method: return method(self)
    raise AttributeError,name

import types
try:
    _object = types.ObjectType
    _newclass = 1
except AttributeError:
    class _object : pass
    _newclass = 0
del types

#end of the header generated by SWIG



import numarray
import numarray.ma

#some utility functions

def _get_mag(arg0): 
	"""
	Returns the array of receiving gain not yet normalized.
	"""
    	n_theta = _get_n_theta(arg0)
	n_phi = _get_n_phi(arg0)
	ar = numarray.reshape(_PyNEC.nec_norm_rx_pattern_get_mag(arg0),(n_theta, n_phi))
	ar.transpose()
	return ar


def _get_n_theta(arg0):
	"""
	Returns the number of theta angles.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_n_theta(arg0)


def _get_n_phi(arg0):
	"""
	Returns the number of phi angles.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_n_phi(arg0)


def _get_theta_start(arg0):
	"""
	Returns the first value of theta in degrees.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_theta_start(arg0)


def _get_phi_start(arg0):
	"""
	Returns the first value of phi angles in degrees.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_phi_start(arg0)


def _get_delta_theta(arg0):
	"""
	Returns the increment for theta in degrees.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_delta_theta(arg0)


def _get_delta_phi(arg0):
	"""
	Returns the increment for phi in degrees.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_delta_phi(arg0)



#class "nec_norm_rx_pattern"

class nec_norm_rx_pattern(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, nec_norm_rx_pattern, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, nec_norm_rx_pattern, name)
    def __init__(self): raise RuntimeError, "No constructor defined"
    def __repr__(self):
        return "<%s.%s; proxy of C++ nec_norm_rx_pattern instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
    
    
    def get_frequency(*args):
    	"""
	Returns the frequency in Hertz.
	"""
    	return _PyNEC.nec_norm_rx_pattern_get_frequency(*args)
    
    
    def get_eta(*args):
    	"""
	Returns the value of eta in degrees.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_eta(*args)
	
	
    def get_axial_ratio(*args):
    	"""
	Returns the axial ratio (no units).
	"""
	return _PyNEC.nec_norm_rx_pattern_get_axial_ratio(*args)
	
	
    def get_segment_number(*args):
    	"""
	Returns the segment number.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_segment_number(*args)
	
	
    def get_polarization_type(*args):
    	"""
	Return the polarization type.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_type(*args)
	
	
    def get_norm_factor(*args):
    	"""
	Returns the normalization factor in Amperes.
	"""
	return _PyNEC.nec_norm_rx_pattern_get_norm_factor(*args)
	
	
    def get_coordinates(*args):
    	"""
	Returns the array of coordinates of the elements of the other arrays :
		an array of tuples (theta, phi)  - in (degrees, degrees).
	""" 
    	n_theta=_get_n_theta(*args)
        n_phi=_get_n_phi(*args)
	theta_start = _get_theta_start(*args)
	delta_theta = _get_delta_theta(*args)
	phi_start = _get_phi_start(*args)
	delta_phi = _get_delta_phi(*args)
	l=[]
	
	for i in range(n_phi) :
			for j in range(n_theta) :
				l.append((theta_start+j*delta_theta, phi_start+i*delta_phi))
	
	ar = numarray.array(l);
	ar = numarray.reshape(ar, (n_phi,n_theta,2))
	return ar 

	    
    def get_magnitude(*args):
    	"""
	Returns the array of magnitude of the normalized receiving gain (no units).
	"""
    	norm_factor = nec_norm_rx_pattern.get_norm_factor(*args)
    	return _get_mag(*args)/norm_factor
	

    def get_gain(self,*args):
    	"""
	Returns the array of normalized receiving gain in dB.
	""" 
    	mag = self.get_magnitude(*args)
	gain = 20*numarray.ma.log10(mag)
	gain.set_fill_value(-999.999)
	return gain.filled()



class nec_norm_rx_patternPtr(nec_norm_rx_pattern):
    def __init__(self, this):
        _swig_setattr(self, nec_norm_rx_pattern, 'this', this)
        if not hasattr(self,"thisown"): _swig_setattr(self, nec_norm_rx_pattern, 'thisown', 0)
        _swig_setattr(self, nec_norm_rx_pattern,self.__class__,nec_norm_rx_pattern)
_PyNEC.nec_norm_rx_pattern_swigregister(nec_norm_rx_patternPtr)