|
3 | 3 | import healpy as hp
|
4 | 4 | from datetime import datetime
|
5 | 5 |
|
| 6 | +import scipy.special as special |
| 7 | + |
6 | 8 | import scipy.interpolate as interpolate
|
7 | 9 |
|
8 | 10 | import numba_funcs as irnf
|
@@ -659,6 +661,77 @@ def transform_basis(nside, jones, z0_cza, R_z0):
|
659 | 661 |
|
660 | 662 | return jones_out
|
661 | 663 |
|
| 664 | +def AiryBeam(th, lmbda, a): |
| 665 | + k = 2. * np.pi / lmbda |
| 666 | + B = np.abs(2. * special.jv(1, k * a * np.sin(th)) / (k * a * np.sin(th))) |
| 667 | + B[np.where(np.abs(th) < 1e-10)[0]] = 1 |
| 668 | + B[np.where(th > np.pi/2.)[0]] = 0. |
| 669 | + return B |
| 670 | + |
| 671 | +def airy_dipole_setup(nside, nu_axis, a, z0_cza=None): |
| 672 | + def transform_basis(nside, jones, z0_cza, R_z0): |
| 673 | + |
| 674 | + npix = hp.nside2npix(nside) |
| 675 | + hpxidx = np.arange(npix) |
| 676 | + cza, ra = hp.pix2ang(nside, hpxidx) |
| 677 | + |
| 678 | + fR = R_z0 |
| 679 | + |
| 680 | + tb, pb = rotate_sphr_coords(fR, cza, ra) |
| 681 | + |
| 682 | + cza_v = t_hat_cart(cza, ra) |
| 683 | + ra_v = p_hat_cart(cza, ra) |
| 684 | + |
| 685 | + tb_v = t_hat_cart(tb, pb) |
| 686 | + |
| 687 | + fRcza_v = np.einsum('ab...,b...->a...', fR, cza_v) |
| 688 | + fRra_v = np.einsum('ab...,b...->a...', fR, ra_v) |
| 689 | + |
| 690 | + cosX = np.einsum('a...,a...', fRcza_v, tb_v) |
| 691 | + sinX = np.einsum('a...,a...', fRra_v, tb_v) |
| 692 | + |
| 693 | + |
| 694 | + basis_rot = np.array([[cosX, sinX],[-sinX, cosX]]) |
| 695 | + basis_rot = np.transpose(basis_rot,(2,0,1)) |
| 696 | + |
| 697 | + return np.einsum('...ab,...bc->...ac', jones, basis_rot) |
| 698 | + |
| 699 | + if z0_cza is None: |
| 700 | + z0_cza = np.radians(120.72) |
| 701 | + |
| 702 | + nfreq = len(nu_axis) |
| 703 | + |
| 704 | + npix = hp.nside2npix(nside) |
| 705 | + hpxidx = np.arange(npix) |
| 706 | + th, phi = hp.pix2ang(nside, hpxidx) |
| 707 | + |
| 708 | + R_z0 = hp.rotator.Rotator(rot=[0,-np.degrees(z0_cza)]) |
| 709 | + |
| 710 | + th_l, phi_l = R_z0(th, phi) |
| 711 | + phi_l[phi_l < 0] += 2. * np.pi |
| 712 | + |
| 713 | + ct,st = np.cos(th_l), np.sin(th_l) |
| 714 | + cp,sp = np.cos(phi_l), np.sin(phi_l) |
| 715 | + |
| 716 | + jones_dipole = np.array([ |
| 717 | + [ct * cp, -sp], |
| 718 | + [ct * sp, cp] |
| 719 | + ], dtype=np.complex128).transpose(2,0,1) |
| 720 | + |
| 721 | + jones_c = transform_basis(nside, jones_dipole, z0_cza, np.array(R_z0.mat)) |
| 722 | + |
| 723 | + c = 299792458. |
| 724 | + # a = 14.6/2. |
| 725 | + |
| 726 | + B = np.zeros((nfreq, npix,2,2)) |
| 727 | + for nu_i, nu in enumerate(nu_axis): |
| 728 | + B[nu_i] = np.broadcast_to(AiryBeam(th_l, c/nu, a), (2,2,npix)).T |
| 729 | + |
| 730 | + jones_c = np.broadcast_to(jones_c, (nfreq, npix, 2, 2)) |
| 731 | + jones_out = B * jones_c |
| 732 | + |
| 733 | + return jones_out |
| 734 | + |
662 | 735 | def PAPER_transform_basis(nside, jones, z0_cza, R_z0):
|
663 | 736 |
|
664 | 737 | npix = hp.nside2npix(nside)
|
|
0 commit comments