コード例 #1
0
def disp_delay_inf(freq1=0.184975, DM=0.0):
    """
	Accepts lower band-edge frequency and a DM, returns the dispersion delay 
	in milliseconds realtive to infinite frequncy.
	Default: frequency = 184.975 MHz, DM = 0 pc/cm^3
	"""
    A = e.value ** 2 / (8 * pi ** 2 * m_e.value * c.value * eps0.value)
    A = A * (1.0 / 1.0e9) ** 2 * (1e6) * (1e3) * pc.to("m").value

    del_t = A * DM * freq ** (-2)

    return del_t
コード例 #2
0
def disp_delay(freq1=0.184975, freq2=0.200335, DM=0.0):
    """
	Accepts two frequencies as input (low then high, in GHz) as well as a 
	DM (in pc/cm^3) and reports the delay in milliseconds (ms).
	Default frequncies: 184.975 and 200.355 MHz, default DM=0.0 pc/cm^3
	"""

    # constant from analytic cold plasma dispersion
    A = e.value ** 2 / (8 * pi ** 2 * m_e.value * c.value * eps0.value)

    # convert into units: GHz^2 cm^3 ms / pc
    A = A * (1.0 / 1.0e9) ** 2 * (1e6) * (1e3) * pc.to("m").value

    del_t = A * DM * ((freq1) ** (-2) - (freq2) ** (-2))

    return del_t
コード例 #3
0
def get_qsfit_M1450(qsfit,alpha_nu=-0.4):
    cwave = np.zeros(len(qsfit))
    qsfitCont = np.zeros(len(qsfit))
    for wv in ['1450','2245','3000','4210','5100']:
        contk = 'CONT%s__LUM' % wv
        contwk = 'CONT%s__WAVE' % wv
        ii = np.where((cwave==0) & ~np.isnan(qsfit[contk]))[0]
        if len(ii) > 0:
            cwave[ii] = qsfit[contwk][ii]
            qsfitCont[ii] = qsfit[contk][ii]
    cnu = (cwave*u.Angstrom).to(u.Hz,equivalencies=u.spectral())
    cnu1450 = (1450.*u.Angstrom).to(u.Hz,equivalencies=u.spectral())
    qsfitLnu1450 = (qsfitCont*1e42/cnu)*(cnu1450/cnu)**alpha_nu
    fourpidsqr = 4*np.pi*(10*pc.to('cm').value)**2
    qsfitM1450 = -2.5*np.log10(qsfitLnu1450.value/fourpidsqr) - 48.6
    return qsfitM1450
コード例 #4
0
    def __init__(self,model,dx,nphi=2**12,screen_res=2,\
                 wavelength=1.3e-3,dpc=8400,rpc=5800,r0 = 'sgra',\
                 r_outer=10000000,r_inner=12,alpha='kolmogorov',\
                 anisotropy=2.045,pa=78,match_screen_res=False,live_dangerously=False,think_positive=False):

        # set initial members
        self.logger = logging.getLogger(self.__class__.__name__)
        self.live_dangerously = live_dangerously
        self.think_positive = think_positive

        self.wavelength = wavelength * 1e-3  # observing wavelength in km
        self.dpc = float(dpc)  # earth-source distance in pc
        self.rpc = float(rpc)  # R: source-scatterer distance in pc
        self.d = self.dpc - self.rpc  # D: earth-scatterer distance in pc
        self.m = self.d / self.rpc  # magnification factor (D/R)
        if r0 == 'sgra':
            # major axis (EW) phase coherence length in km
            self.r0 = 3136.67 * (1.3e-6 / self.wavelength)
        else:
            try:
                self.r0 = float(r0)
            except:
                raise ValueError('Bad value for r0')
        self.anisotropy = anisotropy  # anisotropy for screen = (EW / NS elongation)
        self.pa = pa  # orientation of major axis, E of N (or CCW of +y)

        # Fresnel scale in km
        self.rf = sqrt(self.dpc * pc.to(units.km).value /
                       (2 * pi / self.wavelength) * self.m / (1 + self.m)**2)

        # compute pixel scale for image
        if match_screen_res:
            self.ips = 1
            self.screen_dx = screen_res * self.r0
        else:
            self.screen_dx = screen_res * self.r0  # size of a screen pixel in km
            self.ips = int(
                ceil(1e-6 * dx * self.d * au.to(units.km).value /
                     self.screen_dx))  # image pixel / screen pixel

        # image arrays
        self.dx = 1e6 * self.ips * (self.screen_dx /
                                    (au.to(units.km).value * self.d)
                                    )  # image pixel scale in uas
        self.nx = int(ceil(model.shape[-1] * dx /
                           self.dx))  # number of image pixels
        self.model = model  # source model
        self.model_dx = dx  # source model resolution
        self.iss = np.array([], dtype=np.float64)  # scattered image
        self.isrc = np.array(
            [],
            dtype=np.float64)  # source image at same scale as scattered image

        # screen parameters
        if type(nphi) == int:
            self.nphi = (nphi, nphi)  # size of screen array
        else:
            self.nphi = nphi
        self.nphi = np.asarray(self.nphi)
        self.r_inner = r_inner  # inner turbulence scale in r0
        self.r_outer = r_outer  # outer turbulence scale in r0
        #self.qmax = 1.*screen_res/r_inner                            # 1 / inner turbulence scale in pix
        #self.qmin = 1.*screen_res/r_outer                            # 1 / outer tubulence scale in pix
        if alpha == 'kolmogorov':
            self.alpha = 5. / 3
        else:
            try:
                self.alpha = float(alpha)
            except:
                raise ValueError('Bad value for alpha')

        # use logger to report
        self.chatter()

        # includes sanity check
        self.setModel(self.model,
                      self.model_dx,
                      think_positive=self.think_positive)
コード例 #5
0
ファイル: brane.py プロジェクト: achael/scatterbrane
  def __init__(self,model,dx,nphi=2**12,screen_res=2,\
               wavelength=1.3e-3,dpc=8400,rpc=5800,r0 = 'sgra',\
               r_outer=10000000,r_inner=12,alpha='kolmogorov',\
               anisotropy=2.045,pa=78,match_screen_res=False,live_dangerously=False,think_positive=False):

    # set initial members
    self.logger = logging.getLogger(self.__class__.__name__)
    self.live_dangerously = live_dangerously
    self.think_positive = think_positive

    self.wavelength = wavelength*1e-3          # observing wavelength in km
    self.dpc = float(dpc)                      # earth-source distance in pc
    self.rpc = float(rpc)                      # R: source-scatterer distance in pc
    self.d   = self.dpc - self.rpc             # D: earth-scatterer distance in pc
    self.m   = self.d/self.rpc                 # magnification factor (D/R)
    if r0 == 'sgra':
        # major axis (EW) phase coherence length in km
        self.r0  = 3136.67*(1.3e-6/self.wavelength)
    else:
        try:
            self.r0 = float(r0)
        except:
            raise ValueError('Bad value for r0')
    self.anisotropy = anisotropy               # anisotropy for screen = (EW / NS elongation)
    self.pa = pa                               # orientation of major axis, E of N (or CCW of +y)

    # Fresnel scale in km
    self.rf = sqrt(self.dpc*pc.to(units.km).value / (2*pi / self.wavelength) * self.m / (1+self.m)**2)

    # compute pixel scale for image
    if match_screen_res:
      self.ips = 1
      self.screen_dx = screen_res * self.r0
    else:
      self.screen_dx = screen_res * self.r0                     # size of a screen pixel in km   
      self.ips = int(ceil(1e-6*dx*self.d*au.to(units.km).value/self.screen_dx)) # image pixel / screen pixel

    # image arrays
    self.dx = 1e6 * self.ips * (self.screen_dx / (au.to(units.km).value * self.d))  # image pixel scale in uas
    self.nx = int(ceil(model.shape[-1] * dx / self.dx))          # number of image pixels
    self.model = model                                           # source model
    self.model_dx = dx                                           # source model resolution
    self.iss  = np.array([],dtype=np.float64)                    # scattered image
    self.isrc = np.array([],dtype=np.float64)                    # source image at same scale as scattered image

    # screen parameters
    if type(nphi) == int:
        self.nphi = (nphi,nphi)                                  # size of screen array
    else:
        self.nphi = nphi
    self.nphi = np.asarray(self.nphi)
    self.r_inner = r_inner                                       # inner turbulence scale in r0
    self.r_outer = r_outer                                       # outer turbulence scale in r0
    #self.qmax = 1.*screen_res/r_inner                            # 1 / inner turbulence scale in pix
    #self.qmin = 1.*screen_res/r_outer                            # 1 / outer tubulence scale in pix
    if alpha == 'kolmogorov':
        self.alpha = 5./3
    else:
        try:
            self.alpha = float(alpha)
        except:
            raise ValueError('Bad value for alpha')

    # use logger to report
    self.chatter()

    # includes sanity check
    self.setModel(self.model,self.model_dx,think_positive=self.think_positive)