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

Method __init__

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

Create a new Epoch object. Build an epoch 1 of 2 ways: Using seconds past a Julian date: # Epoch('ET', sec=1e8, jd=2451545) or using a matplotlib day number # Epoch('ET', daynum=730119.5) = ERROR CONDITIONS - If the input units

(self, frame, sec=None, jd=None, daynum=None, dt=None)

Source from the content-addressed store, hash-verified

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:
70 # 1-JAN-0001 in JD = 1721425.5
71 jd = float(daynum) + 1721425.5
72 self._jd = math.floor(jd)
73 self._seconds = (jd - self._jd) * 86400.0
74
75 else:
76 self._seconds = float(sec)
77 self._jd = float(jd)
78
79 # Resolve seconds down to [ 0, 86400)
80 deltaDays = math.floor(self._seconds / 86400)
81 self._jd += deltaDays

Callers

nothing calls this directly

Calls 1

date2numFunction · 0.90

Tested by

no test coverage detected