From 865671b19a6c95af189c49665a598f77e2fc71b9 Mon Sep 17 00:00:00 2001 From: "Michael T. Kelbaugh" Date: Tue, 11 Feb 2020 10:03:43 -0500 Subject: [PATCH 1/2] updating latlon grid squares in the instance graph to have mongo-friendly formatting Former-commit-id: d46dc0c7daf9b66ba811b994fb50d407e7378f55 --- abstract-graph.geojson | 2 +- instance-graph.geojson.REMOVED.git-id | 2 +- models/examples/gfdl_cm3/schemas/output/gfdl_cm3.json | 4 ++-- models/examples/gfdl_cm3/src/climate_model.py | 5 +++-- models/examples/gfdl_cm3/src/inner_wrapper.py | 6 +++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/abstract-graph.geojson b/abstract-graph.geojson index 82afdb9..628f637 100644 --- a/abstract-graph.geojson +++ b/abstract-graph.geojson @@ -1 +1 @@ -{"directed": true, "multigraph": false, "graph": {}, "nodes": [{"id": "UnitedStates"}, {"id": "state"}, {"id": "county"}, {"id": "NERC"}, {"id": "HUC8"}, {"id": "climate"}, {"id": "NERC^state"}, {"id": "HUC8^state"}, {"id": "climate^state"}, {"id": "HUC8^NERC"}, {"id": "NERC^climate"}, {"id": "NERC^county"}, {"id": "HUC8^climate"}, {"id": "HUC8^county"}, {"id": "climate^county"}], "links": [{"source": "UnitedStates", "target": "state"}, {"source": "UnitedStates", "target": "NERC"}, {"source": "UnitedStates", "target": "HUC8"}, {"source": "UnitedStates", "target": "climate"}, {"source": "state", "target": "county"}, {"source": "state", "target": "NERC^state"}, {"source": "state", "target": "HUC8^state"}, {"source": "state", "target": "climate^state"}, {"source": "county", "target": "NERC^county"}, {"source": "county", "target": "HUC8^county"}, {"source": "county", "target": "climate^county"}, {"source": "NERC", "target": "NERC^state"}, {"source": "NERC", "target": "HUC8^NERC"}, {"source": "NERC", "target": "NERC^climate"}, {"source": "NERC", "target": "NERC^county"}, {"source": "HUC8", "target": "HUC8^state"}, {"source": "HUC8", "target": "HUC8^NERC"}, {"source": "HUC8", "target": "HUC8^climate"}, {"source": "HUC8", "target": "HUC8^county"}, {"source": "climate", "target": "climate^state"}, {"source": "climate", "target": "NERC^climate"}, {"source": "climate", "target": "HUC8^climate"}, {"source": "climate", "target": "climate^county"}, {"source": "NERC^state", "target": "NERC^county"}, {"source": "HUC8^state", "target": "HUC8^county"}, {"source": "climate^state", "target": "climate^county"}]} \ No newline at end of file +{"directed": true, "multigraph": false, "graph": {"id": "d26744a8-2dfd-4bae-8e14-221fb96fb92b", "projection": 3085, "granularities": ["UnitedStates", "state", "NERC", "HUC8", "latlon", "county"], "minimum_intersect_area": 1, "nodes": 35614, "links": 65720, "counts": {"UnitedStates": 1, "state": 49, "NERC": 22, "HUC8": 2118, "latlon": 209, "county": 3108, "UnitedStates^state": 0, "NERC^UnitedStates": 0, "HUC8^UnitedStates": 0, "UnitedStates^latlon": 0, "UnitedStates^county": 0, "NERC^state": 126, "HUC8^state": 2830, "latlon^state": 428, "county^state": 0, "HUC8^NERC": 2643, "NERC^latlon": 350, "NERC^county": 3219, "HUC8^latlon": 4016, "HUC8^county": 11700, "county^latlon": 4795}, "areas": {"UnitedStates": 7792222.205781722, "state": 7792129.761006697, "NERC": 7792222.20578146, "HUC8": 7790895.333544435, "latlon": 7792221.132959093, "county": 7792129.761006684, "UnitedStates^state": 0, "NERC^UnitedStates": 0, "HUC8^UnitedStates": 0, "UnitedStates^latlon": 0, "UnitedStates^county": 0, "NERC^state": 7792119.496465746, "HUC8^state": 7790787.976451337, "latlon^state": 7792125.899565454, "county^state": 0, "HUC8^NERC": 7790884.9456620645, "NERC^latlon": 7792219.4876443455, "NERC^county": 7791903.372250843, "HUC8^latlon": 7790880.130752959, "HUC8^county": 7790559.405443681, "county^latlon": 7792114.229985136}}, "nodes": [{"id": "UnitedStates"}, {"id": "state"}, {"id": "county"}, {"id": "NERC"}, {"id": "HUC8"}, {"id": "latlon"}, {"id": "NERC^state"}, {"id": "HUC8^state"}, {"id": "latlon^state"}, {"id": "HUC8^NERC"}, {"id": "NERC^latlon"}, {"id": "NERC^county"}, {"id": "HUC8^latlon"}, {"id": "HUC8^county"}, {"id": "county^latlon"}], "links": [{"source": "UnitedStates", "target": "state"}, {"source": "UnitedStates", "target": "NERC"}, {"source": "UnitedStates", "target": "HUC8"}, {"source": "UnitedStates", "target": "latlon"}, {"source": "state", "target": "county"}, {"source": "state", "target": "NERC^state"}, {"source": "state", "target": "HUC8^state"}, {"source": "state", "target": "latlon^state"}, {"source": "county", "target": "NERC^county"}, {"source": "county", "target": "HUC8^county"}, {"source": "county", "target": "county^latlon"}, {"source": "NERC", "target": "NERC^state"}, {"source": "NERC", "target": "HUC8^NERC"}, {"source": "NERC", "target": "NERC^latlon"}, {"source": "NERC", "target": "NERC^county"}, {"source": "HUC8", "target": "HUC8^state"}, {"source": "HUC8", "target": "HUC8^NERC"}, {"source": "HUC8", "target": "HUC8^latlon"}, {"source": "HUC8", "target": "HUC8^county"}, {"source": "latlon", "target": "latlon^state"}, {"source": "latlon", "target": "NERC^latlon"}, {"source": "latlon", "target": "HUC8^latlon"}, {"source": "latlon", "target": "county^latlon"}]} \ No newline at end of file diff --git a/instance-graph.geojson.REMOVED.git-id b/instance-graph.geojson.REMOVED.git-id index ec72fd1..a23ab06 100644 --- a/instance-graph.geojson.REMOVED.git-id +++ b/instance-graph.geojson.REMOVED.git-id @@ -1 +1 @@ -b9a4ec463f5fa11e23a0b0fd2f142ef913ba9860 \ No newline at end of file +0e80818e3e9aaf580248a07fd4eb12586301e5e9 \ No newline at end of file diff --git a/models/examples/gfdl_cm3/schemas/output/gfdl_cm3.json b/models/examples/gfdl_cm3/schemas/output/gfdl_cm3.json index 887a653..2716efd 100644 --- a/models/examples/gfdl_cm3/schemas/output/gfdl_cm3.json +++ b/models/examples/gfdl_cm3/schemas/output/gfdl_cm3.json @@ -5,14 +5,14 @@ "type": "object", "properties":{ "data": {"type": "object"}, - "granularity": {"type": "string", "value": "HUC8"} + "granularity": {"type": "string", "value": "latlon"} } }, "evaporation": { "type": "object", "properties":{ "data": {"type": "object"}, - "granularity": {"type": "string", "value": "HUC8"} + "granularity": {"type": "string", "value": "latlon"} } }, "global_temp": { diff --git a/models/examples/gfdl_cm3/src/climate_model.py b/models/examples/gfdl_cm3/src/climate_model.py index b243b82..fd0215e 100644 --- a/models/examples/gfdl_cm3/src/climate_model.py +++ b/models/examples/gfdl_cm3/src/climate_model.py @@ -41,10 +41,11 @@ def temp_inc(init_data, year): translated_ev = {} for lat, lat_values in single_year_US.items(): for lon, lon_values in lat_values.items(): + lat = float(lat) lon = float(lon) if lon < 0: lon += 180 - translated_pr["lat_" + str(lat) + "_lon_" + str(lon)] = lon_values[0] - translated_ev["lat_" + str(lat) + "_lon_" + str(lon)] = lon_values[1] + translated_pr[f"lat_{int(lat*100)}_lon_{int(lon*100)}"] = lon_values[0] + translated_ev[f"lat_{int(lat*100)}_lon_{int(lon*100)}"] = lon_values[1] return weighted_sum-273.15, translated_pr, translated_ev #single_year_US diff --git a/models/examples/gfdl_cm3/src/inner_wrapper.py b/models/examples/gfdl_cm3/src/inner_wrapper.py index c0e62e6..3a9f5b2 100644 --- a/models/examples/gfdl_cm3/src/inner_wrapper.py +++ b/models/examples/gfdl_cm3/src/inner_wrapper.py @@ -14,7 +14,7 @@ class InnerWrapper(OuterWrapper): def configure(self, **kwargs): self.raw_data = kwargs['rcp26data'] if 'rcp26data' in kwargs.keys(): - self.mean_temp, self.climate_data0, self.climate_data1 = temp_inc(self.raw_data, self.incstep) + self.global_temp, self.precipitation, self.evaporation = temp_inc(self.raw_data, self.incstep) else: print('rcp data not found') @@ -25,9 +25,9 @@ class InnerWrapper(OuterWrapper): {'global_temp': {'data': {'temp': self.global_temp}, 'granularity': 'global'}, 'precipitation': - {'data': self.precipitation, 'granularity': 'climate'}, + {'data': self.precipitation, 'granularity': 'latlon'}, 'evaporation': - {'data': self.evaporation, 'granularity': 'climate'} + {'data': self.evaporation, 'granularity': 'latlon'} } } return results From 7c1959f5e46cc0f1affa31ddba8e86f3e4d46770 Mon Sep 17 00:00:00 2001 From: "Michael T. Kelbaugh" Date: Tue, 11 Feb 2020 13:54:48 -0500 Subject: [PATCH 2/2] removing bokeh requirement Former-commit-id: 00a423d21ad64cdf2860eca606ec47aa1a6a2bcc --- models/examples/population/requirements.txt | 1 - models/examples/power_demand/requirements.txt | 1 - models/examples/power_supply/requirements.txt | 1 - models/examples/water_demand/requirements.txt | 1 - 4 files changed, 4 deletions(-) diff --git a/models/examples/population/requirements.txt b/models/examples/population/requirements.txt index 2a3fd7c..999667a 100644 --- a/models/examples/population/requirements.txt +++ b/models/examples/population/requirements.txt @@ -2,4 +2,3 @@ pandas numpy statsmodels scipy==1.2.1 -bokeh diff --git a/models/examples/power_demand/requirements.txt b/models/examples/power_demand/requirements.txt index 4d1e955..fb6c7ed 100644 --- a/models/examples/power_demand/requirements.txt +++ b/models/examples/power_demand/requirements.txt @@ -1,2 +1 @@ pandas -bokeh diff --git a/models/examples/power_supply/requirements.txt b/models/examples/power_supply/requirements.txt index 4d1e955..fb6c7ed 100644 --- a/models/examples/power_supply/requirements.txt +++ b/models/examples/power_supply/requirements.txt @@ -1,2 +1 @@ pandas -bokeh diff --git a/models/examples/water_demand/requirements.txt b/models/examples/water_demand/requirements.txt index 4d1e955..fb6c7ed 100644 --- a/models/examples/water_demand/requirements.txt +++ b/models/examples/water_demand/requirements.txt @@ -1,2 +1 @@ pandas -bokeh