diff --git a/flows/load_image.py b/flows/load_image.py index 3e47795..cefbdeb 100644 --- a/flows/load_image.py +++ b/flows/load_image.py @@ -300,7 +300,7 @@ def load_image(FILENAME): elif telescope == 'SAI-2.5' and instrument == 'ASTRONIRCAM': image.site = api.get_site(13) # Hard-coded the siteid for Caucasus Mountain Observatory if 'MIDPOINT' in hdr: - image.obstime = Time(hdr['MIDPOINT'], format='mjd', scale='utc', location=image.site['EarthLocation']) + image.obstime = Time(hdr['MIDPOINT'], format='isot', scale='utc', location=image.site['EarthLocation']) else: image.obstime = Time(hdr['MJD-AVG'], format='mjd', scale='utc', location=image.site['EarthLocation']) image.photfilter = { diff --git a/tests/input/SN2020aatc_K_20201213_495s.fits.gz b/tests/input/SN2020aatc_K_20201213_495s.fits.gz new file mode 100644 index 0000000..0b00ece --- /dev/null +++ b/tests/input/SN2020aatc_K_20201213_495s.fits.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94a1bdcfbfd75da8c66f7d37271125353953acb16d087982d4241f05f9864c6a +size 2909171 diff --git a/tests/test_load_image.py b/tests/test_load_image.py new file mode 100644 index 0000000..77a8f07 --- /dev/null +++ b/tests/test_load_image.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Test loading of images. + +.. codeauthor:: Rasmus Handberg +""" + +import pytest +import numpy as np +from astropy.time import Time +from astropy.wcs import WCS +import os.path +import conftest +from flows.load_image import load_image + +#-------------------------------------------------------------------------------------------------- +@pytest.mark.parametrize('fpath', ['SN2020aatc_K_20201213_495s.fits.gz']) +def test_load_image(fpath): + + # The test input directory containing the test-images: + INPUT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'input') + + # Load the image from the test-set: + img = load_image(os.path.join(INPUT_DIR, fpath)) + + # Check the attributes of the image object: + assert isinstance(img.image, np.ndarray) + assert img.image.dtype in ('float32', 'float64') + assert isinstance(img.mask, np.ndarray) + assert img.mask.dtype == 'bool' + assert isinstance(img.clean, np.ma.MaskedArray) + assert img.clean.dtype == img.image.dtype + assert isinstance(img.obstime, Time) + assert isinstance(img.exptime, float) + assert img.exptime > 0 + assert isinstance(img.photfilter, str) + assert isinstance(img.wcs, WCS) + +#-------------------------------------------------------------------------------------------------- +if __name__ == '__main__': + pytest.main([__file__])