コード例 #1
0
 def init_voltage_beams (self):
   """initializes VoltageBeams for the given set of FITS files (per each _vb_key, that is).
   Returns list of 1 or 4 VoltageBeam objects."""
   # maintain a global dict of VoltageBeam objects per each filename set, so that we reuse them
   global _voltage_beams;
   if not '_voltage_beams' in globals():
     _voltage_beams = {};
   # get VoltageBeam object from global dict, or init new one if not already defined
   vbs,beam_max = _voltage_beams.get(self._vb_key,(None,None));
   if not vbs:
     vbs = [];
     for filename_real,filename_imag in self._vb_key:
       # if files do not exist, replace with blanks
       if not ( os.path.exists(filename_real) and os.path.exists(filename_imag) ) and self.missing_is_null:
         filename_real = None;
         print "No beam pattern %s or %s, assuming null beam"%(filename_real,filename_imag);
       # now, create VoltageBeam if at least the real part still exists
       if filename_real:
         vb = LMVoltageBeam(
                 l0=self.l_0,m0=self.m_0,
                 ampl_interpolation=self.ampl_interpolation,spline_order=self.spline_order,
                 verbose=self.verbose);
         vb.read(filename_real,filename_imag);
       else:
         vb = None;
       # work out norm of beam
       vbs.append(vb);
     xx = [ vb.beam() if vb else numpy.array([0]) for vb in vbs[:len(vbs)/2] ];
     yy = [ vb.beam() if vb else numpy.array([0]) for vb in vbs[len(vbs)/2:] ];
     beam_max = math.sqrt(max([ (abs(x)**2+abs(y)**2).max() for x,y in zip(xx,yy)]));
     _voltage_beams[self._vb_key] = vbs,beam_max;
   return vbs,beam_max;
コード例 #2
0
 def init_voltage_beams(self):
     """initializes VoltageBeams for the given set of FITS files (per each _vb_key, that is).
 Returns list of 1 or 4 VoltageBeam objects."""
     # maintain a global dict of VoltageBeam objects per each filename set, so that we reuse them
     global _voltage_beams
     if not '_voltage_beams' in globals():
         _voltage_beams = {}
     # get VoltageBeam object from global dict, or init new one if not already defined
     vbs, beam_max = _voltage_beams.get(self._vb_key, (None, None))
     if not vbs:
         vbs = []
         for filename_real, filename_imag in self._vb_key:
             # if files do not exist, replace with blanks
             if not (os.path.exists(filename_real) and os.path.exists(
                     filename_imag)) and self.missing_is_null:
                 filename_real = None
                 print("No beam pattern %s or %s, assuming null beam" %
                       (filename_real, filename_imag))
             # now, create VoltageBeam if at least the real part still exists
             if filename_real:
                 vb = LMVoltageBeam(
                     l0=self.l_0,
                     m0=self.m_0,
                     ampl_interpolation=self.ampl_interpolation,
                     spline_order=self.spline_order,
                     verbose=self.verbose)
                 vb.read(filename_real, filename_imag)
             else:
                 vb = None
             # work out norm of beam
             vbs.append(vb)
         xx = [
             vb.beam() if vb else numpy.array([0])
             for vb in vbs[:len(vbs) // 2]
         ]
         yy = [
             vb.beam() if vb else numpy.array([0])
             for vb in vbs[len(vbs) // 2:]
         ]
         beam_max = math.sqrt(
             max([(abs(x)**2 + abs(y)**2).max() for x, y in zip(xx, yy)]))
         _voltage_beams[self._vb_key] = vbs, beam_max
     return vbs, beam_max
コード例 #3
0
        vellsets.append(meq.vellset(vells));
    # create result object
    cells = request.cells if hasfreq else getattr(lm,'cells',None);
    result = meq.result(vellsets[0],cells=cells);
    result.vellsets[1:] = vellsets[1:];
    result.dims = (2,len(vellsets)/2);
    return result;



# test clause
if __name__ == "__main__":
  _verbosity.set_verbose(5);

  vb = LMVoltageBeam(spline_order=3);
  vb.read("beam_xx_re.fits","beam_xx_im.fits");

  l0 = numpy.array([-2,-1,0,1,2])*DEG;
  l = numpy.vstack([l0]*len(l0));

  print vb.interpolate(l,l.T);

  vb = LMVoltageBeam(spline_order=3);
  vb.read("XX_0_Re.fits","XX_0_Im.fits");

  l0 = numpy.array([-4,-2,0,2,4])*DEG;
  l = numpy.vstack([l0]*len(l0));

  a = vb.interpolate(l,l.T,freq=[1e+9],freqaxis=2);
  b = vb.interpolate(l,l.T,freq=[1e+9,1.1e+9,1.2e+9],freqaxis=2);
  c = vb.interpolate(l,l.T,freq=[1e+9,1.1e+9,1.2e+9,1.3e+9,1.4e+9],freqaxis=1);
コード例 #4
0
                # make vells and return result
                vellsets.append(meq.vellset(vells))
        # create result object
        cells = request.cells if hasfreq else getattr(lm, 'cells', None)
        result = meq.result(vellsets[0], cells=cells)
        result.vellsets[1:] = vellsets[1:]
        result.dims = (2, len(vellsets) // 2)
        return result


# test clause
if __name__ == "__main__":
    _verbosity.set_verbose(5)

    vb = LMVoltageBeam(spline_order=3)
    vb.read("beam_xx_re.fits", "beam_xx_im.fits")

    l0 = numpy.array([-2, -1, 0, 1, 2]) * DEG
    l = numpy.vstack([l0] * len(l0))

    print(vb.interpolate(l, l.T))

    vb = LMVoltageBeam(spline_order=3)
    vb.read("XX_0_Re.fits", "XX_0_Im.fits")

    l0 = numpy.array([-4, -2, 0, 2, 4]) * DEG
    l = numpy.vstack([l0] * len(l0))

    a = vb.interpolate(l, l.T, freq=[1e+9], freqaxis=2)
    b = vb.interpolate(l, l.T, freq=[1e+9, 1.1e+9, 1.2e+9], freqaxis=2)
    c = vb.interpolate(l,