From 490cedc6b205e7b2dcedd6c4ed6d4c6bb65ae8bf Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Mon, 3 Jan 2022 20:22:10 -0800 Subject: [PATCH 1/4] Update noaa_forecast.py --- python_extras/noaa_forecast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_extras/noaa_forecast.py b/python_extras/noaa_forecast.py index 846d97bcb..306b30202 100644 --- a/python_extras/noaa_forecast.py +++ b/python_extras/noaa_forecast.py @@ -115,7 +115,7 @@ def getforecast(lat,lon): headers = {'User-agent' : user_agent} location = json.loads(requests.get(url,headers=headers).content.decode("utf-8")) - data = json.loads(requests.get(location["properties"]["forecast"],headers=headers).content.decode("utf-8")) + data = json.loads(requests.get(location["properties"]["forecastHourly"],headers=headers).content.decode("utf-8")) result = { "datetime" : [], "temperature[degF]" : [], From ff49e219c625b0c97ff37747f7cfb460708cc0f4 Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Tue, 4 Jan 2022 14:11:51 -0800 Subject: [PATCH 2/4] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ad1b45bd3..69f88fd47 100644 --- a/.gitignore +++ b/.gitignore @@ -178,3 +178,5 @@ gldcore/gridlabd.in geodata.conf gldcore/autotest/output.csv python_extras/example/output.csv +*.egg +gridlabd.egg-* From d0412b4b116f6b8a0d4933d682b3aee1685b407f Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Tue, 4 Jan 2022 14:11:59 -0800 Subject: [PATCH 3/4] Update noaa_forecast.py --- python_extras/noaa_forecast.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python_extras/noaa_forecast.py b/python_extras/noaa_forecast.py index 306b30202..2851b1025 100644 --- a/python_extras/noaa_forecast.py +++ b/python_extras/noaa_forecast.py @@ -146,10 +146,10 @@ def getforecast(lat,lon): df.index.name = "datetime" return df -def writeglm(data, glm=sys.stdout, name=None, csv="/dev/stdout",download_now=True): +def writeglm(data, glm=sys.stdout, name=None, csv=None,download_now=True): """Write weather object based on NOAA forecast""" if glm: - if csv == 'auto': + if csv == 'auto' or csv == None: if type(glm) is str: csv = glm.replace(".glm",".csv") else: @@ -172,7 +172,11 @@ def writeglm(data, glm=sys.stdout, name=None, csv="/dev/stdout",download_now=Tru glm.write("}\n") if download_now: data.to_csv(csv,header=False,float_format=float_format,date_format=date_format) - elif csv: + else: + if csv == None: + csv = "/dev/stdout" + elif csv == 'auto': + raise Exception("csv cannot be automatically named if GLM is not specified") data.to_csv(csv,header=True,float_format=float_format,date_format=date_format) if __name__ == "__main__": From a2d41885c1362d4031f8f952ff83016785935a35 Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Wed, 5 Jan 2022 13:57:36 -0800 Subject: [PATCH 4/4] Update noaa_forecast.py --- python_extras/noaa_forecast.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python_extras/noaa_forecast.py b/python_extras/noaa_forecast.py index 2851b1025..920ac1616 100644 --- a/python_extras/noaa_forecast.py +++ b/python_extras/noaa_forecast.py @@ -89,11 +89,11 @@ The following command downloads only the CSV data for a location: - bash$ gridlabd python -m noaa_forecast -p=45.62,-122.70 -c=test.csv + bash$ gridlabd noaa_forecast -p=45.62,-122.70 -c=test.csv The following command downloads the CSV data and creates a GLM file with the data linked and weather object named: - bash$ gridlabd python -m noaa_forecast -p=45.62,-122.70 -c=test.csv -n=test -g=test.glm + bash$ gridlabd noaa_forecast -p=45.62,-122.70 -c=test.csv -n=test -g=test.glm SEE ALSO