Browse Source

Source now supports the SkyCoord optional params

When initializing a Source object, you can pass the typical parameters that you could pass to SkyCoord (e.g. unit).
master
Benito Marcote 1 month ago
parent
commit
c6be270ce0
2 changed files with 8 additions and 5 deletions
  1. +3
    -3
      tests/test_observation.py
  2. +5
    -2
      vlbiplanobs/observation.py

+ 3
- 3
tests/test_observation.py View File

@@ -31,11 +31,11 @@ def test_source():
obs.Source(name='WQQWE')

s1 = obs.Source('10h20m10s 40d30m10s', 'a_name')
# s2 = obs.Source('10:20:10 40:30:10', 'a_name', unit=(u.hourangle, u.deg))
s2 = obs.Source('10:20:10 40:30:10', 'a_name', unit=(u.hourangle, u.deg))
s3 = obs.Source(name='Cyg X-1')
assert s1.name == 'a_name'
# assert s2.name == 'a_name'
# assert s1.coordinates == s2.coordinates
assert s2.name == 'a_name'
assert s1.coord == s2.coord
assert s3.name == 'Cyg X-1'



+ 5
- 2
vlbiplanobs/observation.py View File

@@ -25,7 +25,7 @@ class SourceNotVisible(Exception):
class Source(FixedTarget):
"""Defines a target source located at some coordinates and with a given name.
"""
def __init__(self, coordinates: str = None, name: str = None):
def __init__(self, coordinates: str = None, name: str = None, **kwargs):
"""Initializes a Source object.

Inputs
@@ -36,6 +36,9 @@ class Source(FixedTarget):
If not provided, name must be a source name recognized by astroquery.
- name : str [OPTIONAL]
Name associated to the source. By default is None.
- kwargs
keyword arguments to be passed to astropy.coordinates.SkyCoord() if needed.
For example, unit= parameter.

If both provided, the given coordinates will be used for the given source.

@@ -49,7 +52,7 @@ class Source(FixedTarget):
if (name is not None) and (coordinates is None):
coordinates = coord.get_icrs_coordinates(name)

super().__init__(coord.SkyCoord(coordinates), name)
super().__init__(coord.SkyCoord(coordinates, **kwargs), name)





Loading…
Cancel
Save