No more numpy
This commit is contained in:
		
							parent
							
								
									c55ab31671
								
							
						
					
					
						commit
						45e1340c35
					
				
					 4 changed files with 41 additions and 48 deletions
				
			
		|  | @ -19,8 +19,7 @@ Prerequisites | |||
| - SQLAlchemy (0.8.2) | ||||
| - psycopg2 (2.5.1) | ||||
| - flask-wtf (0.9.1) | ||||
| - numpy (1.7.1) | ||||
| - PostgreSQL | ||||
| - PostgreSQL (9.4+) | ||||
| 
 | ||||
| 
 | ||||
| Installation | ||||
|  |  | |||
|  | @ -14,37 +14,37 @@ | |||
|     <table class="table table-hover table-condensed table-bordered"> | ||||
|         <thead> | ||||
|             <tr> | ||||
|                 <th>Year<br> </th> | ||||
|                 <th>January<br>°C</th> | ||||
|                 <th>February<br>°C</th> | ||||
|                 <th>March<br>°C</th> | ||||
|                 <th>April<br>°C</th> | ||||
|                 <th>May<br>°C</th> | ||||
|                 <th>June<br>°C</th> | ||||
|                 <th>July<br>°C</th> | ||||
|                 <th>August<br>°C</th> | ||||
|                 <th>September<br>°C</th> | ||||
|                 <th>October<br>°C</th> | ||||
|                 <th>November<br>°C</th> | ||||
|                 <th>December<br>°C</th> | ||||
|                 <th class="col-md-1">Year<br> </th> | ||||
|                 <th class="col-md-1">January<br>°C</th> | ||||
|                 <th class="col-md-1">February<br>°C</th> | ||||
|                 <th class="col-md-1">March<br>°C</th> | ||||
|                 <th class="col-md-1">April<br>°C</th> | ||||
|                 <th class="col-md-1">May<br>°C</th> | ||||
|                 <th class="col-md-1">June<br>°C</th> | ||||
|                 <th class="col-md-1">July<br>°C</th> | ||||
|                 <th class="col-md-1">August<br>°C</th> | ||||
|                 <th class="col-md-1">September<br>°C</th> | ||||
|                 <th class="col-md-1">October<br>°C</th> | ||||
|                 <th class="col-md-1">November<br>°C</th> | ||||
|                 <th class="col-md-1">December<br>°C</th> | ||||
|             </tr> | ||||
|         </thead> | ||||
|         <tbody> | ||||
|            {% for temp in temps %} | ||||
|                 <tr> | ||||
|                     <td>{{ temp[0]|int }}</td> | ||||
|                     <td>{{ temp[1]|round(2) }}</td> | ||||
|                     <td>{{ temp[2]|round(2) }}</td> | ||||
|                     <td>{{ temp[3]|round(2) }}</td> | ||||
|                     <td>{{ temp[4]|round(2) }}</td> | ||||
|                     <td>{{ temp[5]|round(2) }}</td> | ||||
|                     <td>{{ temp[6]|round(2) }}</td> | ||||
|                     <td>{{ temp[7]|round(2) }}</td> | ||||
|                     <td>{{ temp[8]|round(2) }}</td> | ||||
|                     <td>{{ temp[9]|round(2) }}</td> | ||||
|                     <td>{{ temp[10]|round(2) }}</td> | ||||
|                     <td>{{ temp[11]|round(2) }}</td> | ||||
|                     <td>{{ temp[12]|round(2) }}</td> | ||||
|                     <td>{{ temp[0] }}</td> | ||||
|                     <td>{{ temp[1][0] }}</td> | ||||
|                     <td>{{ temp[1][1] }}</td> | ||||
|                     <td>{{ temp[1][2] }}</td> | ||||
|                     <td>{{ temp[1][3] }}</td> | ||||
|                     <td>{{ temp[1][4] }}</td> | ||||
|                     <td>{{ temp[1][5] }}</td> | ||||
|                     <td>{{ temp[1][6] }}</td> | ||||
|                     <td>{{ temp[1][7] }}</td> | ||||
|                     <td>{{ temp[1][8] }}</td> | ||||
|                     <td>{{ temp[1][9] }}</td> | ||||
|                     <td>{{ temp[1][10] }}</td> | ||||
|                     <td>{{ temp[1][11] }}</td> | ||||
|                 </tr> | ||||
|        {% endfor %} | ||||
|    </tbody> | ||||
|  |  | |||
|  | @ -1,5 +1,3 @@ | |||
| import numpy | ||||
| 
 | ||||
| from .models import DB | ||||
| 
 | ||||
| 
 | ||||
|  | @ -23,8 +21,7 @@ def avg_air_temp(temps): | |||
| 
 | ||||
| def ann_air_indices(temps): | ||||
|     ATI, AFI = 0.0, 0.0 | ||||
|     # TODO: drop numpy | ||||
|     indices = numpy.zeros((len(temps), 2), dtype='int') | ||||
|     indices = [[0 for x in range(2)] for y in range(len(temps))] | ||||
|     months = [0.0 for m in range(12)] | ||||
|     days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | ||||
|     i = 0 | ||||
|  | @ -39,25 +36,27 @@ def ann_air_indices(temps): | |||
|                 ATI = ATI + ind | ||||
|             else: | ||||
|                 AFI = AFI + ind | ||||
|         indices[i, 0], indices[i, 1] = int(ATI), int(AFI) | ||||
|         indices[i][0], indices[i][1] = int(ATI), int(AFI) | ||||
|         ATI, AFI = 0.0, 0.0 | ||||
|         i += 1 | ||||
|     return indices | ||||
| 
 | ||||
| 
 | ||||
| def avg_air_indices(indices): | ||||
|     # TODO: drop numpy | ||||
|     temp = numpy.average(indices, axis=0) | ||||
|     return (int(temp[0]), int(temp[1])) | ||||
|     year_counter, total_freezing, total_thawing = 0, 0, 0 | ||||
|     for index in indices: | ||||
|         total_thawing += index[0] | ||||
|         total_freezing += index[1] | ||||
|         year_counter += 1 | ||||
|     return (int(total_thawing / year_counter), int(total_freezing / year_counter)) | ||||
| 
 | ||||
| 
 | ||||
| def des_air_indices(indices): | ||||
|     if indices.shape[0] > 2: | ||||
|         # TODO: drop numpy | ||||
|         ati = numpy.sort(indices[:, 0]) | ||||
|         afi = numpy.sort(indices[:, 1]) | ||||
|         dti = (ati[-1] + ati[-2] + ati[-3]) / 3.0 | ||||
|         dfi = (afi[0] + afi[1] + afi[2]) / 3.0 | ||||
|     if len(indices) > 2: | ||||
|         ati = sorted(indices, key=lambda arr: arr[0]) | ||||
|         afi = sorted(indices, key=lambda arr: arr[1]) | ||||
|         dti = (ati[-1][0] + ati[-2][0] + ati[-3][0]) / 3.0 | ||||
|         dfi = (afi[0][1] + afi[1][1] + afi[2][1]) / 3.0 | ||||
|         return (int(dti), int(dfi)) | ||||
|     else: | ||||
|         return (None, None) | ||||
|  |  | |||
|  | @ -1,5 +1,3 @@ | |||
| from numpy import arange, hstack | ||||
| 
 | ||||
| from flask import session, render_template, request, redirect, url_for | ||||
| 
 | ||||
| from . import main | ||||
|  | @ -76,10 +74,7 @@ def details(): | |||
|     community_id = request.args.get('community_id', '') | ||||
|     minyear = request.args.get('minyear', '') | ||||
|     maxyear = request.args.get('maxyear', '') | ||||
|     temps = getTemps(datasets, community_id, minyear, maxyear) | ||||
|     years = arange(int(minyear), | ||||
|                    int(maxyear)+1).reshape(int(maxyear)-int(minyear) + 1, 1) | ||||
|     temps = hstack((years, temps)) | ||||
|     temps = getTemps(session) | ||||
|     return render_template('main/details.html', | ||||
|                            lat=request.args.get('lat', ''), | ||||
|                            lon=request.args.get('lon', ''), | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Matthew Dillon
						Matthew Dillon