adding units

Former-commit-id: 2ee2db80b24ea29438b7bbafafa1c372e2464fcd
This commit is contained in:
Michael T. Kelbaugh
2020-03-19 15:50:17 -04:00
parent d5b17b7d2c
commit 8b2af7659c
7 changed files with 14 additions and 10 deletions

View File

@@ -4,21 +4,21 @@
"precipitation": {
"type": "object",
"properties":{
"data": {"type": "object"},
"data": {"type": "object", "unit": "mm"},
"granularity": {"type": "string", "value": "huc8"}
}
},
"evaporation": {
"type": "object",
"properties":{
"data": {"type": "object"},
"data": {"type": "object", "unit": "mm"},
"granularity": {"type": "string", "value": "latlon"}
}
},
"global_temp": {
"type": "object",
"properties":{
"data": {"type": "object"},
"data": {"type": "object", "unit": "\u00b0C"},
"granularity": {"type": "null"}
}
}

View File

@@ -4,7 +4,7 @@
"power_demand": {
"type": "object",
"properties":{
"data": {"type": "object"},
"data": {"type": "object", "unit": "MWh"},
"granularity": {"type": "string", "value": "county"}
}
}

View File

@@ -4,14 +4,14 @@
"co2": {
"type": "object",
"properties":{
"data": {"type": "object"},
"data": {"type": "object", "unit": "tons"},
"granularity": {"type": "string", "value": "nerc"}
}
},
"thermo_water": {
"type": "object",
"properties":{
"data": {"type": "object"},
"data": {"type": "object", "unit": "Mgal"},
"granularity": {"type": "string", "value": "nerc"}
}
}

View File

@@ -4,8 +4,8 @@
"water_demand": {
"type": "object",
"properties":{
"data": {"type": "object"},
"granularity": {"type": "string", "value": "state"}
"data": {"type": "object", "unit": "Mgal"},
"granularity": {"type": "string", "value": "county"}
}
}
},

View File

@@ -556,6 +556,7 @@ class OuterWrapper(ABC):
disagg_name=dagg,
)
message["payload"][item]["data"] = data
message["payload"][item]["unit"] = schema["properties"][item]["properties"]["data"].get("unit", "")
message["payload"][item]["granularity"] = dest_gran
except ValidationError:
@@ -673,6 +674,7 @@ class OuterWrapper(ABC):
disagg_name=dagg,
)
message["payload"][item]["data"] = data
message["payload"][item]["unit"] = schema["properties"][item]["properties"]["data"].get("unit", "")
message["payload"][item]["granularity"] = dest_gran
self.validated_schemas[name] = message["payload"]

View File

@@ -188,6 +188,7 @@
" print(f\"plotting {dataset} (granularity: {granularity})\")\n",
" instance_col_name = 'ID'\n",
" year = data['year']\n",
" unit = data['payload'][dataset]['unit']\n",
"\n",
" df[dataset] = pd.DataFrame.from_dict(\n",
" data['payload'][dataset]['data'],\n",
@@ -235,7 +236,7 @@
" )\n",
" \n",
" fig = figure(\n",
" title=f\"USA {dataset} ({year})\",\n",
" title=f\"{dataset} ({unit}, {year})\",\n",
" tools=TOOLS,\n",
" plot_width=plot_width,\n",
" plot_height=plot_height,\n",

View File

@@ -102,6 +102,7 @@ def plot_mongo_doc(
print(f"plotting {dataset} (granularity: {granularity})")
instance_col_name = "ID"
year = data["year"]
unit = data["payload"][dataset]["unit"]
df[dataset] = pd.DataFrame.from_dict(
data["payload"][dataset]["data"],
@@ -147,7 +148,7 @@ def plot_mongo_doc(
else ("(x, y)", "($x, $y)")
)
fig = figure(
title=f"USA {dataset} ({year})",
title=f"{dataset} ({unit}, {year})",
tools=TOOLS,
plot_width=plot_width,
plot_height=plot_height,