From efb2b2bee6b5d649005f804e6d21d686b4974a48 Mon Sep 17 00:00:00 2001
From: tuckersiegel <siegel.tucker@gmail.com>
Date: Mon, 22 Feb 2021 18:11:23 -0500
Subject: [PATCH] removal of leap days

---
 README.md         |  2 ++
 models/normals.js |  3 ---
 test_server.py    |  5 +++++
 to_mongo.py       | 17 +++++++++++++----
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 61b7add..61787da 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@
 
 There is a ~90gb folder of the data that is needed to be able to upload the data to mongodb. 
 
+IGNORES ALL LEAP DAYS
+
 Go to ```/docs``` to view the Swagger generated API docs, and to play around with the server
 
 The mongodb is hosted on mongodb atlas. PLEASE do not run ```python to_mongo.py``` or ```python pull_data.py``` without asking Tucker first. You need the data and will overwrite all data on the mongodb server.
diff --git a/models/normals.js b/models/normals.js
index e0ce27e..16fed71 100644
--- a/models/normals.js
+++ b/models/normals.js
@@ -26,9 +26,6 @@ var normalsSchema = mongoose.Schema({
     max_temps: {
         type: Array,
     },
-    normal: {
-        type: Boolean,
-    }
 });
 
 var Model = module.exports = mongoose.model('normals', normalsSchema, "normals");
diff --git a/test_server.py b/test_server.py
index 60df3fc..ed6b546 100644
--- a/test_server.py
+++ b/test_server.py
@@ -13,6 +13,11 @@ print (r.status_code)
 print (r.json())
 print (time.time() - t)
 print ()
+r = requests.post("http://localhost:4000/api/soybean/daily/2016", data=data)
+print (r.status_code)
+print (r.json())
+print (time.time() - t)
+print ()
 r = requests.post("http://localhost:4000/api/soybean/normal", data=data)
 print (r.status_code)
 print (r.json())
diff --git a/to_mongo.py b/to_mongo.py
index 415fe4f..ec86643 100644
--- a/to_mongo.py
+++ b/to_mongo.py
@@ -61,6 +61,19 @@ for year in years:
     tmins = data.tmin.data
     tmaxs = data.tmax.data 
 
+
+    if is_leap_year(year): # extra day in leap year screws everything up
+
+        tmin_1 = tmins[:59]
+        tmin_2 = tmins[60:]
+
+        tmax_1 = tmaxs[:59]
+        tmin_2 = tmaxs[60:]
+
+        tmins = np.concatenate([tmin_1, tmin_2], axis=0)
+        tmaxs = np.concatenate([tmax_1, tmin_2], axis=0)
+
+
     locs = []
 
     count = 0
@@ -92,7 +105,6 @@ for year in years:
         t["min_temps"] = list([float(a) for a in tmin_])
         t["max_temps"] = list([float(a) for a in tmax_])
         t["_id"] = _id
-        t["normal"] = False
      
         locs.append(t)
         
@@ -190,9 +202,6 @@ for i in tqdm.tqdm(x):
     t["min_temps"] = list([float(a) for a in tmin_])
     t["max_temps"] = list([float(a) for a in tmax_])
     t["_id"] = _id
-
-    t["normal"] = True
-
     
     locs.append(t)
     
-- 
GitLab