def test_parse_observing_summary_dbase_file(): """ Test that we get the observing summary database file with the content we expect. """ obssum = rhessi.parse_observing_summary_dbase_file( get_test_filepath("hsi_obssumm_filedb_201104.txt")) assert obssum['filename'][0][0:20] == 'hsi_obssumm_20110401' assert obssum['filename'][1][0:20] == 'hsi_obssumm_20110402' assert obssum['orb_st'][0] == 0 assert obssum['orb_st'][-1] == 0 assert obssum['orb_end'][0] == 0 assert obssum['orb_end'][-1] == 0 assert obssum['start_time'][0] == parse_time((2011, 4, 1, 0, 0, 0)) assert obssum['start_time'][-1] == parse_time((2011, 4, 30, 0, 0, 0)) assert obssum['end_time'][0] == parse_time((2011, 4, 2, 0, 0, 0)) assert obssum['end_time'][-1] == parse_time((2011, 5, 1, 0, 0, 0)) assert obssum['status_flag'][0] == 0 assert obssum['status_flag'][-1] == 0 assert obssum['npackets'][0] == 0 assert obssum['npackets'][-1] == 0
def test_backprojection(): """ Test that backprojection returns a map with the expected time. """ test_filename = 'hsi_calib_ev_20020220_1106_20020220_1106_25_40.fits' amap = rhessi.backprojection(get_test_filepath(test_filename)) assert isinstance(amap, sunpy.map.GenericMap) assert is_time_equal(amap.date, parse_time((2002, 2, 20, 11, 6, 21)))
def test_imagecube2map_edgecase(): fname = get_test_filepath("hsi_imagecube_clean_20150930_1307_1tx1e.fits") maps = rhessi.imagecube2map(fname) assert list(maps.keys()) == ['6-12 keV'] assert len(maps['6-12 keV']) == 1 assert isinstance(maps['6-12 keV'], sunpy.map.MapSequence) assert maps['6-12 keV'][0].fits_header['DATAMIN'] == pytest.approx(-0.0835, abs=1e-4) assert maps['6-12 keV'][0].fits_header['DATAMAX'] == pytest.approx(1.9085, abs=1e-4)
def test_imagecube2map(): fname = get_test_filepath("hsi_imagecube_clean_20151214_2255_2tx2e.fits") maps = rhessi.imagecube2map(fname) assert list(maps.keys()) == ['3-6 keV', '6-12 keV'] assert len(maps['3-6 keV']) == 2 assert len(maps['6-12 keV']) == 2 assert isinstance(maps['3-6 keV'], sunpy.map.MapSequence) assert isinstance(maps['6-12 keV'], sunpy.map.MapSequence) assert maps['3-6 keV'][0].fits_header['DATAMIN'] == pytest.approx(0.0, abs=1e-4) assert maps['3-6 keV'][1].fits_header['DATAMIN'] == pytest.approx(0.0, abs=1e-4) assert maps['3-6 keV'][0].fits_header['DATAMAX'] == pytest.approx(0.0, abs=1e-4) assert maps['3-6 keV'][1].fits_header['DATAMAX'] == pytest.approx(0.0, abs=1e-4) assert maps['6-12 keV'][0].fits_header['DATAMIN'] == pytest.approx(-0.00765, abs=1e-4) assert maps['6-12 keV'][1].fits_header['DATAMIN'] == pytest.approx(-0.00765, abs=1e-4) assert maps['6-12 keV'][0].fits_header['DATAMAX'] == pytest.approx(0.1157, abs=1e-4) assert maps['6-12 keV'][1].fits_header['DATAMAX'] == pytest.approx(0.1157, abs=1e-4)
def test_parse_obssum_dbase_file(): fname = get_test_filepath("hsi_obssumm_filedb_201104.txt") obssum = rhessi.parse_observing_summary_dbase_file(fname) assert obssum['filename'][0] == 'hsi_obssumm_20110401_043.fit' assert obssum['filename'][-1] == 'hsi_obssumm_20110430_029.fit' assert obssum['orb_st'][0] == 0 assert obssum['orb_st'][-1] == 0 assert obssum['orb_end'][0] == 0 assert obssum['orb_end'][-1] == 0 assert obssum['start_time'][0] == parse_time((2011, 4, 1, 0, 0, 0)) assert obssum['start_time'][-1] == parse_time((2011, 4, 30, 0, 0, 0)) assert obssum['end_time'][0] == parse_time((2011, 4, 2, 0, 0, 0)) assert obssum['end_time'][-1] == parse_time((2011, 5, 1, 0, 0, 0)) assert obssum['status_flag'][0] == 0 assert obssum['status_flag'][-1] == 0 assert obssum['npackets'][0] == 0 assert obssum['npackets'][-1] == 0
def test_get_parse_obssum_hdulist(): hdulist = sunpy.io.read_file(get_test_filepath('hsi_obssumm_20110404_042.fits.gz')) header, _data = rhessi.parse_observing_summary_hdulist(hdulist) assert header.get('DATE_OBS') == '2011-04-04T00:00:00.000' assert header.get('DATE_END') == '2011-04-05T00:00:00.000' assert header.get('TELESCOP') == 'HESSI'
def test_imagecube2map_nonrhessi(): fname = get_test_filepath("go1520110607.fits") with pytest.raises(ValueError, match="Expected a RHESSI datacube*"): rhessi.imagecube2map(fname)
def goeslc(): return timeseries.TimeSeries(get_test_filepath("go1520110607.fits"))