Beispiel #1
0
def run(gp):
    import gr_params
    gpr = gr_params.grParams(gp)
    print('input: ', gpr.fil)
    M0,x0,y0,z0,vx0, vy0, vz0, comp0 = read_data(gpr.fil)
    # [Msun], 3*[pc], 3*[km/s], [1]

    # assign population
    if gp.pops==2:
        pm1 = (comp0 == 1) # will be overwritten below if gp.metalpop
        pm2 = (comp0 == 2) # same same
    elif gp.pops==1:
        pm1 = (comp0 < 3)
        pm2 = (comp0 == -1) # assign none, but of same length as comp0

    # cut to subsets
    ind1 = gh.draw_random_subset(x1, gp.ntracer[1-1])
    M1, x1, y1, z1, vx1, vy1, vz1, comp1 = select_pm(M1, x1, y1, z1, vx1, vy1, vz1, comp1, ind1)

    ind2 = gh.draw_random_subset(x2, gp.ntracer[2-1])
    M2, x2, y2, z2, vx2, vy2, vz2, comp2 = select_pm(M2, x2, y2, z2, vx2, vy2, vz2, comp2, ind2)

    # use vz for no contamination, or vb for with contamination
    M0, x0, y0, z0, vx0, vy0, vz0 = concat_pops(M1, M2, x1, x2, y1, y2, z1, z2, vx1, vx2, vy1, vy2, vz1, vz2, gp)
    com_x, com_y, com_z, com_vz = com_shrinkcircle_v(x0, y0, z0, vz0, pm0) # [pc]
    print('COM [pc]: ', com_x, com_y, com_z)   # [pc]
    print('VOM [km/s]', com_vz)                # [km/s]

    # from now on, work with 2D data only; z0 was only used to get
    # center in (x,y) better
    x0 -= com_x # [pc]
    y0 -= com_y # [pc]
    vz0 -= com_vz # [km/s]

    R0 = np.sqrt(x0**2+y0**2) # [pc]
    Rhalf = np.median(R0) # [pc]
    Rscale = Rhalf        # [pc] from all tracer points

    pop = -1
    for pmn in [pm, pm1, pm2]:
        pop = pop + 1                    # population number
        pmr = ( R0 < (gp.maxR*Rscale) )  # read max extension for data
                                         #(rprior*Rscale) from
                                         #gi_params
        pmn = pmn*pmr                    # [1]
        print("fraction of members = ", 1.0*sum(pmn)/len(pmn))

        x, y, z, comp, vz, vb, Mg, PMN = select_pm(x0, y0, z0, comp0, vz0, vb0, Mg0, PM0, pmn)
        R = np.sqrt(x*x+y*y)             # [pc]
        Rscalei = np.median(R)
        gf.write_Xscale(gp.files.get_scale_file(pop), Rscalei)
        gf.write_data_output(gp.files.get_com_file(pop), x/Rscalei, y/Rscalei, vz, Rscalei)

        if gpr.showplots:
            gpr.show_part_pos(x, y, pmn, Rscale)
Beispiel #2
0
def run(gp):
    import gr_params
    gpr = gr_params.grParams(gp)
    print('input:', gpr.fil)
    x0, y0, z0, vx, vy, vz = np.transpose(np.loadtxt(gpr.fil))
    # for purely tangential beta=-0.5 models, have units of kpc instead of pc
    if gp.case == 9 or gp.case == 10:
        x0 *= 1000.  # [pc]
        y0 *= 1000.  # [pc]
        z0 *= 1000.  # [pc]
    # cutting pm_i to a maximum of ntracers particles:
    import gi_helper as gh
    ind1 = gh.draw_random_subset(x0, gp.ntracer[1 - 1])
    x0, y0, z0, vz0 = select_pm(x0, y0, z0, vz, ind1)

    PM = np.ones(
        len(x0))  # assign all particles the full probability of membership
    import gi_centering as glc
    com_x, com_y, com_z, com_vz = glc.com_shrinkcircle_v(x0, y0, z0, vz, PM)
    # from now on, work with 2D data only;
    # z0 was only used to get center in (x,y) better
    x0 -= com_x  # [pc]
    y0 -= com_y  # [pc]
    vz -= com_vz  # [km/s]
    R0 = np.sqrt(x0 * x0 + y0 * y0)  # [pc]
    Rscale = np.median(R0)  # [pc]
    import gi_file as gf
    for pop in range(gp.pops + 1):  # gp.pops +1 for all components together
        pmr = (R0 < (gp.maxR * Rscale))
        #m = np.ones(len(R0))
        x = x0[pmr]  # [pc]
        y = y0[pmr]  # [pc]
        R = np.sqrt(x * x + y * y)  # [pc]
        Rscalei = np.median(R)
        # print("x y z" on first line, to interprete data later on)
        gf.write_Xscale(gp.files.get_scale_file(pop), Rscalei)
        gf.write_data_output(gp.files.get_com_file(pop), x / Rscalei,
                             y / Rscalei, vz, Rscalei)
Beispiel #3
0
def run(gp):
    import gr_params
    gpr = gr_params.grParams(gp)
    print('input:', gpr.fil)
    x0, y0, z0, vx, vy, vz = np.transpose(np.loadtxt(gpr.fil))
    # for purely tangential beta=-0.5 models, have units of kpc instead of pc
    if gp.case == 9 or gp.case == 10:
        x0 *= 1000. # [pc]
        y0 *= 1000. # [pc]
        z0 *= 1000. # [pc]
    # cutting pm_i to a maximum of ntracers particles:
    import gi_helper as gh
    ind1 = gh.draw_random_subset(x0, gp.ntracer[1-1])
    x0, y0, z0, vz0 = select_pm(x0, y0, z0, vz, ind1)

    PM = np.ones(len(x0)) # assign all particles the full probability of membership
    import gi_centering as glc
    com_x, com_y, com_z, com_vz = glc.com_shrinkcircle_v(x0, y0, z0, vz, PM)
    # from now on, work with 2D data only;
    # z0 was only used to get center in (x,y) better
    x0 -= com_x  # [pc]
    y0 -= com_y  # [pc]
    vz -= com_vz # [km/s]
    R0 = np.sqrt(x0*x0+y0*y0) # [pc]
    Rscale = np.median(R0) # [pc]
    import gi_file as gf
    for pop in range(gp.pops+1):      # gp.pops +1 for all components together
        pmr = (R0<(gp.maxR*Rscale))
        #m = np.ones(len(R0))
        x = x0[pmr] # [pc]
        y = y0[pmr] # [pc]
        R = np.sqrt(x*x+y*y) # [pc]
        Rscalei = np.median(R)
        # print("x y z" on first line, to interprete data later on)
        gf.write_Xscale(gp.files.get_scale_file(pop), Rscalei)
        gf.write_data_output(gp.files.get_com_file(pop), x/Rscalei, y/Rscalei, vz, Rscalei)
Beispiel #4
0
def run(gp):
    import gr_params
    gpr = gr_params.grParams(gp)
    print('input: ', gpr.fil)
    x0,y0,z0,vb0,vz0,Mg0,PM0,comp0 = read_data(gpr.fil)
    # [pc], [km/s], [1]

    # only use stars which are members of the dwarf: exclude pop3 by
    # construction
    pm = (PM0 >= gpr.pmsplit) # exclude foreground contamination,
                              #outliers

    x0, y0, z0, comp0, vb0, vz0, Mg0, PM0 = select_pm(x0, y0, z0, comp0, vb0, vz0, Mg0, PM0, pm)

    # assign population
    if gp.pops==2:
        pm1 = (comp0 == 1) # will be overwritten below if gp.metalpop
        pm2 = (comp0 == 2) # same same
    elif gp.pops==1:
        pm1 = (comp0 < 3)
        pm2 = (comp0 == -1) # assign none, but of same length as comp0

    if gp.metalpop:
        # drawing of populations based on metallicity get parameters
        # from function in pymcmetal.py

        import pickle
        fi = open('metalsplit.dat', 'rb')
        DATA = pickle.load(fi)
        fi.close()
        p, mu1, sig1, mu2, sig2, M, pm1, pm2 = DATA

    x1, y1, z1, comp1, vb1, vz1, Mg1, PM1 = select_pm(x0, y0, z0, comp0, vb0, vz0, Mg0, PM0, pm1)
    x2, y2, z2, comp2, vb2, vz2, Mg2, PM2 = select_pm(x0, y0, z0, comp0, vb0, vz0, Mg0, PM0, pm2)

    # cut to subsets
    ind1 = gh.draw_random_subset(x1, gp.ntracer[1-1])
    x1, y1, z1, comp1, vb1, vz1, Mg1, PM1 = select_pm(x1, y1, z1, comp1, vb1, vz1, Mg1, PM1, ind1)

    ind2 = gh.draw_random_subset(x2, gp.ntracer[2-1])
    x2, y2, z2, comp2, vb2, vz2, Mg2, PM2 = select_pm(x2, y2, z2, comp2, vb2, vz2, Mg2, PM2, ind2)

    # use vz for no contamination, or vb for with contamination
    x0, y0, z0, vz0, pm1, pm2, pm = concat_pops(x1, x2, y1, y2, z1, z2, vz1, vz2, gp)
    com_x, com_y, com_z, com_vz = com_shrinkcircle_v(x0, y0, z0, vz0, pm) # [pc]
    print('COM [pc]: ', com_x, com_y, com_z)   # [pc]
    print('VOM [km/s]', com_vz)                # [km/s]

    # from now on, work with 2D data only; z0 was only used to get
    # center in (x,y) better
    x0 -= com_x # [pc]
    y0 -= com_y # [pc]
    vz0 -= com_vz # [km/s]

    R0 = np.sqrt(x0**2+y0**2) # [pc]
    Rhalf = np.median(R0) # [pc]
    Rscale = Rhalf        # [pc] from all tracer points

    pop = -1
    for pmn in [pm, pm1, pm2]:
        pop = pop + 1                    # population number
        pmr = ( R0 < (gp.maxR*Rscale) )  # read max extension for data
                                         #(rprior*Rscale) from
                                         #gi_params
        pmn = pmn*pmr                    # [1]
        print("fraction of members = ", 1.0*sum(pmn)/len(pmn))

        x, y, z, comp, vz, vb, Mg, PMN = select_pm(x0, y0, z0, comp0, vz0, vb0, Mg0, PM0, pmn)
        R = np.sqrt(x*x+y*y)             # [pc]
        Rscalei = np.median(R)
        gf.write_Xscale(gp.files.get_scale_file(pop), Rscalei)
        gf.write_data_output(gp.files.get_com_file(pop), x/Rscalei, y/Rscalei, vz, Rscalei)

        if gpr.showplots:
            gpr.show_part_pos(x, y, pmn, Rscale)
Beispiel #5
0
def run(gp):
    import gr_params
    gpr = gr_params.grParams(gp)
    print('input: ', gpr.fil)
    x0, y0, z0, vb0, vz0, Mg0, PM0, comp0 = read_data(gpr.fil)
    # [pc], [km/s], [1]

    # only use stars which are members of the dwarf: exclude pop3 by
    # construction
    pm = (PM0 >= gpr.pmsplit)  # exclude foreground contamination,
    #outliers

    x0, y0, z0, comp0, vb0, vz0, Mg0, PM0 = select_pm(x0, y0, z0, comp0, vb0,
                                                      vz0, Mg0, PM0, pm)

    # assign population
    if gp.pops == 2:
        pm1 = (comp0 == 1)  # will be overwritten below if gp.metalpop
        pm2 = (comp0 == 2)  # same same
    elif gp.pops == 1:
        pm1 = (comp0 < 3)
        pm2 = (comp0 == -1)  # assign none, but of same length as comp0

    if gp.metalpop:
        # drawing of populations based on metallicity get parameters
        # from function in pymcmetal.py

        import pickle
        fi = open('metalsplit.dat', 'rb')
        DATA = pickle.load(fi)
        fi.close()
        p, mu1, sig1, mu2, sig2, M, pm1, pm2 = DATA

    x1, y1, z1, comp1, vb1, vz1, Mg1, PM1 = select_pm(x0, y0, z0, comp0, vb0,
                                                      vz0, Mg0, PM0, pm1)
    x2, y2, z2, comp2, vb2, vz2, Mg2, PM2 = select_pm(x0, y0, z0, comp0, vb0,
                                                      vz0, Mg0, PM0, pm2)

    # cut to subsets
    ind1 = gh.draw_random_subset(x1, gp.ntracer[1 - 1])
    x1, y1, z1, comp1, vb1, vz1, Mg1, PM1 = select_pm(x1, y1, z1, comp1, vb1,
                                                      vz1, Mg1, PM1, ind1)

    ind2 = gh.draw_random_subset(x2, gp.ntracer[2 - 1])
    x2, y2, z2, comp2, vb2, vz2, Mg2, PM2 = select_pm(x2, y2, z2, comp2, vb2,
                                                      vz2, Mg2, PM2, ind2)

    # use vz for no contamination, or vb for with contamination
    x0, y0, z0, vz0, pm1, pm2, pm = concat_pops(x1, x2, y1, y2, z1, z2, vz1,
                                                vz2, gp)
    com_x, com_y, com_z, com_vz = com_shrinkcircle_v(x0, y0, z0, vz0,
                                                     pm)  # [pc]
    print('COM [pc]: ', com_x, com_y, com_z)  # [pc]
    print('VOM [km/s]', com_vz)  # [km/s]

    # from now on, work with 2D data only; z0 was only used to get
    # center in (x,y) better
    x0 -= com_x  # [pc]
    y0 -= com_y  # [pc]
    vz0 -= com_vz  # [km/s]

    R0 = np.sqrt(x0**2 + y0**2)  # [pc]
    Rhalf = np.median(R0)  # [pc]
    Rscale = Rhalf  # [pc] from all tracer points

    pop = -1
    for pmn in [pm, pm1, pm2]:
        pop = pop + 1  # population number
        pmr = (R0 < (gp.maxR * Rscale))  # read max extension for data
        #(rprior*Rscale) from
        #gi_params
        pmn = pmn * pmr  # [1]
        print("fraction of members = ", 1.0 * sum(pmn) / len(pmn))

        x, y, z, comp, vz, vb, Mg, PMN = select_pm(x0, y0, z0, comp0, vz0, vb0,
                                                   Mg0, PM0, pmn)
        R = np.sqrt(x * x + y * y)  # [pc]
        Rscalei = np.median(R)
        gf.write_Xscale(gp.files.get_scale_file(pop), Rscalei)
        gf.write_data_output(gp.files.get_com_file(pop), x / Rscalei,
                             y / Rscalei, vz, Rscalei)

        if gpr.showplots:
            gpr.show_part_pos(x, y, pmn, Rscale)