% Create a color for visualizing conductivity value inside a finite
% difference grid.
%
% Arguments:
% cond      value of the conductivity
% condmax   maximum of the conductivity scale
%
% Returns:
% color     RGB color as a three-vector with entries in range [0,1]
%
% Samuli Siltanen February 2025

function color = colorscale_cond(cond,condmax)

% Check validity of the request
if (cond<0)|(cond>condmax)
    error('Conductivity value must be non-negative and at most condmax')
end
if condmax<0
    error('Maximal conductivity condmax must be positive')
end

% Extreme colors
color_condmin = [.5 .6 .5]; % Color of minimal conductivity, i.e. zero
color_condmax = [.8 .9 .8]; % Color of maximal conductivity

% Calculate appropriate color
color = color_condmin + (cond/condmax)*(color_condmax-color_condmin);


