Ejemplo n.º 1
0
def site_graph_data(site_id):
    site = Site.get_by_key_name(site_id)
    if site is None:
        return Response(status = 404)

    day = date.today()
    if request.args.has_key('day'):
        p = request.args.get('day')
        day = parse_yyyy_mm_dd_date(p)

    # obs data first
    obs = ObservationTimestep.find_by_site_and_date(site, day)

    series = [make_series('Observation temperature &degC', obs, 'observation_datetime', 'temperature')]

    return json_response({'day': str(day), 'series': series})
Ejemplo n.º 2
0
def site_observations(site_id):
    site = Site.get_by_key_name(site_id)
    if site is None:
        return Response(status = 404)

    if request.args.has_key('day'):
        p = request.args.get('day')
        day = parse_yyyy_mm_dd_date(p)
    else:
        return Response("day query parameter is required",status = 400)

    observation_day = ObservationDay.get_by_key_name(make_key_name(site,day))

    if observation_day is None:
        return Response(status = 404)

    return json_response(observation_day)
Ejemplo n.º 3
0
def days(data):
    days = data["Location"]["Day"]
    for day in ensure_array(days):
        date = parse_yyyy_mm_dd_date(day["@date"])
        yield date, day
Ejemplo n.º 4
0
def days(data):
    days = data["Location"]["Day"]
    for day in ensure_array(days):
        date = parse_yyyy_mm_dd_date(day["@date"])
        yield date, day