Open stephenholleran opened 1 year ago
@dancasey-ie, @shwetajoshi601 what is URL that I should use to pull the cleaning logs for a particular measurement station?
Suggested code:
import requests
import pandas as pd
from io import StringIO
import numpy as np
def get_cleaning_log(measurement_station_uuid):
"""
Get the cleaning log from BrightHub for a particular measurement station.
:param measurement_station_uuid: A specific measurement station's uuid.
:type measurement_station_uuid: str
:return: The cleaning logs for the measurement station.
:rtype: pd.DataFrame
"""
response = bw.LoadBrightHub._brighthub_request(url_end="/measurement-locations/{}/cleaning-log"
.format(measurement_station_uuid))
response_json = response.json()
if 'Error' in response_json: # catch if error comes back e.g. measurement_location_uuid isn't found
raise ValueError(response_json['Error'])
pre_signed_url = response_json["url"]
cleaning_log_response = requests.get(pre_signed_url)
return pd.read_csv(StringIO(cleaning_log_response.text,))
The BrightHub wind resource data management platform is opening up a new API to allow users to pull the cleaning logs for a particular measurement station. Without this new function, a user would have to log into BrightHub and manually download the cleaning log file and then load that file into the brightwind library.
I expect the new function would look something like the below:
And be used this way:
The new URL is yet to be released.