Beispiel #1
0
    def test_constant(self):

        with TemporaryDirectory() as f:

            bootstrap_dir(f, m(V), '5', mm(DEV), configurator=default)

            args, data = bootstrap_dir(
                f, m(V), '5', mm(DEV), 'read',
                'data/test/source/personal/2018-03-04-qdp.fit')
            read(args, data)

            with data.db.session_context() as s:
                stats = Statistics(s, activity_journal='2018-03-04 07:16:33', with_timespan=True). \
                    by_name(SegmentReader, N.LATITUDE, N.LONGITUDE, N.SPHERICAL_MERCATOR_X,
                            N.SPHERICAL_MERCATOR_Y, N.DISTANCE, N.ELEVATION, N.SPEED, N.CADENCE, N.HEART_RATE).df
                stats.describe()

                sepn = pd.Series(stats.index).diff().median()  # 7 secs
                start = stats.index.min()  # 2018-03-04 10:16:33+00:00
                finish = stats.index.max()  # 2018-03-04 16:34:51+00:00
                even = pd.DataFrame({'keep': True},
                                    index=pd.date_range(start=start,
                                                        end=finish,
                                                        freq=sepn))
                both = stats.join(even, how='outer', sort=True)
                both.interpolate(method='index',
                                 limit_area='inside',
                                 inplace=True)
                both = both.loc[both['keep'] == True].drop(columns=['keep'])
                both = both.loc[both[N.TIMESPAN_ID].isin(
                    stats[N.TIMESPAN_ID].unique())]
                both.describe()
Beispiel #2
0
 def spline(self, smooth=0):
     with TemporaryDirectory() as f:
         bootstrap_dir(f, m(V), '5', mm(DEV), configurator=default)
         args, data = bootstrap_dir(f, m(V), '5', 'constants', 'set',
                                    SRTM1_DIR_CNAME,
                                    '/home/andrew/archive/srtm1', mm(FORCE))
         constants(args, data)
         with data.db.session_context() as s:
             yield spline_elevation_from_constant(s, smooth=smooth)
Beispiel #3
0
 def test_florian(self):
     with TemporaryDirectory() as f:
         bootstrap_dir(f, m(V), '5')
         bootstrap_dir(f, m(V), '5', mm(DEV), configurator=default)
         args, data = bootstrap_dir(f, m(V), '5', mm(DEV), 'read',
                                    'data/test/source/private/florian.fit')
         read(args, data)
         # run('sqlite3 %s ".dump"' % f.name, shell=True)
         run_pipeline(data, PipelineType.CALCULATE, n_cpu=1)
         # run('sqlite3 %s ".dump"' % f.name, shell=True)
         with data.db.session_context() as s:
             self.__assert_basic_stats(s)
Beispiel #4
0
 def test_920(self):
     for src in '920xt-2019-05-16_19-42-54.fit', '920xt-2019-05-16_19-42-54.fit':
         with TemporaryDirectory() as f:
             bootstrap_dir(f, m(V), '5')
             bootstrap_dir(f, m(V), '5', mm(DEV), configurator=default)
             args, data = bootstrap_dir(f, m(V), '5', mm(DEV), 'read',
                                        f'data/test/source/other/{src}')
             read(args, data)
             # run('sqlite3 %s ".dump"' % f.name, shell=True)
             run_pipeline(data, PipelineType.CALCULATE, n_cpu=1)
             # run('sqlite3 %s ".dump"' % f.name, shell=True)
             with data.db.session_context() as s:
                 self.__assert_basic_stats(s)
Beispiel #5
0
 def test_michael(self):
     with TemporaryDirectory() as f:
         bootstrap_dir(f, m(V), '5')
         bootstrap_dir(f, m(V), '5', mm(DEV), configurator=default)
         args, data = bootstrap_dir(
             f, m(V), '5', mm(DEV), 'read',
             'data/test/source/other/2019-05-09-051352-Running-iWatchSeries3.fit'
         )
         read(args, data)
         # run('sqlite3 %s ".dump"' % f.name, shell=True)
         run_pipeline(data, PipelineType.CALCULATE, n_cpu=1)
         # run('sqlite3 %s ".dump"' % f.name, shell=True)
         with data.db.session_context() as s:
             self.__assert_basic_stats(s)
Beispiel #6
0
 def test_heart_alarms(self):
     with TemporaryDirectory() as f:
         bootstrap_dir(f, m(V), '5')
         bootstrap_dir(f, m(V), '5', mm(DEV), configurator=default)
         args, data = bootstrap_dir(
             f, m(V), '5', mm(DEV), 'read',
             'data/test/source/personal/2016-07-19-mpu-s-z2.fit')
         read(args, data)
         # run('sqlite3 %s ".dump"' % f.name, shell=True)
         run_pipeline(data, PipelineType.CALCULATE, n_cpu=1)
         # run('sqlite3 %s ".dump"' % f.name, shell=True)
         with data.db.session_context() as s:
             for stat in s.query(StatisticJournal). \
                     join(StatisticName). \
                     filter(StatisticName.name == N.ACTIVE_DISTANCE).all():
                 self.assertGreater(stat.value, 30)
Beispiel #7
0
 def bilinear(self):
     with NamedTemporaryFile() as f:
         bootstrap_file(f, m(V), '5', mm(DEV), configurator=default)
         args, sys, db = bootstrap_file(f, m(V), '5', 'constants', 'set',
                                        SRTM1_DIR,
                                        '/home/andrew/archive/srtm1')
         constants(args, sys, db)
         with db.session_context() as s:
             yield bilinear_elevation_from_constant(s)
Beispiel #8
0
    def test_activities(self):

        with TemporaryDirectory() as base:

            bootstrap_dir(base, m(V), '5')

            bootstrap_dir(base, m(V), '5', mm(DEV), configurator=default)

            args, data = bootstrap_dir(base, m(V), '5', 'constants', 'set',
                                       'SRTM1.dir',
                                       '/home/andrew/archive/srtm1', mm(FORCE))
            constants(args, data)

            args, data = bootstrap_dir(
                base, m(V), '5', mm(DEV), 'read',
                'data/test/source/personal/2018-08-27-rec.fit')
            read(args, data)

            # run('sqlite3 %s ".dump"' % f.name, shell=True)

            run_pipeline(data,
                         PipelineType.CALCULATE,
                         force=True,
                         start='2018-01-01',
                         n_cpu=1)

            # run('sqlite3 %s ".dump"' % f.name, shell=True)

            with data.db.session_context() as s:
                n_raw = s.query(count(StatisticJournalFloat.id)). \
                    join(StatisticName). \
                    filter(StatisticName.name == N.RAW_ELEVATION).scalar()
                self.assertEqual(2099, n_raw)
                n_fix = s.query(count(StatisticJournalFloat.id)). \
                    join(StatisticName). \
                    filter(StatisticName.name == N.ELEVATION).scalar()
                self.assertEqual(2099, n_fix)
                # WHY does this jump around?
                n = s.query(count(StatisticJournal.id)).scalar()
                # self.assertEqual(50403, n)
                self.assertTrue(n > 30000)
                self.assertTrue(n < 100000)
                journal = s.query(ActivityJournal).one()
                self.assertNotEqual(journal.start, journal.finish)