Commit a5745cc5 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+5 −0
Original line number Diff line number Diff line
__pycache__
venv/
build/
*.whl
*.egg-info/

README.md

0 → 100644
+21 −0
Original line number Diff line number Diff line
# Coords Library

Toy Python module for demonstrating GitLab CI features.

## Example usage

```python
import coords

# -- Returns complete name from Astropy observatory identifier --
print(coords.get_location_name('ekar'))
# 'Mt. Ekar 182 cm. Telescope'
print(coords.get_location_name('lbt'))
# 'Large Binocular Telescope'

# -- Returns object coordinates for a given observatory at current time --
print(coords.get_coords('m31', 'lbt'))
# {'Alt': '47d 13m 43.8866s', 'Az': '62d 25m 55.5019s'}
print(coords.get_coords('m31', 'ekar'))
# {'Alt': '41d 59m 31.3084s', 'Az': '290d 28m 01.2741s'}
```

coords/__init__.py

0 → 100644
+2 −0
Original line number Diff line number Diff line
from .coords_library import get_coords
from .coords_library import get_location_name
+18 −0
Original line number Diff line number Diff line
from astropy.coordinates import AltAz, EarthLocation, SkyCoord
from astropy.time import Time


def get_location_name(location_id):
    return EarthLocation.of_site(location_id).info.name


def get_coords(object_name, location_id):
    object_coord = SkyCoord.from_name(object_name)
    location = EarthLocation.of_site(location_id)
    alt_az = AltAz(location=location, obstime=Time.now())
    object_coord = object_coord.transform_to(alt_az)
    return {'Alt': format_angle(object_coord.alt), 'Az': format_angle(object_coord.az)}


def format_angle(angle):
    return angle.to_string().replace('d', 'd ').replace('m', 'm ')

requirements.txt

0 → 100644
+2 −0
Original line number Diff line number Diff line
astropy==4.1
numpy==1.19.5