| Total Complexity | 1 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import healpy as hp |
||
|
|
|||
| 2 | import numpy as np |
||
| 3 | |||
| 4 | |||
| 5 | def radec_to_vec(ra, dec): |
||
| 6 | |||
| 7 | assert 0 <= ra <= 360 |
||
| 8 | assert -90 <= dec <= 90 |
||
| 9 | |||
| 10 | # Healpix uses the convention -180 - 180 for longitude, instead |
||
| 11 | # we get RA between 0 and 360, so we need to wrap |
||
| 12 | wrap_angle = 180.0 |
||
| 13 | |||
| 14 | lon = np.mod(ra - wrap_angle, 360.0) - (360.0 - wrap_angle) |
||
| 15 | |||
| 16 | vec = hp.dir2vec(lon, dec, lonlat=True) |
||
| 17 | |||
| 18 | return vec |
||
| 19 | |||
| 28 | # return ra, dec |
||
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.