Return the color code for colorize based on the coolwarm color map
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | v | Value to map |
||
real(kind=wp), | intent(in), | dimension(2) | :: | r | Range over which to scale the colors |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
function colorMap(v,r) result(c)
!! Return the color code for colorize based on the coolwarm color map
real(wp),intent(in)::v
!! Value to map
real(wp),dimension(2),intent(in)::r
!! Range over which to scale the colors
integer,dimension(3)::c
integer::s
if(v<sum(r)/2.0_wp) then
s = nint((v-r(1))/(sum(r)/2.0_wp-r(1))*5.0_wp)
c = [s,s,5]
else
s = 5-nint((v-sum(r)/2.0_wp)/(r(2)-sum(r)/2.0_wp)*5.0_wp)
c = [5,s,s]
end if
end function colorMap