function plot_isocurve(ctx, array, isolevel=0.5, line_params={}){
const w = ctx.canvas.width;
const h = ctx.canvas.height;
if(!("color" in line_params))
line_params.color = "red";
if(!("opacity" in line_params))
line_params.opacity = 1.0;
if(!("width" in line_params))
line_params.width = 1.0;
if(!("dash_pattern" in line_params))
line_params.dash_pattern = [];
const array_flat = flatten(array);
const contour_extractor = d3.contours().size([h, w]);
const contour_geo_path = contour_extractor.contour(array_flat, isolevel);
let color = d3.color(line_params.color);
color.opacity = line_params.opacity;
ctx.strokeStyle = color;
ctx.lineWidth = line_params.width;
ctx.setLineDash(line_params.dash_pattern);
const path = d3.geoPath().context(ctx);
ctx.beginPath();
path(contour_geo_path);
ctx.stroke();
return line_params;
}