# Names¶

class sbpy.data.Names[source]

Bases: object

Class for parsing target identifiers. The functions in this class will identify designation, name strings, and number for both comets and asteroids. It also includes functionality to distinguish between comet and asteroid identifiers.

Attributes Summary

Methods Summary

 Checks if an object identifier is more likely to belong to an asteroid or a comet. Unpack asteroid designation/number. Parse a string as if it were an asteroid name. Parse a string as if it were a comet name. Convert asteroid designation/number to packed identifier.

Attributes Documentation

pkd = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghifklmnopqrstuvwxyz'

Methods Documentation

static asteroid_or_comet(s)[source]

Checks if an object identifier is more likely to belong to an asteroid or a comet.

Parameters
sstr

Target identifier.

Returns
target_typestr

The target identification: 'comet' or 'asteroid'.

Notes

This function uses the results of parse_asteroid and parse_comet. Hence, it is affected by ambiguities in the name/number/designation identification. If the name is ambiguous, a TargetNameParseError will be raised. Note that for any identifier that does not contain a comet type (P, D, C etc.), it is likely that the object gets identified as an asteroid.

Examples

>>> from sbpy.data import Names
>>> print(Names.asteroid_or_comet('2P'))
comet
>>> print(Names.asteroid_or_comet('(1) Ceres'))
asteroid

static from_packed(p)[source]

Unpack asteroid designation/number.

Parameters
pstr

Packed target identifier.

Returns
sstr

Unpacked designation/number.

Examples

>>> from sbpy.data import Names
>>> Names.from_packed('J95A01A')
'1995 AA1'

static parse_asteroid(s)[source]

Parse a string as if it were an asteroid name.

Considers IAU-formatted permanent and new-style designations, as well as MPC packed designations and numbers. Note that letter case is important. Parentheses are ignored in the parsing.

Parameters
sstr or list of str

The string, or a list/array of strings, to parse.

Returns
rdict

The dictionary contains the components identified from s: IAU number, designation, and/or name. If none of these components are identified, a TargetNameParseError is raised

Raises
TargetNameParseErrorException

If the string does not appear to be an asteroid name.

Notes

This function has absolutely no knowledge whether the Solar System small body s is an asteroid or a comet. It simply searches for common patterns in string s that are common for asteroid names, numbers, or designations. For instance, if s contains a comet name, this function will identify that part as an asteroid name. Hence, the user is advised to take that into account when interpreting the parsing results.

Examples

>>> from sbpy.data import Names
>>> ceres = Names.parse_asteroid('(1) Ceres')
>>> ceres['number'], ceres['name']
(1, 'Ceres')
>>> mu = Names.parse_asteroid('2014 MU69')
>>> mu['desig']
'2014 MU69'


The following table shows results of the parsing:

targetname

desig

number

name

1

1

2 Pallas

2

Pallas

(2001) Einstein

2001

Einstein

1714 Sy

1714

Sy

2014 MU69

2014 MU69

(228195) 6675 P-L

6675 P-L

228195

4101 T-3

4101 T-3

4015 Wilson-Harrington (1979 VA)

1979 VA

4015

Wilson-Harrington

J95X00A

1995 XA

K07Tf8A

2007 TA418

G3693

163693

1A

1A

static parse_comet(s)[source]

Parse a string as if it were a comet name.

Considers IAU-formatted permanent and new-style designations. Note that comet types (P, D, C etc) are required and letter case is important.

Parameters
sstr or list/array of str

String, or a list/array of strings, to parse.

Returns
rdict

The dictionary contains the components identified from s: number, orbit type, designation, name, and/or fragment. If none of these components are identified, a TargetNameParseError is raised.

Raises
TargetNameParseErrorException

If the string does not appear to be a comet name.

Notes

This function has absolutely no knowledge whether the Solar System small body s is an asteroid or a comet. It simply searches for common patterns in string s that are common for comet names and designations. For instance, if s contains an asteroid name, this function will identify that part as a comet name. Hence, the user is advised to take that into account when interpreting the parsing results.

Examples

>>> from sbpy.data import Names
>>> tempel = Names.parse_comet('9P/Tempel 1')
>>> tempel['type'], tempel['name']
('P', 'Tempel 1')
>>> linear = Names.parse_comet('C/2001 A2-A (LINEAR)')
>>> linear['desig'], linear['fragm'], linear['name']
('2001 A2', 'A', 'LINEAR')


The following table shows results of the parsing:

targetname

number

type

fragm

desig

name

1P/Halley

1

P

Halley

3D/Biela

3

D

Biela

P/Encke

P

Encke

9P/Tempel 1

9

P

Tempel 1

73P/Schwassmann Wachmann 3 C

73

P

Schwassmann Wachmann 3 C

73P-C/Schwassmann Wachmann 3 C

73

P

C

Schwassmann Wachmann 3 C

73P-BB

73

P

BB

322P

322

P

X/1106 C1

X

1066 C1

P/1994 N2 (McNaught-Hartley)

P

1994 N2

McNaught-Hartley

P/2001 YX127 (LINEAR)

P

2001 YX127

LINEAR

P/2010 WK (LINEAR)

P

2010 WK

LINEAR

C/-146 P1

C

-146 P1

C/2001 A2-A (LINEAR)

C

A

2001 A2

LINEAR

C/2013 US10

C

2013 US10

C/2015 V2 (Johnson)

C

2015 V2

Johnson

static to_packed(s)[source]

Convert asteroid designation/number to packed identifier.

Parameters
sstr

Target identifier.

Returns
pstr

Packed designation/number.

Examples

>>> from sbpy.data import Names
>>> Names.to_packed('1995 AA1')
'J95A01A'