# Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 2015 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
# 
#  ***************************** LICENSE END ************************************

lat = 51
lon = 1


fs = read("t2m_forecast_24.grib")
vals = nearest_gridpoint(fs, lat, lon)
print(vals)

date_list = valid_date(fs)
print(date_list)


time_series_fc = input_visualiser(
    input_x_type        : "date",
    input_y_values      : vals,
    input_date_x_values : date_list
    )

graph_fc = mgraph(
    graph_line_colour    : "sky",
    graph_line_thickness : 3
    )

#plot(time_series, graph_fc)


# -----------------------------------------------
# Now do everything again for the analysis data!
# Note that it would be better to do most of the
# work within a function which we could re-use.
# -----------------------------------------------

fs = read("t2m_analysis.grib")
vals = nearest_gridpoint(fs, lat, lon)
print(vals)

date_list = valid_date(fs)
print(date_list)


time_series_an = input_visualiser(
    input_x_type        : "date",
    input_y_values      : vals,
    input_date_x_values : date_list
    )

graph_an = mgraph(
    graph_line_colour    : "red",
    graph_line_thickness : 3
    )

plot(time_series_fc, graph_fc, time_series_an, graph_an)



