Esempio n. 1
0
def test_sres_ext():
    file = remote_data_file(
        filename=MaNGADataCube.build_file_name(7815, 3702, log=True))
    hdu = fits.open(file)
    assert MaNGADataCube.spectral_resolution_extension(hdu) == 'LSFPRE', \
                'Bad spectral resolution extension selection'
    assert MaNGADataCube.spectral_resolution_extension(hdu, ext='SPECRES') == 'SPECRES', \
                'Bad spectral resolution extension selection'
    assert MaNGADataCube.spectral_resolution_extension(hdu, ext='junk') is None, \
                'Should return None for a bad extension name.'
Esempio n. 2
0
def test_read():
    cube = MaNGADataCube.from_plateifu(7815,
                                       3702,
                                       directory_path=remote_data_file())

    assert cube.file_name == MaNGADataCube.build_file_name(
        cube.plate, cube.ifudesign, log=cube.log), 'Name mismatch'
    assert cube.log, 'Should read the log-binned version by default.'
    assert cube.wcs is not None, 'WCS should be defined.'
    assert cube.shape[:
                      2] == cube.spatial_shape, 'Spatial shape should be first two axes.'
    assert cube.nspec == numpy.prod(
        cube.spatial_shape), 'Definition of number of spectra changed.'
    assert cube.sres is not None, 'Spectral resolution data was not constructed.'
    assert cube.sres_ext == 'LSFPRE', 'Should default to LSFPRE extension.'
    assert abs(cube.pixelscale -
               cube._get_pixelscale()) < 1e-6, 'Bad match in pixel scale.'
    # NOTE: This is worse than it should be because of how the WCS in MaNGA is defined.
    assert numpy.all(numpy.absolute(cube.wave - cube._get_wavelength_vector(cube.nwave)) < 2e-4), \
            'Bad calculation of wavelength vector.'
    assert cube.covar is None, 'Covariance should not have been read'
Esempio n. 3
0
def test_read_drp():
    drpfile = os.path.join(remote_data_file(),
                           MaNGADataCube.build_file_name(7815, 3702))

    assert os.path.isfile(drpfile), 'Did not find file'

    with fits.open(drpfile) as hdu:
        covar = Covariance.from_fits(hdu,
                                     ivar_ext=None,
                                     covar_ext='GCORREL',
                                     impose_triu=True,
                                     correlation=True)
        var = numpy.ma.power(
            hdu['IVAR'].data[hdu['GCORREL'].header['BBINDEX']].T.ravel(),
            -1).filled(0.0)

    covar = covar.apply_new_variance(var)
    covar.revert_correlation()

    assert numpy.array_equal(var, numpy.diag(
        covar.toarray())), 'New variance not applied'