coordinates2statistics returning weird mean temperature values for sub-zero temperature months

19 views
Skip to first unread message

Jake Gysland

unread,
Jun 17, 2015, 1:34:08 PM6/17/15
to dstk-...@googlegroups.com
So, Minnesota is cold during the winter months, but if you were to believe what coordinates2statistics is telling me, you'd think it was very, very hot.

Code in Python, pretty self-explanatory. What I'm seeing is odd temperatures during months that have mean temps below 0 Celsius.

In [1]: import pandas as pd

In [2]: from dstk import DSTK
 
In [3]: dstk = DSTK()

In [4]: points = [{'lat': 44.899813000000002, 'lon': -92.938633999999993}, {'lat': 44.726937999999997, 'lon': -93.150003999999996}, {'lat': 44.928581999999999, 'lon': -93.253738999999996}, {'lat': 45.040778000000003, 'lon': -93.199742999999998}, {'lat': 45.089854000000003, 'lon': -93.355270000000004}, {'lat': 46.83661, 'lon': -96.778188}, {'lat': 45.637742000000003, 'lon': -95.878079999999997}, {'lat': 44.930801000000002, 'lon': -93.074884999999995}, {'lat': 45.155304999999998, 'lon': -93.404616000000004}, {'lat': 46.737921999999998, 'lon': -92.210528999999994}, {'lat': 44.851410999999999, 'lon': -93.459175000000002}, {'lat': 44.904764, 'lon': -93.090863999999996}, {'lat': 44.789743999999999, 'lon': -92.798895000000002}, {'lat': 45.024510999999997, 'lon': -93.014259999999993}, {'lat': 46.738717999999999, 'lon': -92.209926999999993}, {'lat': 46.829337000000002, 'lon': -96.779167000000001}, {'lat': 44.886828000000001, 'lon': -93.314926}, {'lat': 44.924363999999997, 'lon': -93.516407000000001}, {'lat': 45.119869000000001, 'lon': -95.041657999999998}, {'lat': 45.009732, 'lon': -92.982157000000001}]
 
In [5]: temps = pd.DataFrame(columns=['lat', 'lon', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])

In [6]: for p in points:
   
...:         stats = dstk.coordinates2statistics([p['lat'], p['lon']])
   
...:         stats_temps = stats[0]['statistics']['mean_temperature']['value']
   
...:         newtemps = pd.Series(stats_temps, index=temps.columns[2:])
   
...:         newtemps['lat'] = p['lat']
   
...:         newtemps['lon'] = p['lon']
   
...:         temps = temps.append(newtemps, ignore_index=True)
   
...:    

In [7]: temps

Out[7]:  

          lat        lon  
Jan   Feb  Mar  Apr   May   Jun   Jul   Aug   Sep   Oct  Nov   Dec
0   44.899813 -92.938634 -10.9  -7.6 -0.8  7.7  14.7  19.8  22.6  20.9  15.9   9.6  0.8  -7.7
1   44.726938 -93.150004 -11.2  -7.8 -1.1  7.6  14.5  19.7  22.3  20.7  15.7   9.5  0.4  -7.9
2   44.928582 -93.253739 -10.7  -7.4 -0.9  7.7  14.8  19.9  22.6  21.1  15.8   9.6  0.6  -7.3
3   45.040778 -93.199743 -10.8  -7.5 -0.9  7.6  14.8  19.7  22.4  21.1  15.8   9.5  0.6  -7.6
4   45.089854 -93.355270 -11.0  -7.7 -1.1  7.5  14.7  19.7  22.4  20.9  15.6   9.3  0.4  -7.7
5   46.836610 -96.778188 -14.3 -10.5 -3.4  6.1  13.7  18.8  21.5  20.6  14.5   7.8 -2.2 -10.6
6   45.637742 -95.878080 -13.3  -9.6 -2.7  6.3  13.7  18.7  21.3  20.2  14.6   8.2 -1.4  -9.5
7   44.930801 -93.074885 -10.2  -6.9 -0.4  8.3  15.3  20.2  22.9  21.5  16.3  10.1  1.3  -6.9
8   45.155305 -93.404616 -11.2  -8.0 -1.2  7.4  14.6  19.6  22.2  20.7  15.4   9.1  0.3  -8.0
9   46.737922 -92.210529 -13.3 -10.1 -4.0  3.7   9.9  14.9  18.6  17.6  12.7   6.8 -1.8  -9.8
10  44.851411 -93.459175 -11.4  -8.0 -1.2  7.5  14.5  19.6  22.2  20.7  15.3   9.1  0.0  -8.0
11  44.904764 -93.090864 -10.9  -7.6 -1.0  7.6  14.7  19.7  22.4  21.0  15.8   9.5  0.7  -7.5
12  44.789744 -92.798895 -10.8  -7.5 -0.4  8.1  15.1  20.1  22.8  21.3  16.2   9.9  1.1  -7.5
13  45.024511 -93.014260 -10.7  -7.5 -0.8  7.7  14.8  19.8  22.6  21.1  15.8   9.7  0.8  -7.5
14  46.738718 -92.209927 -13.3 -10.1 -4.0  3.7   9.9  14.9  18.6  17.6  12.7   6.8 -1.8  -9.8
15  46.829337 -96.779167 -14.3 -10.5 -3.4  6.1  13.7  18.8  21.6  20.6  14.5   7.8 -2.2 -10.6
16  44.886828 -93.314926 -11.1  -7.7 -1.0  7.6  14.6  19.9  22.4  20.9  15.6   9.4  0.3  -7.5
17  44.924364 -93.516407 -11.2  -8.0 -1.2  7.4  14.5  19.7  22.2  20.7  15.3   9.1  0.1  -7.9
18  45.119869 -95.041658 -12.7  -9.2 -1.9  7.0  14.4  19.6  22.1  20.7  15.2   8.8 -0.6  -9.7
19  45.009732 -92.982157 -11.0  -7.6 -1.0  7.7  14.7  19.7  22.5  20.9  15.7   9.5  0.7  -7.8

Jake Gysland

unread,
Jun 17, 2015, 2:08:59 PM6/17/15
to dstk-...@googlegroups.com
Okay, this probably doesn't make sense—I encountered problems when running the error on the VM vagrant box version of dstk. Here's the output I get from that (with dstk = DSTK({'apiBase': 'http://127.0.0.1:8080'})):

          lat        lon     Jan     Feb     Mar  Apr   May   Jun   Jul   Aug   Sep   Oct     Nov     Dec
0   44.899813 -92.938634  6542.7  6546.0  6552.8  7.7  14.7  19.8  22.6  20.9  15.9   9.6     0.8  6545.9
1   44.726938 -93.150004  6542.4  6545.8  6552.5  7.6  14.5  19.7  22.3  20.7  15.7   9.5     0.4  6545.7
2   44.928582 -93.253739  6542.9  6546.2  6552.7  7.7  14.8  19.9  22.6  21.1  15.8   9.6     0.6  6546.3
3   45.040778 -93.199743  6542.8  6546.1  6552.7  7.6  14.8  19.7  22.4  21.1  15.8   9.5     0.6  6546.0
4   45.089854 -93.355270  6542.6  6545.9  6552.5  7.5  14.7  19.7  22.4  20.9  15.6   9.3     0.4  6545.9
5   46.836610 -96.778188  6539.3  6543.1  6550.2  6.1  13.7  18.8  21.5  20.6  14.5   7.8  6551.4  6543.0
6   45.637742 -95.878080  6540.3  6544.0  6550.9  6.3  13.7  18.7  21.3  20.2  14.6   8.2  6552.2  6544.1
7   44.930801 -93.074885  6543.4  6546.7  6553.2  8.3  15.3  20.2  22.9  21.5  16.3  10.1     1.3  6546.7
8   45.155305 -93.404616  6542.4  6545.6  6552.4  7.4  14.6  19.6  22.2  20.7  15.4   9.1     0.3  6545.6
9   46.737922 -92.210529  6540.3  6543.5  6549.6  3.7   9.9  14.9  18.6  17.6  12.7   6.8  6551.8  6543.8
10  44.851411 -93.459175  6542.2  6545.6  6552.4  7.5  14.5  19.6  22.2  20.7  15.3   9.1     0.0  6545.6
11  44.904764 -93.090864  6542.7  6546.0  6552.6  7.6  14.7  19.7  22.4  21.0  15.8   9.5     0.7  6546.1
12  44.789744 -92.798895  6542.8  6546.1  6553.2  8.1  15.1  20.1  22.8  21.3  16.2   9.9     1.1  6546.1
13  45.024511 -93.014260  6542.9  6546.1  6552.8  7.7  14.8  19.8  22.6  21.1  15.8   9.7     0.8  6546.1
14  46.738718 -92.209927  6540.3  6543.5  6549.6  3.7   9.9  14.9  18.6  17.6  12.7   6.8  6551.8  6543.8
15  46.829337 -96.779167  6539.3  6543.1  6550.2  6.1  13.7  18.8  21.6  20.6  14.5   7.8  6551.4  6543.0
16  44.886828 -93.314926  6542.5  6545.9  6552.6  7.6  14.6  19.9  22.4  20.9  15.6   9.4     0.3  6546.1
17  44.924364 -93.516407  6542.4  6545.6  6552.4  7.4  14.5  19.7  22.2  20.7  15.3   9.1     0.1  6545.7
18  45.119869 -95.041658  6540.9  6544.4  6551.7  7.0  14.4  19.6  22.1  20.7  15.2   8.8  6553.0  6543.9
19  45.009732 -92.982157  6542.6  6546.0  6552.6  7.7  14.7  19.7  22.5  20.9  15.7   9.5     0.7  6545.8

On Wednesday, June 17, 2015 at 12:34:08 PM UTC-5, Jake Gysland wrote:
So, Minnesota is cold during the winter months, but if you were to believe what coordinates2statistics is telling me, you'd think it was very, very hot.

Code in Python, pretty self-explanatory. What I'm seeing is odd temperatures during months that have mean temps below 0 Celsius.

In [1]: import pandas as pd

In [2]: from dstk import DSTK
 
In [3]: dstk = DSTK()

In [4]: points = [{'lat': 44.899813000000002, 'lon': -92.938633999999993}, {'lat': 44.726937999999997, 'lon': -93.150003999999996}, {'lat': 44.928581999999999, 'lon': -93.253738999999996}, {'lat': 45.040778000000003, 'lon': -93.199742999999998}, {'lat': 45.089854000000003, 'lon': -93.355270000000004}, {'lat': 46.83661, 'lon': -96.778188}, {'lat': 45.637742000000003, 'lon': -95.878079999999997}, {'lat': 44.930801000000002, 'lon': -93.074884999999995}, {'lat': 45.155304999999998, 'lon': -93.404616000000004}, {'lat': 46.737921999999998, 'lon': -92.210528999999994}, {'lat': 44.851410999999999, 'lon': -93.459175000000002}, {'lat': 44.904764, 'lon': -93.090863999999996}, {'lat': 44.789743999999999, 'lon': -92.798895000000002}, {'lat': 45.024510999999997, 'lon': -93.014259999999993}, {'lat': 46.738717999999999, 'lon': -92.209926999999993}, {'lat': 46.829337000000002, 'lon': -96.779167000000001}, {'lat': 44.886828000000001, 'lon': -93.314926}, {'lat': 44.924363999999997, 'lon': -93.516407000000001}, {'lat': 45.119869000000001, 'lon': -95.041657999999998}, {'lat': 45.009732, 'lon': -92.982157000000001}]
 
In [5]: temps = pd.DataFrame(columns=['lat', 'lon', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])

In [6]: for p in points:
   
...:         stats = dstk.coordinates2statistics([p['lat'], p['lon']])
   
...:         stats_temps = stats[0]['statistics']['mean_temperature']['value']
   
...:         newtemps = pd.Series(stats_temps, index=temps.columns[2:])
   
...:         newtemps['lat'] = p['lat']
   
...:         newtemps['lon'] = p['lon']
   
...:         temps = temps.append(newtemps, ignore_index=True)
   
...:    

In [7]: temps

Out[7]:  

          lat        lon  
Jan   Feb  Mar  Apr   May   Jun   Jul   Aug   Sep   Oct  Nov   Dec
0   44.899813 -92.938634 -10.9  -7.6 -0.8  7.7  14.7  19.8  22.6  20.9  15.9   9.6  0.8  -7.7
1   44.726938 -93.150004 -11.2  -7.8 -1.1  7.6  14.5  19.7  22.3  20.7  15.7   9.5  0.4  -7.9
2   44.928582 -93.253739 -10.7  -7.4 -0.9  7.7  
...
Reply all
Reply to author
Forward
0 new messages