| |
|
|
|
|
| import os |
|
|
| import pytest |
| import numpy as np |
|
|
| from astropy.utils.data import get_pkg_data_filenames, get_pkg_data_contents |
| from astropy.utils.misc import NumpyRNGContext |
|
|
| from astropy import wcs |
|
|
| |
|
|
| |
| |
| hdr_map_file_list = [os.path.basename(fname) for fname in get_pkg_data_filenames("data/maps", pattern="*.hdr")] |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| def test_read_map_files(): |
| |
| n_map_files = 28 |
|
|
| assert len(hdr_map_file_list) == n_map_files, ( |
| "test_read_map_files has wrong number data files: found {}, expected " |
| " {}".format(len(hdr_map_file_list), n_map_files)) |
|
|
|
|
| @pytest.mark.parametrize("filename", hdr_map_file_list) |
| def test_map(filename): |
| header = get_pkg_data_contents(os.path.join("data/maps", filename)) |
| wcsobj = wcs.WCS(header) |
|
|
| with NumpyRNGContext(123456789): |
| x = np.random.rand(2 ** 12, wcsobj.wcs.naxis) |
| world = wcsobj.wcs_pix2world(x, 1) |
| pix = wcsobj.wcs_world2pix(x, 1) |
|
|
|
|
| hdr_spec_file_list = [os.path.basename(fname) for fname in get_pkg_data_filenames("data/spectra", pattern="*.hdr")] |
|
|
|
|
| def test_read_spec_files(): |
| |
| n_spec_files = 6 |
|
|
| assert len(hdr_spec_file_list) == n_spec_files, ( |
| "test_spectra has wrong number data files: found {}, expected " |
| " {}".format(len(hdr_spec_file_list), n_spec_files)) |
| |
| |
|
|
|
|
| @pytest.mark.parametrize("filename", hdr_spec_file_list) |
| def test_spectrum(filename): |
| header = get_pkg_data_contents(os.path.join("data", "spectra", filename)) |
| wcsobj = wcs.WCS(header) |
| with NumpyRNGContext(123456789): |
| x = np.random.rand(2 ** 16, wcsobj.wcs.naxis) |
| world = wcsobj.wcs_pix2world(x, 1) |
| pix = wcsobj.wcs_world2pix(x, 1) |
|
|