Example #1
0
def _get_min_max_alpha_beta(ds):
    amin = None
    amax = None
    bmin = None
    bmax = None

    for quad in ds.get_all():
        for dp in quad.values():
            a = alpha(dp)
            b = beta(dp)

            if not amin:
                amin = a
                amax = a
                bmax = b
                bmin = b

            if a < amin:
                amin = a
            if a > amax:
                amax = a
            if b < bmin:
                bmin = b
            if b > bmax:
                bmax = b

    return amin, amax, bmin, bmax
Example #2
0
def plot(ds):
    fig = pl.figure(figsize=(13, 8))
    ax = pl.gca()

    a = []
    b = []

    for ups in ds.get_all_up():
        a = []
        b = []
        ps = []
        for point in ups.values():
            a.append(alpha(point))
            b.append(beta(point))
            ps.append(point.phi0)
        ps = np.array(ps)
        pmin = str(np.amin(ps) / np.pi)[:4]
        pmax = str(np.amax(ps) / np.pi)[:4]
        ax.plot(a,
                b,
                label=r'$\varphi$ from ' + pmin + r'$\pi$ to ' + pmax +
                r'$\pi$')

    a = np.array(a)
    b = np.array(b)

    ax.legend()

    p = np.linspace(0, np.pi * 2, num=1000)
    ax.plot(np.cos(p), np.sin(p), c='black', alpha=0.7)

    ax.grid()
    ax.set_xlabel(r'$\alpha$')
    ax.set_ylabel(r'$\beta$')
Example #3
0
def get_edge_points(ds):
    a = []
    b = []

    for quad in ds.get_all():
        for dp in quad.values():
            a.append(alpha(dp))
            b.append(beta(dp))

    a = np.array(a)
    b = np.array(b)

    # sort alpha and beta arrays
    arr_inds = a.argsort()

    a = a[arr_inds]
    b = b[arr_inds]

    # create lists for every quadrant
    a_ul = [np.amin(a)]
    b_ul = [b[a == np.amin(a)][0]]

    a_ll = [np.amin(a).tolist()]
    b_ll = [b[a == np.amin(a)][0]]

    a_ur = [np.amax(a).tolist()]
    b_ur = [b[a == np.amax(a)][0]]

    a_lr = [np.amax(a).tolist()]
    b_lr = [b[a == np.amax(a)][0]]

    for aa, bb in zip(a, b):
        # upper left:
        if np.amin(a) < aa <= a[b == np.amax(b)]:
            if b[a == np.amin(a)] < bb <= np.amax(b) and bb > b_ul[-1]:
                a_ul.append(aa)
                b_ul.append(bb)

            elif np.amin(b) < bb <= b[a == np.amin(a)] and bb < b_ll[-1]:
                a_ll.append(aa)
                b_ll.append(bb)

    for aa, bb in zip(a[::-1], b[::-1]):
        if a[b == np.amax(b)] < aa <= np.amax(a):
            if b[a == np.amax(a)] < bb <= np.amax(b) and bb > b_ur[-1]:# and bb > 0:
                a_ur.append(aa)
                b_ur.append(bb)

            elif np.amin(b) < bb <= b[a == np.amax(a)] and bb < b_lr[-1]:#
                a_lr.append(aa)
                b_lr.append(bb)

    alphas = np.array(a_ul + a_ur[::-1] + a_lr + a_ll[::-1])
    betas = np.array(b_ul + b_ur[::-1] + b_lr + b_ll[::-1])

    return alphas, betas
Example #4
0
def plot_solid_angle(ds, both=True, ax=None):
    if not ax:
        fig = pl.figure(figsize=(10, 10))
        ax = fig.add_subplot(111)

    colors = ['blue', 'red', 'green', 'orange']
    i = 0

    if both:
        for ds0 in ds:
            for quad, quad2 in zip(ds0.get_all_up(), ds0.get_all_down()):
                phi2 = []
                th2 = []
                phi0 = []
                cos = []

                for dp in quad.values():
                    phi2.append(alpha(dp))
                    th2.append(beta(dp))

                    #if np.isclose(dp.phi0, np.pi * 2) or np.isclose(dp.phi0, np.pi) or np.isclose(dp.phi0, 1.5 * np.pi):
                    #    ax.scatter(alpha(dp), beta(dp), marker='x', c=colors[i])

                for dp in quad2.values():
                    phi0.append(alpha(dp))
                    cos.append(beta(dp))

                ax.plot(phi2, th2, c=colors[i])
                ax.plot(phi0, cos, ls='--', c=colors[i])
            i += 1

    else:
        j = 0
        pmin, pmax = get_phiminmax(8, 0.5 * np.pi, np.pi / 2, 0.2)
        tmin, tmax = get_thetaminmax(8, 0.5 * np.pi, np.pi / 2, 0.2)
        print(pmin, pmax, tmin, tmax)
        #pmax += np.pi

        for ds0 in ds:
            all = []
            gs = []
            for quad in ds0.get_all():
                phi2 = []
                th2 = []

                for dp in quad.values():
                    #if check_if_inside(dp, tmin, tmax, pmin, pmax).size:
                    #    print(j)
                    #    j += 1
                    #else:
                    col = check_if_inside(dp, tmin, tmax, pmin, pmax)
                    if dp.r0 >= 8:  #len(col) <= 7:
                        #if len(col) < 100:#dp.r0 <= 8.:
                        print(pmin)
                        phi2.append(alpha(dp))
                        th2.append(beta(dp))
                        all.append([alpha(dp), beta(dp)])
                        gs.append(g(dp))

                #ax.scatter(phi2, th2, c='black', s=1)
                print(len(phi2))
                #ax.scatter(0.03457183975193295, 7.159903237573876, c=colors[i], marker='x')

            i += 1

    p = np.linspace(0, np.pi * 2, num=1000)

    return np.array(all), np.array(gs), ax
Example #5
0
def new():

    amin = None
    amax = None
    bmin = None
    bmax = None

    pmin, pmax = get_phiminmax(8, 1.5 * np.pi, np.pi / 2, 0.2)
    tmin, tmax = get_thetaminmax(8, 1.5 * np.pi, np.pi / 2, 0.2)
    ds0 = []

    for quad in ds0.get_all():
        for dp in quad.values():
            a = alpha(dp)
            b = beta(dp)

            if not amin:
                amin = a
                amax = a
                bmax = b
                bmin = b

            if a < amin:
                amin = a
            if a > amax:
                amax = a
            if b < bmin:
                bmin = b
            if b > bmax:
                bmax = b

    from scipy.integrate import odeint
    from geodesics.equations import geod

    sigma = np.linspace(0, 25, num=100000)

    r = 8
    t = np.pi / 2

    E = 0.7897629504703588
    L = -0.01824821023802678
    Q = 30.037438098323914

    q = Q / E**2
    l = L / E

    dt = 1 / (1 - 2 / r)
    dr = -np.sqrt(1 - (q + l**2) / r**2 * (1 - 2 / r))
    dtheta = -np.sqrt(q - l**2 / np.tan(t)) / r**2
    dphi = l / (r**2 * np.sin(t)**2)

    res = odeint(geod, [0, dt, r, dr, t, dtheta, 3 * np.pi / 2, dphi],
                 sigma,
                 atol=1e-5,
                 rtol=1e-5)

    fig = pl.figure(figsize=(12, 12))
    ax = fig.add_subplot(111, projection='3d')

    r = res[:, 2]
    t = res[:, 4]
    p = res[:, 6]

    ax.plot(r * np.cos(p) * np.sin(t),
            r * np.sin(p) * np.sin(t), r * np.cos(t))

    ax.scatter(0, -8, 0)
    ax.scatter(0, 15 * np.sin(1.25), 15 * np.cos(1.25))

    ax.set_xlim(-15, 15)
    ax.set_ylim(-15, 15)
    ax.set_zlim(-10, 10)

    pl.show()
Example #6
0
def get_redshift_area(ds):
    a = []
    b = []
    gg = []

    for quad in ds.get_all():
        for dp in quad.values():
            a.append(alpha(dp))
            b.append(beta(dp))
            gg.append(g(dp))

    a = np.array(a)
    b = np.array(b)
    gg = np.array(gg)

    arr_inds = a.argsort()

    a = a[arr_inds]
    b = b[arr_inds]
    gg = gg[arr_inds]

    b_mean = (b[a == np.amax(a)] + b[a == np.amin(a)]) / 2

    idx = np.where([b > b_mean[0]])[-1]
    id2 = np.where([b < b_mean[0]])[-1]

    xup = a[idx]
    yup = b[idx]
    gup = gg[idx]

    xdown = a[id2]
    ydown = b[id2]
    gdown = gg[id2]

    #matrix = []
    #last_gup = np.nan
    #for y in yup[np.argsort(yup)]:
    #    row = []
    #    for x in xup:
    #        if y == yup[x == xup]:
    #            row.append(gup[x == xup][0])
    #            last_gup = row[-1]
    #        else:
    #            row.append(np.nan)
    #    matrix.append(row)

    #from scipy.interpolate import interp2d
    #z = interp2d(xup, yup, gup)
    #z = z(np.linspace(np.amin(xup), np.amax(xup), 106), np.linspace(np.amin(yup), np.amax(yup), 106))
    #pl.pcolormesh(xup, yup[np.argsort(yup)], z)

    #pl.scatter(xup, yup, c=gup)
    #pl.scatter(xdown, ydown, c=gdown)

    pl.scatter(a, b, c=gg)
    pl.xlim(np.min(a) - 0.1, np.max(a) + 0.1)
    pl.ylim(np.min(b) - 0.1, np.max(b) + 0.1)
    pl.grid()
    pl.xlabel(r'$\alpha$')
    pl.ylabel(r'$\beta$')
    pl.show()