diff --git a/README.md b/README.md index 61b7adda8e953e7ace732a161fd5a17ee6cac0eb..61787da8d19dcef7caf28955eb0854e9ab44be62 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 e0ce27e8da27acfd9551f3ae28df2961b5fb719b..16fed71ae8c1166443d526828e25b163d6d8073d 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 60df3fc6abed3dfee29ebb52b62d76d7e419f7be..ed6b5463d6b5b7c798a6e68f4794dfa56eb76114 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 415fe4fc6340df52841156cfa47f343e77589de7..ec86643c2fb03ed7ebd261a86c0e89d46e075516 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)