Example #1
0
File: mass.py Project: DJRumble/PHD
def djr_err(S,dS,T,dT,N):
    """Produces error in M/Mj = Takes inputs of; Flux (S in Jy), Flux error (S in Jy), Temperature (T in Kelvin) and Temperature error (T in Kelvin)"""
    
    A =(((np.exp(34./T)-(2.*np.exp(17./T))+1.)*(dS**2.)))
    B = (((17.*(S/T**2.))**2.)*(np.exp(34./T)*(dT**2.)))
    C = (0.39**2)*(A+B)
    dM = np.sqrt(C)
    M = djr(S,T,0.012,250)
    Mj = jeans.sadavoy(T,250,N)

    frac_m = dM/M
    frac_mj = dT/T
    print A, B, C
    print 'frac error in M =', frac_m, 'and frac error in Mj =', frac_mj

    
    R = M/Mj

    dR = R*np.sqrt((frac_m**2)+(frac_mj**2))
    print 'R =', R
    print 'error in R =', dR
    print 'Frac error in R =', dR/R

    return dM
Example #2
0
        print 'size = ',round(size_pc,2),' psc'
        density = (CDi*1E21)/size_cm
        print 'Density = ',round(density,-4), ' cm-3'

        ############
        #jeans mass#
        ############
        #Run Stats and extract NUMBER of pixels
        cmd = '%s/stats ndf=%s %s'%(kapdir,magic,'> /dev/null')
        os.system(cmd)
        cmd = '%s/parget parname=%s applic=%s'%(kapdir,'numgood','stats') 
        status, output = commands.getstatusoutput(cmd)
        Ni = float(output)

        #run module for jeans mass and error
        Ji = jeans.sadavoy(temp_mi,d,Ni)
        err_Ji = Ji * dTi
        
        #run calculation of jeans stability and error
        if float(Ji) == 0:
            equ = 0
        else:
            equ = float(mi) / float(Ji)

        #Error in mass ratio:
        frac = ((float(dMi)/float(mi))**2.)+((err_Ji/float(Ji))**2.)
        err_equ = equ * ((frac)**0.5)

        print 'Jeans mass = ',round(Ji,2),'pm',round(err_Ji,2),' Mdot'
        print 'Jeans mass ratio = ',round(equ,2),'pm',round(err_equ,2)