From 65263a542b7b535f81def44c5d7baf84a8ff1476 Mon Sep 17 00:00:00 2001 From: CommonClimate Date: Sun, 5 Feb 2023 16:24:16 -0800 Subject: [PATCH] reshuffling code to solve #299 Also set verbose=False in time_unit_to_datum_exp_dir( ) to avoid incessant notifications. --- pyleoclim/core/series.py | 18 +- pyleoclim/tests/series.csv | 1610 +++++++++++++++++++++++++ pyleoclim/tests/test_core_Series.py | 2 +- pyleoclim/tests/test_utils_tsbase.py | 146 +++ pyleoclim/tests/test_utils_tsutils.py | 140 --- pyleoclim/utils/tsbase.py | 124 ++ pyleoclim/utils/tsutils.py | 120 -- 7 files changed, 1890 insertions(+), 270 deletions(-) create mode 100644 pyleoclim/tests/series.csv create mode 100644 pyleoclim/tests/test_utils_tsbase.py diff --git a/pyleoclim/core/series.py b/pyleoclim/core/series.py index 1f748dca..99bf2232 100644 --- a/pyleoclim/core/series.py +++ b/pyleoclim/core/series.py @@ -206,8 +206,8 @@ def __repr__(self): @property def datetime_index(self): - datum, exponent, direction = tsutils.time_unit_to_datum_exp_dir(self.time_unit) - index = tsutils.time_to_datetime(self.time, datum, exponent, direction) + datum, exponent, direction = tsbase.time_unit_to_datum_exp_dir(self.time_unit) + index = tsbase.time_to_datetime(self.time, datum, exponent, direction) return pd.DatetimeIndex(index, name='datetime') @property @@ -229,7 +229,7 @@ def metadata(self): def from_pandas(cls, ser, metadata): if isinstance(ser.index, pd.DatetimeIndex): index = ser.index.as_unit('s') if ser.index.unit != 's' else ser.index - time = tsutils.convert_datetime_index_to_time(index, metadata['time_unit'], metadata['time_name']) + time = tsbase.convert_datetime_index_to_time(index, metadata['time_unit'], metadata['time_name']) else: raise ValueError('The provided index must be a proper DatetimeIndex object') @@ -243,7 +243,7 @@ def from_pandas(cls, ser, metadata): # Alternate formulation # def from_pandas(ser, metadata): - # time = tsutils.convert_datetime_index_to_time(ser.index, metadata['time_unit'], metadata['time_name']) + # time = tsbase.convert_datetime_index_to_time(ser.index, metadata['time_unit'], metadata['time_name']) # ts = Series(value=ser.values, time=time, # time_name = metadata['time_name'] if metadata['time_name'] is not None else ser.index.name, # time_unit = metadata['time_unit'], @@ -553,7 +553,7 @@ def convert_time_unit(self, time_unit='ky BP', keep_log=False): else: return new_ts - new_time = tsutils.convert_datetime_index_to_time(self.datetime_index, time_unit_label, time_name) + new_time = tsbase.convert_datetime_index_to_time(self.datetime_index, time_unit_label, time_name) dt = np.diff(new_time) if any(dt<=0): @@ -4015,13 +4015,13 @@ def resample(self, rule, **kwargs): else: multiplier = int(multiplier) unit = search.group(2) - if unit.lower() in tsutils.MATCH_A: + if unit.lower() in tsbase.MATCH_A: pass - elif unit.lower() in tsutils.MATCH_KA: + elif unit.lower() in tsbase.MATCH_KA: multiplier *= 1_000 - elif unit.lower() in tsutils.MATCH_MA: + elif unit.lower() in tsbase.MATCH_MA: multiplier *= 1_000_000 - elif unit.lower() in tsutils.MATCH_GA: + elif unit.lower() in tsbase.MATCH_GA: multiplier *= 1_000_000_000 else: raise ValueError(f'Invalid unit provided, got: {unit}') diff --git a/pyleoclim/tests/series.csv b/pyleoclim/tests/series.csv new file mode 100644 index 00000000..f1e91278 --- /dev/null +++ b/pyleoclim/tests/series.csv @@ -0,0 +1,1610 @@ +###,Series metadata +written by,Pyleoclim 1.0.0b0 +time_unit,year C.E. +time_name,time +value_unit,$^{\circ}$C +value_name,NINO3 +label, +lat, +lon, +archiveType, +importedFrom, +log,"({0: 'clean_ts', 'applied': True, 'verbose': False},)" +###,end metadata +time [year C.E.],NINO3 [$^{\circ}$C] +1871.0,-0.35825 +1871.0833333333333,-0.2924584 +1871.1666666666663,-0.1435833 +1871.25,-0.149625 +1871.333333333333,-0.27425 +1871.4166666666663,-0.3724167 +1871.4999999999995,-0.2715 +1871.5833333333328,-0.3378333 +1871.666666666666,-0.175625 +1871.7499999999995,-0.052208334 +1871.8333333333328,-0.0050000013 +1871.9166666666656,-0.218875 +1871.999999999999,-0.5075001 +1872.0833333333323,-0.533375 +1872.1666666666656,-0.5465834 +1872.2499999999989,-0.598875 +1872.333333333332,-0.6535 +1872.4166666666652,-0.5886667 +1872.4999999999984,-0.5147501 +1872.583333333332,-0.6217501 +1872.6666666666647,-1.00625 +1872.7499999999984,-0.9237084 +1872.833333333332,-0.8687084 +1872.916666666665,-0.783375 +1872.9999999999984,-0.7317083 +1873.0833333333317,-0.8480834 +1873.1666666666647,-0.8297084 +1873.249999999998,-0.6962501 +1873.3333333333312,-0.4467084 +1873.4166666666645,-0.3306667 +1873.4999999999975,-0.151875 +1873.583333333331,-0.3927917 +1873.666666666664,-0.3576667 +1873.7499999999973,-0.6431251 +1873.8333333333308,-1.021875 +1873.916666666664,-1.1575 +1873.9999999999973,-0.977125 +1874.0833333333303,-1.094875 +1874.166666666664,-0.9694167 +1874.249999999997,-0.838 +1874.3333333333303,-0.7487084 +1874.416666666664,-0.7400834 +1874.4999999999968,-0.8526251 +1874.58333333333,-1.169375 +1874.6666666666636,-1.00825 +1874.7499999999968,-1.027667 +1874.8333333333296,-1.241292 +1874.916666666663,-0.78575 +1874.9999999999964,-0.5002084 +1875.0833333333296,-0.7718334 +1875.1666666666629,-0.4692917 +1875.249999999996,-0.7503334 +1875.3333333333292,-0.6111667 +1875.4166666666624,-0.5960833 +1875.499999999996,-0.4154584 +1875.5833333333287,-0.7095 +1875.6666666666624,-0.5875417 +1875.749999999996,-0.87975 +1875.833333333329,-0.7973334 +1875.9166666666624,-0.64225 +1875.9999999999957,-0.9426667 +1876.0833333333287,-0.9870834 +1876.166666666662,-0.9531251 +1876.2499999999952,-0.9444584 +1876.3333333333285,-0.48925 +1876.4166666666615,-0.2585834 +1876.499999999995,-0.022625001 +1876.5833333333285,-0.039333332 +1876.6666666666613,-0.065291673 +1876.7499999999948,0.4621667 +1876.833333333328,0.44225 +1876.9166666666613,0.3955834 +1876.9999999999943,0.6929584 +1877.083333333328,0.644125 +1877.166666666661,0.7826667 +1877.2499999999943,1.152708 +1877.333333333328,1.144458 +1877.4166666666608,1.700083 +1877.499999999994,1.855333 +1877.5833333333276,2.149458 +1877.6666666666608,2.492959 +1877.7499999999936,2.531792 +1877.8333333333271,2.617208 +1877.9166666666604,2.767667 +1877.9999999999936,2.706458 +1878.083333333327,2.489792 +1878.16666666666,2.063375 +1878.2499999999932,1.616333 +1878.333333333327,1.422458 +1878.41666666666,1.187625 +1878.4999999999927,0.8755417 +1878.5833333333264,0.4312917 +1878.66666666666,-0.079916663 +1878.749999999993,-0.3452917 +1878.8333333333264,-0.3299583 +1878.9166666666597,-0.3771667 +1878.9999999999927,-0.085000001 +1879.083333333326,0.125875 +1879.1666666666592,-0.037000004 +1879.2499999999925,-0.050875004 +1879.3333333333255,-0.064750001 +1879.416666666659,-0.211625 +1879.4999999999925,-0.340875 +1879.5833333333253,-0.7759584 +1879.6666666666588,-0.5237917 +1879.749999999992,-0.5384583 +1879.8333333333253,-0.6566667 +1879.9166666666583,-0.9757084 +1879.999999999992,-1.141333 +1880.083333333325,-0.3616667 +1880.1666666666583,-0.1692917 +1880.249999999992,-0.081583336 +1880.3333333333248,-0.120875 +1880.416666666658,-0.2335833 +1880.4999999999916,-0.4069167 +1880.5833333333248,-0.106875 +1880.6666666666576,0.198125 +1880.7499999999911,0.4769167 +1880.8333333333244,0.3572083 +1880.9166666666576,0.441 +1880.999999999991,0.424375 +1881.083333333324,0.2991667 +1881.1666666666572,0.3142917 +1881.249999999991,0.4110417 +1881.333333333324,0.3185 +1881.4166666666567,0.120375 +1881.4999999999905,-0.039375 +1881.583333333324,0.093166672 +1881.666666666657,0.010208331 +1881.7499999999905,-0.1216667 +1881.8333333333237,-0.3246667 +1881.9166666666567,-0.3718334 +1881.99999999999,-0.4365 +1882.0833333333237,-0.3974583 +1882.1666666666565,-0.2572917 +1882.2499999999895,-0.1872917 +1882.333333333323,-0.3114583 +1882.4166666666565,-0.772375 +1882.4999999999893,-0.9150833 +1882.5833333333228,-0.6934167 +1882.666666666656,-0.3923334 +1882.7499999999893,-0.5960417 +1882.8333333333223,-0.71075 +1882.916666666656,-0.63225 +1882.999999999989,-0.5949167 +1883.0833333333223,-0.4695417 +1883.166666666656,-0.059458334 +1883.2499999999889,0.1316667 +1883.333333333322,0.1386667 +1883.4166666666556,0.1852083 +1883.4999999999889,0.232125 +1883.583333333322,0.2109167 +1883.6666666666551,0.088708334 +1883.7499999999884,-0.1018333 +1883.8333333333217,0.052208338 +1883.916666666655,-0.172625 +1883.999999999988,-0.2718334 +1884.0833333333212,-0.246375 +1884.1666666666547,0.100625 +1884.249999999988,0.518 +1884.3333333333208,0.463625 +1884.4166666666545,0.2621667 +1884.499999999988,0.2916667 +1884.583333333321,0.4677917 +1884.6666666666545,0.4278334 +1884.7499999999875,0.7608334 +1884.8333333333208,0.751875 +1884.916666666654,0.8725833 +1884.9999999999875,0.7250001 +1885.0833333333203,0.2949167 +1885.1666666666536,0.4200417 +1885.249999999987,0.3786667 +1885.3333333333203,0.16825 +1885.4166666666536,0.1327917 +1885.4999999999868,-0.04025 +1885.58333333332,0.1744583 +1885.666666666653,0.5649583 +1885.7499999999864,0.7364167 +1885.83333333332,0.7877501 +1885.916666666653,0.6388751 +1885.9999999999864,0.071375005 +1886.08333333332,-0.4070834 +1886.1666666666529,-0.3071667 +1886.249999999986,-0.3339584 +1886.3333333333196,-0.5292084 +1886.4166666666529,-0.9582917 +1886.499999999986,-0.9317084 +1886.5833333333192,-0.8658334 +1886.6666666666524,-0.66 +1886.7499999999857,-0.9444167 +1886.833333333319,-0.9131667 +1886.916666666652,-1.1235 +1886.9999999999852,-0.9293334 +1887.0833333333187,-0.8668334 +1887.166666666652,-0.668875 +1887.2499999999848,-0.5621667 +1887.3333333333185,-0.1482917 +1887.416666666652,-0.018666666 +1887.499999999985,-0.0044166646 +1887.5833333333185,-0.3265834 +1887.6666666666515,-0.013166666 +1887.7499999999848,0.0032916653 +1887.833333333318,0.2019167 +1887.9166666666515,0.29225 +1887.9999999999843,0.5075834 +1888.0833333333176,0.6724584 +1888.166666666651,0.5879584 +1888.2499999999843,0.4784167 +1888.3333333333176,0.8720834 +1888.4166666666508,0.8656251 +1888.499999999984,0.8955417 +1888.5833333333171,0.9285834 +1888.6666666666504,1.491667 +1888.749999999984,1.800875 +1888.833333333317,1.976417 +1888.9166666666504,2.133417 +1888.999999999984,2.080333 +1889.083333333317,1.609333 +1889.16666666665,1.285208 +1889.2499999999836,0.9745001 +1889.333333333317,0.7251667 +1889.41666666665,0.213875 +1889.4999999999832,-0.2727083 +1889.5833333333164,-0.9476667 +1889.6666666666497,-0.734125 +1889.749999999983,-1.057833 +1889.833333333316,-1.149708 +1889.9166666666492,-1.107625 +1889.9999999999827,-1.387458 +1890.083333333316,-0.8440834 +1890.1666666666488,-0.8429584 +1890.2499999999825,-0.5572917 +1890.333333333316,-0.4417084 +1890.416666666649,-0.573 +1890.4999999999825,-0.6245 +1890.5833333333155,-0.6909584 +1890.6666666666488,-0.630625 +1890.749999999982,-0.972875 +1890.8333333333155,-0.8632084 +1890.9166666666488,-0.2230833 +1890.9999999999816,0.0080833323 +1891.083333333315,0.1995 +1891.1666666666483,0.1517917 +1891.2499999999816,0.5333334 +1891.3333333333148,0.6607917 +1891.416666666648,0.6017917 +1891.4999999999811,0.4714167 +1891.5833333333144,0.3405834 +1891.666666666648,-0.080291674 +1891.749999999981,0.081125006 +1891.8333333333144,0.1595833 +1891.916666666648,-0.014874998 +1891.999999999981,0.016916668 +1892.0833333333144,-0.042416666 +1892.1666666666476,-0.1315833 +1892.249999999981,-0.3770834 +1892.333333333314,-0.427375 +1892.4166666666472,-0.6754584 +1892.4999999999804,-0.8216251 +1892.5833333333137,-0.9602084 +1892.666666666647,-1.269583 +1892.74999999998,-1.720042 +1892.8333333333132,-1.53575 +1892.9166666666467,-1.372083 +1892.99999999998,-1.338 +1893.0833333333128,-1.46625 +1893.1666666666465,-1.1235 +1893.24999999998,-1.090375 +1893.333333333313,-1.163208 +1893.4166666666465,-1.078 +1893.4999999999795,-0.8739167 +1893.5833333333128,-0.8139584 +1893.666666666646,-0.7962084 +1893.7499999999795,-0.8024583 +1893.8333333333128,-0.787375 +1893.9166666666456,-0.6128334 +1893.999999999979,-0.7223334 +1894.0833333333123,-0.7022917 +1894.1666666666456,-0.7405417 +1894.2499999999789,-0.544875 +1894.333333333312,-0.5567917 +1894.4166666666451,-0.2485417 +1894.4999999999784,-0.1227083 +1894.583333333312,-0.3525833 +1894.6666666666447,-0.19175 +1894.7499999999784,-0.3084584 +1894.833333333312,-0.257 +1894.916666666645,-0.4374584 +1894.9999999999784,-0.29525 +1895.0833333333117,-0.3299583 +1895.1666666666447,-0.036875002 +1895.249999999978,0.1225417 +1895.3333333333112,0.2082084 +1895.4166666666445,0.071833342 +1895.4999999999775,0.034249999 +1895.583333333311,0.1906667 +1895.666666666644,0.5338334 +1895.7499999999773,0.4949583 +1895.8333333333107,0.8026667 +1895.916666666644,0.6525834 +1895.9999999999773,0.4958333 +1896.0833333333103,0.4000417 +1896.166666666644,0.4307083 +1896.249999999977,0.3883334 +1896.3333333333103,0.3617917 +1896.416666666644,0.4791667 +1896.4999999999768,0.8193334 +1896.58333333331,1.329792 +1896.6666666666436,1.171667 +1896.7499999999768,1.297125 +1896.8333333333096,1.748625 +1896.916666666643,2.118833 +1896.9999999999764,1.829625 +1897.0833333333096,1.48775 +1897.1666666666429,0.8815417 +1897.249999999976,0.4305 +1897.3333333333092,0.2119583 +1897.4166666666424,0.096708342 +1897.499999999976,0.053416669 +1897.5833333333087,-0.176 +1897.6666666666424,-0.033958334 +1897.749999999976,-0.2251667 +1897.833333333309,-0.44 +1897.9166666666424,-0.3957084 +1897.9999999999757,-0.2940833 +1898.0833333333087,-0.4296667 +1898.166666666642,-0.491375 +1898.2499999999752,-0.1282083 +1898.3333333333085,-0.178375 +1898.4166666666415,-0.2380833 +1898.499999999975,-0.38575 +1898.583333333308,-0.5320417 +1898.6666666666413,-0.4879167 +1898.7499999999748,-0.5490834 +1898.833333333308,-0.6995834 +1898.9166666666413,-0.7157084 +1898.9999999999743,-0.5652917 +1899.083333333308,-0.3799584 +1899.166666666641,-0.1103333 +1899.2499999999743,0.2863334 +1899.333333333308,0.5398334 +1899.4166666666408,0.604625 +1899.499999999974,0.7571667 +1899.5833333333076,1.064542 +1899.6666666666408,1.128333 +1899.7499999999736,1.298375 +1899.833333333307,1.327333 +1899.9166666666404,1.540083 +1899.9999999999736,1.431417 +1900.0833333333069,1.351583 +1900.16666666664,1.038333 +1900.2499999999732,1.026667 +1900.3333333333069,0.9553334 +1900.41666666664,0.8507084 +1900.4999999999727,0.7727084 +1900.5833333333064,0.622875 +1900.66666666664,0.4963334 +1900.749999999973,0.5059167 +1900.8333333333064,0.2985 +1900.9166666666397,0.5063334 +1900.9999999999727,0.327375 +1901.083333333306,0.136125 +1901.1666666666392,-0.112375 +1901.2499999999725,0.012583335 +1901.3333333333055,-0.098666668 +1901.416666666639,-0.2424167 +1901.4999999999725,-0.394125 +1901.5833333333053,-0.31425 +1901.6666666666388,-0.2810833 +1901.749999999972,-0.098124996 +1901.8333333333053,-0.093250006 +1901.9166666666383,-0.0016250025 +1901.999999999972,0.2580833 +1902.083333333305,0.4116667 +1902.1666666666383,0.491125 +1902.249999999972,0.6415 +1902.3333333333048,0.8915833 +1902.416666666638,1.180208 +1902.4999999999716,1.549333 +1902.5833333333048,1.597583 +1902.6666666666376,1.634208 +1902.7499999999711,1.550208 +1902.8333333333044,1.778667 +1902.9166666666376,1.554833 +1902.999999999971,1.133708 +1903.083333333304,0.8522917 +1903.1666666666372,0.5903333 +1903.249999999971,0.23875 +1903.333333333304,-0.022041667 +1903.4166666666367,-0.297875 +1903.4999999999704,-0.4165 +1903.583333333304,-0.4931667 +1903.666666666637,-0.570875 +1903.7499999999704,-0.5977917 +1903.8333333333037,-0.7731667 +1903.9166666666367,-0.9750417 +1903.99999999997,-0.6440833 +1904.0833333333032,-0.428 +1904.1666666666365,-0.2572083 +1904.2499999999695,0.010875 +1904.333333333303,0.2477084 +1904.4166666666365,0.3547917 +1904.4999999999693,0.6286667 +1904.5833333333028,0.7090834 +1904.666666666636,0.5278333 +1904.7499999999693,0.7075 +1904.8333333333023,0.7598334 +1904.916666666636,0.9316251 +1904.999999999969,1.019167 +1905.0833333333023,0.8944167 +1905.166666666636,1.034833 +1905.2499999999688,1.164208 +1905.333333333302,1.537708 +1905.4166666666356,1.602917 +1905.4999999999688,1.505667 +1905.5833333333017,1.491333 +1905.6666666666351,1.676708 +1905.7499999999684,1.574875 +1905.8333333333017,1.520417 +1905.916666666635,1.506417 +1905.999999999968,1.362167 +1906.0833333333012,0.9341251 +1906.166666666635,0.4799584 +1906.249999999968,0.6007917 +1906.3333333333007,0.1574167 +1906.4166666666345,0.054291662 +1906.499999999968,-0.241875 +1906.583333333301,-0.7842917 +1906.6666666666345,-0.5009583 +1906.7499999999677,-0.559125 +1906.8333333333007,-0.5752917 +1906.916666666634,-0.4164167 +1906.9999999999677,-0.406125 +1907.0833333333003,-0.383875 +1907.1666666666335,-0.182625 +1907.249999999967,0.027749997 +1907.3333333333003,0.195625 +1907.416666666633,0.424625 +1907.4999999999668,0.414 +1907.5833333333,0.16975 +1907.666666666633,0.093208335 +1907.7499999999663,-0.013416667 +1907.8333333333,-0.2274167 +1907.916666666633,0.1665833 +1907.9999999999663,-0.076125003 +1908.0833333333,-0.1080833 +1908.1666666666329,-0.3264167 +1908.249999999966,-0.5873333 +1908.3333333332996,-0.5269583 +1908.4166666666329,-0.3969167 +1908.499999999966,-0.6345834 +1908.5833333332992,-0.4517917 +1908.6666666666324,-0.597125 +1908.7499999999657,-0.6689584 +1908.833333333299,-0.84425 +1908.916666666632,-1.075167 +1908.9999999999652,-0.8266667 +1909.0833333332987,-0.6670001 +1909.166666666632,-0.511 +1909.2499999999648,-0.3935 +1909.3333333332985,-0.331875 +1909.416666666632,-0.4347917 +1909.499999999965,-0.4260834 +1909.5833333332985,-0.4435417 +1909.6666666666315,-0.5923334 +1909.7499999999648,-0.9321667 +1909.833333333298,-1.226875 +1909.9166666666315,-1.02675 +1909.9999999999643,-0.9135417 +1910.0833333332976,-0.9789167 +1910.166666666631,-0.96975 +1910.2499999999643,-1.154583 +1910.3333333332976,-1.004042 +1910.4166666666308,-0.649875 +1910.499999999964,-0.61075 +1910.583333333297,-0.8955 +1910.6666666666304,-0.5580417 +1910.749999999964,-0.5992084 +1910.833333333297,-0.6202917 +1910.9166666666304,-0.5151667 +1910.999999999964,-0.4992917 +1911.0833333332969,-0.835375 +1911.16666666663,-0.7784167 +1911.2499999999636,-0.6631667 +1911.3333333332969,-0.213125 +1911.41666666663,0.1304583 +1911.4999999999632,0.3517084 +1911.5833333332964,0.5590417 +1911.6666666666297,0.7210833 +1911.749999999963,0.984875 +1911.833333333296,1.256125 +1911.9166666666292,1.547542 +1911.9999999999627,1.391042 +1912.083333333296,1.138958 +1912.1666666666288,0.8085417 +1912.2499999999625,0.7455834 +1912.333333333296,0.471375 +1912.416666666629,0.2027917 +1912.4999999999625,-0.159 +1912.5833333332955,-0.2946667 +1912.6666666666288,-0.1462917 +1912.749999999962,-0.017583333 +1912.8333333332955,0.027333332 +1912.9166666666283,-0.034875002 +1912.9999999999616,0.33625 +1913.083333333295,0.3775834 +1913.1666666666283,-0.047041669 +1913.2499999999616,-0.2415833 +1913.3333333332948,-0.1526667 +1913.416666666628,0.1026667 +1913.4999999999611,0.2762917 +1913.5833333332944,0.3826667 +1913.666666666628,0.4737084 +1913.749999999961,0.6095001 +1913.8333333332944,0.827 +1913.916666666628,1.058167 +1913.999999999961,1.061042 +1914.083333333294,0.7104584 +1914.1666666666276,0.7070417 +1914.249999999961,1.0035 +1914.333333333294,0.8069584 +1914.4166666666272,0.4959167 +1914.4999999999604,0.7023751 +1914.5833333332937,1.031 +1914.666666666627,1.057417 +1914.74999999996,1.202125 +1914.8333333332932,1.358708 +1914.9166666666267,1.464042 +1914.99999999996,1.508792 +1915.0833333332928,1.496 +1915.1666666666265,1.468292 +1915.24999999996,1.344417 +1915.333333333293,1.323167 +1915.4166666666265,1.216 +1915.4999999999595,1.066542 +1915.5833333332928,0.5688334 +1915.666666666626,0.2486667 +1915.7499999999595,0.1170833 +1915.8333333332928,-0.058958333 +1915.9166666666256,-0.317 +1915.999999999959,-0.5287501 +1916.0833333332923,-0.6020417 +1916.1666666666256,-0.582625 +1916.2499999999588,-0.6352084 +1916.333333333292,-0.8247917 +1916.4166666666251,-0.9106667 +1916.4999999999584,-0.9301667 +1916.583333333292,-1.302542 +1916.666666666625,-1.20875 +1916.7499999999584,-1.114375 +1916.833333333292,-1.212958 +1916.916666666625,-1.279917 +1916.9999999999584,-1.413417 +1917.0833333332916,-1.187125 +1917.166666666625,-1.308708 +1917.249999999958,-0.6171667 +1917.3333333332912,-0.2916667 +1917.4166666666245,0.1084167 +1917.4999999999577,0.1105 +1917.583333333291,-0.1784167 +1917.666666666624,-0.4289167 +1917.7499999999573,-0.7699167 +1917.8333333332907,-1.043167 +1917.916666666624,-1.0985 +1917.9999999999573,-1.100208 +1918.0833333332905,-0.776625 +1918.166666666624,-0.2953333 +1918.249999999957,0.1034167 +1918.3333333332905,0.5635417 +1918.4166666666235,0.841 +1918.4999999999568,1.06325 +1918.58333333329,1.173333 +1918.6666666666235,1.415042 +1918.7499999999568,1.760667 +1918.8333333332896,1.932667 +1918.916666666623,1.797208 +1918.9999999999563,1.730833 +1919.0833333332896,1.558167 +1919.1666666666229,1.312458 +1919.249999999956,1.159042 +1919.3333333332891,0.8925417 +1919.4166666666224,0.599875 +1919.499999999956,0.3899584 +1919.5833333332887,0.6140833 +1919.6666666666224,0.5985417 +1919.749999999956,0.4863333 +1919.833333333289,0.589 +1919.9166666666224,0.9495417 +1919.9999999999557,1.106708 +1920.0833333332887,1.144208 +1920.166666666622,0.9491251 +1920.2499999999552,0.964875 +1920.3333333332885,1.019875 +1920.4166666666215,0.74275 +1920.499999999955,0.2820417 +1920.583333333288,0.163 +1920.6666666666213,0.142375 +1920.7499999999548,-0.1117083 +1920.833333333288,-0.144125 +1920.9166666666213,-0.055499997 +1920.9999999999543,-0.188375 +1921.083333333288,-0.5710417 +1921.166666666621,-1.287125 +1921.2499999999543,-0.5607083 +1921.333333333288,-0.2544583 +1921.4166666666208,-0.1210417 +1921.499999999954,-0.1094583 +1921.5833333332876,-0.1855417 +1921.6666666666208,-0.072791673 +1921.7499999999536,-0.08754167 +1921.833333333287,-0.1747083 +1921.9166666666204,-0.3365 +1921.9999999999536,-0.425 +1922.0833333332869,0.2158334 +1922.16666666662,0.3493333 +1922.2499999999532,0.214 +1922.3333333332864,0.1818333 +1922.41666666662,-0.095083341 +1922.4999999999527,-0.6167084 +1922.5833333332864,-1.315792 +1922.66666666662,-0.9475417 +1922.749999999953,-0.644 +1922.8333333332864,-0.5449584 +1922.9166666666197,-0.4859584 +1922.9999999999527,-0.4077083 +1923.083333333286,-0.2070834 +1923.1666666666192,0.021666668 +1923.2499999999525,0.3290834 +1923.3333333332855,0.6767917 +1923.416666666619,0.7594167 +1923.4999999999525,0.5658334 +1923.5833333332853,0.8487917 +1923.6666666666188,0.7702084 +1923.749999999952,0.5781251 +1923.8333333332853,0.94575 +1923.9166666666183,1.034917 +1923.999999999952,0.7594167 +1924.083333333285,0.6881667 +1924.1666666666183,0.6669584 +1924.249999999952,0.1530417 +1924.3333333332848,-0.5044584 +1924.416666666618,-0.7379584 +1924.4999999999516,-0.7727084 +1924.5833333332848,-0.8528334 +1924.6666666666176,-0.8373334 +1924.7499999999511,-0.6697917 +1924.8333333332844,-0.798375 +1924.9166666666176,-0.691 +1924.999999999951,-1.075708 +1925.083333333284,-0.4490834 +1925.1666666666172,0.1318333 +1925.249999999951,0.4714167 +1925.333333333284,0.315 +1925.4166666666167,0.572375 +1925.4999999999504,0.8339167 +1925.583333333284,0.920375 +1925.666666666617,0.904375 +1925.7499999999504,0.822625 +1925.8333333332837,1.438417 +1925.9166666666167,1.619417 +1925.99999999995,1.501083 +1926.0833333332832,1.119333 +1926.1666666666165,1.224417 +1926.2499999999495,1.195833 +1926.333333333283,0.8802084 +1926.4166666666165,0.5204583 +1926.4999999999493,0.6054584 +1926.5833333332828,0.3292917 +1926.666666666616,-0.116875 +1926.7499999999493,-0.1063333 +1926.8333333332823,0.03804167 +1926.916666666616,-0.005708335 +1926.999999999949,-0.058333337 +1927.0833333332823,0.49525 +1927.166666666616,0.1548333 +1927.2499999999488,-0.094208337 +1927.333333333282,0.17325 +1927.4166666666156,0.126875 +1927.4999999999488,-0.3045 +1927.5833333332816,-0.1492917 +1927.6666666666151,0.1732083 +1927.7499999999484,0.379625 +1927.8333333332816,0.34025 +1927.916666666615,0.17675 +1927.999999999948,-0.018541668 +1928.0833333332812,-0.050083335 +1928.166666666615,-0.0068750014 +1928.249999999948,0.1599583 +1928.3333333332807,0.4234167 +1928.4166666666144,0.0044166646 +1928.499999999948,0.029791664 +1928.583333333281,0.039375003 +1928.6666666666144,0.072374992 +1928.7499999999477,-0.184 +1928.8333333332807,-0.2445417 +1928.916666666614,-0.1870833 +1928.9999999999472,-0.2834584 +1929.0833333332805,0.093500003 +1929.1666666666135,0.081500001 +1929.249999999947,0.3543333 +1929.3333333332805,0.3577917 +1929.4166666666133,0.41175 +1929.4999999999468,0.3048334 +1929.58333333328,0.4515 +1929.6666666666133,0.5615833 +1929.7499999999463,0.531375 +1929.83333333328,0.7834167 +1929.916666666613,0.5436251 +1929.9999999999463,0.1510833 +1930.08333333328,0.0036666652 +1930.1666666666129,0.193 +1930.249999999946,0.6871667 +1930.3333333332796,0.378375 +1930.4166666666129,0.4411667 +1930.4999999999457,1.203583 +1930.5833333332791,1.197708 +1930.6666666666124,1.299667 +1930.7499999999457,1.549375 +1930.833333333279,2.141167 +1930.916666666612,1.91975 +1930.9999999999452,1.941167 +1931.0833333332787,1.566542 +1931.166666666612,1.207333 +1931.2499999999447,1.125583 +1931.3333333332785,0.715 +1931.416666666612,0.23675 +1931.499999999945,0.0052499999 +1931.5833333332785,-0.313125 +1931.6666666666115,-0.603875 +1931.7499999999447,-0.6668751 +1931.833333333278,-0.601875 +1931.9166666666115,-0.4265417 +1931.9999999999443,-0.2193334 +1932.0833333332776,0.043583337 +1932.166666666611,0.4449167 +1932.2499999999443,0.5001251 +1932.3333333332776,0.700875 +1932.4166666666108,0.5854167 +1932.499999999944,0.2077083 +1932.583333333277,-0.089750007 +1932.6666666666104,0.025875002 +1932.749999999944,0.010749999 +1932.833333333277,0.081208333 +1932.9166666666104,-0.118625 +1932.999999999944,-0.2709167 +1933.0833333332769,0.150875 +1933.16666666661,0.194625 +1933.2499999999436,0.1936667 +1933.3333333332769,-0.293375 +1933.41666666661,-0.5236667 +1933.4999999999432,-0.5617501 +1933.5833333332764,-0.8795 +1933.6666666666097,-0.8390834 +1933.749999999943,-0.9021251 +1933.833333333276,-1.059958 +1933.9166666666092,-0.8913334 +1933.9999999999427,-0.4659583 +1934.083333333276,-0.4307917 +1934.1666666666088,-0.5059584 +1934.2499999999425,0.1855417 +1934.333333333276,0.154875 +1934.416666666609,0.322875 +1934.4999999999425,0.1207083 +1934.5833333332755,0.213625 +1934.6666666666088,0.1159583 +1934.749999999942,-0.1340833 +1934.8333333332755,0.094125003 +1934.9166666666083,-0.2142917 +1934.9999999999416,-0.5080417 +1935.083333333275,-0.566875 +1935.1666666666083,-0.3685 +1935.2499999999416,-0.24025 +1935.3333333332748,-0.2174167 +1935.416666666608,-0.101625 +1935.499999999941,-0.1764583 +1935.5833333332744,0.35125 +1935.666666666608,0.2804584 +1935.749999999941,0.294125 +1935.8333333332744,0.181875 +1935.916666666608,0.048250005 +1935.9999999999409,0.30975 +1936.083333333274,0.3025417 +1936.1666666666076,0.029625 +1936.2499999999409,0.217 +1936.333333333274,0.138125 +1936.4166666666072,-0.258625 +1936.4999999999404,-0.1512083 +1936.5833333332737,-0.082041658 +1936.666666666607,0.0098333359 +1936.74999999994,0.4034167 +1936.8333333332732,0.2052917 +1936.9166666666067,0.131 +1936.99999999994,0.1172083 +1937.0833333332728,0.1554583 +1937.1666666666065,0.2308334 +1937.24999999994,0.4564167 +1937.333333333273,-0.17975 +1937.4166666666065,-0.3534167 +1937.4999999999395,-0.290375 +1937.5833333332728,-0.4097084 +1937.666666666606,0.017625 +1937.7499999999395,-0.2217083 +1937.8333333332723,-0.26075 +1937.9166666666056,-0.3933333 +1937.999999999939,-0.4881667 +1938.0833333332723,-0.47075 +1938.1666666666056,-0.4057083 +1938.2499999999388,-0.323125 +1938.333333333272,-0.4740833 +1938.4166666666051,-0.8281251 +1938.4999999999384,-1.143958 +1938.583333333272,-0.8866667 +1938.666666666605,-0.7235417 +1938.7499999999384,-0.6121667 +1938.833333333272,-0.8842917 +1938.916666666605,-0.8051667 +1938.9999999999384,-0.768125 +1939.0833333332716,-0.8232084 +1939.166666666605,-0.6046667 +1939.249999999938,-0.088916674 +1939.3333333332712,0.060333334 +1939.4166666666044,0.141125 +1939.4999999999377,0.087000005 +1939.583333333271,0.2357917 +1939.666666666604,-0.00054166716 +1939.7499999999372,-0.1009583 +1939.8333333332707,0.2470417 +1939.916666666604,0.61475 +1939.9999999999368,0.9335834 +1940.0833333332705,1.164458 +1940.166666666604,1.63275 +1940.249999999937,1.513167 +1940.3333333332705,1.353583 +1940.4166666666035,0.936875 +1940.4999999999368,0.7663333 +1940.58333333327,0.6572917 +1940.6666666666035,0.5510833 +1940.7499999999368,0.5604167 +1940.8333333332696,0.988375 +1940.916666666603,1.370958 +1940.9999999999363,1.946417 +1941.0833333332696,2.049917 +1941.1666666666029,2.080167 +1941.249999999936,2.095625 +1941.3333333332691,1.883542 +1941.4166666666024,1.587375 +1941.499999999936,0.6562501 +1941.583333333269,0.4623333 +1941.6666666666024,0.6121667 +1941.749999999936,0.9626251 +1941.833333333269,1.7065 +1941.9166666666024,1.835417 +1941.9999999999357,0.9143334 +1942.083333333269,0.3991667 +1942.166666666602,0.1945417 +1942.2499999999352,0.2915833 +1942.3333333332685,0.1094167 +1942.4166666666017,-0.5429167 +1942.499999999935,-0.9152501 +1942.583333333268,-1.450417 +1942.6666666666013,-1.467042 +1942.7499999999347,-1.700417 +1942.833333333268,-1.704708 +1942.9166666666013,-1.435208 +1942.9999999999343,-1.313917 +1943.083333333268,-1.302083 +1943.166666666601,-0.8265833 +1943.2499999999343,-0.3650833 +1943.3333333332675,0.3725 +1943.4166666666008,0.3801667 +1943.499999999934,0.268125 +1943.5833333332675,0.018874999 +1943.6666666666008,-0.437625 +1943.7499999999336,-0.4134584 +1943.833333333267,-0.3527917 +1943.9166666666003,-0.4010417 +1943.9999999999336,-0.5440417 +1944.0833333332669,0.1988333 +1944.1666666666,0.0056666653 +1944.2499999999332,0.031125005 +1944.3333333332664,0.1789167 +1944.4166666666,0.328 +1944.4999999999327,0.1750834 +1944.5833333332664,0.067708336 +1944.6666666666,-0.4274584 +1944.749999999933,-0.4665834 +1944.8333333332664,-0.7762083 +1944.9166666665997,-0.5870417 +1944.9999999999327,-0.6265834 +1945.083333333266,-0.3135417 +1945.1666666665992,-0.432125 +1945.2499999999325,-0.055083331 +1945.3333333332655,0.2042917 +1945.416666666599,0.058791671 +1945.499999999932,-0.37225 +1945.5833333332653,-0.2225 +1945.6666666665988,-0.1917083 +1945.749999999932,-0.166 +1945.8333333332653,-0.1162083 +1945.9166666665983,0.044583336 +1945.999999999932,-0.065458335 +1946.083333333265,-0.2592917 +1946.1666666665983,-0.448 +1946.249999999932,-0.3714167 +1946.3333333332648,-0.1468333 +1946.416666666598,-0.30325 +1946.4999999999316,-0.202 +1946.5833333332648,-1.166583 +1946.6666666665976,-0.5346251 +1946.749999999931,-0.2429167 +1946.8333333332644,0.012999999 +1946.9166666665976,-0.03604167 +1946.9999999999309,0.089333341 +1947.083333333264,0.0061666672 +1947.1666666665972,0.099500008 +1947.2499999999309,0.068000004 +1947.333333333264,0.144375 +1947.4166666665967,0.176125 +1947.4999999999304,0.048125003 +1947.583333333264,-0.2539167 +1947.666666666597,-0.448125 +1947.7499999999304,-0.4247083 +1947.8333333332637,-0.3174167 +1947.9166666665967,-0.1245417 +1947.99999999993,-0.186 +1948.0833333332632,0.261625 +1948.1666666665965,0.428125 +1948.2499999999295,0.1349583 +1948.333333333263,0.1329167 +1948.4166666665965,-0.039875001 +1948.4999999999293,-0.3564167 +1948.5833333332628,-0.3035834 +1948.666666666596,-0.51975 +1948.7499999999293,-0.79225 +1948.8333333332623,-0.337 +1948.916666666596,-0.1490417 +1948.999999999929,-0.3777917 +1949.0833333332623,0.119625 +1949.166666666596,-0.41575 +1949.2499999999288,0.37075 +1949.333333333262,0.2958333 +1949.4166666665956,-0.4814167 +1949.4999999999288,-0.8129584 +1949.5833333332616,-0.6470417 +1949.6666666665951,-0.9257084 +1949.7499999999284,-1.08475 +1949.8333333332616,-1.513708 +1949.916666666595,-1.293167 +1949.999999999928,-1.264958 +1950.0833333332612,-1.398792 +1950.166666666595,-0.5907917 +1950.249999999928,-0.6573334 +1950.3333333332607,-1.079458 +1950.4166666665944,-0.561375 +1950.499999999928,-0.4275833 +1950.583333333261,-0.3512084 +1950.6666666665944,-0.9217501 +1950.7499999999277,-0.6642917 +1950.8333333332607,-0.69525 +1950.916666666594,-0.4615 +1950.9999999999272,-0.2005417 +1951.0833333332605,-0.113 +1951.1666666665935,-0.08070834 +1951.249999999927,0.12925 +1951.3333333332605,0.3492084 +1951.4166666665933,0.6534584 +1951.4999999999268,0.9438334 +1951.58333333326,0.9537084 +1951.6666666665933,0.8770834 +1951.7499999999263,0.9367084 +1951.83333333326,1.058167 +1951.916666666593,0.7833334 +1951.9999999999263,0.6069583 +1952.08333333326,0.437875 +1952.1666666665928,0.2175417 +1952.249999999926,0.4243334 +1952.3333333332596,0.1422917 +1952.4166666665928,-0.265125 +1952.4999999999256,-0.4897917 +1952.5833333332591,-0.2794583 +1952.6666666665924,-0.1289583 +1952.7499999999256,-0.074583337 +1952.833333333259,-0.4577917 +1952.916666666592,-0.22925 +1952.9999999999252,0.15475 +1953.083333333259,0.37275 +1953.166666666592,0.2254584 +1953.2499999999247,0.6130417 +1953.3333333332585,0.4869584 +1953.416666666592,0.5982917 +1953.499999999925,0.40175 +1953.5833333332585,0.422375 +1953.6666666665917,1.030625 +1953.7499999999247,0.535 +1953.833333333258,0.3735417 +1953.9166666665917,0.428875 +1953.9999999999245,0.2042917 +1954.0833333332575,-0.031291667 +1954.166666666591,-0.1205417 +1954.2499999999245,-0.767 +1954.333333333257,-0.76675 +1954.4166666665908,-0.6817917 +1954.499999999924,-0.7750834 +1954.583333333257,-0.7529167 +1954.6666666665903,-0.9442918 +1954.749999999924,-0.8057501 +1954.833333333257,-0.5814584 +1954.9166666665903,-0.8240417 +1954.999999999924,-0.4450417 +1955.0833333332569,-0.393625 +1955.16666666659,-0.3714584 +1955.2499999999236,-0.4055 +1955.3333333332569,-0.9582501 +1955.41666666659,-0.8116667 +1955.4999999999231,-0.5105417 +1955.5833333332564,-0.5210417 +1955.6666666665897,-0.9434167 +1955.749999999923,-1.259667 +1955.833333333256,-1.72825 +1955.9166666665892,-1.362417 +1955.9999999999227,-0.8777917 +1956.083333333256,-0.29675 +1956.1666666665888,-0.335875 +1956.2499999999225,-0.3919167 +1956.333333333256,-0.2565417 +1956.416666666589,-0.31225 +1956.4999999999225,-0.3865417 +1956.5833333332555,-0.459 +1956.6666666665888,-0.5269583 +1956.749999999922,-0.61125 +1956.8333333332555,-0.9212084 +1956.9166666665883,-0.5896667 +1956.9999999999216,-0.548875 +1957.083333333255,0.134125 +1957.1666666665883,0.5798751 +1957.2499999999216,0.6876667 +1957.3333333332548,0.7767917 +1957.416666666588,0.9380417 +1957.499999999921,1.17175 +1957.5833333332544,1.39425 +1957.666666666588,0.8230417 +1957.749999999921,0.8654584 +1957.8333333332544,1.295542 +1957.916666666588,1.24575 +1957.9999999999209,1.454958 +1958.083333333254,1.122625 +1958.1666666665876,0.6045001 +1958.2499999999209,0.3869167 +1958.333333333254,0.5602916 +1958.4166666665872,0.3310834 +1958.4999999999204,0.2275833 +1958.5833333332537,0.1564583 +1958.666666666587,-0.0017916639 +1958.74999999992,-0.021416668 +1958.8333333332532,0.1468333 +1958.9166666665867,0.1662917 +1958.99999999992,-0.010083335 +1959.0833333332528,-0.028083334 +1959.1666666665865,-0.1025 +1959.24999999992,0.3557083 +1959.333333333253,0.3619167 +1959.4166666665865,-0.042000003 +1959.4999999999195,-0.3919584 +1959.5833333332528,-0.5303334 +1959.666666666586,-0.255875 +1959.7499999999195,0.050375003 +1959.8333333332523,-0.0043750014 +1959.9166666665856,-0.039875001 +1959.999999999919,0.065375 +1960.0833333332523,-0.1235 +1960.1666666665856,0.2257917 +1960.2499999999188,0.056375004 +1960.333333333252,-0.039416671 +1960.4166666665851,-0.289125 +1960.4999999999184,-0.17875 +1960.583333333252,0.1907917 +1960.666666666585,0.1380417 +1960.7499999999184,-0.5229583 +1960.833333333252,-0.4422917 +1960.916666666585,-0.3513333 +1960.999999999918,-0.34575 +1961.0833333332516,0.1231667 +1961.166666666585,0.027375001 +1961.249999999918,0.5303333 +1961.3333333332512,0.3475417 +1961.4166666665844,0.6330834 +1961.4999999999177,-0.2915834 +1961.583333333251,-0.6474167 +1961.666666666584,-0.969 +1961.7499999999172,-0.6770417 +1961.8333333332507,-0.2874167 +1961.916666666584,-0.089416675 +1961.9999999999168,-0.2354583 +1962.0833333332505,-0.083666667 +1962.166666666584,-0.4315417 +1962.249999999917,-0.6563751 +1962.3333333332505,-0.4654167 +1962.4166666665835,-0.2419167 +1962.4999999999168,-0.1547083 +1962.58333333325,-0.078333341 +1962.6666666665835,-0.4087084 +1962.7499999999168,-0.4275417 +1962.8333333332496,-0.600375 +1962.916666666583,-0.7388334 +1962.9999999999163,-0.4727083 +1963.0833333332496,-0.3284583 +1963.1666666665828,0.059791666 +1963.249999999916,0.2882083 +1963.3333333332491,0.4530833 +1963.4166666665824,0.5908334 +1963.499999999916,0.9572917 +1963.583333333249,1.027917 +1963.6666666665824,0.9019167 +1963.749999999916,1.025583 +1963.833333333249,0.8132917 +1963.9166666665824,1.148458 +1963.9999999999156,0.5010417 +1964.083333333249,0.1721667 +1964.166666666582,-0.3676667 +1964.2499999999152,-0.65725 +1964.3333333332484,-1.065667 +1964.4166666665817,-1.141208 +1964.499999999915,-0.8432084 +1964.583333333248,-1.017333 +1964.6666666665812,-0.8000417 +1964.7499999999147,-0.6323751 +1964.833333333248,-0.817625 +1964.9166666665808,-1.11775 +1964.9999999999145,-0.6389583 +1965.083333333248,-0.1990833 +1965.166666666581,-0.1632083 +1965.2499999999145,0.2124167 +1965.3333333332475,0.9646251 +1965.4166666665808,0.92475 +1965.499999999914,1.028125 +1965.5833333332475,1.262 +1965.6666666665808,1.471042 +1965.7499999999136,1.46025 +1965.833333333247,1.617833 +1965.9166666665803,1.512708 +1965.9999999999136,1.333667 +1966.0833333332469,0.7800834 +1966.16666666658,0.2234583 +1966.2499999999131,0.2398333 +1966.3333333332464,-0.4439167 +1966.41666666658,0.02541667 +1966.4999999999127,0.2542084 +1966.5833333332464,-0.1462917 +1966.66666666658,-0.250125 +1966.749999999913,-0.1090417 +1966.8333333332464,-0.3313333 +1966.9166666665797,-0.4881667 +1966.9999999999127,-0.2909583 +1967.083333333246,-0.095416673 +1967.1666666665792,-0.2873333 +1967.2499999999125,-0.5887083 +1967.3333333332455,-0.2104584 +1967.416666666579,0.1040417 +1967.499999999912,-0.2443333 +1967.5833333332453,-0.7592917 +1967.6666666665787,-0.9951667 +1967.749999999912,-0.9199584 +1967.8333333332453,-0.9175001 +1967.9166666665783,-0.871125 +1967.999999999912,-1.018083 +1968.083333333245,-1.241583 +1968.1666666665783,-1.086333 +1968.249999999912,-0.6218334 +1968.3333333332448,-0.5748333 +1968.416666666578,0.093333334 +1968.4999999999116,0.5954583 +1968.5833333332448,0.4332917 +1968.6666666665776,0.3615417 +1968.749999999911,0.30025 +1968.8333333332444,0.56225 +1968.9166666665776,0.6919167 +1968.9999999999109,0.953875 +1969.083333333244,0.5150834 +1969.1666666665772,0.52825 +1969.2499999999104,0.5159167 +1969.333333333244,1.1275 +1969.4166666665767,0.9589584 +1969.4999999999104,0.4381667 +1969.583333333244,0.5562917 +1969.666666666577,1.054083 +1969.7499999999104,1.008292 +1969.8333333332437,1.065292 +1969.9166666665767,1.118542 +1969.99999999991,1.108375 +1970.0833333332432,0.6450834 +1970.1666666665765,0.3089584 +1970.2499999999095,0.245375 +1970.333333333243,-0.2194584 +1970.416666666576,-0.7600001 +1970.4999999999093,-1.693625 +1970.5833333332428,-1.713375 +1970.666666666576,-1.241958 +1970.7499999999093,-1.112875 +1970.8333333332423,-1.270458 +1970.916666666576,-1.647375 +1970.999999999909,-1.5305 +1971.0833333332423,-1.316417 +1971.166666666576,-1.174458 +1971.2499999999088,-0.46425 +1971.333333333242,-0.6747917 +1971.4166666665756,-0.5715 +1971.4999999999088,-0.373 +1971.5833333332416,-0.6012917 +1971.666666666575,-0.5732501 +1971.7499999999084,-0.782625 +1971.8333333332416,-0.8493334 +1971.9166666665749,-0.9325417 +1971.999999999908,-0.33425 +1972.0833333332412,-0.1992917 +1972.1666666665749,-0.026458334 +1972.249999999908,0.4203333 +1972.3333333332407,0.8338751 +1972.4166666665744,1.061708 +1972.499999999908,1.456083 +1972.583333333241,1.941125 +1972.6666666665744,1.839542 +1972.7499999999077,2.044333 +1972.8333333332407,2.290125 +1972.916666666574,2.321167 +1972.9999999999072,1.636292 +1973.0833333332405,1.2655 +1973.1666666665735,0.785625 +1973.249999999907,0.1032083 +1973.3333333332405,-0.8864584 +1973.4166666665733,-0.9628751 +1973.4999999999068,-1.038542 +1973.58333333324,-1.399625 +1973.6666666665733,-1.241917 +1973.7499999999063,-1.424875 +1973.83333333324,-1.562292 +1973.916666666573,-1.525208 +1973.9999999999063,-1.394792 +1974.08333333324,-1.156375 +1974.1666666665728,-0.441875 +1974.249999999906,-0.2852083 +1974.3333333332396,0.1253333 +1974.4166666665728,0.2641667 +1974.4999999999056,-0.09070833 +1974.5833333332391,0.078291677 +1974.6666666665724,-0.2987083 +1974.7499999999056,-0.2244584 +1974.833333333239,-0.55025 +1974.916666666572,-0.4072917 +1974.9999999999052,-0.1984583 +1975.083333333239,-0.3962917 +1975.166666666572,-0.4005 +1975.2499999999047,-0.043125 +1975.3333333332384,-0.4488333 +1975.416666666572,-0.8572917 +1975.499999999905,-0.8129584 +1975.5833333332384,-0.503375 +1975.6666666665717,-0.8416667 +1975.7499999999047,-1.100583 +1975.833333333238,-1.127542 +1975.9166666665712,-1.465 +1975.9999999999045,-1.739667 +1976.0833333332375,-1.0405 +1976.166666666571,-0.2500834 +1976.2499999999045,-0.051666666 +1976.3333333332373,0.1636667 +1976.4166666665708,0.7459584 +1976.499999999904,0.6729584 +1976.5833333332373,1.182292 +1976.6666666665703,1.214958 +1976.749999999904,1.315208 +1976.833333333237,1.123917 +1976.9166666665703,1.025167 +1976.999999999904,1.211042 +1977.0833333332369,0.6994584 +1977.16666666657,0.583625 +1977.2499999999036,-0.2445417 +1977.3333333332369,0.309875 +1977.4166666665697,0.32825 +1977.4999999999031,0.090666674 +1977.5833333332364,-0.3710417 +1977.6666666665697,-0.054500002 +1977.749999999903,0.39225 +1977.833333333236,0.6213334 +1977.9166666665692,0.4562083 +1977.999999999903,0.5896667 +1978.083333333236,0.2877083 +1978.1666666665687,0.050124999 +1978.2499999999025,-0.4830833 +1978.333333333236,-0.2818334 +1978.416666666569,-0.6512501 +1978.4999999999025,-0.6697084 +1978.5833333332355,-0.7621251 +1978.6666666665687,-0.5003334 +1978.749999999902,-0.32825 +1978.8333333332355,-0.044791669 +1978.9166666665683,0.2444167 +1978.9999999999015,-0.1144167 +1979.083333333235,0.0057500014 +1979.1666666665683,0.2442917 +1979.249999999901,0.4585834 +1979.3333333332348,0.5518333 +1979.416666666568,0.4878334 +1979.499999999901,0.098583341 +1979.5833333332343,0.515875 +1979.666666666568,1.07025 +1979.749999999901,0.5534167 +1979.8333333332343,0.3419167 +1979.916666666568,0.5520417 +1979.9999999999009,0.4616667 +1980.083333333234,0.2633334 +1980.1666666665676,0.1430833 +1980.2499999999009,0.294375 +1980.333333333234,0.390875 +1980.4166666665672,0.5747917 +1980.4999999999004,0.012124998 +1980.5833333332337,-0.078000002 +1980.666666666567,-0.1484583 +1980.7499999999,-0.3381667 +1980.8333333332332,0.1805 +1980.9166666665667,0.4969167 +1980.9999999999,-0.5247084 +1981.0833333332328,-0.6013334 +1981.1666666665665,-0.2345833 +1981.2499999999,-0.5125417 +1981.333333333233,-0.034958337 +1981.4166666665665,0.0083333347 +1981.4999999998995,-0.3842917 +1981.5833333332328,-0.6066667 +1981.666666666566,-0.078625001 +1981.7499999998995,0.055041667 +1981.8333333332323,-0.1394436 +1981.9166666665656,0.245679 +1981.999999999899,0.4787224 +1982.0833333332323,0.1933715 +1982.1666666665656,0.049264032 +1982.2499999998988,0.4472539 +1982.333333333232,1.045563 +1982.416666666565,1.211087 +1982.4999999998984,0.8999302 +1982.583333333232,1.261593 +1982.666666666565,1.899197 +1982.7499999998984,2.35988 +1982.833333333232,2.720195 +1982.9166666665649,3.343411 +1982.999999999898,3.443757 +1983.0833333332316,2.87916 +1983.1666666665649,2.217402 +1983.249999999898,1.970927 +1983.3333333332312,2.329366 +1983.4166666665644,2.062147 +1983.4999999998977,1.356797 +1983.583333333231,1.187653 +1983.666666666564,0.7677793 +1983.7499999998972,0.07111416 +1983.8333333332307,-0.2986768 +1983.916666666564,-0.2742858 +1983.9999999998968,-0.4900808 +1984.0833333332305,-0.093203679 +1984.166666666564,0.1046514 +1984.249999999897,0.097652987 +1984.3333333332305,-0.1839782 +1984.4166666665635,-0.6828744 +1984.4999999998968,-0.4949481 +1984.58333333323,-0.3552837 +1984.6666666665635,-0.1610741 +1984.7499999998963,-0.5522128 +1984.8333333332296,-0.5852469 +1984.916666666563,-1.072721 +1984.9999999998963,-0.7977945 +1985.0833333332296,-0.9878023 +1985.1666666665628,-0.6982444 +1985.249999999896,-0.4904598 +1985.3333333332291,-0.4573462 +1985.4166666665624,-0.6342896 +1985.499999999896,-0.6949093 +1985.583333333229,-0.6211753 +1985.6666666665624,-0.5324952 +1985.749999999896,-0.5369645 +1985.833333333229,-0.5141952 +1985.9166666665624,-0.5429232 +1985.9999999998956,-0.6772506 +1986.083333333229,-0.4032578 +1986.166666666562,-0.1076584 +1986.2499999998952,-0.015625795 +1986.3333333332284,0.036354978 +1986.4166666665617,0.058384735 +1986.499999999895,0.1436919 +1986.583333333228,0.2002011 +1986.6666666665612,0.7306641 +1986.7499999998947,0.8307792 +1986.833333333228,1.11288 +1986.9166666665608,1.032658 +1986.9999999998945,1.206627 +1987.083333333228,1.236719 +1987.166666666561,1.319378 +1987.2499999998945,1.291177 +1987.3333333332275,1.465812 +1987.4166666665608,1.450272 +1987.499999999894,1.562424 +1987.5833333332275,1.671488 +1987.6666666665608,1.973287 +1987.7499999998936,1.563092 +1987.833333333227,1.410939 +1987.9166666665603,1.312021 +1987.9999999998936,0.770139 +1988.0833333332268,0.4307343 +1988.16666666656,0.3418088 +1988.2499999998931,-0.2554331 +1988.3333333332264,-0.9647219 +1988.41666666656,-1.567755 +1988.499999999893,-1.692774 +1988.5833333332264,-1.452004 +1988.66666666656,-0.8992996 +1988.749999999893,-1.339106 +1988.8333333332264,-1.521344 +1988.9166666665596,-1.56684 +1988.999999999893,-1.299349 +1989.083333333226,-0.6468049 +1989.1666666665592,-0.8288125 +1989.2499999998925,-0.4289884 +1989.3333333332257,-0.1921278 +1989.416666666559,-0.091809563 +1989.499999999892,-0.136659 +1989.5833333332253,-0.2793966 +1989.6666666665587,-0.1443113 +1989.749999999892,-0.1283587 +1989.8333333332253,-0.1327569 +1989.9166666665585,-0.1622639 +1989.999999999892,-0.1544882 +1990.083333333225,0.1561754 +1990.1666666665585,0.1196446 +1990.2499999998915,0.4925371 +1990.3333333332248,0.6210604 +1990.416666666558,0.3083963 +1990.4999999998915,0.029720167 +1990.5833333332248,0.1911423 +1990.6666666665576,0.3149866 +1990.749999999891,0.1848168 +1990.8333333332243,0.097667642 +1990.9166666665576,0.2242653 +1990.9999999998909,0.2793717 +1991.083333333224,0.1684127 +1991.1666666665571,0.2148169 +1991.2499999998904,0.2318955 +1991.333333333224,0.924937 +1991.4166666665567,1.19877 +1991.4999999998904,1.076829 +1991.583333333224,0.6549006 +1991.666666666557,0.4541135 +1991.7499999998904,0.9030719 +1991.8333333332237,1.287249 +1991.9166666665567,1.559261 +1991.99999999989,1.562361 +1992.0833333332232,1.454479 +1992.1666666665565,1.367549 +1992.2499999998895,1.581219 +1992.333333333223,1.656618 +1992.416666666556,0.7269766 +1992.4999999998893,0.2436432 +1992.5833333332228,-0.023825595 +1992.666666666556,-0.017980186 +1992.7499999998893,-0.040174477 +1992.8333333332223,-0.0079594171 +1992.916666666556,0.049429875 +1992.999999999889,0.033455979 +1993.0833333332223,0.3503805 +1993.166666666556,0.5832611 +1993.2499999998888,1.173008 +1993.333333333222,1.403829 +1993.4166666665556,0.8243058 +1993.4999999998888,0.3868412 +1993.5833333332216,0.2405857 +1993.666666666555,0.4521553 +1993.7499999998884,0.5291239 +1993.8333333332216,0.3899363 +1993.9166666665549,0.4125022 +1993.999999999888,0.2741834 +1994.0833333332212,-0.087564394 +1994.1666666665544,0.0024894834 +1994.249999999888,-0.068991773 +1994.3333333332207,0.3881823 +1994.4166666665544,0.3140596 +1994.499999999888,-0.200651 +1994.583333333221,-0.1455645 +1994.6666666665544,0.2675676 +1994.7499999998877,0.7593633 +1994.8333333332207,1.045656 +1994.916666666554,1.129236 +1994.9999999998872,0.937923 +1995.0833333332205,0.6835793 +1995.1666666665535,0.2343409 +1995.249999999887,0.014058105 +1995.3333333332205,-0.1218222 +1995.4166666665533,0.011198606 +1995.4999999998868,-0.054928906 +1995.58333333322,-0.3730626 +1995.6666666665533,-0.4147711 +1995.7499999998863,-0.5710534 +1995.83333333322,-0.7022923 +1995.916666666553,-0.6446774 +1995.9999999998863,-0.5400862 +1996.08333333322,-0.4814011 +1996.1666666665528,-0.1030336 +1996.249999999886,-0.3715828 +1996.3333333332196,-0.3292112 +1996.4166666665528,-0.2382723 +1996.4999999998856,-0.1316241 +1996.5833333332191,-0.1635223 +1996.6666666665524,-0.1646935 +1996.7499999998856,-0.2054505 +1996.833333333219,-0.2535642 +1996.916666666552,-0.6168354 +1996.9999999998852,-0.6102584 +1997.083333333219,-0.303581 +1997.166666666552,0.1707174 +1997.2499999998847,0.5996162 +1997.3333333332184,1.449097 +1997.416666666552,1.983257 +1997.499999999885,2.408996 +1997.5833333332184,2.915967 +1997.6666666665517,3.122397 +1997.7499999998847,3.308315 +1997.833333333218,3.547784 +1997.9166666665512,3.724903 +1997.9999999998845,3.43036 +1998.0833333332175,2.761615 +1998.166666666551,2.229913 +1998.2499999998845,1.896097 +1998.3333333332173,1.568013 +1998.4166666665508,0.1962749 +1998.499999999884,-0.022825558 +1998.5833333332173,0.079480097 +1998.6666666665503,-0.1270769 +1998.749999999884,-0.4242516 +1998.833333333217,-0.4510868 +1998.9166666665503,-0.7682984 +1998.999999999884,-0.8359101 +1999.0833333332168,-0.5222874 +1999.16666666655,-0.1487616 +1999.2499999998836,-0.4309283 +1999.3333333332168,-0.084772326 +1999.4166666665496,-0.3957591 +1999.4999999998831,-0.4942223 +1999.5833333332164,-0.6333401 +1999.6666666665496,-0.7109451 +1999.749999999883,-0.8085802 +1999.833333333216,-1.138787 +1999.9166666665492,-1.251376 +1999.999999999883,-1.432551 +2000.083333333216,-0.92368 +2000.1666666665487,-0.4545587 +2000.2499999998824,0.060650181 +2000.333333333216,0.028873539 +2000.416666666549,-0.4213194 +2000.4999999998824,-0.537641 +2000.5833333332157,-0.5081417 +2000.6666666665487,-0.2256393 +2000.749999999882,-0.2572685 +2000.8333333332157,-0.5338784 +2000.9166666665485,-0.3640887 +2000.9999999998815,-0.3958249 +2001.083333333215,-0.182546 +2001.1666666665485,0.2835068 +2001.2499999998813,0.3611216 +2001.3333333332148,0.2217147 +2001.416666666548,0.1750913 +2001.4999999998813,-0.038524158 +2001.5833333332143,-0.1522177 +2001.666666666548,-0.2743973 +2001.749999999881,-0.266176 +2001.8333333332143,-0.4197773 +2001.916666666548,-0.2828763 +2001.9999999998809,-0.2653425 +2002.083333333214,0.015816124 +2002.1666666665476,0.2507458 +2002.2499999998809,0.3834586 +2002.333333333214,0.6018103 +2002.4166666665471,0.8766004 +2002.4999999998804,0.563215 +2002.5833333332137,0.5706242 +2002.666666666547,0.9055965 +2002.74999999988,1.16279 +2002.8333333332132,1.528841 +2002.9166666665467,1.504215 +2002.99999999988,0.940943 +2003.0833333332127,0.5549844 +2003.1666666665465,0.4025691 +2003.24999999988,0.02793373 +2003.333333333213,-0.388851 +2003.4166666665465,-0.2685696 +2003.4999999998795,0.1682665 +2003.5833333332127,0.2384973 +2003.666666666546,0.4114488 +2003.7499999998795,0.5927562 +2003.8333333332123,0.6641306 +2003.9166666665456,0.6043244 diff --git a/pyleoclim/tests/test_core_Series.py b/pyleoclim/tests/test_core_Series.py index ade0a12c..51f5d67e 100644 --- a/pyleoclim/tests/test_core_Series.py +++ b/pyleoclim/tests/test_core_Series.py @@ -998,7 +998,7 @@ def test_sort_t1(self): class TestResample: - @pytest.mark.parametrize('rule', pyleo.utils.tsutils.MATCH_A) + @pytest.mark.parametrize('rule', pyleo.utils.tsbase.MATCH_A) def test_resample_simple(self, rule, dataframe_dt, metadata): # note: resample with large ranges is still not supported, # so for now we're only testing 'years' as the rule diff --git a/pyleoclim/tests/test_utils_tsbase.py b/pyleoclim/tests/test_utils_tsbase.py new file mode 100644 index 00000000..cf475c69 --- /dev/null +++ b/pyleoclim/tests/test_utils_tsbase.py @@ -0,0 +1,146 @@ + +import pytest +from pyleoclim.utils import tsbase +import numpy as np + + +def test_time_unit_to_datum_exp_dir_unknown_time_unit(): + # unknown time unit, gets default values + time_unit = 'unknown_value' + with pytest.warns(match='Time unit'): + (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit) + assert datum == 0 + assert exponent == 0 + assert direction == 'prograde' + + with pytest.warns(match='Time unit'): + (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit, time_name='unknown') + assert datum == 0 + assert exponent == 0 + assert direction == 'prograde' + + # with pytest.warns(match='Time unit'): + # (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit, time_name='age') + # assert datum == 0 + # assert exponent == 0 + # assert direction == 'retrograde' + + +@pytest.mark.parametrize('time_unit', tsbase.MATCH_KA) +def test_time_unit_to_datum_exp_dir_ka(time_unit): + (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit) + assert datum == 1950 + assert exponent == 3 + assert direction == 'retrograde' + + +@pytest.mark.parametrize('time_unit', tsbase.MATCH_MA) +def test_time_unit_to_datum_exp_dir_ma(time_unit): + (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit) + assert datum == 1950 + assert exponent == 6 + assert direction == 'retrograde' + + +@pytest.mark.parametrize('time_unit', tsbase.MATCH_GA) +def test_time_unit_to_datum_exp_dir_ga(time_unit): + (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit) + assert datum == 1950 + assert exponent == 9 + assert direction == 'retrograde' + + +def test_time_unit_to_datum_exp_dir_b2k(): + time_unit = 'years b2k' + (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit) + assert datum == 2000 + assert exponent == 0 + assert direction == 'retrograde' + + +@pytest.mark.parametrize('time_unit', ['years bp', 'years bnf']) +def test_time_unit_to_datum_exp_dir_bp(time_unit): + (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit) + assert datum == 1950 + assert exponent == 0 + assert direction == 'retrograde' + + +@pytest.mark.parametrize('time_unit', ['years AD', 'yr CE']) +def test_time_unit_to_datum_exp_dir_ad(time_unit): + (datum, exponent, direction) = tsbase.time_unit_to_datum_exp_dir(time_unit) + assert datum == 0 + assert exponent == 0 + assert direction == 'prograde' + + +def test_convert_datetime_index_ka(dataframe_dt): + time_unit = 'ka' + time_name = None + time = tsbase.convert_datetime_index_to_time( + dataframe_dt.index, + time_unit, + time_name=time_name, + ) + expected = np.array([-996577.75451608, -996577.75551608, -999315.60730322, -996577.75751608, -996577.75851608]) + assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) + + +def test_convert_datetime_index_ma(dataframe_dt): + time_unit = 'ma' + time_name = None + time = tsbase.convert_datetime_index_to_time( + dataframe_dt.index, + time_unit, + time_name=time_name, + ) + expected = np.array([-996.57775452, -996.57775552, -999.3156073 , -996.57775752, -996.57775852]) + assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) + + +def test_convert_datetime_index_ga(dataframe_dt): + time_unit = 'ga' + time_name = None + time = tsbase.convert_datetime_index_to_time( + dataframe_dt.index, + time_unit, + time_name=time_name, + ) + expected = np.array([-0.99657775, -0.99657776, -0.99931561, -0.99657776, -0.99657776]) + assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) + + +def test_convert_datetime_index_bp(dataframe_dt): + time_unit = 'years B.P.' + time_name = None + time = tsbase.convert_datetime_index_to_time( + dataframe_dt.index, + time_unit, + time_name=time_name, + ) + expected = np.array([-9.96577755e+08, -9.96577756e+08, -9.99315607e+08, -9.96577758e+08, -9.96577759e+08]) + assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) + + +def test_convert_datetime_index_ad(dataframe_dt): + time_unit = 'AD' + time_name = None + time = tsbase.convert_datetime_index_to_time( + dataframe_dt.index, + time_unit, + time_name=time_name, + ) + expected = np.array([9.96579705e+08, 9.96579706e+08, 9.99317557e+08, 9.96579708e+08, 9.96579709e+08]) + assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) + + +def test_convert_datetime_index_nondt_index(dataframe): + time_unit = 'yr' + time_name = None + with pytest.raises(ValueError, match='not a proper DatetimeIndex object'): + tsbase.convert_datetime_index_to_time( + dataframe.index, + time_unit, + time_name=time_name, + ) + diff --git a/pyleoclim/tests/test_utils_tsutils.py b/pyleoclim/tests/test_utils_tsutils.py index 500608df..7515ff47 100644 --- a/pyleoclim/tests/test_utils_tsutils.py +++ b/pyleoclim/tests/test_utils_tsutils.py @@ -4,146 +4,6 @@ import numpy as np -def test_time_unit_to_datum_exp_dir_unknown_time_unit(): - # unknown time unit, gets default values - time_unit = 'unknown_value' - with pytest.warns(match='Time unit'): - (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit) - assert datum == 0 - assert exponent == 0 - assert direction == 'prograde' - - with pytest.warns(match='Time unit'): - (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit, time_name='unknown') - assert datum == 0 - assert exponent == 0 - assert direction == 'prograde' - - # with pytest.warns(match='Time unit'): - # (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit, time_name='age') - # assert datum == 0 - # assert exponent == 0 - # assert direction == 'retrograde' - - -@pytest.mark.parametrize('time_unit', tsutils.MATCH_KA) -def test_time_unit_to_datum_exp_dir_ka(time_unit): - (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit) - assert datum == 1950 - assert exponent == 3 - assert direction == 'retrograde' - - -@pytest.mark.parametrize('time_unit', tsutils.MATCH_MA) -def test_time_unit_to_datum_exp_dir_ma(time_unit): - (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit) - assert datum == 1950 - assert exponent == 6 - assert direction == 'retrograde' - - -@pytest.mark.parametrize('time_unit', tsutils.MATCH_GA) -def test_time_unit_to_datum_exp_dir_ga(time_unit): - (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit) - assert datum == 1950 - assert exponent == 9 - assert direction == 'retrograde' - - -def test_time_unit_to_datum_exp_dir_b2k(): - time_unit = 'years b2k' - (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit) - assert datum == 2000 - assert exponent == 0 - assert direction == 'retrograde' - - -@pytest.mark.parametrize('time_unit', ['years bp', 'years bnf']) -def test_time_unit_to_datum_exp_dir_bp(time_unit): - (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit) - assert datum == 1950 - assert exponent == 0 - assert direction == 'retrograde' - - -@pytest.mark.parametrize('time_unit', ['years AD', 'yr CE']) -def test_time_unit_to_datum_exp_dir_ad(time_unit): - (datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit) - assert datum == 0 - assert exponent == 0 - assert direction == 'prograde' - - -def test_convert_datetime_index_ka(dataframe_dt): - time_unit = 'ka' - time_name = None - time = tsutils.convert_datetime_index_to_time( - dataframe_dt.index, - time_unit, - time_name=time_name, - ) - expected = np.array([-996577.75451608, -996577.75551608, -999315.60730322, -996577.75751608, -996577.75851608]) - assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) - - -def test_convert_datetime_index_ma(dataframe_dt): - time_unit = 'ma' - time_name = None - time = tsutils.convert_datetime_index_to_time( - dataframe_dt.index, - time_unit, - time_name=time_name, - ) - expected = np.array([-996.57775452, -996.57775552, -999.3156073 , -996.57775752, -996.57775852]) - assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) - - -def test_convert_datetime_index_ga(dataframe_dt): - time_unit = 'ga' - time_name = None - time = tsutils.convert_datetime_index_to_time( - dataframe_dt.index, - time_unit, - time_name=time_name, - ) - expected = np.array([-0.99657775, -0.99657776, -0.99931561, -0.99657776, -0.99657776]) - assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) - - -def test_convert_datetime_index_bp(dataframe_dt): - time_unit = 'years B.P.' - time_name = None - time = tsutils.convert_datetime_index_to_time( - dataframe_dt.index, - time_unit, - time_name=time_name, - ) - expected = np.array([-9.96577755e+08, -9.96577756e+08, -9.99315607e+08, -9.96577758e+08, -9.96577759e+08]) - assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) - - -def test_convert_datetime_index_ad(dataframe_dt): - time_unit = 'AD' - time_name = None - time = tsutils.convert_datetime_index_to_time( - dataframe_dt.index, - time_unit, - time_name=time_name, - ) - expected = np.array([9.96579705e+08, 9.96579706e+08, 9.99317557e+08, 9.96579708e+08, 9.96579709e+08]) - assert np.allclose(time.values, expected, rtol=1e-05, atol=1e-08) - - -def test_convert_datetime_index_nondt_index(dataframe): - time_unit = 'yr' - time_name = None - with pytest.raises(ValueError, match='not a proper DatetimeIndex object'): - tsutils.convert_datetime_index_to_time( - dataframe.index, - time_unit, - time_name=time_name, - ) - def test_bin_t0(unevenly_spaced_series): res_dict = tsutils.bin(unevenly_spaced_series.time,unevenly_spaced_series.value) t = res_dict['bins'] diff --git a/pyleoclim/utils/tsbase.py b/pyleoclim/utils/tsbase.py index e43c976c..5e1e96cd 100644 --- a/pyleoclim/utils/tsbase.py +++ b/pyleoclim/utils/tsbase.py @@ -6,6 +6,10 @@ import numpy as np from typing import OrderedDict +import operator +import warnings +import pandas as pd + #APIs @@ -17,6 +21,126 @@ 'reduce_duplicated_timestamps', ] +SECONDS_PER_YEAR = 365.25 * 60 * 60 * 24 ## TODO: generalize to different calendars using cftime + +MATCH_A = frozenset(['y', 'yr', 'yrs', 'year', 'years']) +MATCH_KA = frozenset(['ka', 'ky', 'kyr', 'kyrs', 'kiloyear', 'kiloyr', 'kiloyrs']) +MATCH_MA = frozenset(['ma', 'my','myr','myrs']) +MATCH_GA = frozenset(['ga', 'gy', 'gyr', 'gyrs']) + +def time_unit_to_datum_exp_dir(time_unit, time_name=None, verbose=False): + + tu = time_unit.lower().split() + + # deal with statements explicit about exponents, and take a first guess at datum/direction + if tu[0] in MATCH_A: + exponent = 0 + datum = 0 + direction = 'prograde' + elif tu[0] in MATCH_KA: + datum = 1950 + exponent = 3 + direction = 'retrograde' + elif tu[0] in MATCH_MA: + datum = 1950 + exponent = 6 + direction = 'retrograde' + elif tu[0] in MATCH_GA: + datum = 1950 + exponent = 9 + direction = 'retrograde' + elif tu[0].replace('.','') in ['ad', 'ce']: + exponent = 0 + datum = 0 + direction = 'prograde' + else: + warnings.warn(f'Time unit "{time_unit}" unknown; triggering defaults', stacklevel=4) + exponent = 0 + datum = 0 + direction = 'prograde' + + # if provided, deal with statements about datum/direction, like kyr BP, years CE, etc + if len(tu) > 1: + datum_str = tu[1].replace('.','') # make lowercase + strip stops, so "B.P." --> "bp" + if datum_str == 'b2k': + datum = 2000 + direction = 'retrograde' + elif datum_str in ['bp', 'bnf', 'b1950']: + datum = 1950 + direction = 'retrograde' + elif datum_str in ['ad', 'ce']: + datum = 0 + direction = 'prograde' + + if time_name is not None: + if time_name.lower() == 'age': + direction = 'retrograde' + + if verbose: + print(f'Provided time medata translated to {direction} flow, 10^{exponent} year units, and year {datum} datum') + + return (datum, exponent, direction) + +def convert_datetime_index_to_time(datetime_index, time_unit, time_name): + datum, exponent, direction = time_unit_to_datum_exp_dir(time_unit, time_name) + #import operator + if direction == 'prograde': + multiplier = 1 + elif direction == 'retrograde': + multiplier = -1 + else: + raise ValueError(f'Expected one of {"prograde", "retrograde"}, got {direction}') + + if not isinstance(datetime_index, pd.DatetimeIndex): + raise ValueError('The provided index is not a proper DatetimeIndex object') + else: + year_diff = (datetime_index.year - int(datum)) + numpy_datetime_index = datetime_index.to_numpy() + years_floor = numpy_datetime_index.astype('datetime64[Y]').astype('datetime64[s]') + seconds_diff = (numpy_datetime_index - years_floor).astype('int') + diff = year_diff + seconds_diff / SECONDS_PER_YEAR + time = multiplier * diff / 10**exponent + + return time + +def time_to_datetime(time, datum=0, exponent=0, direction='prograde', unit='s'): + ''' + Converts a vector of time values to a pandas datetime object + + Parameters + ---------- + time : array-like + the time axis to be converted + datum : int, optional + origin point for the time scale. The default is 0. + exponent : int, optional + Base-10 exponent for year multiplier. Dates in kyr should use 3, dates in Myr should use 6, etc. + The default is 0. + direction : str, optional + Direction of time flow, 'prograde' [default] or 'retrograde'. + unit : str, optional + Units of the datetime. Default is 's', corresponding to seconds. + Only change if you have an excellent reason to use finer resolution! + + Returns + ------- + index, a datetime64[unit] object + + ''' + if direction == 'prograde': + op = operator.add + elif direction == 'retrograde': + op = operator.sub + else: + raise ValueError(f'Expected one of {"prograde", "retrograde"}, got {direction}') + + timedelta = np.array(time) * 10**exponent + years = timedelta.astype('int') + seconds = ((timedelta - timedelta.astype('int')) * SECONDS_PER_YEAR).astype('timedelta64[s]') # incorporate unit here + index = op(op(int(datum), years).astype(str).astype('datetime64[s]'), seconds) # incorporate unit here? + + return index + def clean_ts(ys, ts, verbose=False): ''' Cleaning the timeseries diff --git a/pyleoclim/utils/tsutils.py b/pyleoclim/utils/tsutils.py index d4fbe0ea..f8af82e6 100644 --- a/pyleoclim/utils/tsutils.py +++ b/pyleoclim/utils/tsutils.py @@ -19,7 +19,6 @@ 'remove_outliers' ] -import operator import numpy as np import pandas as pd import warnings @@ -44,125 +43,6 @@ clean_ts ) -SECONDS_PER_YEAR = 365.25 * 60 * 60 * 24 - -MATCH_A = frozenset(['y', 'yr', 'yrs', 'year', 'years']) -MATCH_KA = frozenset(['ka', 'ky', 'kyr', 'kyrs', 'kiloyear', 'kiloyr', 'kiloyrs']) -MATCH_MA = frozenset(['ma', 'my','myr','myrs']) -MATCH_GA = frozenset(['ga', 'gy', 'gyr', 'gyrs']) - -def time_unit_to_datum_exp_dir(time_unit, time_name=None, verbose=True): - - tu = time_unit.lower().split() - - # deal with statements explicit about exponents, and take a first guess at datum/direction - if tu[0] in MATCH_A: - exponent = 0 - datum = 0 - direction = 'prograde' - elif tu[0] in MATCH_KA: - datum = 1950 - exponent = 3 - direction = 'retrograde' - elif tu[0] in MATCH_MA: - datum = 1950 - exponent = 6 - direction = 'retrograde' - elif tu[0] in MATCH_GA: - datum = 1950 - exponent = 9 - direction = 'retrograde' - elif tu[0].replace('.','') in ['ad', 'ce']: - exponent = 0 - datum = 0 - direction = 'prograde' - else: - warnings.warn(f'Time unit "{time_unit}" unknown; triggering defaults', stacklevel=4) - exponent = 0 - datum = 0 - direction = 'prograde' - - # if provided, deal with statements about datum/direction, like kyr BP, years CE, etc - if len(tu) > 1: - datum_str = tu[1].replace('.','') # make lowercase + strip stops, so "B.P." --> "bp" - if datum_str == 'b2k': - datum = 2000 - direction = 'retrograde' - elif datum_str in ['bp', 'bnf', 'b1950']: - datum = 1950 - direction = 'retrograde' - elif datum_str in ['ad', 'ce']: - datum = 0 - direction = 'prograde' - - if time_name is not None: - if time_name.lower() == 'age': - direction = 'retrograde' - - if verbose: - print(f'Provided time medata translated to {direction} flow, 10^{exponent} year units, and year {datum} datum') - - return (datum, exponent, direction) - -def convert_datetime_index_to_time(datetime_index, time_unit, time_name): - datum, exponent, direction = time_unit_to_datum_exp_dir(time_unit, time_name) - #import operator - if direction == 'prograde': - multiplier = 1 - elif direction == 'retrograde': - multiplier = -1 - else: - raise ValueError(f'Expected one of {"prograde", "retrograde"}, got {direction}') - - if not isinstance(datetime_index, pd.DatetimeIndex): - raise ValueError('The provided index is not a proper DatetimeIndex object') - else: - year_diff = (datetime_index.year - int(datum)) - numpy_datetime_index = datetime_index.to_numpy() - years_floor = numpy_datetime_index.astype('datetime64[Y]').astype('datetime64[s]') - seconds_diff = (numpy_datetime_index - years_floor).astype('int') - diff = year_diff + seconds_diff / SECONDS_PER_YEAR - time = multiplier * diff / 10**exponent - - return time - -def time_to_datetime(time, datum=0, exponent=0, direction='prograde', unit='s'): - ''' - Converts a vector of time values to a pandas datetime object - - Parameters - ---------- - time : array-like - the time axis to be converted - datum : int, optional - origin point for the time scale. The default is 0. - exponent : int, optional - Base-10 exponent for year multiplier. Dates in kyr should use 3, dates in Myr should use 6, etc. - The default is 0. - direction : str, optional - Direction of time flow, 'prograde' [default] or 'retrograde'. - unit : str, optional - Units of the datetime. Default is 's', corresponding to seconds. - Only change if you have an excellent reason to use finer resolution! - - Returns - ------- - index, a datetime64[unit] object - - ''' - if direction == 'prograde': - op = operator.add - elif direction == 'retrograde': - op = operator.sub - else: - raise ValueError(f'Expected one of {"prograde", "retrograde"}, got {direction}') - - timedelta = np.array(time) * 10**exponent - years = timedelta.astype('int') - seconds = ((timedelta - timedelta.astype('int')) * SECONDS_PER_YEAR).astype('timedelta64[s]') # incorporate unit here - index = op(op(int(datum), years).astype(str).astype('datetime64[s]'), seconds) # incorporate unit here? - - return index def simple_stats(y, axis=None): """ Computes simple statistics