コード例 #1
0
 def setUp(self):
     import pkg_resources
     import tempfile
     file_name = 'data/sample_data_NGC7023.tbl'
     file_path = pkg_resources.resource_filename('pypahdb', file_name)
     self.observation = Observation(file_path)
     self.decomposer = Decomposer(self.observation.spectrum)
     self.tmpdir = tempfile.gettempdir()
コード例 #2
0
    def test_read_fits(self):
        """Can we create an instance of Observation from a FITS file?"""
        file_name = 'resources/sample_data_NGC7023.fits'
        file_path = pkg_resources.resource_filename('pypahdb', file_name)

        assert isinstance(Observation(file_path), Observation)
コード例 #3
0
    def test_read_ascii(self):
        """Can we create an instance of Observation from an ASCII file?"""
        file_name = 'data/sample_data_NGC7023.tbl'
        file_path = pkg_resources.resource_filename('pypahdb', file_name)

        self.assertIsInstance(Observation(file_path), Observation)
コード例 #4
0
#!/usr/bin/env python3
"""
example.py

Example of using pypahdb to decompose an astronomical PAH spectrum.
"""

import pkg_resources

from pypahdb.decomposer import Decomposer
from pypahdb.observation import Observation

if __name__ == '__main__':

    # Sample data (in FITS format).
    file_path = 'resources/sample_data_NGC7023.fits'
    data_file = pkg_resources.resource_filename('pypahdb', file_path)

    # Construct an Observation object.
    obs = Observation(data_file)

    # Pass the Observation's spectrum to Decomposer, which performs the fit.
    pahdb_fit = Decomposer(obs.spectrum)

    # Write the results to file.
    # doplots is disabled due to significant CPU overhead
    pahdb_fit.save_pdf('NGC7023_pypahdb_fits_example.pdf',
                       header=obs.header,
                       doplots=False)
    pahdb_fit.save_fits('NGC7023_pypahdb_fits_example.fits', header=obs.header)