-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
279 additions
and
112 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
def get_package_data(): | ||
# Installs the testing data files. Unable to get package_data | ||
# to deal with a directory hierarchy of files, so just explicitly list. | ||
return {'linetools.isgm.tests': ['files/*.fits', 'files/*.dat', 'files/*.json', 'files/*.all', 'files/*.fits.gz', 'files/*.out']} | ||
return {'linetools.isgm.tests': ['files/*.fits', 'files/*.dat', 'files/*.json', 'files/*.all', 'files/*.fits.gz', 'files/*.VP', 'files/*.out']} |
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,4 @@ | ||
specfile|restwave|zsys|col|sigcol|bval|sigbval|vel|sigvel|nflag|bflag|vflag|vlim1|vlim2|wobs1|wobs2|pix1|pix2|z_comp|trans | ||
TON580_cont.fits|1215.67|0.2895|12.789|0.201|25.558|5.802|33.939|8.036|3|3|3|-100.0|100.0|1567.20683282|1568.01784055|13707|13729|0.28965|H I | ||
TON580_cont.fits|1025.7222|0.28978|12.738|0.212|8.697|5.126|-16.281|2.0|2|2|2|-100.0|100.0|1322.61207078|1323.29635897|6256|6279|0.28971|H I | ||
TON580_cont.fits|1215.67|0.28978|12.738|0.0|8.697|0.0|-16.281|0.0|2|2|2|-100.0|100.0|1567.53925778|1568.35026551|13716|13738|0.28971|H I |
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,50 @@ | ||
# Module to run tests on using AbsComponent | ||
|
||
from __future__ import print_function, absolute_import, division, unicode_literals | ||
|
||
# TEST_UNICODE_LITERALS | ||
|
||
import pytest | ||
import os | ||
|
||
from pkg_resources import resource_filename | ||
|
||
from astropy.coordinates import SkyCoord | ||
from astropy import units as u | ||
|
||
from linetools.isgm.io import read_joebvp_to_components | ||
from linetools.isgm.io import write_joebvp_from_components | ||
|
||
from .utils import mk_comp, compare_two_files | ||
|
||
def data_path(filename): | ||
data_dir = os.path.join(os.path.dirname(__file__), 'files') | ||
return os.path.join(data_dir, filename) | ||
|
||
|
||
def test_read_joebvp(): | ||
vp_file = data_path('group_9.VP') | ||
# Load | ||
icoord = SkyCoord(ra=12., dec=-12, unit='deg') | ||
comps = read_joebvp_to_components(vp_file, icoord) | ||
# Test | ||
assert isinstance(comps, list) | ||
assert len(comps) == 2 | ||
assert len(comps[1]._abslines) == 2 | ||
assert comps[1]._abslines[0].attrib['N'].value > 0. | ||
|
||
|
||
def test_complist_to_joebvp(): | ||
# will write a file in directory ./files/ | ||
abscomp, HIlines = mk_comp('HI', b=15*u.km/u.s, use_rand=False) | ||
comp_list = [abscomp, abscomp] | ||
write_joebvp_from_components(comp_list, 'test.fits', data_path('test_joebvp_repr.joebvp')) | ||
# now read the output and compare to reference | ||
compare_two_files(data_path('test_joebvp_repr.joebvp'), | ||
resource_filename('linetools', '/data/tests/test_joebvp_repr_reference.joebvp')) | ||
# now add attribute to comp and compare again | ||
abscomp.attrib['b'] = 15*u.km/u.s | ||
write_joebvp_from_components(comp_list, 'test.fits', data_path('test_joebvp_repr.joebvp')) | ||
compare_two_files(data_path('test_joebvp_repr.joebvp'), | ||
resource_filename('linetools', '/data/tests/test_joebvp_repr_reference.joebvp')) | ||
|
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
Oops, something went wrong.