示例#1
0
        v = v * u.Unit('km/s')
    
    # b
    bval = (v/const.c.to('km/s'))
    
    # R
    R = np.sqrt((1-bval)/(1+bval))
    # Finally
    znew = (1+z)/R - 1

    return znew.value


# ###################
# TESTING
if __name__ == '__main__':

    from astropy.relativity import velocities as arv
    # v_from_z
    z1=2.0
    z2=2.01
    v = arv.v_from_z(z1,z2)
    print('v_from_z: v = {:g}, for (z1,z2) = ({:g},{:g})'.format(v,z1,z2))

    # z_from_v
    z1 = arv.z_from_v(z2,v)
    print('z_from_v: v = {:g}, for (z1,z2) = ({:g},{:g})'.format(v,z1,z2))
    twov = np.array([-300., -3000.])
    z2 = arv.z_from_v(z1,twov)
    print(z2)
示例#2
0
    def get_zpeak(self):
        ''' Measure zpeak from an ionic transition
        '''
        if self.ions is None:
            print('get_zpeak: Need to fill ions with get_ions first.')
            return

        # Ions for analysis
        low_ions = [ (14,2), (6,2), (13,2), (26,2), (13,3)]
        high_ions= [(14,4), (6,4)]

        for tt in range(4):
            if tt == 0:
                ions = low_ions
                iflg = 1 # Standard
            elif tt == 1:
                ions = low_ions
                iflg = 2 # Saturated
            elif tt == 2:
                ions = high_ions
                iflg = 1 # Standard
            elif tt == 3:
                ions = high_ions
                iflg = 2 # Standard
            else:
                raise ValueError('Bad value')

            # Search 
            for ion in ions:
                try:
                    t = self.ions[ion]
                except KeyError:
                    continue
                # Measurement?
                if t['flg_clm'] == iflg:
                # Identify the transition
                    gdi = np.where( (self.ions.trans['Z'] == ion[0]) &
                                (self.ions.trans['ion'] == ion[1]) &
                                (self.ions.trans['flg_clm'] <= iflg) )[0]
                    # Take the first one
                    gdt = self.ions.trans[gdi[0]]
                    wrest = gdt['wrest']
                    flgs = self.clm_analy.clm_lines[wrest].analy['FLAGS']
                    spec_file = self.clm_analy.fits_files[flgs[1] % 64]
                    # Generate an Abs_Line with spectrum
                    line = abs_line.Abs_Line(wrest, z=self.clm_analy.zsys, spec_file=spec_file)
                    # vpeak
                    from astropy.relativity import velocities as arv
                    vpeak = line.vpeak()
                    self.zpeak = arv.z_from_v(self.clm_analy.zsys, vpeak)
                    if tt == 3:
                        print('zpeak WARNING: Using saturated high-ions!!')
                    break
            else:
                continue
            # get out
            break

        # Error catching
        if self.zpeak is None:
            # Skip primordial LLS
            print('lls_utils.zpeak: No transition in {:s}'.format(self.clm_analy.clm_fil))
            xdb.set_trace()
            return (0,0), 0.
        # Return
        return ion, vpeak
示例#3
0
        v = v * u.Unit('km/s')

    # b
    bval = (v / const.c.to('km/s'))

    # R
    R = np.sqrt((1 - bval) / (1 + bval))
    # Finally
    znew = (1 + z) / R - 1

    return znew.value


# ###################
# TESTING
if __name__ == '__main__':

    from astropy.relativity import velocities as arv
    # v_from_z
    z1 = 2.0
    z2 = 2.01
    v = arv.v_from_z(z1, z2)
    print('v_from_z: v = {:g}, for (z1,z2) = ({:g},{:g})'.format(v, z1, z2))

    # z_from_v
    z1 = arv.z_from_v(z2, v)
    print('z_from_v: v = {:g}, for (z1,z2) = ({:g},{:g})'.format(v, z1, z2))
    twov = np.array([-300., -3000.])
    z2 = arv.z_from_v(z1, twov)
    print(z2)