pyronear / pyro-risks

Data science for wildfire risk forecasting and monitoring
https://pyronear.github.io/pyro-risks
Apache License 2.0
25 stars 8 forks source link

add : get_score(lat, lon) #79

Closed GHCamille closed 3 months ago

GHCamille commented 4 months ago

Add function to get the fwi score for a specific lat lon.

Acruve15 commented 4 months ago

Hey @GHCamille 👋🏼

I have an additional question. How is this function expected to be used? Will @MateoLostanlen add the pyro-risk repo to the app backend directly? Or something else (using the API for example)

Thx 😃

GHCamille commented 4 months ago

I'm not sure how @MateoLostanlen wants to use it ! @MateoLostanlen any ideas ?

MateoLostanlen commented 4 months ago

Hello @Acruve15 @GHCamille, Hi, there,

Sorry for the late reply, ideally the less you install on the pi the better. Especially since installing a whole repo for one request doesn't seem very adapted. The best thing would be to deploy a small api that the pi can easily call. Is that feasible for you? Do you need help ?

MateoLostanlen commented 4 months ago

smothing like this :

import requests

def get_risk_score(lat, lon):
    url = "https://example.com/risk_score"
    params = {
        'lat': lat,
        'lon': lon
    }

    try:
        response = requests.get(url, params=params)
        response.raise_for_status()  # Check if the request failed
        data = response.json()  # Assume the API returns a JSON response
        return data['risk_score']  # Assume the risk score is under the 'risk_score' key
    except requests.exceptions.RequestException as e:
        print(f"An error occurred: {e}")
        return None