Exemple #1
0
 def test_guess_all(self, shared_datadir, filename):
     formats = loaders.whatformat(shared_datadir / filename)
     spectra = SpectrumList.read(
         shared_datadir / filename
     )
     print("format for {0} is {1} and number of spectra is {2}".format(filename, formats, len(spectra)))
     for spectrum in spectra:
         print(spectrum)
Exemple #2
0
 def test_marz_guess_2(self, shared_datadir):
     formats = loaders.whatformat(shared_datadir / "marz/alldata_combined_runz_x12_b02.fits")
     if len(formats) > 1:
         loaders.unregister(formats[0])
     spectra = SpectrumList.read(
         shared_datadir / "marz/alldata_combined_runz_x12_b02.fits"
     )
     # Should be main spectra, with sky, and normalised
     assert len(spectra) == 2
Exemple #3
0
 def test_marz_guess_1(self, shared_datadir):
     formats = loaders.whatformat(shared_datadir / "marz/quasarLinearSkyAirNoHelio.fits")
     if len(formats) > 1:
         loaders.unregister(formats[0])
     spectra = SpectrumList.read(
         shared_datadir / "marz/quasarLinearSkyAirNoHelio.fits"
     )
     # Should be main spectra, with sky, and normalised
     assert len(spectra) == 2
Exemple #4
0
def toJSON(args):

    spectrum_file = args.input
    try:
        formatguess = loaders.whatformat(spectrum_file)
        spectrum_data = read_spectra_file_simple(spectrum_file)
        print("good {} {}".format(spectrum_file, formatguess))
    except Exception as x:
        print("bad {}".format(spectrum_file))
        if args.verbose:
            print("{} guess={}".format(x, formatguess))
Exemple #5
0
 def test_fits2json_2(self, shared_datadir):
     from ssv.viewer import read_spectra_file, read_spectra_file_simple, SimpleSpectrum
     from ssv import utils
     spectrum_file = shared_datadir / "marz/spec-4444-55538-1000.fits"
     formats = loaders.whatformat(spectrum_file)
     if len(formats) > 1:
         loaders.unregister(formats[0])
     spectrum_data = read_spectra_file_simple(spectrum_file)
     loaders.restore_registered_loaders()
     spectrum = SimpleSpectrum('fits2JSON', spectrum_data)
     asjson = utils.toMarzJSON(spectrum)
Exemple #6
0
 def test_not_marz_guess_1(self, shared_datadir):
     formats = loaders.whatformat(shared_datadir / "OBJ0032red.fits")
     if len(formats) > 1:
         loaders.unregister(formats[0])
     spectra = SpectrumList.read(
         shared_datadir / "OBJ0032red.fits"
     )
     # Should be main spectra, with sky, and normalised
     assert len(spectra) > 0
     assert spectra[0].spectral_axis.unit == u.Angstrom
     assert spectra[0].meta.get("header") is not None
Exemple #7
0
 def test_not_marz_guess_2(self, shared_datadir):
     formats = loaders.whatformat(shared_datadir / "J091726.21+003424.0_a14_040423.fit")
     if len(formats) > 1:
         loaders.unregister(formats[0])
     spectra = SpectrumList.read(
         shared_datadir / "J091726.21+003424.0_a14_040423.fit"
     )
     loaders.restore_registered_loaders()
     # Should be main spectra, with sky, and normalised
     assert len(spectra) > 0
     assert spectra[0].spectral_axis.unit == u.Angstrom
     assert spectra[0].meta.get("header") is not None