MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / Epoch

Class Epoch

lib/matplotlib/testing/jpl_units/Epoch.py:12–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12class Epoch:
13 # Frame conversion offsets in seconds
14 # t(TO) = t(FROM) + allowed[ FROM ][ TO ]
15 allowed = {
16 "ET": {
17 "UTC": +64.1839,
18 },
19 "UTC": {
20 "ET": -64.1839,
21 },
22 }
23
24 def __init__(self, frame, sec=None, jd=None, daynum=None, dt=None):
25 """
26 Create a new Epoch object.
27
28 Build an epoch 1 of 2 ways:
29
30 Using seconds past a Julian date:
31 # Epoch('ET', sec=1e8, jd=2451545)
32
33 or using a matplotlib day number
34 # Epoch('ET', daynum=730119.5)
35
36 = ERROR CONDITIONS
37 - If the input units are not in the allowed list, an error is thrown.
38
39 = INPUT VARIABLES
40 - frame The frame of the epoch. Must be 'ET' or 'UTC'
41 - sec The number of seconds past the input JD.
42 - jd The Julian date of the epoch.
43 - daynum The matplotlib day number of the epoch.
44 - dt A python datetime instance.
45 """
46 if ((sec is None and jd is not None) or
47 (sec is not None and jd is None) or
48 (daynum is not None and
49 (sec is not None or jd is not None)) or
50 (daynum is None and dt is None and
51 (sec is None or jd is None)) or
52 (daynum is not None and dt is not None) or
53 (dt is not None and (sec is not None or jd is not None)) or
54 ((dt is not None) and not isinstance(dt, DT.datetime))):
55 raise ValueError(
56 "Invalid inputs. Must enter sec and jd together, "
57 "daynum by itself, or dt (must be a python datetime).\n"
58 "Sec = %s\n"
59 "JD = %s\n"
60 "dnum= %s\n"
61 "dt = %s" % (sec, jd, daynum, dt))
62
63 _api.check_in_list(self.allowed, frame=frame)
64 self._frame = frame
65
66 if dt is not None:
67 daynum = date2num(dt)
68
69 if daynum is not None:

Callers 2

convertMethod · 0.85
__add__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…