forcolormap Module

The Colormap class and the colormaps_list.


Uses

  • module~~forcolormap~~UsesGraph module~forcolormap forcolormap module~forcolormap_cm_matplotlib forcolormap_cm_matplotlib module~forcolormap->module~forcolormap_cm_matplotlib module~forcolormap_cm_miscellaneous forcolormap_cm_miscellaneous module~forcolormap->module~forcolormap_cm_miscellaneous module~forcolormap_cm_scientific forcolormap_cm_scientific module~forcolormap->module~forcolormap_cm_scientific module~forcolormap_info forcolormap_info module~forcolormap->module~forcolormap_info module~forcolormap_parameters forcolormap_parameters module~forcolormap->module~forcolormap_parameters module~forcolormap_utils forcolormap_utils module~forcolormap->module~forcolormap_utils module~forcolormap_cm_matplotlib->module~forcolormap_parameters module~forcolormap_cm_miscellaneous->module~forcolormap_parameters module~forcolormap_cm_scientific->module~forcolormap_parameters module~forcolormap_info->module~forcolormap_cm_matplotlib module~forcolormap_info->module~forcolormap_cm_miscellaneous module~forcolormap_info->module~forcolormap_cm_scientific module~forcolormap_info->module~forcolormap_parameters iso_fortran_env iso_fortran_env module~forcolormap_parameters->iso_fortran_env module~forcolormap_utils->module~forcolormap_parameters

Used by

  • module~~forcolormap~~UsedByGraph module~forcolormap forcolormap proc~test_038 test_038 proc~test_038->module~forcolormap proc~test_039 test_039 proc~test_039->module~forcolormap proc~test_040 test_040 proc~test_040->module~forcolormap proc~test_041 test_041 proc~test_041->module~forcolormap proc~test_042 test_042 proc~test_042->module~forcolormap proc~test_043 test_043 proc~test_043->module~forcolormap proc~test_044 test_044 proc~test_044->module~forcolormap proc~test_045 test_045 proc~test_045->module~forcolormap proc~test_046 test_046 proc~test_046->module~forcolormap proc~test_047 test_047 proc~test_047->module~forcolormap proc~test_048 test_048 proc~test_048->module~forcolormap proc~test_049 test_049 proc~test_049->module~forcolormap proc~test_051 test_051 proc~test_051->module~forcolormap proc~test_052 test_052 proc~test_052->module~forcolormap proc~test_053 test_053 proc~test_053->module~forcolormap proc~test_054 test_054 proc~test_054->module~forcolormap proc~test_055 test_055 proc~test_055->module~forcolormap proc~test_056 test_056 proc~test_056->module~forcolormap proc~test_057 test_057 proc~test_057->module~forcolormap proc~test_058 test_058 proc~test_058->module~forcolormap proc~test_059 test_059 proc~test_059->module~forcolormap proc~test_060 test_060 proc~test_060->module~forcolormap proc~test_061 test_061 proc~test_061->module~forcolormap proc~test_062 test_062 proc~test_062->module~forcolormap proc~test_063 test_063 proc~test_063->module~forcolormap proc~test_064 test_064 proc~test_064->module~forcolormap proc~test_065 test_065 proc~test_065->module~forcolormap proc~test_066 test_066 proc~test_066->module~forcolormap proc~test_067 test_067 proc~test_067->module~forcolormap proc~test_068 test_068 proc~test_068->module~forcolormap proc~test_069 test_069 proc~test_069->module~forcolormap proc~test_070 test_070 proc~test_070->module~forcolormap proc~test_071 test_071 proc~test_071->module~forcolormap proc~test_072 test_072 proc~test_072->module~forcolormap proc~test_073 test_073 proc~test_073->module~forcolormap proc~test_074 test_074 proc~test_074->module~forcolormap proc~test_075 test_075 proc~test_075->module~forcolormap proc~test_076 test_076 proc~test_076->module~forcolormap proc~test_077 test_077 proc~test_077->module~forcolormap proc~test_078 test_078 proc~test_078->module~forcolormap proc~test_079 test_079 proc~test_079->module~forcolormap proc~test_080 test_080 proc~test_080->module~forcolormap proc~test_081 test_081 proc~test_081->module~forcolormap proc~test_082 test_082 proc~test_082->module~forcolormap proc~test_083 test_083 proc~test_083->module~forcolormap proc~test_084 test_084 proc~test_084->module~forcolormap proc~test_085 test_085 proc~test_085->module~forcolormap proc~zfun_1d zfun_1d proc~zfun_1d->module~forcolormap proc~zfun_2d zfun_2d proc~zfun_2d->module~forcolormap program~colormaps_list colormaps_list program~colormaps_list->module~forcolormap program~create create program~create->module~forcolormap program~demo demo program~demo->module~forcolormap program~demo_reverse demo_reverse program~demo_reverse->module~forcolormap program~example1 example1 program~example1->module~forcolormap program~extract extract program~extract->module~forcolormap program~modify modify program~modify->module~forcolormap program~write_info write_info program~write_info->module~forcolormap

Abstract Interfaces

abstract interface

  • private pure function zf1d(x) result(z)

    An interface for passing a 1D function

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(in) :: x

    Return Value real(kind=wp)

abstract interface

  • private pure function zf2d(x, y) result(z)

    An interface for passing a 2D function

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(in) :: y

    Return Value real(kind=wp)


Derived Types

type, public ::  Colormap

The Colormap class (attributes are encapsulated):

Components

Type Visibility Attributes Name Initial
integer, private :: levels
integer, private, allocatable :: map(:,:)
character(len=colormap_name_length), private :: name
logical, private :: status(5) = .false.
real(kind=wp), private :: zmax
real(kind=wp), private :: zmin

Type-Bound Procedures

procedure, public :: blend
procedure, public :: colorbar => write_ppm_colorbar
procedure, public :: colorbar_ansi
generic, public :: colormap => write_ppm_colormap_1d, write_ppm_colormap_2d
procedure, public :: compute_RGB
procedure, public :: create
procedure, public :: create_bezier
procedure, public :: create_lagrange
procedure, public :: export_paraview_preset
procedure, public :: extract
procedure, public :: finalize
procedure, public :: get_RGB
procedure, public :: get_levels
procedure, public :: get_name
procedure, public :: get_zmax
procedure, public :: get_zmin
procedure, public :: load
procedure, public :: print
procedure, public :: print_status
procedure, public :: reverse
procedure, public :: set
procedure, public :: shift
procedure, private :: assign_map
procedure, private :: check
procedure, private :: write_ppm_colormap_1d
procedure, private :: write_ppm_colormap_2d

Functions

private pure function get_levels(self) result(levels)

Returns the number of levels in the colormap

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self

Return Value integer

private pure function get_name(self) result(name)

Returns the name of the colormap

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self

Return Value character(len=colormap_name_length)

private pure function get_zmax(self) result(zmax)

Returns the maximal value of the z range

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self

Return Value real(kind=wp)

private pure function get_zmin(self) result(zmin)

Returns the minimal value of the z range

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self

Return Value real(kind=wp)


Subroutines

private pure subroutine assign_map(self, map)

Assign a colormap from a given "map" array

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
integer, intent(in) :: map(:,:)

private pure subroutine blend(self, other, alpha, name)

Blend this colormap with another one: blend = (1-alpha)self + alphaother

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
type(Colormap), intent(in) :: other
real(kind=wp), intent(in) :: alpha
character(len=*), intent(in), optional :: name

private pure subroutine check(self, check_name, check_bounds, check_levels, check_extract, extractedLevels)

Check the validity of the colormap and fix it if necessary

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
logical, intent(in), optional :: check_name
logical, intent(in), optional :: check_bounds
logical, intent(in), optional :: check_levels
logical, intent(in), optional :: check_extract
integer, intent(in), optional :: extractedLevels

private impure subroutine colorbar_ansi(self, width)

Preview the colormap in a truecolor ANSI terminal. Optional width controls how many color blocks are printed.

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self
integer, intent(in), optional :: width

private pure subroutine compute_RGB(self, z, red, green, blue)

Compute the RGB values for a z real value

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self
real(kind=wp), intent(in) :: z
integer, intent(out) :: red
integer, intent(out) :: green
integer, intent(out) :: blue

private pure subroutine create(self, name, zmin, zmax, map, reverse, sanitize)

Create a custom colormap from a "map" array.

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
character(len=*), intent(in) :: name
real(kind=wp), intent(in) :: zmin
real(kind=wp), intent(in) :: zmax
integer, intent(in) :: map(:,:)
logical, intent(in), optional :: reverse
logical, intent(in), optional :: sanitize

private pure subroutine create_bezier(self, name, zmin, zmax, colors, levels, reverse, sanitize)

Create a custom colormap using Bezier interpolation:

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
character(len=*), intent(in) :: name
real(kind=wp), intent(in) :: zmin
real(kind=wp), intent(in) :: zmax
integer, intent(in) :: colors(:,:)
integer, intent(in) :: levels
logical, intent(in), optional :: reverse
logical, intent(in), optional :: sanitize

private pure subroutine create_lagrange(self, name, zmin, zmax, colors, levels, reverse, sanitize)

Create a custom colormap using Lagrange interpolation:

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
character(len=*), intent(in) :: name
real(kind=wp), intent(in) :: zmin
real(kind=wp), intent(in) :: zmax
integer, intent(in) :: colors(:,:)
integer, intent(in) :: levels
logical, intent(in), optional :: reverse
logical, intent(in), optional :: sanitize

private impure subroutine export_paraview_preset(self, filename)

Export the colormap as a Paraview preset file (.json)

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self
character(len=*), intent(in) :: filename

private pure subroutine extract(self, extractedLevels, name, zmin, zmax, reverse, sanitize)

Extracts colors from the colormap based on specified number of levels (extractedLevels).

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
integer, intent(in) :: extractedLevels
character(len=*), intent(in), optional :: name
real(kind=wp), intent(in), optional :: zmin
real(kind=wp), intent(in), optional :: zmax
logical, intent(in), optional :: reverse
logical, intent(in), optional :: sanitize

private pure subroutine finalize(self)

Finalize the colormap, deallocating the map array and resetting status.

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self

private pure subroutine get_RGB(self, level, red, green, blue)

Compute the RGB values directly from an integer level number

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self
integer, intent(in) :: level
integer, intent(out) :: red
integer, intent(out) :: green
integer, intent(out) :: blue

private impure subroutine load(self, filename, zmin, zmax, reverse, sanitize)

Load a .txt colormap with RGB integers separated by spaces on each line. Remark: if no path is indicated in filename, the .txt must be present at the root of the fpm project of the user.

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
character(len=*), intent(in) :: filename
real(kind=wp), intent(in) :: zmin
real(kind=wp), intent(in) :: zmax
logical, intent(in), optional :: reverse
logical, intent(in), optional :: sanitize

private impure subroutine print(self)

Useful for testing and debugging:

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self

private impure subroutine print_status(self)

Print error and fix messages for unvalid colormaps

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self

private pure subroutine reverse(self, name)

Reverse the colormap

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
character(len=*), intent(in), optional :: name

private pure subroutine set(self, name, zmin, zmax, levels, varargs, reverse, sanitize)

Choose a colormap and set its parameters

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
character(len=*), intent(in) :: name
real(kind=wp), intent(in) :: zmin
real(kind=wp), intent(in) :: zmax
integer, intent(in), optional :: levels
real(kind=wp), intent(in), optional :: varargs(:)
logical, intent(in), optional :: reverse
logical, intent(in), optional :: sanitize

private pure subroutine shift(self, sh)

Apply a circular shift to the colormap (left is +, right is -)

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(inout) :: self
integer, intent(in) :: sh

The shift

private impure subroutine write_ppm_colorbar(self, filename, width, height, encoding)

Writes the colorbar of the colormap in a PPM file

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self
character(len=*), intent(in) :: filename
integer, intent(in), optional :: width
integer, intent(in), optional :: height
character(len=*), intent(in), optional :: encoding

private impure subroutine write_ppm_colormap_1d(self, filename, zfun, xmin, xmax, width, height, encoding)

render a colormap defined by a 1D function into a PPM file

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self
character(len=*), intent(in) :: filename
procedure(zf1d) :: zfun
real(kind=wp), intent(in) :: xmin
real(kind=wp), intent(in) :: xmax
integer, intent(in), optional :: width
integer, intent(in), optional :: height
character(len=*), intent(in), optional :: encoding

private impure subroutine write_ppm_colormap_2d(self, filename, zfun, xmin, xmax, width, height, encoding)

render a colormap defined by a 2D function into a PPM file

Arguments

Type IntentOptional Attributes Name
class(Colormap), intent(in) :: self
character(len=*), intent(in) :: filename
procedure(zf2d) :: zfun
real(kind=wp), intent(in) :: xmin(2)
real(kind=wp), intent(in) :: xmax(2)
integer, intent(in), optional :: width
integer, intent(in), optional :: height
character(len=*), intent(in), optional :: encoding