예제 #1
0
 def load_ffe(self, filename, request=None):
     ffefile = FEKOffe(filename)
     if request is None:
         if len(ffefile.Requests) == 1:
             request = ffefile.Requests.pop()
         else:
             raise RuntimeError("File contains multiple FFs (specify one): "
                                + ','.join(ffefile.Requests))
     ffereq = ffefile.Request[request]
     self.R = numpy.array(ffereq.freqs)
     self.thetaMsh = numpy.deg2rad(ffereq.theta)
     self.phiMsh = numpy.deg2rad(ffereq.phi)
     nrRs = len(self.R)
     self.Fthetas = numpy.zeros((nrRs, ffereq.stheta, ffereq.sphi),
                                dtype=complex)
     self.Fphis = numpy.zeros((nrRs, ffereq.stheta, ffereq.sphi),
                              dtype=complex)
     # Maybe this could be done better?
     # Convert list over R of arrays over theta,phi to array
     # over R, theta, phi
     for ridx in range(nrRs):
         self.Fthetas[ridx, :, :] = ffereq.etheta[ridx]
         self.Fphis[ridx, :, :] = ffereq.ephi[ridx]
     # Remove redundant azimuth endpoint 2*pi
     if ffereq.phi[0, 0] == 0. and ffereq.phi[0, -1] == 360.:
         self.thetaMsh = numpy.delete(self.thetaMsh, -1, 1)
         self.phiMsh = numpy.delete(self.phiMsh, -1, 1)
         self.Fthetas = numpy.delete(self.Fthetas, -1, 2)
         self.Fphis = numpy.delete(self.Fphis, -1, 2)
예제 #2
0
 def load_ffes(self, filename_p, filename_q):
     """Load a pair of FFE and make them correspond to this DualPolElem
     object. First file will be pol-channel p and second q."""
     ffefile_p = FEKOffe(filename_p)
     tvf_p = tvecfun.TVecFields()
     tvf_q = tvecfun.TVecFields()
     tvf_p.load_ffe(filename_p)
     tvf_q.load_ffe(filename_q)
     self.radFFp = RadFarField(tvf_p)
     self.radFFq = RadFarField(tvf_q)
예제 #3
0
    def save_ffe(self, filename, request='FarField', source='Unknown'):
        """ """
        ffefile = FEKOffe()
        ffefile.ftype = 'Far Field'
        ffefile.fformat = '3'
        ffefile.source = source
        ffefile.date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        # Setup request
        ffereq = FEKOffeRequest(request)
        if self.R is not None:
            freqs = self.R
        else:
            freqs = [0.0]
        ffereq.theta = numpy.rad2deg(self.thetaMsh)
        ffereq.phi = numpy.rad2deg(self.phiMsh)
        coord = 'Spherical'
        stheta = ffereq.theta.shape[0]
        sphi = ffereq.phi.shape[1]
        rtype = 'Gain'
        for ridx in range(len(freqs)):
            ffereq._add_head(freqs[ridx], coord, stheta, sphi, rtype)
            if self.R is not None:
                ffereq.etheta.append(self.Fthetas[ridx, :, :].squeeze())
                ffereq.ephi.append(self.Fphis[ridx, :, :].squeeze())
                gtheta = numpy.abs(self.Fthetas[ridx, :, :].squeeze())**2
                gphi = numpy.abs(self.Fphis[ridx, :, :].squeeze())**2
            else:
                ffereq.etheta.append(self.Fthetas)
                ffereq.ephi.append(self.Fphis)
                gtheta = numpy.abs(self.Fthetas)**2
                gphi = numpy.abs(self.Fphis)**2
            gtotal = gtheta + gphi
            ffereq.gtheta.append(gtheta)
            ffereq.gphi.append(gphi)
            ffereq.gtotal.append(gtotal)
        # Add redundant azimuth endpoint 2*pi ?

        ffefile.Requests.add(request)
        ffefile.Request[request] = ffereq
        ffefile.write(filename)
예제 #4
0
    def save_ffe(self, filename, request='FarField', source='Unknown'):
        """ """
        ffefile = FEKOffe()
        ffefile.ftype = 'Far Field'
        ffefile.fformat = '3'
        ffefile.source = source
        ffefile.date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        # Setup request
        ffereq = FEKOffeRequest(request)
        if self.R is not None:
            freqs = self.R
        else:
            freqs = [0.0]
        ffereq.theta   = numpy.rad2deg(self.thetaMsh)
        ffereq.phi     = numpy.rad2deg(self.phiMsh)
        coord = 'Spherical'
        stheta = ffereq.theta.shape[0]
        sphi = ffereq.phi.shape[1]
        rtype = 'Gain'
        for ridx in range(len(freqs)):
            ffereq._add_head(freqs[ridx], coord, stheta, sphi, rtype)
            if self.R is not None:
                ffereq.etheta.append(self.Fthetas[ridx,:,:].squeeze())
                ffereq.ephi.append(  self.Fphis[  ridx,:,:].squeeze())
                gtheta = numpy.abs(self.Fthetas[ridx,:,:].squeeze())**2
                gphi = numpy.abs(self.Fphis[  ridx,:,:].squeeze())**2
            else:
                ffereq.etheta.append(self.Fthetas)
                ffereq.ephi.append(  self.Fphis)
                gtheta = numpy.abs(self.Fthetas)**2
                gphi = numpy.abs(self.Fphis)**2
            gtotal = gtheta + gphi
            ffereq.gtheta.append(gtheta)
            ffereq.gphi.append(  gphi)
            ffereq.gtotal.append(gtotal)
        # Add redundant azimuth endpoint 2*pi ?

        ffefile.Requests.add(request)
        ffefile.Request[request] = ffereq
        ffefile.write(filename)
예제 #5
0
 def load_ffe(self, filename, request_p=None, request_q=None):
     #FIX: This not the most efficient way to do this as it does two passes over feko file.
     ffefile = FEKOffe(filename)
     if request_p is None and request_q is None:
         if len(ffefile.Requests) == 2:
             requests = list(ffefile.Requests)
             requests.sort()  # # FIXME: Not sure how to order requests
             request_p = requests[0]
             request_q = requests[1]
         else:
             raise RuntimeError(
                 "File contains multiple FFs (specify one): " +
                 ','.join(ffefile.Requests))
     print("Request_p= " + request_p)
     print("Request_q= " + request_q)
     tvf_p = tvecfun.TVecFields()
     tvf_q = tvecfun.TVecFields()
     tvf_p.load_ffe(filename, request_p)
     tvf_q.load_ffe(filename, request_q)
     self.radFFp = RadFarField(tvf_p)
     self.radFFq = RadFarField(tvf_q)