예제 #1
0
def test_bad_lon():
    """see if anything breaks when longitude outside of [0, 360)"""
    print test_bad_lon.__doc__

    tol = 1e-5
    dec = np.array([45.]) # arb
    for r in [-10., 370.]:
        ra = np.array([r])
        val = wssa_utils.wssa_getval(ra, dec)
        assert isinstance(val, np.ndarray)
        assert val.dtype.name == 'float32'
        assert val.shape == (1,)        
        tru = wssa_utils.wssa_getval(np.array([(r+360.) % 360.]), dec)
        assert np.abs(val-tru) < tol
예제 #2
0
def test_bad_lon():
    """see if anything breaks when longitude outside of [0, 360)"""
    print test_bad_lon.__doc__

    tol = 1e-5
    dec = np.array([45.])  # arb
    for r in [-10., 370.]:
        ra = np.array([r])
        val = wssa_utils.wssa_getval(ra, dec)
        assert isinstance(val, np.ndarray)
        assert val.dtype.name == 'float32'
        assert val.shape == (1, )
        tru = wssa_utils.wssa_getval(np.array([(r + 360.) % 360.]), dec)
        assert np.abs(val - tru) < tol
예제 #3
0
def test_unit_conversion():
    """test that conversion to to MJy/sr from DN happening when appropriate"""
    print test_unit_conversion.__doc__

    nsam = 1
    ra, dec = random_lonlat(nsam, deg=True)
    val = wssa_utils.wssa_getval(ra, dec)
    val_mjysr = wssa_utils.wssa_getval(ra, dec, mjysr=True)
    assert isinstance(val_mjysr, np.ndarray)
    assert val_mjysr.dtype.name == 'float32'
    assert val.shape == (nsam,)
    assert val[0] != 0

    rat = val_mjysr[0]/val[0]
    tol = 1.0e-5
    tru = wssa_utils.tile_par_struc()['calfac']
    assert np.abs(rat-tru) < tol
예제 #4
0
def test_unit_conversion():
    """test that conversion to to MJy/sr from DN happening when appropriate"""
    print test_unit_conversion.__doc__

    nsam = 1
    ra, dec = random_lonlat(nsam, deg=True)
    val = wssa_utils.wssa_getval(ra, dec)
    val_mjysr = wssa_utils.wssa_getval(ra, dec, mjysr=True)
    assert isinstance(val_mjysr, np.ndarray)
    assert val_mjysr.dtype.name == 'float32'
    assert val.shape == (nsam, )
    assert val[0] != 0

    rat = val_mjysr[0] / val[0]
    tol = 1.0e-5
    tru = wssa_utils.tile_par_struc()['calfac']
    assert np.abs(rat - tru) < tol
예제 #5
0
def test_tilepath(tilepath='/n/fink1/ameisner/tile-combine-8k'):
    """try non-default tile path"""
    print test_tilepath.__doc__, ': ' + tilepath

    nsam = 1
    ra, dec = random_lonlat(nsam, deg=True)
    val = wssa_utils.wssa_getval(ra, dec, tilepath=tilepath)
    assert isinstance(val, np.ndarray)
    assert val.shape == (nsam, )
예제 #6
0
def test_tilepath(tilepath='/n/fink1/ameisner/tile-combine-8k'):
    """try non-default tile path"""
    print test_tilepath.__doc__, ': '+tilepath
    
    nsam = 1
    ra, dec = random_lonlat(nsam, deg=True)
    val = wssa_utils.wssa_getval(ra, dec, tilepath=tilepath)
    assert isinstance(val, np.ndarray)
    assert val.shape == (nsam,)
예제 #7
0
파일: comp.py 프로젝트: ameisner/wssa_utils
def test_vals_mjysr(outname):
    """test that conversion to MJy/sr doesn't create any problems"""
    ra  = np.array([228.06533, 336.88487,  132.85047, 296.63675, 174.24343,
                     304.68113])
    dec = np.array([9.6944888, 25.149593, -29.273778, 11.994469, 43.651411,
                    -10.985369])

    vals = wssa_utils.wssa_getval(ra, dec, mjysr=True)
    arrs2fits(outname, vals)
예제 #8
0
파일: comp.py 프로젝트: ameisner/wssa_utils
def test_vals_rect(outname, fname='rect.fits', exten=0):
    """sample values for all ra, dec in rectangular grid"""
    fname = os.path.join(os.environ['WISE_DATA'], fname)
    hdus = pyfits.open(fname)
    ra  = hdus[0].data
    dec = hdus[1].data

    vals = wssa_utils.wssa_getval(ra, dec, exten=exten)
    arrs2fits(outname, vals)
예제 #9
0
def test_many_tiles():
    """lon and lat both 1d arrays, spread over multiple tiles"""
    print test_many_tiles.__doc__

    nsam = 10
    ra, dec = random_lonlat(nsam, deg=True)
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.dtype.name == 'float32'
    assert vals.shape == (nsam, )
예제 #10
0
def test_single_pair():
    """test a single (lon, lat) pair"""
    print test_single_pair.__doc__

    nsam = 1
    ra, dec = random_lonlat(nsam, deg=True)
    val = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(val, np.ndarray)
    assert val.dtype.name == 'float32'
    assert val.shape == (nsam, )
예제 #11
0
def test_bad_lat():
    """see if anything breaks when latitude outside of [-90, 90]"""
    print test_bad_lat.__doc__

    ra = np.array([45.]) #arb
    # just see if this runs without crashing ...
    for d in [-100., 100.]:
        dec = np.array([d])
        val = wssa_utils.wssa_getval(ra, dec)
        assert (val == -1)
예제 #12
0
def test_single_pair():
    """test a single (lon, lat) pair"""
    print test_single_pair.__doc__

    nsam = 1
    ra, dec = random_lonlat(nsam, deg=True)
    val = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(val, np.ndarray)
    assert val.dtype.name == 'float32'
    assert val.shape == (nsam,)
예제 #13
0
def test_bad_lat():
    """see if anything breaks when latitude outside of [-90, 90]"""
    print test_bad_lat.__doc__

    ra = np.array([45.])  #arb
    # just see if this runs without crashing ...
    for d in [-100., 100.]:
        dec = np.array([d])
        val = wssa_utils.wssa_getval(ra, dec)
        assert (val == -1)
예제 #14
0
파일: comp.py 프로젝트: ameisner/wssa_utils
def test_val_float(outname):
    """get tile value for one lon, lat pair"""
    ra = np.array([308.49839])
    dec = np.array([-30.757660])

    ra  = ra.astype('float32')
    dec = dec.astype('float32')

    val = wssa_utils.wssa_getval(ra, dec)
    arrs2fits(outname, val)
예제 #15
0
def test_many_tiles():
    """lon and lat both 1d arrays, spread over multiple tiles"""
    print test_many_tiles.__doc__
    
    nsam = 10
    ra, dec = random_lonlat(nsam, deg=True)
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.dtype.name == 'float32'
    assert vals.shape == (nsam,)
예제 #16
0
def test_poles():
    """see if anything breaks at poles"""
    print test_poles.__doc__

    ra = np.array([0.])
    for d in [-90., 90.]:
        dec = np.array([d])
        val = wssa_utils.wssa_getval(ra, dec)
        assert isinstance(val, np.ndarray)
        assert val.dtype.name == 'float32'
        assert val[0] != 0
예제 #17
0
def test_poles():
    """see if anything breaks at poles"""
    print test_poles.__doc__
    
    ra = np.array([0.])
    for d in [-90., 90.]:
        dec = np.array([d])
        val = wssa_utils.wssa_getval(ra, dec)
        assert isinstance(val, np.ndarray)
        assert val.dtype.name == 'float32'
        assert val[0] != 0
예제 #18
0
파일: comp.py 프로젝트: ameisner/wssa_utils
def test_vals_float(outname):
    """get tile values more than one lon, lat pair"""
    ra  = np.array([228.06533, 336.88487,  132.85047, 296.63675, 174.24343,
                     304.68113])
    dec = np.array([9.6944888, 25.149593, -29.273778, 11.994469, 43.651411,
                    -10.985369])  
    ra  = ra.astype('float32')
    dec = dec.astype('float32')

    vals = wssa_utils.wssa_getval(ra, dec)
    arrs2fits(outname, vals)
예제 #19
0
파일: dust.py 프로젝트: schlafly/dust
def wgetval(l, b, **kw):
    import os
    import sys
    try:
        import wssa_utils
    except:
        raise ImportError('wgetval requires wssa_utils')
    from lsd.builtins.misc import galequ
    if os.environ.get('WISE_TILE', None) is None:
        os.environ['WISE_TILE'] = '/n/fink1/ameisner/tile-combine'
        sys.path.append('/n/home09/ameisner/wssa_utils/python')
    return wssa_utils.wssa_getval(*galequ(l, b), **kw)
예제 #20
0
def test_ext_type():
    """test that extension samples are of correct type, e.g. mask is integer"""
    print test_ext_type.__doc__

    nsam = 1
    ra, dec = random_lonlat(nsam, deg=True)
    msk = wssa_utils.tile_par_struc()['ismsk']
    for ext, ismsk in enumerate(msk):
        if not ismsk: continue
        val = wssa_utils.wssa_getval(ra, dec, exten=ext)
        assert isinstance(val, np.ndarray)
        assert val.dtype.name == 'int32'
예제 #21
0
def test_ext_type():
    """test that extension samples are of correct type, e.g. mask is integer"""
    print test_ext_type.__doc__

    nsam = 1
    ra, dec = random_lonlat(nsam, deg=True)
    msk = wssa_utils.tile_par_struc()['ismsk']
    for ext, ismsk in enumerate(msk):
        if not ismsk: continue
        val = wssa_utils.wssa_getval(ra, dec, exten=ext)
        assert isinstance(val, np.ndarray)
        assert val.dtype.name == 'int32'
예제 #22
0
def test_full_sky():
    """lon, lat for every nside=16 HEALPix pixel center"""
    print test_full_sky.__doc__
    
    nside = 16
    npix = 12*(nside**2)
    pix = np.arange(npix)
    theta, phi = pix2ang_ring(nside, pix)
    ra = (180./np.pi)*phi
    dec = 90. - (180./np.pi)*theta
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.shape == (npix,)
예제 #23
0
def test_full_sky():
    """lon, lat for every nside=16 HEALPix pixel center"""
    print test_full_sky.__doc__

    nside = 16
    npix = 12 * (nside**2)
    pix = np.arange(npix)
    theta, phi = pix2ang_ring(nside, pix)
    ra = (180. / np.pi) * phi
    dec = 90. - (180. / np.pi) * theta
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.shape == (npix, )
예제 #24
0
def test_many_coords():
    """lon and lat both 1d arrays, all within single tile"""
    print test_many_coords.__doc__

    racen = wssa_utils.com_tiles['RA'][114]
    deccen = wssa_utils.com_tiles['DEC'][114]
    nsam = 100
    ra = np.random.rand(nsam) - 0.5 + racen
    dec = np.random.rand(nsam) - 0.5 + deccen
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.dtype.name == 'float32'
    assert vals.shape == (nsam,)
예제 #25
0
def test_many_coords():
    """lon and lat both 1d arrays, all within single tile"""
    print test_many_coords.__doc__

    racen = wssa_utils.com_tiles['RA'][114]
    deccen = wssa_utils.com_tiles['DEC'][114]
    nsam = 100
    ra = np.random.rand(nsam) - 0.5 + racen
    dec = np.random.rand(nsam) - 0.5 + deccen
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.dtype.name == 'float32'
    assert vals.shape == (nsam, )
예제 #26
0
def test_2d_coords():
    """lon and lat both 2d arrays, all within single tile"""
    print test_2d_coords.__doc__

    racen = wssa_utils.com_tiles['RA'][114]
    deccen = wssa_utils.com_tiles['DEC'][114]
    nsam = 100
    ra = np.random.rand(nsam) - 0.5 + racen
    dec = np.random.rand(nsam) - 0.5 + deccen
    sh = (10, 10)
    ra = ra.reshape(sh)
    dec = dec.reshape(sh)
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.shape == sh
예제 #27
0
def test_2d_coords():
    """lon and lat both 2d arrays, all within single tile"""
    print test_2d_coords.__doc__

    racen = wssa_utils.com_tiles['RA'][114]
    deccen = wssa_utils.com_tiles['DEC'][114]
    nsam = 100
    ra = np.random.rand(nsam) - 0.5 + racen
    dec = np.random.rand(nsam) - 0.5 + deccen
    sh = (10, 10)
    ra = ra.reshape(sh)
    dec = dec.reshape(sh)
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.shape == sh
예제 #28
0
def test_2d_many():
    """lon and lat both 2d arrays, spread over multiple tiles"""
    print test_2d_many.__doc__

    racen = wssa_utils.com_tiles['RA'][114]
    deccen = wssa_utils.com_tiles['DEC'][114]
    nsam = 100
    dist = 10.
    ra = dist*(np.random.rand(nsam) - 0.5) + racen
    dec = dist*(np.random.rand(nsam) - 0.5) + deccen
    sh = (20, 5) # try non-square
    ra = ra.reshape(sh)
    dec = dec.reshape(sh)
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.shape == sh
예제 #29
0
def test_2d_many():
    """lon and lat both 2d arrays, spread over multiple tiles"""
    print test_2d_many.__doc__

    racen = wssa_utils.com_tiles['RA'][114]
    deccen = wssa_utils.com_tiles['DEC'][114]
    nsam = 100
    dist = 10.
    ra = dist * (np.random.rand(nsam) - 0.5) + racen
    dec = dist * (np.random.rand(nsam) - 0.5) + deccen
    sh = (20, 5)  # try non-square
    ra = ra.reshape(sh)
    dec = dec.reshape(sh)
    vals = wssa_utils.wssa_getval(ra, dec)
    assert isinstance(vals, np.ndarray)
    assert vals.shape == sh