Ejemplo n.º 1
0
def test_observed_mollview():
    """ Generate animated maps of observing coverage over 24 hours """

    (latitude, longitude, elevation) = ('37.2', '-118.2', 1222)
    ov = GSMObserver()
    ov.lon = longitude
    ov.lat = latitude
    ov.elev = elevation

    obs = []
    for ii in range(0, 24, 1):
        ov.date = datetime(2000, 1, 1, ii, 0)
        ov.generate(50)
        sky = ov.view_observed_gsm(logged=True, show=False, min=9, max=20)
        plt.savefig('generated_sky/galactic-%02d.png' % ii)
        plt.close()

        hp.mollview(sky, coord=['G', 'E'], min=9, max=20)
        plt.savefig('generated_sky/ecliptic-%02d.png' % ii)
        plt.close()

        hp.mollview(sky, coord=['G', 'C'], min=9, max=20)
        plt.savefig('generated_sky/equatorial-%02d.png' % ii)
        plt.close()

        ov.view(logged=True, show=False, min=9, max=20)
        plt.savefig('generated_sky/ortho-%02d.png' % ii)
        plt.close()

        print ii

    os.system('convert -delay 20 generated_sky/ortho-*.png ortho.gif')
    os.system('convert -delay 20 generated_sky/galactic-*.png galactic.gif')
    os.system('convert -delay 20 generated_sky/ecliptic-*.png ecliptic.gif')
    os.system('convert -delay 20 generated_sky/equatorial-*.png equatorial.gif')
Ejemplo n.º 2
0
def test_gsm_observer():
    """ Test GSMObserver() is working
    """
    (latitude, longitude, elevation) = ('37.2', '-118.2', 1222)
    ov = GSMObserver()
    ov.lon = longitude
    ov.lat = latitude
    ov.elev = elevation
    ov.date = datetime(2000, 1, 1, 23, 0)
    ov.generate(50)
    ov.view(logged=True)
    ov.view_observed_gsm(logged=True)
Ejemplo n.º 3
0
def test_gsm_observer():
    """ Test GSMObserver() is working
    """
    (latitude, longitude, elevation) = ('37.2', '-118.2', 1222)
    ov = GSMObserver()
    ov.lon = longitude
    ov.lat = latitude
    ov.elev = elevation
    ov.date = datetime(2000, 1, 1, 23, 0)
    ov.generate(50)
    ov.view(logged=True)
    ov.view_observed_gsm(logged=True)
Ejemplo n.º 4
0
def observer_test():

    # Setup observatory location - in this case, Parkes Australia
    (latitude, longitude, elevation) = ('-32.998370', '148.263659', 100)
    ov = GSMObserver2016()
    ov.lon = longitude
    ov.lat = latitude
    ov.elev = elevation
    ov.date = datetime(2000, 1, 1, 23, 0)

    ov.generate(1400)
    d = ov.view(logged=True)

    ov = GSMObserver()
    ov.lon = longitude
    ov.lat = latitude
    ov.elev = elevation
    ov.date = datetime(2000, 1, 1, 23, 0)

    ov.generate(1400)
    d = ov.view(logged=True)
    plt.show()
Ejemplo n.º 5
0
def observer_test():

    # Setup observatory location - in this case, Parkes Australia
    (latitude, longitude, elevation) = ('-32.998370', '148.263659', 100)
    ov = GSMObserver2016()
    ov.lon = longitude
    ov.lat = latitude
    ov.elev = elevation
    ov.date = datetime(2000, 1, 1, 23, 0)

    ov.generate(1400)
    d = ov.view(logged=True)

    ov = GSMObserver()
    ov.lon = longitude
    ov.lat = latitude
    ov.elev = elevation
    ov.date = datetime(2000, 1, 1, 23, 0)

    ov.generate(1400)
    d = ov.view(logged=True)
    plt.show()
Ejemplo n.º 6
0
def test_observed_mollview():
    """ Generate animated maps of observing coverage over 24 hours """

    (latitude, longitude, elevation) = ('37.2', '-118.2', 1222)
    ov = GSMObserver()
    ov.lon = longitude
    ov.lat = latitude
    ov.elev = elevation

    obs = []
    for ii in range(0, 24, 1):
        ov.date = datetime(2000, 1, 1, ii, 0)
        ov.generate(50)
        sky = ov.view_observed_gsm(logged=True, show=False, min=9, max=20)
        plt.savefig('generated_sky/galactic-%02d.png' % ii)
        plt.close()

        hp.mollview(sky, coord=['G', 'E'], min=9, max=20)
        plt.savefig('generated_sky/ecliptic-%02d.png' % ii)
        plt.close()

        hp.mollview(sky, coord=['G', 'C'], min=9, max=20)
        plt.savefig('generated_sky/equatorial-%02d.png' % ii)
        plt.close()

        ov.view(logged=True, show=False, min=9, max=20)
        plt.savefig('generated_sky/ortho-%02d.png' % ii)
        plt.close()

        print ii

    os.system('convert -delay 20 generated_sky/ortho-*.png ortho.gif')
    os.system('convert -delay 20 generated_sky/galactic-*.png galactic.gif')
    os.system('convert -delay 20 generated_sky/ecliptic-*.png ecliptic.gif')
    os.system(
        'convert -delay 20 generated_sky/equatorial-*.png equatorial.gif')
Ejemplo n.º 7
0
    pixels = hp.ang2pix(nside, thetas, j)
    n[pixels] = func[pixels]
    n[n < 0] = 0
filter_array = n  # This is the filter to apply to GSM

(latitude, longitude, elevation) = ('-32.998370', '148.263659', 100
                                    )  # Near EDGES site
delta_t = 60  # EDGES antenna takes a number of measurements in 24 hours; this is the time between measurements in minutes
sky_array = []
timer = datetime(2018, 1, 1, 0, 0)
while timer.hour < 23:
    gsm = GSMObserver()
    gsm.lon = longitude
    gsm.lat = latitude
    gsm.elev = elevation
    gsm.date = timer
    g = hp.ud_grade(
        gsm.generate(78),
        nside)  # 78MHz is the frequency of the 21cm signal absorption feature
    g_filt = g * n
    #g_filt = g_filt*(np.amax(g)/np.amax(g_filt)) # normalisation
    hp.orthview(g_filt, half_sky=True)
    plt.savefig(timer.strftime("%H:%M:%S") + "_filtered.png")
    g_int = np.trapz(g_filt)
    sky_array.append(g_int)
    timer = timer + timedelta(minutes=delta_t)

sky_array = np.array(sky_array)
sky = np.trapz(sky_array)
print(sky)
Ejemplo n.º 8
0
        # Rotate and project hera beam (Need to figure out how to do this w/o making figure)
        pol_ang = 90 * (1 - poli)  # Extra rotation for X
        hbeam = hp.orthview(hera_beam[pol][:, fi], rot=[pol_ang, 90], fig=fig.number,
                            xsize=400, return_projected_map=True, half_sky=True)
        hbeam[np.isinf(hbeam)] = np.nan
        if calc_paper:
            pbeam = hp.orthview(paper_beam[pol][:, fi], rot=[pol_ang, 90], fig=fig.number,
                                xsize=400, return_projected_map=True, half_sky=True)
            pbeam[np.isinf(pbeam)] = np.nan
        for ti, t in enumerate(hours):
            plt.clf()
            dt = datetime(2013, 1, 1, np.int(t), np.int(60.0 * (t - np.floor(t))),
                          np.int(60.0 * (60.0 * t - np.floor(t * 60.0))))
            lsts[ti] = Time(dt).sidereal_time('apparent', longitude).hour
            ov.date = dt
            ov.generate(freq)
            d = ov.view(fig=fig.number)
            sky = hp.orthview(d, fig=fig.number, xsize=400, return_projected_map=True,
                              half_sky=True)
            sky[np.isinf(sky)] = np.nan
            HERA_Tsky[poli, fi, ti] = np.nanmean(hbeam * sky) / np.nanmean(hbeam)
            if calc_paper:
                PAPER_Tsky[poli, fi, ti] = np.nanmean(pbeam * sky) / np.nanmean(pbeam)

inds = np.argsort(lsts)
lsts = lsts[inds]
HERA_Tsky = HERA_Tsky[:, :, inds]

Tsky_file = '/data4/beards/HERA_IDR1_analysis/HERA_Tsky_nic.npz'
np.savez(Tsky_file, HERA_Tsky=HERA_Tsky, freqs=freqs, lsts=lsts)
if calc_paper:
Ejemplo n.º 9
0
lsts = np.zeros_like(hours)
pols = ['X', 'Y']  # Only have X beam, but try rotating 90 degrees for Y
HERA_Tsky = np.zeros((len(pols), freqs.shape[0], lsts.shape[0]))

# Set up the observer
(latitude, longitude, elevation) = ('-30.7224', '21.4278', 1100)
ov = GSMObserver()
ov.lon = longitude
ov.lat = latitude
ov.elev = elevation

proj_sky = hp.projector.OrthographicProj(rot=[0, 0, 0],
                                         half_sky=True,
                                         xsize=400)

observed_sky = ov.generate(100)

nside_sky = hp.pixelfunc.npix2nside(hp.pixelfunc.get_map_size(observed_sky))
f_sky = lambda x, y, z: hp.pixelfunc.vec2pix(nside_sky, x, y, z, nest=False)
sky = proj_sky.projmap(observed_sky, f_sky)

generated_sky = np.zeros(
    (freqs.shape[0], hours.shape[0], sky.shape[0], sky.shape[1]))

print generated_sky.shape

for fi, freq in enumerate(freqs):
    print 'Forming Tsky for frequency ' + str(freq) + ' MHz.'
    for ti, t in enumerate(hours):
        dt = datetime(2013, 1, 1, np.int(t), np.int(60.0 * (t - np.floor(t))),
                      np.int(60.0 * (60.0 * t - np.floor(t * 60.0))))
Ejemplo n.º 10
0
from pygsm import GlobalSkyModel, GSMObserver
from datetime import datetime
import numpy as np
import healpy as hp
import matplotlib.pyplot as plt

(latitude, longitude, elevation) = ('-26.69719', '116.63903', 373)
freq = np.linspace(50, 99, 3)
amp = []
for i in freq:
    gsm = GSMObserver()
    gsm.lon = longitude
    gsm.lat = latitude
    gsm.elev = elevation
    gsm.date = datetime(2018, 1, 1, 3, 0)
    g = gsm.generate(i)
    gsm.view(logged=False, filename='freq_%i' % i)
Ejemplo n.º 11
0
    def calc_Tsky(self):
        """
        Calculate the Tsky sim based on beam file and the GSM
        """
        if self.beam_file is None:
            raise(ValueError('Beam file is not defined, cannot compute Tsky simulation.'))
        # Otherwise go ahead and calculate
        self.Tsky = np.zeros((len(self.pols), len(self.freqs), len(self.lsts)))

        # First set up beam
        uvb = UVBeam()
        uvb.read_beamfits(self.beam_file)
        beam = {}
        rot_pol = {}
        #temp_f = fits.getdata(self.beam_file, extname='FREQS')
        temp_f = uvb.freq_array[0]*1e-6
        for i, pol in enumerate(self.pols):
            '''try:
                im = fits.getdata(self.beam_file, extname='BEAM_{0}'.format(pol))
                rot_pol[pol] = False
            except KeyError:
                # My example file only has one pol, need to rotate it (later)
                im = fits.getdata(self.beam_file, extname='BEAM_{0}'.format(self.pols[1 - i]))
                rot_pol[pol] = True
            func = interpolate.interp1d(temp_f, im, kind='cubic', axis=1)
            beam[pol] = func(self.freqs)'''
            rot_pol[pol] = False
            im = uvb.data_array[0,0,i].transpose()
            func = interpolate.interp1d(temp_f, im, kind='cubic', axis=1)
            beam[pol] = func(self.freqs)


        # Get the effective area
        self.Ae = np.zeros((len(self.pols), len(self.freqs)))
        for poli, pol in enumerate(self.pols):
            self.Ae[poli] = ((const.c.to('m*MHz').value / self.freqs)**2. /
                             (4 * np.pi / im.shape[0] * np.sum(beam[pol], axis=0) /
                              np.max(beam[pol], axis=0)))

        # Set up observer
        if self.gsm==2008:
            ov = GSMObserver()
        elif self.gsm==2016:
            ov = GSMObserver2016()

        ov.lon = str(self.lon)
        ov.lat = str(self.lat)
        ov.elev = self.elev

        fig = plt.figure('Tsky_calc')  # Never found a way to not open a figure...
        for poli, pol in enumerate(self.pols):
            for fi, freq in enumerate(self.freqs):
                if rot_pol[pol]:
                    pol_ang = 0.0
                else:
                    pol_ang = 90.0
                temp_beam = hp.orthview(beam[pol][:, fi], rot=[pol_ang, 90], fig=fig.number,
                                        xsize=400, return_projected_map=True, half_sky=True)
                temp_beam[np.isinf(temp_beam)] = np.nan
                for ti, t in enumerate(self.hours):
                    plt.clf()
                    dt = datetime(2013, 1, 1, np.int(t), np.int(60.0 * (t - np.floor(t))),
                                  np.int(60.0 * (60.0 * t - np.floor(t * 60.0))))
                    self.lsts[ti] = Time(dt).sidereal_time('apparent', self.lon).hour
                    ov.date = dt
                    ov.generate(freq)
                    d = ov.view(fig=fig.number)
                    sky = hp.orthview(d, fig=fig.number, xsize=400, return_projected_map=True, half_sky=True)
                    sky[np.isinf(sky)] = np.nan
                    self.Tsky[poli, fi, ti] = np.nanmean(temp_beam * sky) / np.nanmean(temp_beam)

        inds = np.argsort(self.lsts)
        self.lsts = self.lsts[inds]
        self.Tsky = self.Tsky[:, :, inds]