y = np.array([59817478.73563218, 56195352.29885057, 59679547.70114943,
61071789.08045977, 56678110.91954023, 56900812.06896552,
61942478.73563218, 57360582.18390805, 57423800.57471264,
61169490.22988506, 58930984.48275862, 56777248.85057471,
60586156.89655172, 59669490.22988506, 55715467.24137931,
60485582.18390805, 61771501.72413793, 56966904.02298851,
60666616.66666666, 56887881.03448276, 60699662.64367816,
61545927.01149426, 56418053.44827586, 58850524.71264368,
61071789.08045977, 57018628.16091954, 57936731.60919541,
62103398.27586207, 58135007.47126437, 56629260.34482759,
61922363.79310345, 59757133.90804598, 56195352.29885057,
60400812.06896552, 61711156.89655172, 56942478.73563218,
60438168.3908046 , 61416616.66666666, 57703972.98850574,
59380697.12643679, 62241329.31034483, 59031559.1954023 ,
58037306.32183908, 61216904.02298851, 61757133.90804598,
56735582.18390805, 58390754.59770115, 62216904.02298851,
58216904.02298851, 57432421.26436782, 61956846.55172414,
60350524.71264368, 61123513.21839081, 58541616.66666666,
56939605.1724138 , 60958283.33333334, 59976961.49425288,
56489892.52873563, 59129260.34482759, 60981271.83908046,
57620639.65517242, 58264317.81609196, 61824662.64367816,
57709720.11494253, 56376386.78160919, 60249950. ,
59544490.22988506, 56629260.34482759, 59455409.77011494,
61320352.29885057])
x = np.array(['1900-01-01T04:39:51.596000000', '1900-01-01T04:39:53.873000000',
'1900-01-01T04:39:56.124000000', '1900-01-01T04:39:58.403000000',
'1900-01-01T04:40:00.655000000', '1900-01-01T04:40:02.904000000',
'1900-01-01T04:40:05.182000000', '1900-01-01T04:40:07.435000000',
'1900-01-01T04:40:09.714000000', '1900-01-01T04:40:11.962000000',
'1900-01-01T04:40:14.213000000', '1900-01-01T04:40:16.495000000',
'1900-01-01T04:40:18.745000000', '1900-01-01T04:40:21.025000000',
'1900-01-01T04:40:23.275000000', '1900-01-01T04:40:25.525000000',
'1900-01-01T04:40:27.804000000', '1900-01-01T04:40:30.115000000',
'1900-01-01T04:40:32.362000000', '1900-01-01T04:40:34.613000000',
'1900-01-01T04:40:36.895000000', '1900-01-01T04:40:39.146000000',
'1900-01-01T04:40:41.423000000', '1900-01-01T04:40:43.676000000',
'1900-01-01T04:40:45.926000000', '1900-01-01T04:40:48.203000000',
'1900-01-01T04:40:50.455000000', '1900-01-01T04:40:52.736000000',
'1900-01-01T04:40:54.986000000', '1900-01-01T04:40:57.235000000',
'1900-01-01T04:40:59.517000000', '1900-01-01T04:41:01.767000000',
'1900-01-01T04:41:04.046000000', '1900-01-01T04:41:06.297000000',
'1900-01-01T04:41:08.547000000', '1900-01-01T04:41:10.827000000',
'1900-01-01T04:41:13.078000000', '1900-01-01T04:41:15.357000000',
'1900-01-01T04:41:17.605000000', '1900-01-01T04:41:19.854000000',
'1900-01-01T04:41:22.138000000', '1900-01-01T04:41:24.387000000',
'1900-01-01T04:41:26.668000000', '1900-01-01T04:41:28.918000000',
'1900-01-01T04:41:31.168000000', '1900-01-01T04:41:33.448000000',
'1900-01-01T04:41:35.698000000', '1900-01-01T04:41:37.978000000',
'1900-01-01T04:41:40.228000000', '1900-01-01T04:41:42.479000000',
'1900-01-01T04:41:44.758000000', '1900-01-01T04:41:47.069000000',
'1900-01-01T04:41:49.319000000', '1900-01-01T04:41:51.569000000',
'1900-01-01T04:41:53.849000000', '1900-01-01T04:41:56.099000000',
'1900-01-01T04:41:58.378000000', '1900-01-01T04:42:00.629000000',
'1900-01-01T04:42:02.876000000', '1900-01-01T04:42:05.159000000',
'1900-01-01T04:42:07.410000000', '1900-01-01T04:42:09.690000000',
'1900-01-01T04:42:11.940000000', '1900-01-01T04:42:14.190000000',
'1900-01-01T04:42:16.471000000', '1900-01-01T04:42:18.720000000',
'1900-01-01T04:42:20.997000000', '1900-01-01T04:42:23.251000000',
'1900-01-01T04:42:25.500000000', '1900-01-01T04:42:27.781000000'],
dtype='datetime64[ns]')
np.trapz(y, x) => numpy.timedelta64(-9204159157384838832,'ns')
Both scipy.integrate and np.trapz give negative values.
utkala mohanty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
After investigating, found integer overflow error. Hope this helps someone else.
utkala mohanty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The default (and most capable) float data type in numpy is numpy.float64 which is limited to values lower than 2^(64-1). You are unlucky here because the last values overflow.
If you plot the trapezoidal integral np.cumsum((y[1:]+y[:-1])/2 * np.diff(x))
:
You could just change units (say divide y
by 1000) and the numbers will look better.