Skip to content
Snippets Groups Projects
Commit 5d0a4602 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Adapted to localhost/REFERENCEM

parent eb858c85
Branches
Tags
No related merge requests found
......@@ -33,13 +33,13 @@ from dateutil import parser
weather_data_source_name = "LMT"
weather_data_source_uri = "https://lmt.nibio.no/services/rest/vips/getdata/forecastfallback?weatherStationId=%s&%s"
weather_param_string = "elementMeasurementTypes[]=TM&elementMeasurementTypes[]=RR&elementMeasurementTypes[]=BT&logInterval=1h&startDate=2016-03-01&startTime=00&endDate=2016-09-30&endTime=00&timeZone=Europe/Oslo"
weather_param_string = "elementMeasurementTypes[]=TM&logInterval=1d&startDate=2016-03-01&startTime=00&endDate=2016-09-30&endTime=00&timeZone=Europe/Oslo"
# Which VIPSCore system to connect to
core_server_uri = "https://coremanager.testvips.nibio.no"
core_server_uri = "http://localhost:8001"
# The unique identificator for the Apple Scab model
model_id = "APPLESCABM"
model_id = "REFERENCEM"
print("Downloading weather data from %s, please wait..." % weather_data_source_name)
weather_data_request = requests.get( weather_data_source_uri % ("5", weather_param_string))
......@@ -49,17 +49,13 @@ weather_data_request = requests.get( weather_data_source_uri % ("5", weather_par
#print(weather_data_request.text)
weather_data = weather_data_request.json()
print ("Sending request to VIPS, waiting for calculation results, please wait...")
print ("Sending request to VIPSCore-Python, waiting for calculation results, please wait...")
# Building the request with config values and weather data to send to VIPS
model_config = {
"loginInfo": {
"username": "testuser",
"password": "testpass"
},
"modelId": "APPLESCABM",
"modelId": "REFERENCEM",
"configParameters": {
"timeZone": "Europe/Oslo",
"startDateAscosporeMaturity": "2016-03-10", # APPLESCABM Specific configuration value
"sowingDate": "2016-03-10", # REFERENCEM Specific configuration value
"observations": weather_data
}
}
......@@ -71,11 +67,12 @@ for result in results:
# Create a Python timestamp from the JSON timestamp string
timestamp = parser.parse(result["validTimeStart"])
# Printing selected result parameters to stdout
#print(result)
allValues = json.loads(result["allValues"])
print ("%s: Ascospore maturation = %s, Accumulated Mills = %s, Warning status = %s" % (
print ("%s: Mean temp today = %s, Accumulated Day Degrees = %s, Warning status = %s" % (
datetime.strftime(timestamp, '%Y-%m-%dT%H:%M %Z'),
allValues["APPLESCABM.ASCMAT"],
allValues["APPLESCABM.ACCMILLS"],
allValues.get("TM"),
allValues.get("TMDD"),
result["warningStatus"]
)
)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment