Exemple #1
0
def test_plt_colormaps():
    spec, spec_r = spectral()
    ja, ja_r = jade()
    plt_colormaps(spec, spec_r, ja, ja_r, ".")
    png = Path("colormaps.png")
    assert png.is_file() is True
    if png.is_file() is True:
        png.unlink()
Exemple #2
0
----------
"""

import argparse
import concurrent.futures
from itertools import repeat
from pathlib import Path

import matplotlib
import numpy as np
from embers.rf_tools.colormaps import jade
from embers.tile_maps.beam_utils import plot_healpix
from matplotlib import pyplot as plt

matplotlib.use("Agg")
jade, _ = jade()

parser = argparse.ArgumentParser(description="""
    Tile Maps paper plot
    """)

parser.add_argument(
    "--out_dir",
    metavar="\b",
    default="../embers_out/paper_plots/tile_maps/",
    help="Output directory. Default=../embers_out/paper_plots/tile_maps",
)
parser.add_argument(
    "--map_dir",
    metavar="\b",
    default="../embers_out/tile_maps/tile_maps/tile_maps_clean/",
Exemple #3
0
def test_jade_r():
    _, ja_r = jade()
    assert type(ja_r).__name__ == "ListedColormap"
Exemple #4
0
def test_jade():
    ja, _ = jade()
    assert type(ja).__name__ == "ListedColormap"
Exemple #5
0
def mwa_fee_model(out_dir, nside, pointings=[0, 2, 4, 41], flags=[]):
    """
    Create MWA FEE beam models at multiple pointings, with dipoles flagged.

    :param out_dir: Path to output directory where beam maps and sample plots  will be saved
    :param nside: The :samp:`NSIDE` of healpix output map :class:`~int`
    :param pointings: :class:`~list` of pointings at which to make beam maps
    :param flags: :class:`~list` of dipoles which are to be flagged with values from 1 to 32. 1-16 are dipoles of XX pol while 17-32 are for YY. Ex: flags=[1,17] represents the first dipole of the XX & YY tiles as being flagged and having a amplitude of 0

    :returns:

        - A set of images of the beam maps, save to :samp:`out_dir`
        - A :func:`~numpy.savez_compressed` :samp:`.npz` file containing all the fee beam maps

    """
    # make output directory if it doesn't exist
    out_dir = f"{out_dir}/mwa_fee"
    Path(out_dir).mkdir(parents=True, exist_ok=True)

    # Custom Jade colormap
    jd, _ = jade()

    # Default amplitudes of 1 for all dipoles
    amps = np.ones((2, 16))

    # Assign aplitudes of 0 to dipoles identified in flags
    if len(flags) != 0:
        xx_flags = [f - 1 for f in flags if f <= 16]
        yy_flags = [f - 17 for f in flags if f > 16]
        amps[0][xx_flags] = 0
        amps[1][yy_flags] = 0

    fee_beam = {}

    for p in pointings:

        # Empty array for model beam
        npix = hp.nside2npix(nside)
        beam_response_XX = np.zeros(npix)
        beam_response_YY = np.zeros(npix)

        # healpix indices above horizon
        # convert to zenith angle and azimuth
        above_horizon = range(int(npix / 2))
        beam_zas, beam_azs = hp.pix2ang(nside, above_horizon)

        # Sweet-spot pointing delays from mwa_pb
        delay_point = np.array(
            [all_grid_points[p][-1], all_grid_points[p][-1]])

        # Make beam response
        response = local_beam(
            [list(beam_zas)],
            [list(beam_azs)],
            freq=137e6,
            delays=delay_point,
            zenithnorm=True,
            power=True,
            interp=False,
            amps=amps,
        )
        response_XX = response[0][0]
        response_YY = response[1][0]

        # Stick in an array, convert to decibels, and noralise
        beam_response_XX[above_horizon] = response_XX
        decibel_beam_XX = 10 * np.log10(beam_response_XX)
        normed_beam_XX = decibel_beam_XX - decibel_beam_XX.max()

        beam_response_YY[above_horizon] = response_YY
        decibel_beam_YY = 10 * np.log10(beam_response_YY)
        normed_beam_YY = decibel_beam_YY - decibel_beam_YY.max()

        fee_beam[str(p)] = [normed_beam_XX, normed_beam_YY]

        plt.style.use("seaborn")
        fig = plt.figure(figsize=(6, 6))
        fig.suptitle(f"MWA FEE MAP @ pointing [{p}] XX", fontsize=16, y=0.92)
        plot_healpix(data_map=normed_beam_XX,
                     sub=(1, 1, 1),
                     cmap=jd,
                     vmin=-50,
                     vmax=0)
        plt.savefig(f"{out_dir}/mwa_fee_beam_{p}_XX.png", bbox_inches="tight")
        plt.close()

        fig = plt.figure(figsize=(6, 6))
        fig.suptitle(f"MWA FEE MAP @ pointing [{p}] YY", fontsize=16, y=0.92)
        plot_healpix(data_map=normed_beam_YY,
                     sub=(1, 1, 1),
                     cmap=jd,
                     vmin=-50,
                     vmax=0)
        plt.savefig(f"{out_dir}/mwa_fee_beam_{p}_YY.png", bbox_inches="tight")
        plt.close()

    np.savez_compressed(f"{out_dir}/mwa_fee_beam.npz", **fee_beam)
Exemple #6
0
Colormaps
=========

Visualise custom colormaps used by embers.
Creates sample plot of ember colormaps
saved to :samp:`./embers_out/rf_tools/colormaps.png`

"""

import argparse
from pathlib import Path

from embers.rf_tools.colormaps import jade, plt_colormaps, spectral

_spec, _spec_r = spectral()
_jade, _jade_r = jade()


def main():
    """
    Preview *EMBERS* two beautiful custom colormaps - :func:`~embers.rf_tools.colormaps.spectral` & :func:`~embers.rf_tools.colormaps.jade`.
    The :samp:`spectral` colormap is non-linear and is just used to visualise raw data and maximize dynamic range, while :samp:`jade` is
    perceptually uniform and sequential and is suitable for science. To get a preview of how amazing they are

    .. code-block:: console

        $ colormaps --help

    """
    _parser = argparse.ArgumentParser(description="""
        Visualization of custom ember colormaps