Giter VIP home page Giter VIP logo

sbpy's Introduction

sbpy

sbpy is an Astropy affiliated package for small-body planetary astronomy.

Powered by Astropy Badge

GitHub testing status

Documentation status

JOSS documentation

codecov status

Overview

For an overview of the sbpy project please visit the project overview page and the official sbpy website.

Installation

The current stable version of sbpy can be installed with pip:

$ pip install sbpy

For details on the installation process, please refer to the detailed installation guide.

Documentation

The official documentation and API reference is avilable.

Status

sbpy is still under development, with v1.0 scheduled for delivery in 2024. For an overview on the status of individual features see the Status Page.

Acknowledgements

sbpy support provided by NASA PDART Grant Nos. 80NSSC18K0987 and 80NSSC22K0143.

If you use sbpy in your work, please acknowledge it by citing

Mommert, Kelley, de-Val Borro, Li et al., (2019). sbpy: A Python module for small-body planetary astronomy. Journal of Open Source Software, 4(38), 1426

sbpy's People

Contributors

bsipocz avatar danielskatz avatar gianninapr avatar jianyangli avatar kyleniemeyer avatar maxmahlke avatar migueldvb avatar mkelley avatar mommermi avatar mwcraig avatar quelqunmadit avatar sjoset avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbpy's Issues

Allow photometric models to be initialized with albedos

For sbpy.thermal it would be great to have functionality in sbpy.photometry such that, e.g., HG models can be initialized with a geometric albedo or Bond albedo in order to calculate the target's radius (with H provided) or H (with radius provided).

Vega calibration fix

Conversion to/from Vega magnitudes should assume Vega has a magnitude of 0.03 (Bessell and Murphy 2012).

Finalize SpectralStandard

There is a philosophical issue with the current state of SpectralStandard. __call__ will interpolate if a single wavelength is passed, but will rebin when multiple wavelengths are passed.
Instead, I propose to only interpolate with __call__ and make a new method, observe() which will always rebin. It could also handle multiple bandpasses, effectively replacing filt().

sun = sbpy.spectroscopy.sun.Sun()
w = [0.4, 0.5, 0.6] * u.um

# interpolated values
sun(w)

# rebinned values, i.e., return three flux densities centered on 0.4, 0.5,
# and 0.6 μm, averaged over 0.1 μm wide bandpasses
sun.observe(w)

# observe through an array of filters
sun.observe(('johnson_b', 'johnson_v', 'cousins_r'))

Also, I need to clean up the documentation and imports. Complete tests.

No module named 'ah_bootstrap' - again

I merged Miguel's astropy_helpers update (#95) since there where no build issues, but now all the Travis-CI builds seem to break. See here: https://travis-ci.org/NASA-Planetary-Science/sbpy/jobs/481600991

The problem seems to be ah_bootstrap again - we had this issue in #1 and solved it by manually copying ah_boostrap.py into the root directory. However, it seems that this is actually triggered when astroquery is being installed. I know that they are currently having build issues, too. Should we wait and see if they can fix it, or is there anything we can do about this?

install pyoorb in test environments

pyoorb can currently not be installed using pip or any other service

pyoorb tests are deactivated if that module is not installed

todo:

  • install (conda environment? of) pyoorb in test scenarios
  • remove test skipping

name parsing errors

Hi Michael - some more examples of names that fail:

V'yus
`I`iwi
`O`o

Unicode issues I expect.
(btw, I'm finding these by just loading the MPCORB.DAT file and running all the "readable names" column through sbpy.data.Names .. if you want a utility to read the MPCORB file (which might fit into your Orbits class?) we've got one at
https://github.com/rhiannonlynne/ssdpu/blob/master/catalog_utils.py which you are welcome to take and presumably modify).

Testing requires extra steps

I tried testing the package after pip install pytest, the only testing dependency listed in the docs, and got an error:

(sbpy37) juanlu@centauri /tmp/sbpy $ pytest -v
============================================= test session starts ==============================================
platform linux -- Python 3.7.3, pytest-4.6.2, py-1.8.0, pluggy-0.12.0 -- /home/juanlu/.miniconda36/envs/sbpy37/bin/python
cachedir: .pytest_cache
rootdir: /tmp/sbpy, inifile: setup.cfg
collecting ... /home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/_pytest/mark/structures.py:337: PytestUnknownMarkWarning: Unknown pytest.mark.remote_data - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
  PytestUnknownMarkWarning,
collected 0 items / 1 errors                                                                                   

==================================================== ERRORS ====================================================
________________________________________ ERROR collecting test session _________________________________________
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/_pytest/config/__init__.py:440: in _importconftest
    return self._conftestpath2mod[conftestpath]
E   KeyError: local('/tmp/sbpy/sbpy/conftest.py')

During handling of the above exception, another exception occurred:
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/_pytest/config/__init__.py:446: in _importconftest
    mod = conftestpath.pyimport()
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/py/_path/local.py:701: in pyimport
    __import__(modname)
<frozen importlib._bootstrap>:983: in _find_and_load
    ???
<frozen importlib._bootstrap>:967: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:668: in _load_unlocked
    ???
<frozen importlib._bootstrap>:638: in _load_backward_compatible
    ???
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:304: in load_module
    exec(co, mod.__dict__)
sbpy/conftest.py:47: in <module>
    TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version
E   NameError: name 'astropy_helpers_version' is not defined

During handling of the above exception, another exception occurred:
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/py/_path/common.py:377: in visit
    for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/py/_path/common.py:418: in gen
    dirs = self.optsort([p for p in entries
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/py/_path/common.py:419: in <listcomp>
    if p.check(dir=1) and (rec is None or rec(p))])
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/_pytest/main.py:661: in _recurse
    ihook = self.gethookproxy(dirpath)
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/_pytest/main.py:482: in gethookproxy
    my_conftestmodules = pm._getconftestmodules(fspath)
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/_pytest/config/__init__.py:424: in _getconftestmodules
    mod = self._importconftest(conftestpath.realpath())
/home/juanlu/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/_pytest/config/__init__.py:463: in _importconftest
    raise ConftestImportFailure(conftestpath, sys.exc_info())
E   _pytest.config.ConftestImportFailure: (local('/tmp/sbpy/sbpy/conftest.py'), (<class 'NameError'>, NameError("name 'astropy_helpers_version' is not defined"), <traceback object at 0x7f5286892948>))
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=========================================== 1 error in 0.61 seconds ============================================

This code is likely the cause:

sbpy/sbpy/conftest.py

Lines 40 to 47 in 9867a86

try:
from .version import version, astropy_helpers_version
except ImportError:
version = 'dev'
packagename = os.path.basename(os.path.dirname(__file__))
TESTED_VERSIONS[packagename] = version
TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version

DataClass does not support masked columns

Seems to be because QTable and Quantity do not support masked columns.

import numpy as np
import astropy.units as u
from astropy.table import QTable

a = np.ma.MaskedArray([1, 2, 3], mask=[True, False, False])
q = a * u.m
tab = QTable(data=[a, q], names=['array', 'quantity'], masked=True)
print(tab)
array quantity
         m    
----- --------
   --      1.0
    2      2.0
    3      3.0

This is presently a problem with Ephem.from_horizons, which drops the masks leaving zeros as column values. For example, it makes comet Encke a naked-eye object:

In [115]: print(Ephem.from_horizons('2P', 'designation', closest_apparition=True)[['Tmag', 'Nmag']])
 Tmag Nmag
 mag  mag 
----- ----
20.91  0.0

astropy/astropy#1852 looks like the main issue.

Test failure from data's field name count

I'm stuck trying to understand this test failure (see also Travis logs). The code works for me by hand and my local machine cannot reproduce it. Is there a quick way I can duplicate the environment so that I can reproduce it?

_______________________ test_alternative_name_uniqueness _______________________
def test_alternative_name_uniqueness():
"""test the uniqueness of alternative field names"""

    from ..core import conf
  assert (len(sum(conf.fieldnames, [])) ==
            len(set(sum(conf.fieldnames, []))))

E AssertionError: assert 133 == 132
E + where 133 = len(['targetname', 'id', 'Object', 'Target Identifier', 'i', 'inc', ...])
E + where ['targetname', 'id', 'Object', 'Target Identifier', 'i', 'inc', ...] = sum([['targetname', 'id', 'Object', 'Target Identifier'], ['i', 'inc', 'incl', 'Inclination'], ['epoch', 'datetime_jd', 'J...ng Node'], ['w', 'argper', 'Argument of the Periapsis'], ['r', 'rh', 'r_hel', 'heldist', 'Heliocentric Distance'], ...], [])
E + where [['targetname', 'id', 'Object', 'Target Identifier'], ['i', 'inc', 'incl', 'Inclination'], ['epoch', 'datetime_jd', 'J...ng Node'], ['w', 'argper', 'Argument of the Periapsis'], ['r', 'rh', 'r_hel', 'heldist', 'Heliocentric Distance'], ...] = <sbpy.data.Conf object at 0x7f036cf2c518>.fieldnames
E + and 132 = len({'AZ', 'Altitude', 'Argument of the Periapsis', 'Azimuth', 'D', 'DEC', ...})
E + where {'AZ', 'Altitude', 'Argument of the Periapsis', 'Azimuth', 'D', 'DEC', ...} = set(['targetname', 'id', 'Object', 'Target Identifier', 'i', 'inc', ...])
E + where ['targetname', 'id', 'Object', 'Target Identifier', 'i', 'inc', ...] = sum([['targetname', 'id', 'Object', 'Target Identifier'], ['i', 'inc', 'incl', 'Inclination'], ['epoch', 'datetime_jd', 'J...ng Node'], ['w', 'argper', 'Argument of the Periapsis'], ['r', 'rh', 'r_hel', 'heldist', 'Heliocentric Distance'], ...], [])
E + where [['targetname', 'id', 'Object', 'Target Identifier'], ['i', 'inc', 'incl', 'Inclination'], ['epoch', 'datetime_jd', 'J...ng Node'], ['w', 'argper', 'Argument of the Periapsis'], ['r', 'rh', 'r_hel', 'heldist', 'Heliocentric Distance'], ...] = <sbpy.data.Conf object at 0x7f036cf2c518>.fieldnames
sbpy/data/tests/test_dataclass.py:185: AssertionError
============== 1 failed, 236 passed, 48 skipped in 278.56 seconds ==============

numpy import error in astropy-helpers

I tried installing sbpy in a clean conda environment (Python 3.6) and stumbled across the missing requirements, which are now fixed in #51.

One problem that still persists is that if you run setup.py install/develop, the script will fail since astropy-helpers requires numpy before the setup routine (which will install numpy) is even reached. No big issue for now: simply install numpy and the setup script will install the rest.

However, it would be nice to have numpy installed automatically, too. Any thoughts on this?

from_mpc does not work with minutes

Via Martin Cordiner:

In [6]: Ephem.from_mpc('C/2016 R2', epochs={'start': '2018-11-15', 'stop': '2018-12-15', 'step': '1 min'})
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-5f1c7ea99ab5> in <module>()
----> 1 Ephem.from_mpc('C/2016 R2', epochs={'start': '2018-11-15', 'stop': '2018-12-15', 'step': '1 min'})

~/local/miniconda3/envs/astroconda/lib/python3.5/site-packages/sbpy-0.0.dev335-py3.5.egg/sbpy/data/ephem.py in from_mpc(cls, targetid, epochs, location, **kwargs)
    243                 if step.unit not in (u.d, u.h, u.m, u.s):
    244                     raise ValueError(
--> 245                         'step must have units of days, hours, minutes,'
    246                         ' or seconds')
    247 

ValueError: step must have units of days, hours, minutes, or seconds

Problem is that u.m should be u.min.

Record numbers cause test failures in test_spec_remote

@migueldvb @gianninapr The target record numbers in test_spec_remote.py are causing failures:

vega/tests/['DXREAD: requested IOBJ=   900918 is out of bounds, no action taken.\r', 'Record boundaries:                         ...001-90004391                         \r', 'If an SPK ID, look-up with "DES=   900918;"                        \r', ...]

Because record numbers can change at any time, I recommending changing these to designations.

existing code for SSOIS querying

Hi folks,
I see there's a 'to implement' on the SSOIS query in sbpy.data.image_query. You are welcome to use the astropy-based SSOIS query wrapper available here as a starting point: https://github.com/OSSOS/MOP/blob/master/src/ossos/core/ossos/ssos.py
This set of classes and functions is built around sending in a set of MPC-format lines for a newly found (i.e. undesignated) minor planet. The class ParamDictBuilder and Query, and the first part of function TrackTarget.query_ssos() will be the most useful (the rest of it is checking SSOIS's returned tables against an existing set of images to see if any are new).

Names class rejects asteroid name "ITA"

Asteroid 1735 ITA (1948 RJ1) (named "ITA" in the astorb output file) triggers an exception in the Names class.

Names.parse_comet('ITA')

Parsing it as a comet returns {'name': 'ITA'}, but this is a main belt asteroid, and

Names.asteroid_or_comet('ITA')

returns 'comet'.

Just another special case to consider, I guess.

No module named 'ah_bootstrap'

This is a problem with the cookiecutter template for astropy affiliated packages.

Trying to do a python setup.py develop, I get the following error:

Traceback (most recent call last):
  File "setup.py", line 8, in <module>
    import ah_bootstrap
ModuleNotFoundError: No module named 'ah_bootstrap'

astropy and astropy-helper are the latest version. I have to comment out the import for ah_bootstrap in setup.py to make it work. Can anyone reproduce this problem?

Allow flexible default solar flux/mag in reflectance equivalency

At this moment the default solar flux and magnitude are hard coded. But @mkelley suggested that they should be allowed to change, both in runtime and in package configuration. Something like:

import numpy as np
import astropy.units as u
from sbpy.units import VEGAmag, reflectance

mag = 3.4 * VEGAmag
xsec = np.pi * (460 * u.km)**2
with default_solar_flux(f_sun, M_sun):
    ref = mag.to('1/sr', reflectance(cross_section=xsec))

Add option to iterate SpectralGradient.from_color

SpectralGradient.from_color, to be introduced in #103, can convert a color index to a spectral gradient given filter bandpasses. It estimates effective wavelengths of the bandpasses using the sbpy default solar spectrum.

Because the effective wavelength depends on the spectral shape of the object, we should have an optional iterate keyword that attempts to converge on a stable solution. It should also take some kind of reddening function, or else assume linear reddening.

Ephem.from_horizons can't handle multiple Time values

Below code generates an error message:

from sbpy.data import Ephem
from astropy.time import Time
epochs = Time(['2015-01-01', '2015-01-02'])
eph = Ephem.from_horizons('Ceres', epochs=epochs)

The problem is that .from_horizons doesn't handle epochs value correctly when it contains multiple values. There are also other bugs for the case isinstance(epochs, (list, tuple, ndarray)).

Ephem.from_oo modifies orbit parameter in place

Ephem.from_oo modifies the orbit parameter in place. Then when reusing the orbit, from_oo crashes because the column 'orbittype' already exists.

(1) Consider copying the orbit object before modifying.
(2) Check for existence of 'orbittype' column before adding it.

In [15]: orbit = Orbit.from_dict({
    ...:     'targetname': ['A109AGz'],
    ...:     'a': [26.0446738] * u.au,
    ...:     'e': [0.9049629],
    ...:     'i': [159.11197] * u.deg,
    ...:     'Omega': [356.78024] * u.deg,
    ...:     'w': [318.64862] * u.deg,
    ...:     'M': [359.78524] * u.deg,
    ...:     'epoch': [Time('2018-10-29').jd],
    ...:     'timescale': ['UTC'],
    ...:     'H': [16.1],
    ...:     'G': [0.15]
    ...: })

In [16]: eph = Ephem.from_oo(orbit, epochs=Time('2018-11-18 21:00').jd + np.arange(25))

In [17]: eph = Ephem.from_oo(orbit, epochs=Time('2018-11-18 21:00').jd + np.arange(25))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-17-d45a0fe59320> in <module>()
----> 1 eph = Ephem.from_oo(orbit, epochs=Time('2018-11-18 21:00').jd + np.arange(25))

/home/msk/local/lib/python3.6/site-packages/sbpy-0.0.dev362-py3.6.egg/sbpy/data/ephem.py in from_oo(self, orbit, epochs, location, scope, timescale, dynmodel, ephfile)
    529 
    530         # add orbittype column
--> 531         orbit.add_column([orbittype] * len(orbit.table), name='orbittype')
    532 
    533         # derive and apply default units

/home/msk/local/lib/python3.6/site-packages/sbpy-0.0.dev362-py3.6.egg/sbpy/data/core.py in add_column(self, data, name, **kwargs)
    538         """
    539 
--> 540         self._table.add_column(Column(data, name=name), **kwargs)
    541         return len(self.column_names)
    542 

/home/msk/local/lib/python3.6/site-packages/astropy-3.0.3-py3.6-linux-x86_64.egg/astropy/table/table.py in add_column(self, col, index, name, rename_duplicate, copy)
   1574             name = (name,)
   1575 
-> 1576         self.add_columns([col], [index], name, copy=copy, rename_duplicate=rename_duplicate)
   1577 
   1578     def add_columns(self, cols, indexes=None, names=None, copy=True, rename_duplicate=False):

/home/msk/local/lib/python3.6/site-packages/astropy-3.0.3-py3.6-linux-x86_64.egg/astropy/table/table.py in add_columns(self, cols, indexes, names, copy, rename_duplicate)
   1711                 existing_names.add(new_name)
   1712 
-> 1713         self._init_from_cols(newcols)
   1714 
   1715     def _replace_column_warnings(self, name, col):

/home/msk/local/lib/python3.6/site-packages/astropy-3.0.3-py3.6-linux-x86_64.egg/astropy/table/table.py in _init_from_cols(self, cols)
    761         # convert columns with units to a Quantity mixin.
    762         newcols = [self._convert_col_for_table(col) for col in cols]
--> 763         self._make_table_from_cols(self, newcols)
    764 
    765         # Deduplicate indices.  It may happen that after pickling or when

/home/msk/local/lib/python3.6/site-packages/astropy-3.0.3-py3.6-linux-x86_64.egg/astropy/table/table.py in _make_table_from_cols(table, cols)
    806             raise TypeError('Cannot have None for column name')
    807         if len(colnames) != len(cols):
--> 808             raise ValueError('Duplicate column names')
    809 
    810         columns = table.TableColumns((col.info.name, col) for col in cols)

ValueError: Duplicate column names

add albedo units

At some point, somebody mentioned to include albedo units to sbpy.units. Is this still considered a good idea?

Support Non-LTE molecular radiative transfer codes

We should add support to non-LTE codes to infer physical and chemical parameters such as temperature, density, and production rates from spectroscopic observations. A python interface to run RADEX models has been developed and could be called from sbpy. The RADEX code is written in fortran and also has a command line interface. Wrapper functions in python would require using numpy.f2py to provide a connection with the fortran code.

https://personal.sron.nl/~vdtak/radex/index.shtml
https://github.com/keflavich/pyradex

Citing sbpy

We've advertised sbpy at two meetings, and there is enough functionality to be useful to someone. Is it time to consider getting a DOI for the development version? Probably via zenodo.

open v0.1 issues

This is a to-do list for open items before we can release v0.1 and submit to JOSS:

If there is anything I did not mention here, simply reply and I will add it to the list.

Haser model tests failing

Haser model tests are failing:

  • test_volume_density - Equation looks fine, test values might be wrong.
  • test_total_number_rho_NJ78 - Cannot reproduce literature. Find alternate test values.
  • test_total_number_circular_ap - Cannot reproduce literature. Find alternate test values.
  • msk

Bibliography does not allow multiple references for a single key.

Consider that there are various estimates for the fluorescence band g-factors of CO2, e.g., Crovisier & Encrenaz 1983 vs. Debout et al. 2016. If we included both in activity.fluorescence_band_strength and a user called both to determine the difference, only the last used citation will be tracked.

>>> from sbpy import bib
>>> with bib.Tracking():
>>>     bib.register('task', {'g': 'reference 1'})
>>>     bib.register('task', {'g': 'reference 2'})
>>> print(bib.to_text())
task:
  g: reference 2

Perhaps the citations should be internally stored as lists, and new citations appended as needed.

Orbit example from docs can't be propagated

I tried the first Orbit example from the docs and the propagation raises an error:

In [1]: %cpaste                                                                                                                         
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:>>> from sbpy.data import Orbit
>>> import astropy.units as u
>>> elements = {'a':1.234*u.au, 'e':0.1234, 'i':12.34*u.deg,
...             'argper': 123.4*u.deg, 'node': 45.2*u.deg,
...             'epoch': 2451200.5*u.d, 'true_anom':23.1*u.deg}
>>> orb = Orbit.from_dict(elements)
>>> print(orb)  # doctest: +SKIP::::::
:<EOF>
<QTable length=1>
   a       e       i     argper   node    epoch   true_anom
   AU             deg     deg     deg       d        deg   
float64 float64 float64 float64 float64  float64   float64 
------- ------- ------- ------- ------- --------- ---------
  1.234  0.1234   12.34   123.4    45.2 2451200.5      23.1

In [2]: from astropy.time import Time                                                                                                   

In [3]: orb.oo_propagate(Time.now())                                                                                                    
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-e36fbfe450f5> in <module>
----> 1 orb.oo_propagate(Time.now())

~/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/sbpy/data/orbit.py in oo_propagate(self, epoch, timescale, dynmodel, ephfile)
    544 
    545         oo_orbits, err = pyoorb.pyoorb.oorb_propagation(
--> 546             in_orbits=self._to_oo(),
    547             in_epoch=ooepoch,
    548             in_dynmodel=dynmodel)

~/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/sbpy/data/orbit.py in _to_oo(self, timescale)
    234         if timescale is None:
    235             timescale_ = [conf.oorb_timeScales[t]
--> 236                           for t in self.table['timescale']]
    237         else:
    238             timescale_ = [conf.oorb_timeScales[timescale]] * len(self.table)

~/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/astropy/table/table.py in __getitem__(self, item)
   1223     def __getitem__(self, item):
   1224         if isinstance(item, str):
-> 1225             return self.columns[item]
   1226         elif isinstance(item, (int, np.integer)):
   1227             return self.Row(self, item)

~/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/astropy/table/table.py in __getitem__(self, item)
    105         """
    106         if isinstance(item, str):
--> 107             return OrderedDict.__getitem__(self, item)
    108         elif isinstance(item, (int, np.integer)):
    109             return self.values()[item]

KeyError: 'timescale'

I then tried to replace the plain Quantity in the dict with a proper Time object without success:

In [8]: elements["epoch"] = Time(2451200.5 * u.d, format="jd")                                                                          

In [9]: elements                                                                                                                        
Out[9]: 
{'a': <Quantity 1.234 AU>,
 'e': 0.1234,
 'i': <Quantity 12.34 deg>,
 'argper': <Quantity 123.4 deg>,
 'node': <Quantity 45.2 deg>,
 'epoch': <Time object: scale='utc' format='jd' value=2451200.5>,
 'true_anom': <Quantity 23.1 deg>}

In [10]: orb = Orbit.from_dict(elements)                                                                                                

In [11]: orb                                                                                                                            
Out[11]: 
<QTable length=1>
   a       e       i     argper   node    epoch   true_anom
   AU             deg     deg     deg                deg   
float64 float64 float64 float64 float64   object   float64 
------- ------- ------- ------- ------- --------- ---------
  1.234  0.1234   12.34   123.4    45.2 2451200.5      23.1

In [12]: orb.oo_propagate(Time.now())                                                                                                   
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-12-e36fbfe450f5> in <module>
----> 1 orb.oo_propagate(Time.now())

~/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/sbpy/data/orbit.py in oo_propagate(self, epoch, timescale, dynmodel, ephfile)
    544 
    545         oo_orbits, err = pyoorb.pyoorb.oorb_propagation(
--> 546             in_orbits=self._to_oo(),
    547             in_epoch=ooepoch,
    548             in_dynmodel=dynmodel)

~/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/sbpy/data/orbit.py in _to_oo(self, timescale)
    234         if timescale is None:
    235             timescale_ = [conf.oorb_timeScales[t]
--> 236                           for t in self.table['timescale']]
    237         else:
    238             timescale_ = [conf.oorb_timeScales[timescale]] * len(self.table)

~/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/astropy/table/table.py in __getitem__(self, item)
   1223     def __getitem__(self, item):
   1224         if isinstance(item, str):
-> 1225             return self.columns[item]
   1226         elif isinstance(item, (int, np.integer)):
   1227             return self.Row(self, item)

~/.miniconda36/envs/sbpy37/lib/python3.7/site-packages/astropy/table/table.py in __getitem__(self, item)
    105         """
    106         if isinstance(item, str):
--> 107             return OrderedDict.__getitem__(self, item)
    108         elif isinstance(item, (int, np.integer)):
    109             return self.values()[item]

KeyError: 'timescale'

Bibliography tracking does not track multiple calls

>>> from sbpy.activity import photo_lengthscale
>>> from sbpy import bib
>>> with bib.Tracking():
>>>     gamma_H2O = photo_lengthscale('H2O')
>>>     gamma_OH = photo_lengthscale('OH')
>>> print(bib.to_text())
activity.gas.photo_lengthscale:
  OH photodissociation lengthscale: 1993Icar..105..235C

Expected: 2 items, one for water, one for OH.

Impossible to understand Horizons errors in Ephem.from_horizons

>>> from sbpy.data import Ephem
>>> h = Ephem.from_horizons('2P', closest_apparition=True)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-20-3ed486ce555c> in <module>()
----> 1 h = Ephem.from_horizons('2P', closest_apparition=True)

/home/msk/local/lib/python3.6/site-packages/sbpy-0.0.dev296-py3.6.egg/sbpy/data/ephem.py in from_horizons(cls, targetids, id_type, epochs, location, **kwargs)
    108             obj = Horizons(id=targetid, id_type=id_type,
    109                            location=location, epochs=epochs)
--> 110             eph = obj.ephemerides(**kwargs)
    111 
    112             # workaround for current version of astroquery to make

/home/msk/local/lib/python3.6/site-packages/astroquery-0.3.9.dev4961-py3.6.egg/astroquery/utils/class_or_instance.py in f(*args, **kwds)
     23         def f(*args, **kwds):
     24             if obj is not None:
---> 25                 return self.fn(obj, *args, **kwds)
     26             else:
     27                 return self.fn(cls, *args, **kwds)

/home/msk/local/lib/python3.6/site-packages/astroquery-0.3.9.dev4961-py3.6.egg/astroquery/utils/process_asyncs.py in newmethod(self, *args, **kwargs)
     27             if kwargs.get('get_query_payload') or kwargs.get('field_help'):
     28                 return response
---> 29             result = self._parse_result(response, verbose=verbose)
     30             self.table = result
     31             return result

/home/msk/local/lib/python3.6/site-packages/astroquery-0.3.9.dev4961-py3.6.egg/astroquery/jplhorizons/core.py in _parse_result(self, response, verbose)
   1221             return None
   1222         else:
-> 1223             data = self._parse_horizons(response.text)
   1224 
   1225         return data

/home/msk/local/lib/python3.6/site-packages/astroquery-0.3.9.dev4961-py3.6.egg/astroquery/jplhorizons/core.py in _parse_horizons(self, src)
   1117                                  err_msg)
   1118             else:
-> 1119                 raise ValueError(('Query failed without error message; '
   1120                                   'check URI for more information'))
   1121         # strip whitespaces from column labels

ValueError: Query failed without error message; check URI for more information

No object is returned, so a user cannot follow up on the error message without running a debugger.

Implement disk-integrated model function fits

Hi everyone, I'd like to contribute to the sbpy development. Specifically, the fitting routine for the different disk-integrated models in the sbpy.photometry.core module. I saw that there's already a placeholder in the code. I was looking for a package which is able to retrieve MPC observations and fit photometric models for my own research, so this is a nice opportunity to contribute, if no one else is already working on an implementation.

Some thoughts I noted down after a look at the photometry.core code:

  • Currently, the photometric model has to be instantiated with the respective parameters (hg = HG1G2() # TypeError). When the model is supposed to be fit to the phase curve, that shouldn't be necessary (as the example already in place shows). There has to be a change here, but I'm unfamiliar with the astropy Parameter class, so I can't yet say where exactly.
  • This might be sbpy/astropy policy that I am unfamiliar with, but why should the input of the fit function be restricted to sbpy.data.Ephem objects? Something like params, chi2 = HG1G2().fit(phi_array, mag_array) could be clear and easier for users unfamiliar with the package structure
  • The fit method is part of the DiskIntegratedModelClass and is inhereted by LinearPhaseFunc and HG12BaseClass (and HG1G2, HG12 accordingly). I would suggest sticking closely to the reference implementation of the Helsinki HG1G2 tools, where they use np.linalg.lstsq for the minimization, so all models (current + not implemented) inheriting from DiskIntegratedModelClass would need to be expressed as linear matrix equations to solve them

Let me know what you think, and other considerations you might have for this method.

Cheers

Max

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.