! The MIT License (MIT) ! ! Copyright (c) 2023 Vincent Magnin, gha3mi ! ! Permission is hereby granted, free of charge, to any person obtaining a copy ! of this software and associated documentation files (the "Software"), to deal ! in the Software without restriction, including without limitation the rights ! to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ! copies of the Software, and to permit persons to whom the Software is ! furnished to do so, subject to the following conditions: ! ! The above copyright notice and this permission notice shall be included in all ! copies or substantial portions of the Software. ! ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ! SOFTWARE. !------------------------------------------------------------------------------- ! Contributed by vmagnin: 2023-09-26 ! Last modifications: gha3mi 2024-01-06, vmagnin 2024-05-09 !------------------------------------------------------------------------------- !> This module contains miscellaneous colormaps, especially black body andf cubehelix. module miscellaneous_colormaps use colormap_parameters, only: colormap_name_length, wp, pi implicit none private public :: fire_colormap, rainbow_colormap, & inv_rainbow_colormap, zebra_colormap, cubehelix_colormap character(*), dimension(6), parameter, public :: miscellaneous_colormaps_list = & [character(colormap_name_length) :: & "fire", "rainbow", "inv_rainbow", "zebra", "cubehelix", & "black_body"] integer, dimension(0:1023, 1:3), public :: black_body=reshape( [ & 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, 1, 0, & 3, 1, 1, 4, 1, 1, 5, 1, 1, 6, 2, 1, & 7, 2, 1, 7, 2, 1, 8, 2, 1, 9, 3, 1, & 10, 3, 2, 11, 3, 2, 12, 3, 2, 12, 4, 2, & 13, 4, 2, 14, 4, 2, 14, 4, 2, 15, 5, 3, & 16, 5, 3, 16, 5, 3, 17, 5, 3, 17, 5, 3, & 18, 6, 3, 19, 6, 3, 19, 6, 3, 20, 6, 4, & 20, 7, 4, 21, 7, 4, 21, 7, 4, 22, 7, 4, & 22, 8, 4, 23, 8, 4, 23, 8, 5, 23, 8, 5, & 24, 9, 5, 24, 9, 5, 25, 9, 5, 25, 9, 5, & 26, 10, 5, 26, 10, 5, 26, 10, 6, 27, 10, 6, & 27, 10, 6, 28, 11, 6, 28, 11, 6, 28, 11, 6, & 29, 11, 6, 29, 12, 7, 29, 12, 7, 30, 12, 7, & 30, 12, 7, 30, 12, 7, 31, 13, 7, 31, 13, 7, & 32, 13, 7, 32, 13, 8, 32, 13, 8, 33, 14, 8, & 33, 14, 8, 33, 14, 8, 33, 14, 8, 34, 14, 8, & 34, 15, 9, 34, 15, 9, 35, 15, 9, 35, 15, 9, & 35, 15, 9, 36, 15, 9, 36, 16, 9, 37, 16, 10, & 37, 16, 10, 37, 16, 10, 38, 16, 10, 38, 16, 10, & 38, 16, 10, 39, 17, 10, 39, 17, 10, 39, 17, 11, & 40, 17, 11, 40, 17, 11, 40, 17, 11, 41, 17, 11, & 41, 17, 11, 42, 17, 11, 42, 17, 12, 42, 18, 12, & 43, 18, 12, 43, 18, 12, 43, 18, 12, 44, 18, 12, & 44, 18, 12, 45, 18, 12, 45, 18, 12, 45, 18, 13, & 46, 18, 13, 46, 18, 13, 47, 19, 13, 47, 19, 13, & 47, 19, 13, 48, 19, 13, 48, 19, 13, 48, 19, 14, & 49, 19, 14, 49, 19, 14, 50, 19, 14, 50, 19, 14, & 50, 19, 14, 51, 20, 14, 51, 20, 14, 52, 20, 14, & 52, 20, 14, 52, 20, 15, 53, 20, 15, 53, 20, 15, & 53, 20, 15, 54, 20, 15, 54, 20, 15, 55, 20, 15, & 55, 20, 15, 55, 21, 15, 56, 21, 15, 56, 21, 16, & 57, 21, 16, 57, 21, 16, 57, 21, 16, 58, 21, 16, & 58, 21, 16, 59, 21, 16, 59, 21, 16, 59, 21, 16, & 60, 21, 16, 60, 22, 16, 61, 22, 17, 61, 22, 17, & 61, 22, 17, 62, 22, 17, 62, 22, 17, 63, 22, 17, & 63, 22, 17, 63, 22, 17, 64, 22, 17, 64, 22, 17, & 65, 22, 17, 65, 23, 18, 65, 23, 18, 66, 23, 18, & 66, 23, 18, 67, 23, 18, 67, 23, 18, 67, 23, 18, & 68, 23, 18, 68, 23, 18, 69, 23, 18, 69, 23, 18, & 69, 23, 18, 70, 23, 18, 70, 24, 19, 71, 24, 19, & 71, 24, 19, 72, 24, 19, 72, 24, 19, 72, 24, 19, & 73, 24, 19, 73, 24, 19, 74, 24, 19, 74, 24, 19, & 74, 24, 19, 75, 24, 19, 75, 24, 19, 76, 24, 19, & 76, 25, 20, 76, 25, 20, 77, 25, 20, 77, 25, 20, & 78, 25, 20, 78, 25, 20, 79, 25, 20, 79, 25, 20, & 79, 25, 20, 80, 25, 20, 80, 25, 20, 81, 25, 20, & 81, 25, 20, 81, 25, 20, 82, 26, 20, 82, 26, 21, & 83, 26, 21, 83, 26, 21, 84, 26, 21, 84, 26, 21, & 84, 26, 21, 85, 26, 21, 85, 26, 21, 86, 26, 21, & 86, 26, 21, 87, 26, 21, 87, 26, 21, 87, 26, 21, & 88, 26, 21, 88, 26, 21, 89, 27, 21, 89, 27, 22, & 89, 27, 22, 90, 27, 22, 90, 27, 22, 91, 27, 22, & 91, 27, 22, 92, 27, 22, 92, 27, 22, 92, 27, 22, & 93, 27, 22, 93, 27, 22, 94, 27, 22, 94, 27, 22, & 95, 27, 22, 95, 27, 22, 95, 28, 22, 96, 28, 23, & 96, 28, 23, 97, 28, 23, 97, 28, 23, 98, 28, 23, & 98, 28, 23, 98, 28, 23, 99, 28, 23, 99, 28, 23, & 100, 28, 23, 100, 28, 23, 101, 28, 23, 101, 28, 23, & 101, 28, 23, 102, 28, 23, 102, 28, 23, 103, 29, 24, & 103, 29, 24, 104, 29, 24, 104, 29, 24, 105, 29, 24, & 105, 29, 24, 105, 29, 24, 106, 29, 24, 106, 29, 24, & 107, 29, 24, 107, 29, 24, 108, 29, 24, 108, 29, 24, & 108, 29, 24, 109, 29, 24, 109, 29, 24, 110, 29, 25, & 110, 29, 25, 111, 29, 25, 111, 30, 25, 112, 30, 25, & 112, 30, 25, 112, 30, 25, 113, 30, 25, 113, 30, 25, & 114, 30, 25, 114, 30, 25, 115, 30, 25, 115, 30, 25, & 115, 30, 25, 116, 30, 25, 116, 30, 26, 117, 30, 26, & 117, 30, 26, 118, 30, 26, 118, 30, 26, 119, 30, 26, & 119, 30, 26, 119, 30, 26, 120, 31, 26, 120, 31, 26, & 121, 31, 26, 121, 31, 26, 122, 31, 26, 122, 31, 26, & 123, 31, 26, 123, 31, 26, 123, 31, 27, 124, 31, 27, & 124, 31, 27, 125, 31, 27, 125, 31, 27, 126, 31, 27, & 126, 31, 27, 127, 31, 27, 127, 31, 27, 128, 31, 27, & 128, 31, 27, 128, 31, 27, 129, 31, 27, 129, 31, 27, & 130, 31, 27, 130, 31, 27, 131, 32, 28, 131, 32, 28, & 132, 32, 28, 132, 32, 28, 132, 32, 28, 133, 32, 28, & 133, 32, 28, 134, 32, 28, 134, 32, 28, 135, 32, 28, & 135, 32, 28, 136, 32, 28, 136, 32, 28, 137, 32, 28, & 137, 32, 28, 137, 32, 28, 138, 32, 29, 138, 32, 29, & 139, 32, 29, 139, 32, 29, 140, 32, 29, 140, 32, 29, & 141, 32, 29, 141, 32, 29, 142, 32, 29, 142, 32, 29, & 142, 32, 29, 143, 32, 29, 143, 33, 29, 144, 33, 29, & 144, 33, 29, 145, 33, 29, 145, 33, 30, 146, 33, 30, & 146, 33, 30, 147, 33, 30, 147, 33, 30, 148, 33, 30, & 148, 33, 30, 148, 33, 30, 149, 33, 30, 149, 33, 30, & 150, 33, 30, 150, 33, 30, 151, 33, 30, 151, 33, 30, & 152, 33, 30, 152, 33, 31, 153, 33, 31, 153, 33, 31, & 154, 33, 31, 154, 33, 31, 154, 33, 31, 155, 33, 31, & 155, 33, 31, 156, 33, 31, 156, 33, 31, 157, 33, 31, & 157, 33, 31, 158, 33, 31, 158, 33, 31, 159, 33, 31, & 159, 33, 31, 160, 33, 32, 160, 33, 32, 160, 33, 32, & 161, 33, 32, 161, 34, 32, 162, 34, 32, 162, 34, 32, & 163, 34, 32, 163, 34, 32, 164, 34, 32, 164, 34, 32, & 165, 34, 32, 165, 34, 32, 166, 34, 32, 166, 34, 32, & 167, 34, 32, 167, 34, 33, 168, 34, 33, 168, 34, 33, & 168, 34, 33, 169, 34, 33, 169, 34, 33, 170, 34, 33, & 170, 34, 33, 171, 34, 33, 171, 34, 33, 172, 34, 33, & 172, 34, 33, 173, 34, 33, 173, 34, 33, 174, 34, 33, & 174, 34, 33, 175, 34, 34, 175, 34, 34, 176, 34, 34, & 176, 34, 34, 176, 34, 34, 177, 34, 34, 177, 34, 34, & 178, 34, 34, 178, 34, 34, 178, 35, 34, 179, 35, 34, & 179, 36, 34, 179, 36, 34, 179, 37, 34, 180, 37, 34, & 180, 38, 34, 180, 38, 34, 180, 39, 33, 181, 39, 33, & 181, 40, 33, 181, 40, 33, 181, 40, 33, 182, 41, 33, & 182, 41, 33, 182, 42, 33, 182, 42, 33, 183, 43, 33, & 183, 43, 33, 183, 43, 33, 183, 44, 33, 184, 44, 33, & 184, 45, 33, 184, 45, 33, 184, 46, 33, 185, 46, 32, & 185, 46, 32, 185, 47, 32, 185, 47, 32, 186, 48, 32, & 186, 48, 32, 186, 48, 32, 186, 49, 32, 187, 49, 32, & 187, 50, 32, 187, 50, 32, 187, 50, 32, 188, 51, 32, & 188, 51, 32, 188, 52, 32, 188, 52, 31, 189, 52, 31, & 189, 53, 31, 189, 53, 31, 189, 53, 31, 190, 54, 31, & 190, 54, 31, 190, 55, 31, 190, 55, 31, 191, 55, 31, & 191, 56, 31, 191, 56, 31, 191, 57, 31, 192, 57, 30, & 192, 57, 30, 192, 58, 30, 192, 58, 30, 193, 58, 30, & 193, 59, 30, 193, 59, 30, 193, 59, 30, 194, 60, 30, & 194, 60, 30, 194, 61, 30, 194, 61, 30, 195, 61, 29, & 195, 62, 29, 195, 62, 29, 195, 62, 29, 196, 63, 29, & 196, 63, 29, 196, 63, 29, 196, 64, 29, 197, 64, 29, & 197, 65, 29, 197, 65, 29, 197, 65, 28, 198, 66, 28, & 198, 66, 28, 198, 66, 28, 198, 67, 28, 199, 67, 28, & 199, 67, 28, 199, 68, 28, 199, 68, 28, 200, 68, 28, & 200, 69, 27, 200, 69, 27, 200, 69, 27, 201, 70, 27, & 201, 70, 27, 201, 70, 27, 201, 71, 27, 202, 71, 27, & 202, 72, 27, 202, 72, 26, 202, 72, 26, 203, 73, 26, & 203, 73, 26, 203, 73, 26, 203, 74, 26, 204, 74, 26, & 204, 74, 26, 204, 75, 25, 204, 75, 25, 204, 75, 25, & 205, 76, 25, 205, 76, 25, 205, 76, 25, 205, 77, 25, & 206, 77, 25, 206, 77, 24, 206, 78, 24, 206, 78, 24, & 207, 78, 24, 207, 79, 24, 207, 79, 24, 207, 79, 24, & 208, 80, 24, 208, 80, 23, 208, 80, 23, 208, 81, 23, & 209, 81, 23, 209, 81, 23, 209, 82, 23, 209, 82, 23, & 210, 82, 22, 210, 83, 22, 210, 83, 22, 210, 83, 22, & 211, 84, 22, 211, 84, 22, 211, 84, 21, 211, 85, 21, & 212, 85, 21, 212, 85, 21, 212, 86, 21, 212, 86, 21, & 213, 86, 20, 213, 87, 20, 213, 87, 20, 213, 87, 20, & 214, 88, 20, 214, 88, 20, 214, 88, 19, 214, 89, 19, & 215, 89, 19, 215, 89, 19, 215, 90, 19, 215, 90, 18, & 216, 90, 18, 216, 91, 18, 216, 91, 18, 216, 91, 18, & 217, 92, 17, 217, 92, 17, 217, 92, 17, 217, 92, 17, & 218, 93, 16, 218, 93, 16, 218, 93, 16, 218, 94, 16, & 219, 94, 16, 219, 94, 15, 219, 95, 15, 219, 95, 15, & 220, 95, 15, 220, 96, 14, 220, 96, 14, 220, 96, 14, & 221, 97, 14, 221, 97, 13, 221, 97, 13, 221, 98, 13, & 222, 98, 12, 222, 98, 12, 222, 99, 12, 222, 99, 12, & 223, 99, 11, 223,100, 11, 223,100, 11, 223,100, 10, & 224,101, 10, 224,101, 10, 224,101, 9, 224,101, 9, & 225,102, 9, 225,102, 8, 225,102, 8, 225,103, 8, & 226,103, 7, 226,103, 7, 226,104, 6, 226,104, 6, & 226,104, 6, 227,105, 5, 227,105, 5, 227,105, 5, & 227,106, 5, 227,106, 5, 227,107, 6, 227,107, 6, & 227,108, 6, 227,108, 6, 227,109, 6, 228,109, 6, & 228,110, 6, 228,110, 6, 228,110, 7, 228,111, 7, & 228,111, 7, 228,112, 7, 228,112, 7, 228,113, 7, & 228,113, 7, 228,114, 8, 228,114, 8, 228,114, 8, & 228,115, 8, 228,115, 8, 228,116, 8, 228,116, 9, & 228,117, 9, 229,117, 9, 229,118, 9, 229,118, 9, & 229,118, 9, 229,119, 9, 229,119, 10, 229,120, 10, & 229,120, 10, 229,121, 10, 229,121, 10, 229,122, 10, & 229,122, 11, 229,122, 11, 229,123, 11, 229,123, 11, & 229,124, 11, 229,124, 11, 229,125, 12, 229,125, 12, & 229,125, 12, 230,126, 12, 230,126, 12, 230,127, 12, & 230,127, 13, 230,128, 13, 230,128, 13, 230,128, 13, & 230,129, 13, 230,129, 13, 230,130, 14, 230,130, 14, & 230,130, 14, 230,131, 14, 230,131, 14, 230,132, 14, & 230,132, 15, 230,133, 15, 230,133, 15, 230,133, 15, & 230,134, 15, 230,134, 15, 230,135, 16, 230,135, 16, & 231,136, 16, 231,136, 16, 231,136, 16, 231,137, 16, & 231,137, 16, 231,138, 17, 231,138, 17, 231,138, 17, & 231,139, 17, 231,139, 17, 231,140, 17, 231,140, 18, & 231,141, 18, 231,141, 18, 231,141, 18, 231,142, 18, & 231,142, 18, 231,143, 19, 231,143, 19, 231,143, 19, & 231,144, 19, 231,144, 19, 231,145, 19, 231,145, 19, & 231,145, 20, 231,146, 20, 231,146, 20, 231,147, 20, & 231,147, 20, 232,147, 20, 232,148, 21, 232,148, 21, & 232,149, 21, 232,149, 21, 232,150, 21, 232,150, 21, & 232,150, 21, 232,151, 22, 232,151, 22, 232,152, 22, & 232,152, 22, 232,152, 22, 232,153, 22, 232,153, 23, & 232,154, 23, 232,154, 23, 232,154, 23, 232,155, 23, & 232,155, 23, 232,156, 24, 232,156, 24, 232,156, 24, & 232,157, 24, 232,157, 24, 232,158, 24, 232,158, 24, & 232,158, 25, 232,159, 25, 232,159, 25, 232,160, 25, & 232,160, 25, 232,160, 25, 232,161, 26, 232,161, 26, & 232,162, 26, 232,162, 26, 232,162, 26, 232,163, 26, & 232,163, 26, 232,164, 27, 232,164, 27, 233,164, 27, & 233,165, 27, 233,165, 27, 233,166, 27, 233,166, 28, & 233,166, 28, 233,167, 28, 233,167, 28, 233,168, 28, & 233,168, 28, 233,168, 28, 233,169, 29, 233,169, 29, & 233,170, 29, 233,170, 29, 233,170, 29, 233,171, 29, & 233,171, 30, 233,172, 30, 233,172, 30, 233,172, 30, & 233,173, 30, 233,173, 30, 233,173, 30, 233,174, 31, & 233,174, 31, 233,175, 31, 233,175, 31, 233,175, 31, & 233,176, 31, 233,176, 32, 233,177, 32, 233,177, 32, & 233,177, 32, 233,178, 32, 233,178, 32, 233,179, 32, & 233,179, 33, 233,179, 33, 233,180, 33, 233,180, 33, & 233,181, 33, 233,181, 33, 233,181, 34, 233,182, 34, & 233,182, 34, 233,183, 34, 233,183, 34, 233,183, 34, & 233,184, 34, 233,184, 35, 233,184, 35, 233,185, 35, & 233,185, 35, 233,186, 35, 233,186, 35, 233,186, 36, & 233,187, 36, 233,187, 36, 233,188, 36, 233,188, 36, & 233,188, 36, 233,189, 36, 233,189, 37, 233,190, 37, & 233,190, 37, 233,190, 37, 233,191, 37, 233,191, 37, & 233,191, 38, 233,192, 38, 233,192, 38, 233,193, 38, & 233,193, 38, 233,193, 38, 233,194, 38, 233,194, 39, & 233,195, 39, 233,195, 39, 233,195, 39, 233,196, 39, & 233,196, 39, 233,197, 40, 233,197, 40, 233,197, 40, & 233,198, 40, 233,198, 40, 233,198, 40, 233,199, 40, & 233,199, 41, 233,200, 41, 233,200, 41, 233,200, 41, & 233,201, 41, 233,201, 41, 232,202, 42, 232,202, 42, & 232,202, 42, 232,203, 42, 232,203, 42, 232,203, 42, & 232,204, 42, 232,204, 43, 232,205, 43, 232,205, 43, & 232,205, 43, 232,206, 43, 232,206, 43, 232,207, 44, & 232,207, 44, 232,207, 44, 232,208, 44, 232,208, 44, & 232,208, 44, 232,209, 44, 232,209, 45, 232,210, 45, & 232,210, 45, 232,210, 45, 232,211, 45, 232,211, 45, & 232,212, 46, 232,212, 46, 232,212, 46, 232,213, 46, & 232,213, 46, 232,213, 46, 232,214, 46, 232,214, 47, & 232,215, 47, 232,215, 47, 232,215, 47, 232,216, 47, & 232,216, 47, 231,217, 48, 231,217, 48, 231,217, 48, & 231,218, 48, 231,218, 48, 231,218, 48, 231,219, 48, & 231,219, 49, 231,220, 49, 231,220, 49, 231,220, 49, & 231,221, 49, 231,221, 49, 231,222, 50, 231,222, 50, & 231,222, 50, 231,223, 50, 231,223, 50, 231,223, 50, & 231,224, 50, 231,224, 51, 231,225, 51, 231,225, 51, & 231,225, 51, 231,226, 51, 230,226, 51, 230,227, 52, & 230,227, 52, 230,227, 52, 230,228, 52, 230,228, 52, & 230,228, 52, 230,229, 53, 230,229, 53, 230,230, 53, & 230,230, 53, 230,230, 55, 231,230, 58, 231,231, 61, & 232,231, 63, 232,231, 66, 232,231, 68, 233,231, 70, & 233,232, 72, 233,232, 75, 234,232, 77, 234,232, 79, & 235,232, 81, 235,233, 83, 235,233, 85, 236,233, 87, & 236,233, 89, 236,233, 91, 237,234, 93, 237,234, 95, & 237,234, 97, 238,234, 99, 238,235,101, 238,235,103, & 239,235,104, 239,235,106, 239,235,108, 240,236,110, & 240,236,112, 240,236,114, 241,236,115, 241,236,117, & 241,237,119, 242,237,121, 242,237,122, 242,237,124, & 243,237,126, 243,238,128, 243,238,129, 243,238,131, & 244,238,133, 244,239,134, 244,239,136, 245,239,138, & 245,239,139, 245,239,141, 245,240,143, 246,240,145, & 246,240,146, 246,240,148, 246,240,150, 247,241,151, & 247,241,153, 247,241,155, 247,241,156, 248,242,158, & 248,242,159, 248,242,161, 248,242,163, 249,242,164, & 249,243,166, 249,243,168, 249,243,169, 249,243,171, & 250,243,173, 250,244,174, 250,244,176, 250,244,177, & 250,244,179, 251,245,181, 251,245,182, 251,245,184, & 251,245,186, 251,245,187, 251,246,189, 252,246,190, & 252,246,192, 252,246,194, 252,247,195, 252,247,197, & 252,247,199, 253,247,200, 253,247,202, 253,248,203, & 253,248,205, 253,248,207, 253,248,208, 253,249,210, & 253,249,211, 254,249,213, 254,249,215, 254,249,216, & 254,250,218, 254,250,219, 254,250,221, 254,250,223, & 254,251,224, 254,251,226, 254,251,228, 254,251,229, & 255,252,231, 255,252,232, 255,252,234, 255,252,236, & 255,252,237, 255,253,239, 255,253,240, 255,253,242, & 255,253,244, 255,254,245, 255,254,247, 255,254,249, & 255,254,250, 255,255,252, 255,255,253, 255,255,255 & ], shape(black_body), order=[2, 1] ) contains pure subroutine fire_colormap(levels, map) integer, intent(in) :: levels integer, dimension(:,:), allocatable, intent(out) :: map integer :: last, i ! Best with 256 levels but you can try other numbers: last = levels - 1 allocate(map(0:last, 1:3)) do concurrent (i = 0:last) map(i, 1) = nint(last * exp(-((last-i) / 200.0_wp)**7.0_wp)) map(i, 2) = nint(last * exp(-((last-i) / 120.0_wp)**1.8_wp)) map(i, 3) = nint(last * exp(-((last-i) / 40.0_wp)**0.7_wp)) end do end subroutine fire_colormap pure subroutine rainbow_colormap(map) integer, dimension(:,:), allocatable, intent(out) :: map integer :: levels, last, i ! The user can not choose the number of levels: levels = 256 last = levels - 1 allocate(map(0:last, 1:3)) ! We add three gaussians (red, green, blue): do concurrent (i = 0:last) map(i, 1) = nint(last * exp(-((206-i) / 70.0_wp)**2.0_wp)) map(i, 2) = nint(last * exp(-((156-i) / 70.0_wp)**2.0_wp)) map(i, 3) = nint(last * exp(-((106-i) / 70.0_wp)**2.0_wp)) end do end subroutine rainbow_colormap pure subroutine inv_rainbow_colormap(map) integer, dimension(:,:), allocatable, intent(out) :: map integer :: levels, last, i ! The user can not choose the number of levels: levels = 256 last = levels - 1 allocate(map(0:last, 1:3)) ! We add three gaussians (red, green, blue): do concurrent (i = 0:last) map(i, 1) = nint(last * exp(-((106-i) / 70.0_wp)**2.0_wp)) map(i, 2) = nint(last * exp(-((156-i) / 70.0_wp)**2.0_wp)) map(i, 3) = nint(last * exp(-((206-i) / 70.0_wp)**2.0_wp)) end do end subroutine inv_rainbow_colormap pure subroutine zebra_colormap(map) integer, dimension(:,:), allocatable, intent(out) :: map integer :: levels, last, i ! The user can not choose the number of levels: levels = 256 last = levels - 1 allocate(map(0:last, 1:3)) ! Black and white zebras: do i = 0, 224, 32 map(i :i+15, :) = 0 map(i+16:i+31, :) = 255 end do end subroutine zebra_colormap !--------------------------------------------------------------------- !> This subroutine is based on the public domain FORTRAN 77 subroutine !> published by D.A. Green: !> Green, D. A., 2011, Bulletin of the Astronomical Society of India, !> Vol.39, p.289 !> For more information on the parameters of cubehelix, see his page: !> https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/ !--------------------------------------------------------------------- pure subroutine cubehelix_colormap(map, nlev, varargs) integer, dimension(:,:), allocatable, intent(out) :: map integer, intent(in) :: nlev real(wp), dimension(:), intent(in), optional :: varargs integer :: i real(wp) :: start, rots, hue, gamma real(wp) :: fract, angle, amp if (present(varargs)) then if (size(varargs) /= 4) error stop "ERROR: cubehelix varargs(:) must have 4 values" start = varargs(1) rots = varargs(2) hue = varargs(3) gamma = varargs(4) else ! Default values: start = 0.5_wp rots = -1.5_wp hue = 1.0_wp gamma = 1.0_wp end if allocate(map(0:nlev-1, 1:3)) do concurrent (i = 0:nlev-1) fract = real(i, kind=wp) / (nlev-1) angle = 2*pi * (start/3 + 1 + rots*fract) fract = fract ** gamma amp = hue * fract * (1-fract)/2 map(i, 1) = nint(255*(fract + amp*(-0.14861_wp*cos(angle) + 1.78277_wp*sin(angle)))) map(i, 2) = nint(255*(fract + amp*(-0.29227_wp*cos(angle) - 0.90649_wp*sin(angle)))) map(i, 3) = nint(255*(fract + amp*(+1.97294_wp*cos(angle)))) end do end subroutine cubehelix_colormap end module miscellaneous_colormaps