Ejemplo n.º 1
0
 def RM(self, newtime, ra=None, dec=None):
     """
     RM=i.RM(newtime, ra=None, dec=None))
     compute Rotation Measure (rad/m**2)
     along the zenith if ra is None
     else along the specified direction
     """
     TEC=self.__call__(newtime, ra=ra, dec=dec)
     if TEC is None:
         return None
     Bx,By,Bz=self.getB(newtime)
     if ra is None:
         # the important B is the Bz
         ZenPunc=0
         AzPunc=0
     else:
         if not isinstance(ra,astropy.units.quantity.Quantity):
             ra=angles.Angle(ra,unit=u.degree)
         if not isinstance(dec,astropy.units.quantity.Quantity):
             dec=angles.Angle(dec,unit=u.degree)
         az,el=ephem_utils.radec2azel(ra.degree,dec.degree,newtime)
         #logger.info('(RA,Dec)=(%.1f,%.1f) deg = (Az,El)=(%.1f,%.1f) deg' % (
         #    ra.degree,dec.degree,az,el))
         az=angles.Angle(az,unit=u.degree)
         el=angles.Angle(el,unit=u.degree)
         za=angles.Angle(90,unit=u.degree)-el
         dLat,dLong,AzPunc,ZenPunc=self.ionosphere_geometry(az,za)
     # convert the components of B to the B along the LOS
     # taken from ionFR.py
     B=Bz*numpy.cos(ZenPunc) + numpy.sin(ZenPunc)*(By*numpy.sin(AzPunc)+Bx*numpy.cos(AzPunc))
         
     # TEC is in 0.1 TECU
     # B is in G
     RM=RMconstant*B*TEC*1e15
     return RM
Ejemplo n.º 2
0
 def __call__(self, newtime, ra=None, dec=None):
     """
     TEC=i(newtime, ra=None, dec=None)
     returns the zenith TEC (if ra is None)
     else the total TEC along the line-of-sight
     in 0.1*TECU
     """
     if ra is None:
         return self.interpolate(newtime)
     else:
         if not isinstance(ra,astropy.units.quantity.Quantity):
             ra=angles.Angle(ra,unit=u.degree)
         if not isinstance(dec,astropy.units.quantity.Quantity):
             dec=angles.Angle(dec,unit=u.degree)
         az,el=ephem_utils.radec2azel(ra.degree,dec.degree,newtime)
         #print '(RA,Dec)=(%.1f,%.1f) deg = (Az,El)=(%.1f,%.1f) deg' % (
         #    ra.degree,dec.degree,az,el)
         az=angles.Angle(az,unit=u.degree)
         el=angles.Angle(el,unit=u.degree)
         za=angles.Angle(90,unit=u.degree)-el
         dLat,dLong,AzPunc,ZenPunc=self.ionosphere_geometry(az,za)
         #print dLat.to(u.degree),dLong.to(u.degree),AzPunc.to(u.degree),ZenPunc.to(u.degree)
         # return the full line of sight TEC, converting from vertical
         return self.interpolate(newtime, dlong=dLong,
                                 dlat=dLat)/numpy.cos(ZenPunc).value
Ejemplo n.º 3
0
                self.calibration = self._Schedule_Metadata.calibration
                self.calibrators = self._Schedule_Metadata.calibrators
            except (psycopg2.InternalError, psycopg2.ProgrammingError), e:
                logger.warning('Database error=%s' % (e.pgerror))
                db.rollback()

            mwa = ephem_utils.Obs[ephem_utils.obscode['MWA']]

            if (self._RFstream.ra is not None):
                logger.info('Found (RA,Dec) in RFstream (%.5f,%.5f)\n' %
                            (self._RFstream.ra, self._RFstream.dec))
                self.RA = self._RFstream.ra
                self.Dec = self._RFstream.dec
                mwatime = ephem_utils.MWATime(gpstime=self.observation_number)

                self.azimuth, self.elevation = ephem_utils.radec2azel(
                    self.RA, self.Dec, self.observation_number)
                self.HA = ephem_utils.HA(self.LST, self.RA, self.Dec,
                                         self.epoch) / 15.0

            elif (self._RFstream.azimuth is not None):
                logger.info('Found (Az,El) in RFstream (%.5f,%.5f)\n' %
                            (self._RFstream.azimuth, self._RFstream.elevation))
                self.azimuth = self._RFstream.azimuth
                self.elevation = self._RFstream.elevation
                self.RA, self.Dec = ephem_utils.azel2radec(
                    self.azimuth, self.elevation, self.observation_number)
                self.HA = ephem_utils.HA(self.LST, self.RA, self.Dec,
                                         self.epoch) / 15.0

            elif (self._RFstream.hex is not None
                  and len(self._RFstream.hex) > 0):
Ejemplo n.º 4
0
    except:
        logger.error("Unable to find coordinates for '%s'" % options.source)
        sys.exit(1)

if coord is None:
    logger.error('Must supply one of (RA,Dec), (l,b), source')
    sys.exit(1)

observation_num = get_observation_info.find_closest_observation(observationid,
                                                                maxdiff=0,
                                                                db=db)
if observation_num is None:
    logger.error('Observation not found for gpstime=%d' % observationid)
    sys.exit(1)
obs = get_observation_info.MWA_Observation(observationid, db=db)
Az, El = ephem_utils.radec2azel(coord.ra.degree, coord.dec.degree,
                                obs.observation_number)
# first go from altitude to zenith angle
theta = numpy.radians((90 - El))
phi = numpy.radians(Az)
# this is the response for XX and YY
try:
    respX, respY = primary_beam.MWA_Tile_analytic(theta,
                                                  phi,
                                                  freq=obs.center_channel *
                                                  1.28e6,
                                                  delays=obs.delays)
except:
    logger.error('Error creating primary beams\n')
    sys.exit(1)

rX = numpy.real(numpy.conj(respX) * respX)