radec_to_vec()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nop 2
dl 0
loc 14
rs 10
c 0
b 0
f 0
1
import healpy as hp
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
import numpy as np
3
4
5
def radec_to_vec(ra, dec):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style Naming introduced by
Argument name "ra" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,30)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
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
20
21
# def pixid_to_radec(nside, pixid, nest=False):
22
#
23
#     theta, phi = hp.pix2ang(nside, pixid, nest=nest, lonlat=False)
24
#
25
#     ra = np.rad2deg(phi)
26
#     dec = np.rad2deg(0.5 * np.pi - theta)
27
#
28
#     return ra, dec
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...