Ejemplo n.º 1
0
 def test_slice(self):
     
     spt_df1 = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo1}, index=self.ix))
     spt_df1_s1 = spt_df1.slice(zeit.Time_Period(dt.datetime(2017, 07, 25, 20, 0, 11), dt.datetime(2017, 07, 25, 20, 0, 20)))
     self.assertEqual(list(spt_df1_s1.dataframe["id"]), [1,2,3,4,5])
     self.assertEqual(spt_df1_s1.dataframe["temp"]["a"], None)
     
     spt_df2 = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo2}))
     spt_df2_s1 = spt_df2.slice(zeit.Time_Period(dt.datetime(2017, 07, 25, 20, 0, 10), dt.datetime(2017, 07, 25, 20, 0, 20)))
     self.assertEqual(len(spt_df2_s1.dataframe), 2)
     self.assertEqual(spt_df2_s1.dataframe["geometry"][4].ts, zeit.Time_Period(dt.datetime(2017, 07, 25, 20, 0, 10), dt.datetime(2017, 07, 25, 20, 0, 20)))
Ejemplo n.º 2
0
 def test_interpolate(self):
     
     spt_df1 = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo1}, index=self.ix))
     spt_df1_t1 = spt_df1.interpolate(dt.datetime(2017, 07, 25, 20, 0, 5))
     self.assertEqual(list(spt_df1_t1.dataframe.temp), [20.7, 19.5, 21, 18.5, 18.3])
     
     spt_df2 = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo2}))
     spt_df2_t1 = spt_df2.interpolate(dt.datetime(2017, 07, 25, 20, 0, 5))
     self.assertEqual(list(spt_df2_t1.dataframe.temp), [19.5, 18.3])
     
     spt_df3 = aly.SPT_DataFrame(pd.DataFrame({"id":[1],
                                               "temp":[zeit.Moving_Object([zeit.TS_Object(20.7, dt.datetime(2017, 07, 25, 20, 0, 0)), zeit.TS_Object(22.1, dt.datetime(2017, 07, 25, 20, 0, 10))], self.ip1)],
                                               "geometry":self.geo3}, index=["a"]))
Ejemplo n.º 3
0
 def test_resampled_slice(self):
     
     spt_df1 = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo1}, index=self.ix))
     spt_df1_s1 = spt_df1.resampled_slice([dt.datetime(2017, 07, 25, 20, 0, 11), dt.datetime(2017, 07, 25, 20, 0, 14), dt.datetime(2017, 07, 25, 20, 0, 20)])
     self.assertEqual(spt_df1_s1.dataframe["temp"]["a"], None)
     self.assertEqual(len(spt_df1_s1.dataframe["temp"]["b"]), 3)
     self.assertEqual(spt_df1_s1.dataframe["temp"]["b"].start_time(), dt.datetime(2017, 07, 25, 20, 0, 11))
     
     spt_df2 = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo2}))
     spt_df2_s1 = spt_df2.resampled_slice([dt.datetime(2017, 07, 25, 20, 0, 10), dt.datetime(2017, 07, 25, 20, 0, 14), dt.datetime(2017, 07, 25, 20, 0, 16)])
     self.assertEqual(len(spt_df2_s1.dataframe), 2)
     self.assertEqual(spt_df2_s1.dataframe["geometry"][4].start_time(), dt.datetime(2017, 07, 25, 20, 0, 10))
     self.assertEqual(spt_df2_s1.dataframe["geometry"][4].end_time(), dt.datetime(2017, 07, 25, 20, 0, 16))
Ejemplo n.º 4
0
 def test_reproject(self):
      
     spt_df1 = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo1}, index=self.ix),crs=pyproj.Proj(init="epsg:4326"))
     spt_df1.reproject(pyproj.Proj(init="epsg:32631"))
     self.assertEqual(spt_df1.dataframe.geometry["a"], sg.Point(1096557.9347183318, 5347346.491066367))
      
     spt_df2 = aly.SPT_DataFrame(pd.DataFrame({"id":[1],
                                               "geometry": [mg.TS_Point(sg.Point(11, 48), dt.datetime(2017, 07, 25, 20, 0, 10), crs=pyproj.Proj(init="epsg:4326"))]}))
Ejemplo n.º 5
0
 def test_init(self):
     
     # test if TypeError is raised if dataframe is not of type pandas.DataFrame
     with self.assertRaises(TypeError):
         aly.SPT_DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo1})
     
     # test if ValueError is raised if 'geometry' not in dataframe.columns
     with self.assertRaises(ValueError):
         aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geo":self.geo1}))
         
     # test if TypeError is raised if crs is not of type pyproj.Proj
     with self.assertRaises(TypeError):
         aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo1}), crs=123)
         
     # test if TypeError is raised if geometry-column contains wrong type of objects
     with self.assertRaises(TypeError):
         aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.ix}))
         
     # test init
     spt_df = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo1}, index=self.ix))
     self.assertEqual(spt_df.crs, None)
Ejemplo n.º 6
0
 def test_geometry_type(self):
     
     spt_df = aly.SPT_DataFrame(pd.DataFrame({"id":self.id, "temp":self.temp, "geometry":self.geo1}))
     self.assertEqual(spt_df.geometry_type, sg.Point)