Skip to content

Commit

Permalink
Closes icenet-ai#2: Basic violations display
Browse files Browse the repository at this point in the history
  • Loading branch information
JimCircadian committed Sep 22, 2023
1 parent 5e6ab5a commit 2b7215f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
22 changes: 19 additions & 3 deletions icenet_app/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
from icenet_app.icenet import get_image_data
from icenet_app.utils import load_json, get_forecast_data, get_forecast_dates

# hover,undo,redo,
TOOLS = "crosshair,pan,wheel_zoom,zoom_in,zoom_out,box_zoom,reset,box_select,poly_select,lasso_select,examine,help"
# undo,redo,
TOOLS = "crosshair,pan,hover,wheel_zoom,zoom_in,zoom_out,box_zoom,reset," \
"box_select,poly_select,lasso_select,examine,help"

plots = Blueprint('plots', __name__, template_folder='templates')

Expand Down Expand Up @@ -72,6 +73,22 @@ def plot_trend_stddev():
title="Ensemble stddev change")


@plots.route("/violations")
def plot_violations():
inventory = get_forecast_data()
data = load_json("threshold_check.json",
icenet_data_inventory=inventory)[0]

years = list([int(k) for k in data.keys() if int(k) != 0])
values = list([int(v) for k, v in data.items() if int(k) != 0])

logging.info((years, values))
p = figure(height=400, width=700, tools=TOOLS,
title="SIC violations against previous years")
p.vbar(x=years, top=values, width=0.9)
return json.dumps(json_item(p))


@plots.route("/date_picker")
def date_picker():
inventory = get_forecast_data()
Expand Down Expand Up @@ -101,4 +118,3 @@ def line_plot(data, title):
p = figure(title=title, tools=TOOLS, width=500, height=300)
p.line(list(data.keys()), list(data.values()))
return json.dumps(json_item(p))

6 changes: 6 additions & 0 deletions icenet_app/templates/index.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<div id="plot_trend_stddev" class="bsk-col-12-md-6 bsk-docs-content-block"></div>
<div id="plot_sie_change" class="bsk-col-12-md-6 bsk-docs-content-block"></div>
</div>
<div class="bsk-row">
<div id="plot_violations" class="bsk-col-12-md-12 bsk-docs-content-block"></div>
</div>
{% else %}
<div class="bsk-row">
<div class="bsk-col-12-md-12 bsk-docs-content-block">
Expand Down Expand Up @@ -102,6 +105,9 @@
fetch('/plots/trend_stddev')
.then(function(response) { return response.json(); })
.then(function(item) { Bokeh.embed.embed_item(item, "plot_trend_stddev"); });
fetch('/plots/violations')
.then(function(response) { return response.json(); })
.then(function(item) { Bokeh.embed.embed_item(item, "plot_violations"); });
$("button#update_date_button").on("click", function() {
console.log(fc_image_cur_id);
Expand Down

0 comments on commit 2b7215f

Please sign in to comment.