Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 59 additions & 21 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ Installation
Requirements
^^^^^^^^^^^^

`sbpy` has the following requirements that will be automatically taken
care of with installation using pip:
`sbpy` has the following requirements that will be automatically taken care of
with installation using pip:

* Python 3.6 or later
* `numpy <https://numpy.org/>`__ 1.16.0 or later
* pytest 3.1 or later
* `astropy <https://www.astropy.org/>`__
* `astroquery <https://astroquery.readthedocs.io/en/latest/>`__ 0.4.1.dev5892 or later: For retrieval of online data, e.g., ephemerides and orbits.
* `scipy <https://www.scipy.org/>`__: For numerical integrations in `sbpy.activity.gas` and `sbpy.photometry`, among others.
* `synphot <https://github.com/spacetelescope/synphot_refactor>`__ 0.1.3 or later: For calibration with respect to the Sun and Vega, filtering spectra through bandpasses.

The following packages will have to be installed manually, if the user
wants to use them:

* `oorb <https://github.com/oorb/oorb/tree/master/python>`__: For
orbit transformations (`~sbpy.data.Orbit.oo_transform`) and
propagations (`~sbpy.data.Orbit.oo_propagate`), as well as
ephemerides calculations (`~sbpy.data.Ephem.from_oo`).
* `pyradex <https://github.com/keflavich/pyradex>`__: For non-LTE
production rate calculation related to cometary activity
(`~sbpy.activity.gas.NonLTE`).
* `ginga <https://ejeschke.github.io/ginga/>`__ and `photutils <https://photutils.readthedocs.io/en/stable/>`__: To interactively enhance images of comets with the `~sbpy.imageanalysis.CometaryEnhancement` Ginga plugin.
* `astroquery <https://astroquery.readthedocs.io/en/latest/>`__ 0.4.1.dev5892 or
later: For retrieval of online data, e.g., ephemerides and orbits.
* `scipy <https://www.scipy.org/>`__: For numerical integrations in
`sbpy.activity.gas` and `sbpy.photometry`, among others.
* `synphot <https://github.com/spacetelescope/synphot_refactor>`__ 0.1.3 or
later: For calibration with respect to the Sun and Vega, filtering spectra
through bandpasses.

The following packages will have to be installed manually, if the user wants to
use them:

* `oorb <https://github.com/oorb/oorb/tree/master/python>`__: For orbit
transformations (`~sbpy.data.Orbit.oo_transform`) and propagations
(`~sbpy.data.Orbit.oo_propagate`), as well as ephemerides calculations
(`~sbpy.data.Ephem.from_oo`).
* `pyradex <https://github.com/keflavich/pyradex>`__: For non-LTE production
rate calculation related to cometary activity (`~sbpy.activity.gas.NonLTE`).
* `ginga <https://ejeschke.github.io/ginga/>`__ and `photutils
<https://photutils.readthedocs.io/en/stable/>`__: To interactively enhance
images of comets with the `~sbpy.imageanalysis.CometaryEnhancement` Ginga
plugin.


Using pip
Expand All @@ -49,9 +55,9 @@ The latest development version of `sbpy` can be easily installed using
Using GitHub
^^^^^^^^^^^^

This way of installing `sbpy` is recommended if you plan to contribute
to the module. The current development version of `sbpy` can be
obtained from `GitHub <https://github.com/NASA-Planetary-Science/sbpy>`__ using
This way of installing `sbpy` is recommended if you plan to contribute to the
module. The current development version of `sbpy` can be obtained from `GitHub
<https://github.com/NASA-Planetary-Science/sbpy>`__ using

.. code-block:: bash

Expand All @@ -63,9 +69,41 @@ This will create a new directory (``sbpy/``). In this directory, run

$ python setup.py install --user

in order to use `sbpy` in your default Python environment. If you plan to work on the code and always want to use the latest version of your code, you can install it with
in order to use `sbpy` in your default Python environment. If you plan to work
on the code and always want to use the latest version of your code, you can
install it with


.. code-block:: bash

$ python setup.py develop --user


Running tests
^^^^^^^^^^^^^

To verify your installation is properly working, run `sbpy`'s testing suite.

First, install the required testing packages by using the "test" option, e.g.,
`sbpy[test]`:

.. code-block:: bash

# for testing a stable package
$ pip install sbpy[test]

# for testing a development packge from a GitHub
$ pip install sbpy[test]@git+https://github.com/NASA-Planetary-Science/sbpy.git

Next, test with pytest:

.. code-block:: bash

$ pytest --pyargs sbpy

Add the `--remote-data` option to aslo run tests that require a network
connection, and `-m "not slow"` to skip any tests marked as slow.

It is recommended that developers use `tox` for testing in order to use
controlled environments. See the ``astropy` testing guidelines
<https://docs.astropy.org/en/latest/development/testguide.html>`__ for more.
26 changes: 15 additions & 11 deletions sbpy/activity/gas/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ def test_column_density_small_angular_aperture(self):
eph = dict(delta=1 * u.au)
parent = 1e4 * u.km
N_avg = 2 * Haser(Q, v, parent).column_density(rho, eph)
rho_km = (rho * eph['delta'] * 725.24 * u.km / u.arcsec / u.au).to('km')
rho_km = (rho * eph['delta'] * 725.24 *
u.km / u.arcsec / u.au).to('km')
ideal = Q / v / 2 / rho_km
assert np.isclose(N_avg.to_value('1/m2'), ideal.to_value('1/m2'), rtol=0.001)
assert np.isclose(N_avg.to_value('1/m2'),
ideal.to_value('1/m2'), rtol=0.001)

def test_column_density(self):
"""
Expand Down Expand Up @@ -412,12 +414,12 @@ def test_grid_count(self):
'tau_d': 101730 * u.s,
'v_outflow': 1 * u.km/u.s,
'sigma': 3e-16 * u.cm**2
})
})
# Fragment molecule is OH
fragment = Phys.from_dict({
'tau_T': photo_timescale('OH') * 0.93,
'v_photo': 1.05 * u.km/u.s
})
})

coma = VectorialModel(base_q=base_q,
parent=parent,
Expand All @@ -441,21 +443,23 @@ def test_total_number_large_aperture(self):
'tau_d': 101730 * u.s,
'v_outflow': 1 * u.km/u.s,
'sigma': 3e-16 * u.cm**2
})
})
# Fragment molecule is OH
fragment = Phys.from_dict({
'tau_T': photo_timescale('OH') * 0.93,
'v_photo': 1.05 * u.km/u.s
})
})

coma = VectorialModel(base_q=base_q,
parent=parent,
fragment=fragment)

fragment_theory = coma.vmodel['num_fragments_theory']
ap = core.CircularAperture((coma.vmodel['max_grid_radius'].value) * u.m)
ap = core.CircularAperture(
(coma.vmodel['max_grid_radius'].value) * u.m)
assert np.isclose(fragment_theory, coma.total_number(ap), rtol=0.02)

@pytest.mark.slow
def test_model_symmetry(self):
"""
The symmetry of the model allows the parent production to be
Expand Down Expand Up @@ -486,12 +490,12 @@ def test_model_symmetry(self):
'tau_d': 101730 * u.s,
'v_outflow': 1 * u.km/u.s,
'sigma': 3e-16 * u.cm**2
})
})
# Fragment molecule is OH
fragment = Phys.from_dict({
'tau_T': photo_timescale('OH') * 0.93,
'v_photo': 1.05 * u.km/u.s
})
})

coma = VectorialModel(base_q=base_production*(1/u.s),
parent=parent,
Expand All @@ -508,12 +512,12 @@ def test_model_symmetry(self):
'tau_d': 101730 * u.s,
'v_outflow': 1 * u.km/u.s,
'sigma': 3e-16 * u.cm**2
})
})
# Fragment molecule is OH
fragment_check = Phys.from_dict({
'tau_T': photo_timescale('OH') * 0.93,
'v_photo': 1.05 * u.km/u.s
})
})
coma_check = VectorialModel(base_q=calculated_q*(1/u.s),
parent=parent_check,
fragment=fragment_check)
Expand Down
7 changes: 3 additions & 4 deletions sbpy/activity/gas/tests/test_prodrate_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def data_path(filename):
return os.path.join(data_dir, filename)


@pytest.mark.slow
@remote_data
def test_remote_prodrate_simple_hcn():

Expand Down Expand Up @@ -151,9 +152,7 @@ def test_remote_prodrate_simple_ch3oh():
assert np.all(err < 0.35)


# Issue #296
# MSK: disabling test as CO and HCN are no longer present in LAMDA database(?)
@pytest.mark.skip
@pytest.mark.slow
@remote_data
def test_einstein():

Expand Down Expand Up @@ -184,7 +183,7 @@ def test_einstein():

mol_name = mol['NAME'].data[0]

lam_search = Lamda.query(mol=mol_name.lower())
lam_search = Lamda().query(mol=mol_name.lower())

lam_result = lam_search[1]

Expand Down
6 changes: 6 additions & 0 deletions sbpy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import os

import pytest
from astropy.version import version as astropy_version

# For Astropy 3.0 and later, we can use the standalone pytest plugin
Expand Down Expand Up @@ -48,6 +49,11 @@ def pytest_configure(config):
packagename = os.path.basename(os.path.dirname(__file__))
TESTED_VERSIONS[packagename] = __version__

config.addinivalue_line(
"markers",
"slow: marks tests as slow (deselect with '-m \"not slow\"')"
)

# Uncomment the last two lines in this block to treat all DeprecationWarnings
# as exceptions. For Astropy v2.0 or later, there are 2 additional keywords,
# as follow (although default should work for most cases).
Expand Down
1 change: 1 addition & 0 deletions sbpy/data/tests/test_obs_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@pytest.mark.remote_data
class TestObsfromMPC:

@pytest.mark.slow
def test_simple(self):
# asteroid
data = Obs.from_mpc('12893')
Expand Down