예제 #1
0
def test_write_fits():
    gsm = GlobalSkyModel()
    gsm.generate(1000)
    gsm.write_fits("test_write_fits.fits")

    d_fits = hp.read_map("test_write_fits.fits")
    d_gsm  = gsm.generated_map_data

    assert d_fits.shape == d_gsm.shape
    assert np.allclose(d_fits, d_gsm)

    os.remove("test_write_fits.fits")
예제 #2
0
def mk_map_GSM(f=150.,frange=None,nbins=None,write2fits=True):
    """
    Make a Stokes I map/cube using pyGSM
    Can also provide frange=[lo,hi] and nbins to get an image cube (ignores f)
    Both f arguments need to be  in MHz
    """
    from pygsm import GlobalSkyModel
    gsm = GlobalSkyModel()

    if frange==None:
        gsm = gsm.generate(f)
        if write2fits: gsm.write_fits("gsm_%sMHz.fits"%str(int(f)))
        M = gsm
    else:
        flo,fhi=frange[0],frange[1]
        try: freqs = np.linspace(flo,fhi,nbins)
        except:
            print 'Did you provide "nbins"?'
            return None
        map_cube = gsm.generate(freqs)
        #if write2fits: map_cube.write_fits("gsm_cube_%s-%sMHz"%(str(int(flo)), str(int(fhi))))
        M = np.swapaxes(map_cube,0,1) #conform to other map making routines
    return M
예제 #3
0
def mk_map_GSM(f=150., frange=None, nbins=None, write2fits=True):
    """
    Make a Stokes I map/cube using pyGSM
    Can also provide frange=[lo,hi] and nbins to get an image cube (ignores f)
    Both f arguments need to be  in MHz
    """
    from pygsm import GlobalSkyModel
    gsm = GlobalSkyModel()

    if frange == None:
        gsm = gsm.generate(f)
        if write2fits: gsm.write_fits("gsm_%sMHz.fits" % str(int(f)))
        M = gsm
    else:
        flo, fhi = frange[0], frange[1]
        try:
            freqs = np.linspace(flo, fhi, nbins)
        except:
            print 'Did you provide "nbins"?'
            return None
        map_cube = gsm.generate(freqs)
        #if write2fits: map_cube.write_fits("gsm_cube_%s-%sMHz"%(str(int(flo)), str(int(fhi))))
        M = np.swapaxes(map_cube, 0, 1)  #conform to other map making routines
    return M