-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1865 from pypeit/mosaic_try_old
Fix bug when reading mosaic data in files from previous pypeit versions.
- Loading branch information
Showing
4 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from pathlib import Path | ||
from IPython import embed | ||
|
||
import pytest | ||
|
||
from astropy.io import fits | ||
|
||
from pypeit.pypmsgs import PypeItDataModelError | ||
from pypeit.tests.tstutils import data_output_path | ||
from pypeit.images.mosaic import Mosaic | ||
from pypeit.spectrographs.util import load_spectrograph | ||
|
||
|
||
def test_io(): | ||
# Create the mosaic | ||
spec = load_spectrograph('keck_deimos') | ||
mpar = spec.get_mosaic_par((1,5)) | ||
|
||
# Write it | ||
ofile = data_output_path('tmp_mosaic.fits') | ||
mpar.to_file(ofile, overwrite=True) | ||
|
||
# Try to read it | ||
_mpar = Mosaic.from_file(ofile) | ||
|
||
# Change the version | ||
_ofile = data_output_path('tmp_mosaic_wrongver.fits') | ||
with fits.open(ofile) as hdu: | ||
hdu['MOSAIC'].header['DMODVER'] = '1.0.0' | ||
hdu.writeto(_ofile, overwrite=True) | ||
|
||
# Reading should fail because version is checked by default | ||
with pytest.raises(PypeItDataModelError): | ||
_mpar = Mosaic.from_file(_ofile) | ||
|
||
# Should not fail because skipping the version check | ||
_mpar = Mosaic.from_file(_ofile, chk_version=False) | ||
|
||
# Remove files | ||
Path(ofile).unlink() | ||
Path(_ofile).unlink() |