def waveunit_fits_directory(tmp_path_factory): # Create a temporary directory of dummy FITS files # from the header data. This directory is then used to # test directory patterns for database waveunit_dir = tmp_path_factory.mktemp('waveunit') header_files = [f for f in test_data_filenames() if f.parents[0].relative_to(f.parents[1]).name == 'waveunit'] for f in header_files: _ = write_image_file_from_header_file(f, waveunit_dir) return pathlib.Path(waveunit_dir)
def eit_fits_directory(tmp_path_factory): # Create a temporary directory of dummy EIT FITS files # from the header data. This directory is then used to # test directory and glob patterns for the map factory eit_dir = tmp_path_factory.mktemp('EIT') eit_header_files = [f for f in test_data_filenames() if f.parents[0].relative_to(f.parents[1]).name == 'EIT_header' and f.suffix == '.header'] for f in eit_header_files: _ = write_image_file_from_header_file(f, eit_dir) return pathlib.Path(eit_dir)
def test_fitsheader(): """Test that all test data can be converted back to a FITS header.""" extensions = ('.fts', '.fits') for ext in extensions: test_files = [f for f in test_data_filenames() if f.suffix == ext] for ffile in test_files: fits_file = fits.open(ffile) fits_file.verify("fix") meta_header = MetaDict(OrderedDict(fits_file[0].header)) _fits.header_to_fits(meta_header) fits_file.close()
eve_filepath = get_test_filepath('EVE_L0CS_DIODES_1m_truncated.txt') esp_filepath = get_test_filepath('eve_l1_esp_2011046_00_truncated.fits') fermi_gbm_filepath = get_test_filepath('gbm.fits') norh_filepath = get_test_filepath('tca110810_truncated') lyra_filepath = get_test_filepath( 'lyra_20150101-000000_lev3_std_truncated.fits.gz') rhessi_filepath = get_test_filepath( 'hsi_obssumm_20120601_018_truncated.fits.gz') noaa_ind_json_filepath = get_test_filepath( 'observed-solar-cycle-indices-truncated.json') noaa_pre_json_filepath = get_test_filepath( 'predicted-solar-cycle-truncated.json') goes_filepath = get_test_filepath('go1520120601.fits.gz') a_list_of_many = [ f for f in test_data_filenames() if f.parents[0].relative_to(f.parents[1]).name == 'eve' ] @pytest.fixture def eve_test_ts(): with pytest.warns(SunpyUserWarning, match='Unknown units'): return sunpy.timeseries.TimeSeries(eve_filepath, source='EVE') @pytest.fixture def esp_test_ts(): return sunpy.timeseries.TimeSeries(esp_filepath, source='ESP')
""" Test cases for SOHO EITMap subclass """ import pytest import astropy.units as u from sunpy.data.test import get_dummy_map_from_header, test_data_filenames from sunpy.map.sources.soho import EITMap header_list = [f for f in test_data_filenames() if 'efz' in f.name and '.header' in f.name] __author__ = "Pritish C. (VaticanCameos)" @pytest.fixture(scope="module", params=header_list) def eit_map(request): """Creates an EITMap from a FITS file.""" return get_dummy_map_from_header(request.param) def test_fitstoEIT(eit_map): """Tests the creation of EITMap using FITS.""" assert isinstance(eit_map, EITMap) def test_is_datasource_for(eit_map): """Test the is_datasource_for method of EITMap. Note that header data to be provided as an argument can be a MetaDict object.""" assert eit_map.is_datasource_for(eit_map.data, eit_map.meta)
import pathlib import tempfile import numpy as np import pytest from astropy.io import fits from astropy.wcs import WCS import sunpy import sunpy.map from sunpy.data.test import get_dummy_map_from_header, get_test_filepath, rootdir, test_data_filenames from sunpy.tests.helpers import skip_glymur from sunpy.util.exceptions import NoMapsInFileError, SunpyMetadataWarning, SunpyUserWarning a_list_of_many = [f for f in test_data_filenames() if 'efz' in f.name] AIA_171_IMAGE = get_test_filepath('aia_171_level1.fits') RHESSI_IMAGE = get_test_filepath('hsi_image_20101016_191218.fits') AIA_193_JP2 = get_test_filepath("2013_06_24__17_31_30_84__SDO_AIA_AIA_193.jp2") AIA_MAP = sunpy.map.Map(AIA_171_IMAGE) VALID_MAP_INPUTS = [ (AIA_171_IMAGE, ), (pathlib.Path(AIA_171_IMAGE), ), (rootdir / "EIT", ), (os.fspath(rootdir / "EIT"), ), (rootdir / "EIT" / "*.fits", ), (AIA_MAP, ), (AIA_MAP.data, AIA_MAP.meta), ((AIA_MAP.data, AIA_MAP.meta), ), ]
from sunpy.util.metadata import MetaDict # ============================================================================= # TimeSeries Tests # ============================================================================= eve_filepath = get_test_filepath('EVE_L0CS_DIODES_1m_truncated.txt') esp_filepath = get_test_filepath('eve_l1_esp_2011046_00_truncated.fits') fermi_gbm_filepath = get_test_filepath('gbm.fits') norh_filepath = get_test_filepath('tca110810_truncated') lyra_filepath = get_test_filepath('lyra_20150101-000000_lev3_std_truncated.fits.gz') rhessi_filepath = get_test_filepath('hsi_obssumm_20120601_018_truncated.fits.gz') noaa_ind_json_filepath = get_test_filepath('observed-solar-cycle-indices-truncated.json') noaa_pre_json_filepath = get_test_filepath('predicted-solar-cycle-truncated.json') goes_filepath = get_test_filepath('go1520120601.fits.gz') a_list_of_many = [f for f in test_data_filenames() if f.parents[0].relative_to(f.parents[1]).name == 'eve'] @pytest.fixture def eve_test_ts(): with pytest.warns(SunpyUserWarning, match='Unknown units'): return sunpy.timeseries.TimeSeries(eve_filepath, source='EVE') @pytest.fixture def esp_test_ts(): return sunpy.timeseries.TimeSeries(esp_filepath, source='ESP') @pytest.fixture def fermi_gbm_test_ts():