text:
# This file contains the schemes derived from colorbrewer2.org.
# The contents of that file are covered under the Apache License 2.0, included
# in this distribution under data/.

loadcolorscheme(:PuRd_3, SA[
    RGB(0.906,0.882,0.937),
    RGB(0.788,0.58,0.78),
    RGB(0.867,0.11,0.467),
], "colorbrewer2", "sequential")

loadcolorscheme(:PuRd_4, SA[
    RGB(0.945,0.933,0.965),
    RGB(0.843,0.71,0.847),
    RGB(0.875,0.396,0.69),
    RGB(0.808,0.071,0.337),
], "colorbrewer2", "sequential")

loadcolorscheme(:PuRd_5, SA[
    RGB(0.945,0.933,0.965),
    RGB(0.843,0.71,0.847),
    RGB(0.875,0.396,0.69),
    RGB(0.867,0.11,0.467),
    RGB(0.596,0.0,0.263),
], "colorbrewer2", "sequential")

loadcolorscheme(:PuRd_6, SA[
    RGB(0.945,0.933,0.965),
    RGB(0.831,0.725,0.855),
    RGB(0.788,0.58,0.78),
    RGB(0.875,0.396,0.69),
    RGB(0.867,0.11,0.467),
    RGB(0.596,0.0,0.263),
], "colorbrewer2", "sequential")

loadcolorscheme(:PuRd_7, SA[
    RGB(0.945,0.933,0.965),
    RGB(0.831,0.725,0.855),
    RGB(0.788,0.58,0.78),
    RGB(0.875,0.396,0.69),
    RGB(0.906,0.161,0.541),
    RGB(0.808,0.071,0.337),
    RGB(0.569,0.0,0.247),
], "colorbrewer2", "sequential")

loadcolorscheme(:PuRd_8, SA[
    RGB(0.969,0.957,0.976),
    RGB(0.906,0.882,0.937),
    RGB(0.831,0.725,0.855),
    RGB(0.788,0.58,0.78),
    RGB(0.875,0.396,0.69),
    RGB(0.906,0.161,0.541),
    RGB(0.808,0.071,0.337),
    RGB(0.569,0.0,0.247),
], "colorbrewer2", "sequential")

loadcolorscheme(:PuRd_9, SA[
    RGB(0.969,0.957,0.976),
    RGB(0.906,0.882,0.937),
    RGB(0.831,0.725,0.855),
    RGB(0.788,0.58,0.78),
    RGB(0.875,0.396,0.69),
    RGB(0.906,0.161,0.541),
    RGB(0.808,0.071,0.337),
    RGB(0.596,0.0,0.263),
    RGB(0.404,0.0,0.122),
], "colorbrewer2", "sequential")

loadcolorscheme(:Purples_3, SA[
    RGB(0.937,0.929,0.961),
    RGB(0.737,0.741,0.863),
    RGB(0.459,0.42,0.694),
], "colorbrewer2", "")

loadcolorscheme(:Purples_4, SA[
    RGB(0.949,0.941,0.969),
    RGB(0.796,0.788,0.886),
    RGB(0.62,0.604,0.784),
    RGB(0.416,0.318,0.639),
], "colorbrewer2", "sequential, white to purple")

loadcolorscheme(:Purples_5, SA[
    RGB(0.949,0.941,0.969),
    RGB(0.796,0.788,0.886),
    RGB(0.62,0.604,0.784),
    RGB(0.459,0.42,0.694),
    RGB(0.329,0.153,0.561),
], "colorbrewer2", "sequential, white to purple")

loadcolorscheme(:Purples_6, SA[
    RGB(0.949,0.941,0.969),
    RGB(0.855,0.855,0.922),
    RGB(0.737,0.741,0.863),
    RGB(0.62,0.604,0.784),
    RGB(0.459,0.42,0.694),
    RGB(0.329,0.153,0.561),
], "colorbrewer2", "sequential, white to purple")

loadcolorscheme(:Purples_7, SA[
    RGB(0.949,0.941,0.969),
    RGB(0.855,0.855,0.922),
    RGB(0.737,0.741,0.863),
    RGB(0.62,0.604,0.784),
    RGB(0.502,0.49,0.729),
    RGB(0.416,0.318,0.639),
    RGB(0.29,0.078,0.525),
], "colorbrewer2", "sequential, white to purple")

loadcolorscheme(:Purples_8, SA[
    RGB(0.988,0.984,0.992),
    RGB(0.937,0.929,0.961),
    RGB(0.855,0.855,0.922),
    RGB(0.737,0.741,0.863),
    RGB(0.62,0.604,0.784),
    RGB(0.502,0.49,0.729),
    RGB(0.416,0.318,0.639),
    RGB(0.29,0.078,0.525),
], "colorbrewer2", "sequential, white to purple")

loadcolorscheme(:Purples_9, SA[
    RGB(0.988,0.984,0.992),
    RGB(0.937,0.929,0.961),
    RGB(0.855,0.855,0.922),
    RGB(0.737,0.741,0.863),
    RGB(0.62,0.604,0.784),
    RGB(0.502,0.49,0.729),
    RGB(0.416,0.318,0.639),
    RGB(0.329,0.153,0.561),
    RGB(0.247,0.0,0.49),
], "colorbrewer2", "sequential, white to purple")

loadcolorscheme(:Set1_3, SA[
    RGB(0.894,0.102,0.11),
    RGB(0.216,0.494,0.722),
    RGB(0.302,0.686,0.29),
], "colorbrewer2", "")

loadcolorscheme(:Set1_4, SA[
    RGB(0.894,0.102,0.11),
    RGB(0.216,0.494,0.722),
    RGB(0.302,0.686,0.29),
    RGB(0.596,0.306,0.639),
], "colorbrewer2", "")

loadcolorscheme(:Set1_5, SA[
    RGB(0.894,0.102,0.11),
    RGB(0.216,0.494,0.722),
    RGB(0.302,0.686,0.29),
    RGB(0.596,0.306,0.639),
    RGB(1.0,0.498,0.0),
], "colorbrewer2", "")

loadcolorscheme(:Set1_6, SA[
    RGB(0.894,0.102,0.11),
    RGB(0.216,0.494,0.722),
    RGB(0.302,0.686,0.29),
    RGB(0.596,0.306,0.639),
    RGB(1.0,0.498,0.0),
    RGB(1.0,1.0,0.2),
], "colorbrewer2", "")

loadcolorscheme(:Set1_7, SA[
    RGB(0.894,0.102,0.11),
    RGB(0.216,0.494,0.722),
    RGB(0.302,0.686,0.29),
    RGB(0.596,0.306,0.639),
    RGB(1.0,0.498,0.0),
    RGB(1.0,1.0,0.2),
    RGB(0.651,0.337,0.157),
], "colorbrewer2", "")

loadcolorscheme(:Set1_8, SA[
    RGB(0.894,0.102,0.11),
    RGB(0.216,0.494,0.722),
    RGB(0.302,0.686,0.29),
    RGB(0.596,0.306,0.639),
    RGB(1.0,0.498,0.0),
    RGB(1.0,1.0,0.2),
    RGB(0.651,0.337,0.157),
    RGB(0.969,0.506,0.749),
], "colorbrewer2", "")

loadcolorscheme(:Set1_9, SA[
    RGB(0.894,0.102,0.11),
    RGB(0.216,0.494,0.722),
    RGB(0.302,0.686,0.29),
    RGB(0.596,0.306,0.639),
    RGB(1.0,0.498,0.0),
    RGB(1.0,1.0,0.2),
    RGB(0.651,0.337,0.157),
    RGB(0.969,0.506,0.749),
    RGB(0.6,0.6,0.6),
], "colorbrewer2", "")

loadcolorscheme(:Greens_3, SA[
    RGB(0.898,0.961,0.878),
    RGB(0.631,0.851,0.608),
    RGB(0.192,0.639,0.329),
], "colorbrewer2", "")

loadcolorscheme(:Greens_4, SA[
    RGB(0.929,0.973,0.914),
    RGB(0.729,0.894,0.702),
    RGB(0.455,0.769,0.463),
    RGB(0.137,0.545,0.271),
], "colorbrewer2", "")

loadcolorscheme(:Greens_5, SA[
    RGB(0.929,0.973,0.914),
    RGB(0.729,0.894,0.702),
    RGB(0.455,0.769,0.463),
    RGB(0.192,0.639,0.329),
    RGB(0.0,0.427,0.173),
], "colorbrewer2", "")

loadcolorscheme(:Greens_6, SA[
    RGB(0.929,0.973,0.914),
    RGB(0.78,0.914,0.753),
    RGB(0.631,0.851,0.608),
    RGB(0.455,0.769,0.463),
    RGB(0.192,0.639,0.329),
    RGB(0.0,0.427,0.173),
], "colorbrewer2", "")

loadcolorscheme(:Greens_7, SA[
    RGB(0.929,0.973,0.914),
    RGB(0.78,0.914,0.753),
    RGB(0.631,0.851,0.608),
    RGB(0.455,0.769,0.463),
    RGB(0.255,0.671,0.365),
    RGB(0.137,0.545,0.271),
    RGB(0.0,0.353,0.196),
], "colorbrewer2", "")

loadcolorscheme(:Greens_8, SA[
    RGB(0.969,0.988,0.961),
    RGB(0.898,0.961,0.878),
    RGB(0.78,0.914,0.753),
    RGB(0.631,0.851,0.608),
    RGB(0.455,0.769,0.463),
    RGB(0.255,0.671,0.365),
    RGB(0.137,0.545,0.271),
    RGB(0.0,0.353,0.196),
], "colorbrewer2", "")

loadcolorscheme(:Greens_9, SA[
    RGB(0.969,0.988,0.961),
    RGB(0.898,0.961,0.878),
    RGB(0.78,0.914,0.753),
    RGB(0.631,0.851,0.608),
    RGB(0.455,0.769,0.463),
    RGB(0.255,0.671,0.365),
    RGB(0.137,0.545,0.271),
    RGB(0.0,0.427,0.173),
    RGB(0.0,0.267,0.106),
], "colorbrewer2", "")

loadcolorscheme(:YlOrRd_3, SA[
    RGB(1.0,0.929,0.627),
    RGB(0.996,0.698,0.298),
    RGB(0.941,0.231,0.125),
], "colorbrewer2", "white through yellow to red")

loadcolorscheme(:YlOrRd_4, SA[
    RGB(1.0,1.0,0.698),
    RGB(0.996,0.8,0.361),
    RGB(0.992,0.553,0.235),
    RGB(0.89,0.102,0.11),
], "colorbrewer2", "white through yellow to red")

loadcolorscheme(:YlOrRd_5, SA[
    RGB(1.0,1.0,0.698),
    RGB(0.996,0.8,0.361),
    RGB(0.992,0.553,0.235),
    RGB(0.941,0.231,0.125),
    RGB(0.741,0.0,0.149),
], "colorbrewer2", "white through yellow to red")

loadcolorscheme(:YlOrRd_6, SA[
    RGB(1.0,1.0,0.698),
    RGB(0.996,0.851,0.463),
    RGB(0.996,0.698,0.298),
    RGB(0.992,0.553,0.235),
    RGB(0.941,0.231,0.125),
    RGB(0.741,0.0,0.149),
], "colorbrewer2", "white through yellow to red")

loadcolorscheme(:YlOrRd_7, SA[
    RGB(1.0,1.0,0.698),
    RGB(0.996,0.851,0.463),
    RGB(0.996,0.698,0.298),
    RGB(0.992,0.553,0.235),
    RGB(0.988,0.306,0.165),
    RGB(0.89,0.102,0.11),
    RGB(0.694,0.0,0.149),
], "colorbrewer2", "white through yellow to red")

loadcolorscheme(:YlOrRd_8, SA[
    RGB(1.0,1.0,0.8),
    RGB(1.0,0.929,0.627),
    RGB(0.996,0.851,0.463),
    RGB(0.996,0.698,0.298),
    RGB(0.992,0.553,0.235),
    RGB(0.988,0.306,0.165),
    RGB(0.89,0.102,0.11),
    RGB(0.694,0.0,0.149),
], "colorbrewer2", "white through yellow to red")

loadcolorscheme(:YlOrRd_9, SA[
    RGB(1.0,1.0,0.8),
    RGB(1.0,0.929,0.627),
    RGB(0.996,0.851,0.463),
    RGB(0.996,0.698,0.298),
    RGB(0.992,0.553,0.235),
    RGB(0.988,0.306,0.165),
    RGB(0.89,0.102,0.11),
    RGB(0.741,0.0,0.149),
    RGB(0.502,0.0,0.149),
], "colorbrewer2", "white through yellow to red")

loadcolorscheme(:Pastel1_3, SA[
    RGB(0.984,0.706,0.682),
    RGB(0.702,0.804,0.89),
    RGB(0.8,0.922,0.773),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel1_4, SA[
    RGB(0.984,0.706,0.682),
    RGB(0.702,0.804,0.89),
    RGB(0.8,0.922,0.773),
    RGB(0.871,0.796,0.894),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel1_5, SA[
    RGB(0.984,0.706,0.682),
    RGB(0.702,0.804,0.89),
    RGB(0.8,0.922,0.773),
    RGB(0.871,0.796,0.894),
    RGB(0.996,0.851,0.651),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel1_6, SA[
    RGB(0.984,0.706,0.682),
    RGB(0.702,0.804,0.89),
    RGB(0.8,0.922,0.773),
    RGB(0.871,0.796,0.894),
    RGB(0.996,0.851,0.651),
    RGB(1.0,1.0,0.8),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel1_7, SA[
    RGB(0.984,0.706,0.682),
    RGB(0.702,0.804,0.89),
    RGB(0.8,0.922,0.773),
    RGB(0.871,0.796,0.894),
    RGB(0.996,0.851,0.651),
    RGB(1.0,1.0,0.8),
    RGB(0.898,0.847,0.741),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel1_8, SA[
    RGB(0.984,0.706,0.682),
    RGB(0.702,0.804,0.89),
    RGB(0.8,0.922,0.773),
    RGB(0.871,0.796,0.894),
    RGB(0.996,0.851,0.651),
    RGB(1.0,1.0,0.8),
    RGB(0.898,0.847,0.741),
    RGB(0.992,0.855,0.925),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel1_9, SA[
    RGB(0.984,0.706,0.682),
    RGB(0.702,0.804,0.89),
    RGB(0.8,0.922,0.773),
    RGB(0.871,0.796,0.894),
    RGB(0.996,0.851,0.651),
    RGB(1.0,1.0,0.8),
    RGB(0.898,0.847,0.741),
    RGB(0.992,0.855,0.925),
    RGB(0.949,0.949,0.949),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:RdYlBu_3, SA[
    RGB(0.988,0.553,0.349),
    RGB(1.0,1.0,0.749),
    RGB(0.569,0.749,0.859),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:RdYlBu_4, SA[
    RGB(0.843,0.098,0.11),
    RGB(0.992,0.682,0.38),
    RGB(0.671,0.851,0.914),
    RGB(0.173,0.482,0.714),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:RdYlBu_5, SA[
    RGB(0.843,0.098,0.11),
    RGB(0.992,0.682,0.38),
    RGB(1.0,1.0,0.749),
    RGB(0.671,0.851,0.914),
    RGB(0.173,0.482,0.714),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:RdYlBu_6, SA[
    RGB(0.843,0.188,0.153),
    RGB(0.988,0.553,0.349),
    RGB(0.996,0.878,0.565),
    RGB(0.878,0.953,0.973),
    RGB(0.569,0.749,0.859),
    RGB(0.271,0.459,0.706),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:RdYlBu_7, SA[
    RGB(0.843,0.188,0.153),
    RGB(0.988,0.553,0.349),
    RGB(0.996,0.878,0.565),
    RGB(1.0,1.0,0.749),
    RGB(0.878,0.953,0.973),
    RGB(0.569,0.749,0.859),
    RGB(0.271,0.459,0.706),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:RdYlBu_8, SA[
    RGB(0.843,0.188,0.153),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.565),
    RGB(0.878,0.953,0.973),
    RGB(0.671,0.851,0.914),
    RGB(0.455,0.678,0.82),
    RGB(0.271,0.459,0.706),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:RdYlBu_9, SA[
    RGB(0.843,0.188,0.153),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.565),
    RGB(1.0,1.0,0.749),
    RGB(0.878,0.953,0.973),
    RGB(0.671,0.851,0.914),
    RGB(0.455,0.678,0.82),
    RGB(0.271,0.459,0.706),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:RdYlBu_10, SA[
    RGB(0.647,0.0,0.149),
    RGB(0.843,0.188,0.153),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.565),
    RGB(0.878,0.953,0.973),
    RGB(0.671,0.851,0.914),
    RGB(0.455,0.678,0.82),
    RGB(0.271,0.459,0.706),
    RGB(0.192,0.212,0.584),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:RdYlBu_11, SA[
    RGB(0.647,0.0,0.149),
    RGB(0.843,0.188,0.153),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.565),
    RGB(1.0,1.0,0.749),
    RGB(0.878,0.953,0.973),
    RGB(0.671,0.851,0.914),
    RGB(0.455,0.678,0.82),
    RGB(0.271,0.459,0.706),
    RGB(0.192,0.212,0.584),
], "colorbrewer2", "red through yellow to blue")

loadcolorscheme(:YlGnBu_3, SA[
    RGB(0.929,0.973,0.694),
    RGB(0.498,0.804,0.733),
    RGB(0.173,0.498,0.722),
], "colorbrewer2", "")

loadcolorscheme(:YlGnBu_4, SA[
    RGB(1.0,1.0,0.8),
    RGB(0.631,0.855,0.706),
    RGB(0.255,0.714,0.769),
    RGB(0.133,0.369,0.659),
], "colorbrewer2", "")

loadcolorscheme(:YlGnBu_5, SA[
    RGB(1.0,1.0,0.8),
    RGB(0.631,0.855,0.706),
    RGB(0.255,0.714,0.769),
    RGB(0.173,0.498,0.722),
    RGB(0.145,0.204,0.58),
], "colorbrewer2", "")

loadcolorscheme(:YlGnBu_6, SA[
    RGB(1.0,1.0,0.8),
    RGB(0.78,0.914,0.706),
    RGB(0.498,0.804,0.733),
    RGB(0.255,0.714,0.769),
    RGB(0.173,0.498,0.722),
    RGB(0.145,0.204,0.58),
], "colorbrewer2", "")

loadcolorscheme(:YlGnBu_7, SA[
    RGB(1.0,1.0,0.8),
    RGB(0.78,0.914,0.706),
    RGB(0.498,0.804,0.733),
    RGB(0.255,0.714,0.769),
    RGB(0.114,0.569,0.753),
    RGB(0.133,0.369,0.659),
    RGB(0.047,0.173,0.518),
], "colorbrewer2", "")

loadcolorscheme(:YlGnBu_8, SA[
    RGB(1.0,1.0,0.851),
    RGB(0.929,0.973,0.694),
    RGB(0.78,0.914,0.706),
    RGB(0.498,0.804,0.733),
    RGB(0.255,0.714,0.769),
    RGB(0.114,0.569,0.753),
    RGB(0.133,0.369,0.659),
    RGB(0.047,0.173,0.518),
], "colorbrewer2", "")

loadcolorscheme(:YlGnBu_9, SA[
    RGB(1.0,1.0,0.851),
    RGB(0.929,0.973,0.694),
    RGB(0.78,0.914,0.706),
    RGB(0.498,0.804,0.733),
    RGB(0.255,0.714,0.769),
    RGB(0.114,0.569,0.753),
    RGB(0.133,0.369,0.659),
    RGB(0.145,0.204,0.58),
    RGB(0.031,0.114,0.345),
], "colorbrewer2", "")

loadcolorscheme(:Blues_3, SA[
    RGB(0.871,0.922,0.969),
    RGB(0.62,0.792,0.882),
    RGB(0.192,0.51,0.741),
], "colorbrewer2", "")

loadcolorscheme(:Blues_4, SA[
    RGB(0.937,0.953,1.0),
    RGB(0.741,0.843,0.906),
    RGB(0.42,0.682,0.839),
    RGB(0.129,0.443,0.71),
], "colorbrewer2", "")

loadcolorscheme(:Blues_5, SA[
    RGB(0.937,0.953,1.0),
    RGB(0.741,0.843,0.906),
    RGB(0.42,0.682,0.839),
    RGB(0.192,0.51,0.741),
    RGB(0.031,0.318,0.612),
], "colorbrewer2", "")

loadcolorscheme(:Blues_6, SA[
    RGB(0.937,0.953,1.0),
    RGB(0.776,0.859,0.937),
    RGB(0.62,0.792,0.882),
    RGB(0.42,0.682,0.839),
    RGB(0.192,0.51,0.741),
    RGB(0.031,0.318,0.612),
], "colorbrewer2", "")

loadcolorscheme(:Blues_7, SA[
    RGB(0.937,0.953,1.0),
    RGB(0.776,0.859,0.937),
    RGB(0.62,0.792,0.882),
    RGB(0.42,0.682,0.839),
    RGB(0.259,0.573,0.776),
    RGB(0.129,0.443,0.71),
    RGB(0.031,0.271,0.58),
], "colorbrewer2", "")

loadcolorscheme(:Blues_8, SA[
    RGB(0.969,0.984,1.0),
    RGB(0.871,0.922,0.969),
    RGB(0.776,0.859,0.937),
    RGB(0.62,0.792,0.882),
    RGB(0.42,0.682,0.839),
    RGB(0.259,0.573,0.776),
    RGB(0.129,0.443,0.71),
    RGB(0.031,0.271,0.58),
], "colorbrewer2", "")

loadcolorscheme(:Blues_9, SA[
    RGB(0.969,0.984,1.0),
    RGB(0.871,0.922,0.969),
    RGB(0.776,0.859,0.937),
    RGB(0.62,0.792,0.882),
    RGB(0.42,0.682,0.839),
    RGB(0.259,0.573,0.776),
    RGB(0.129,0.443,0.71),
    RGB(0.031,0.318,0.612),
    RGB(0.031,0.188,0.42),
], "colorbrewer2", "")

loadcolorscheme(:Set3_3, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
], "colorbrewer2", "")

loadcolorscheme(:Set3_4, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
], "colorbrewer2", "")

loadcolorscheme(:Set3_5, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
    RGB(0.502,0.694,0.827),
], "colorbrewer2", "")

loadcolorscheme(:Set3_6, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
    RGB(0.502,0.694,0.827),
    RGB(0.992,0.706,0.384),
], "colorbrewer2", "")

loadcolorscheme(:Set3_7, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
    RGB(0.502,0.694,0.827),
    RGB(0.992,0.706,0.384),
    RGB(0.702,0.871,0.412),
], "colorbrewer2", "")

loadcolorscheme(:Set3_8, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
    RGB(0.502,0.694,0.827),
    RGB(0.992,0.706,0.384),
    RGB(0.702,0.871,0.412),
    RGB(0.988,0.804,0.898),
], "colorbrewer2", "")

loadcolorscheme(:Set3_9, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
    RGB(0.502,0.694,0.827),
    RGB(0.992,0.706,0.384),
    RGB(0.702,0.871,0.412),
    RGB(0.988,0.804,0.898),
    RGB(0.851,0.851,0.851),
], "colorbrewer2", "")

loadcolorscheme(:Set3_10, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
    RGB(0.502,0.694,0.827),
    RGB(0.992,0.706,0.384),
    RGB(0.702,0.871,0.412),
    RGB(0.988,0.804,0.898),
    RGB(0.851,0.851,0.851),
    RGB(0.737,0.502,0.741),
], "colorbrewer2", "")

loadcolorscheme(:Set3_11, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
    RGB(0.502,0.694,0.827),
    RGB(0.992,0.706,0.384),
    RGB(0.702,0.871,0.412),
    RGB(0.988,0.804,0.898),
    RGB(0.851,0.851,0.851),
    RGB(0.737,0.502,0.741),
    RGB(0.8,0.922,0.773),
], "colorbrewer2", "")

loadcolorscheme(:Set3_12, SA[
    RGB(0.553,0.827,0.78),
    RGB(1.0,1.0,0.702),
    RGB(0.745,0.729,0.855),
    RGB(0.984,0.502,0.447),
    RGB(0.502,0.694,0.827),
    RGB(0.992,0.706,0.384),
    RGB(0.702,0.871,0.412),
    RGB(0.988,0.804,0.898),
    RGB(0.851,0.851,0.851),
    RGB(0.737,0.502,0.741),
    RGB(0.8,0.922,0.773),
    RGB(1.0,0.929,0.435),
], "colorbrewer2", "")

loadcolorscheme(:Reds_3, SA[
    RGB(0.996,0.878,0.824),
    RGB(0.988,0.573,0.447),
    RGB(0.871,0.176,0.149),
], "colorbrewer2", "")

loadcolorscheme(:Reds_4, SA[
    RGB(0.996,0.898,0.851),
    RGB(0.988,0.682,0.569),
    RGB(0.984,0.416,0.29),
    RGB(0.796,0.094,0.114),
], "colorbrewer2", "")

loadcolorscheme(:Reds_5, SA[
    RGB(0.996,0.898,0.851),
    RGB(0.988,0.682,0.569),
    RGB(0.984,0.416,0.29),
    RGB(0.871,0.176,0.149),
    RGB(0.647,0.059,0.082),
], "colorbrewer2", "")

loadcolorscheme(:Reds_6, SA[
    RGB(0.996,0.898,0.851),
    RGB(0.988,0.733,0.631),
    RGB(0.988,0.573,0.447),
    RGB(0.984,0.416,0.29),
    RGB(0.871,0.176,0.149),
    RGB(0.647,0.059,0.082),
], "colorbrewer2", "")

loadcolorscheme(:Reds_7, SA[
    RGB(0.996,0.898,0.851),
    RGB(0.988,0.733,0.631),
    RGB(0.988,0.573,0.447),
    RGB(0.984,0.416,0.29),
    RGB(0.937,0.231,0.173),
    RGB(0.796,0.094,0.114),
    RGB(0.6,0.0,0.051),
], "colorbrewer2", "")

loadcolorscheme(:Reds_8, SA[
    RGB(1.0,0.961,0.941),
    RGB(0.996,0.878,0.824),
    RGB(0.988,0.733,0.631),
    RGB(0.988,0.573,0.447),
    RGB(0.984,0.416,0.29),
    RGB(0.937,0.231,0.173),
    RGB(0.796,0.094,0.114),
    RGB(0.6,0.0,0.051),
], "colorbrewer2", "")

loadcolorscheme(:Reds_9, SA[
    RGB(1.0,0.961,0.941),
    RGB(0.996,0.878,0.824),
    RGB(0.988,0.733,0.631),
    RGB(0.988,0.573,0.447),
    RGB(0.984,0.416,0.29),
    RGB(0.937,0.231,0.173),
    RGB(0.796,0.094,0.114),
    RGB(0.647,0.059,0.082),
    RGB(0.404,0.0,0.051),
], "colorbrewer2", "")

loadcolorscheme(:PuBu_3, SA[
    RGB(0.925,0.906,0.949),
    RGB(0.651,0.741,0.859),
    RGB(0.169,0.549,0.745),
], "colorbrewer2", "")

loadcolorscheme(:PuBu_4, SA[
    RGB(0.945,0.933,0.965),
    RGB(0.741,0.788,0.882),
    RGB(0.455,0.663,0.812),
    RGB(0.02,0.439,0.69),
], "colorbrewer2", "")

loadcolorscheme(:PuBu_5, SA[
    RGB(0.945,0.933,0.965),
    RGB(0.741,0.788,0.882),
    RGB(0.455,0.663,0.812),
    RGB(0.169,0.549,0.745),
    RGB(0.016,0.353,0.553),
], "colorbrewer2", "")

loadcolorscheme(:PuBu_6, SA[
    RGB(0.945,0.933,0.965),
    RGB(0.816,0.82,0.902),
    RGB(0.651,0.741,0.859),
    RGB(0.455,0.663,0.812),
    RGB(0.169,0.549,0.745),
    RGB(0.016,0.353,0.553),
], "colorbrewer2", "")

loadcolorscheme(:PuBu_7, SA[
    RGB(0.945,0.933,0.965),
    RGB(0.816,0.82,0.902),
    RGB(0.651,0.741,0.859),
    RGB(0.455,0.663,0.812),
    RGB(0.212,0.565,0.753),
    RGB(0.02,0.439,0.69),
    RGB(0.012,0.306,0.482),
], "colorbrewer2", "")

loadcolorscheme(:PuBu_8, SA[
    RGB(1.0,0.969,0.984),
    RGB(0.925,0.906,0.949),
    RGB(0.816,0.82,0.902),
    RGB(0.651,0.741,0.859),
    RGB(0.455,0.663,0.812),
    RGB(0.212,0.565,0.753),
    RGB(0.02,0.439,0.69),
    RGB(0.012,0.306,0.482),
], "colorbrewer2", "")

loadcolorscheme(:PuBu_9, SA[
    RGB(1.0,0.969,0.984),
    RGB(0.925,0.906,0.949),
    RGB(0.816,0.82,0.902),
    RGB(0.651,0.741,0.859),
    RGB(0.455,0.663,0.812),
    RGB(0.212,0.565,0.753),
    RGB(0.02,0.439,0.69),
    RGB(0.016,0.353,0.553),
    RGB(0.008,0.22,0.345),
], "colorbrewer2", "")

loadcolorscheme(:BuPu_3, SA[
    RGB(0.878,0.925,0.957),
    RGB(0.62,0.737,0.855),
    RGB(0.533,0.337,0.655),
], "colorbrewer2", "")

loadcolorscheme(:BuPu_4, SA[
    RGB(0.929,0.973,0.984),
    RGB(0.702,0.804,0.89),
    RGB(0.549,0.588,0.776),
    RGB(0.533,0.255,0.616),
], "colorbrewer2", "")

loadcolorscheme(:BuPu_5, SA[
    RGB(0.929,0.973,0.984),
    RGB(0.702,0.804,0.89),
    RGB(0.549,0.588,0.776),
    RGB(0.533,0.337,0.655),
    RGB(0.506,0.059,0.486),
], "colorbrewer2", "")

loadcolorscheme(:BuPu_6, SA[
    RGB(0.929,0.973,0.984),
    RGB(0.749,0.827,0.902),
    RGB(0.62,0.737,0.855),
    RGB(0.549,0.588,0.776),
    RGB(0.533,0.337,0.655),
    RGB(0.506,0.059,0.486),
], "colorbrewer2", "")

loadcolorscheme(:BuPu_7, SA[
    RGB(0.929,0.973,0.984),
    RGB(0.749,0.827,0.902),
    RGB(0.62,0.737,0.855),
    RGB(0.549,0.588,0.776),
    RGB(0.549,0.42,0.694),
    RGB(0.533,0.255,0.616),
    RGB(0.431,0.004,0.42),
], "colorbrewer2", "")

loadcolorscheme(:BuPu_8, SA[
    RGB(0.969,0.988,0.992),
    RGB(0.878,0.925,0.957),
    RGB(0.749,0.827,0.902),
    RGB(0.62,0.737,0.855),
    RGB(0.549,0.588,0.776),
    RGB(0.549,0.42,0.694),
    RGB(0.533,0.255,0.616),
    RGB(0.431,0.004,0.42),
], "colorbrewer2", "")

loadcolorscheme(:BuPu_9, SA[
    RGB(0.969,0.988,0.992),
    RGB(0.878,0.925,0.957),
    RGB(0.749,0.827,0.902),
    RGB(0.62,0.737,0.855),
    RGB(0.549,0.588,0.776),
    RGB(0.549,0.42,0.694),
    RGB(0.533,0.255,0.616),
    RGB(0.506,0.059,0.486),
    RGB(0.302,0.0,0.294),
], "colorbrewer2", "")

loadcolorscheme(:RdYlGn_3, SA[
    RGB(0.988,0.553,0.349),
    RGB(1.0,1.0,0.749),
    RGB(0.569,0.812,0.376),
], "colorbrewer2", "diverging")

loadcolorscheme(:RdYlGn_4, SA[
    RGB(0.843,0.098,0.11),
    RGB(0.992,0.682,0.38),
    RGB(0.651,0.851,0.416),
    RGB(0.102,0.588,0.255),
], "colorbrewer2", "diverging")

loadcolorscheme(:RdYlGn_5, SA[
    RGB(0.843,0.098,0.11),
    RGB(0.992,0.682,0.38),
    RGB(1.0,1.0,0.749),
    RGB(0.651,0.851,0.416),
    RGB(0.102,0.588,0.255),
], "colorbrewer2", "diverging")

loadcolorscheme(:RdYlGn_6, SA[
    RGB(0.843,0.188,0.153),
    RGB(0.988,0.553,0.349),
    RGB(0.996,0.878,0.545),
    RGB(0.851,0.937,0.545),
    RGB(0.569,0.812,0.376),
    RGB(0.102,0.596,0.314),
], "colorbrewer2", "diverging")

loadcolorscheme(:RdYlGn_7, SA[
    RGB(0.843,0.188,0.153),
    RGB(0.988,0.553,0.349),
    RGB(0.996,0.878,0.545),
    RGB(1.0,1.0,0.749),
    RGB(0.851,0.937,0.545),
    RGB(0.569,0.812,0.376),
    RGB(0.102,0.596,0.314),
], "colorbrewer2", "diverging")

loadcolorscheme(:RdYlGn_8, SA[
    RGB(0.843,0.188,0.153),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.545),
    RGB(0.851,0.937,0.545),
    RGB(0.651,0.851,0.416),
    RGB(0.4,0.741,0.388),
    RGB(0.102,0.596,0.314),
], "colorbrewer2", "diverging")

loadcolorscheme(:RdYlGn_9, SA[
    RGB(0.843,0.188,0.153),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.545),
    RGB(1.0,1.0,0.749),
    RGB(0.851,0.937,0.545),
    RGB(0.651,0.851,0.416),
    RGB(0.4,0.741,0.388),
    RGB(0.102,0.596,0.314),
], "colorbrewer2", "diverging")

loadcolorscheme(:RdYlGn_10, SA[
    RGB(0.647,0.0,0.149),
    RGB(0.843,0.188,0.153),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.545),
    RGB(0.851,0.937,0.545),
    RGB(0.651,0.851,0.416),
    RGB(0.4,0.741,0.388),
    RGB(0.102,0.596,0.314),
    RGB(0.0,0.408,0.216),
], "colorbrewer2", "diverging")

loadcolorscheme(:RdYlGn_11, SA[
    RGB(0.647,0.0,0.149),
    RGB(0.843,0.188,0.153),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.545),
    RGB(1.0,1.0,0.749),
    RGB(0.851,0.937,0.545),
    RGB(0.651,0.851,0.416),
    RGB(0.4,0.741,0.388),
    RGB(0.102,0.596,0.314),
    RGB(0.0,0.408,0.216),
], "colorbrewer2", "diverging")

loadcolorscheme(:Pastel2_3, SA[
    RGB(0.702,0.886,0.804),
    RGB(0.992,0.804,0.675),
    RGB(0.796,0.835,0.91),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel2_4, SA[
    RGB(0.702,0.886,0.804),
    RGB(0.992,0.804,0.675),
    RGB(0.796,0.835,0.91),
    RGB(0.957,0.792,0.894),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel2_5, SA[
    RGB(0.702,0.886,0.804),
    RGB(0.992,0.804,0.675),
    RGB(0.796,0.835,0.91),
    RGB(0.957,0.792,0.894),
    RGB(0.902,0.961,0.788),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel2_6, SA[
    RGB(0.702,0.886,0.804),
    RGB(0.992,0.804,0.675),
    RGB(0.796,0.835,0.91),
    RGB(0.957,0.792,0.894),
    RGB(0.902,0.961,0.788),
    RGB(1.0,0.949,0.682),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel2_7, SA[
    RGB(0.702,0.886,0.804),
    RGB(0.992,0.804,0.675),
    RGB(0.796,0.835,0.91),
    RGB(0.957,0.792,0.894),
    RGB(0.902,0.961,0.788),
    RGB(1.0,0.949,0.682),
    RGB(0.945,0.886,0.8),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:Pastel2_8, SA[
    RGB(0.702,0.886,0.804),
    RGB(0.992,0.804,0.675),
    RGB(0.796,0.835,0.91),
    RGB(0.957,0.792,0.894),
    RGB(0.902,0.961,0.788),
    RGB(1.0,0.949,0.682),
    RGB(0.945,0.886,0.8),
    RGB(0.8,0.8,0.8),
], "colorbrewer2", "pastel shades")

loadcolorscheme(:BuGn_3, SA[
    RGB(0.898,0.961,0.976),
    RGB(0.6,0.847,0.788),
    RGB(0.173,0.635,0.373),
], "colorbrewer2", "")

loadcolorscheme(:BuGn_4, SA[
    RGB(0.929,0.973,0.984),
    RGB(0.698,0.886,0.886),
    RGB(0.4,0.761,0.643),
    RGB(0.137,0.545,0.271),
], "colorbrewer2", "")

loadcolorscheme(:BuGn_5, SA[
    RGB(0.929,0.973,0.984),
    RGB(0.698,0.886,0.886),
    RGB(0.4,0.761,0.643),
    RGB(0.173,0.635,0.373),
    RGB(0.0,0.427,0.173),
], "colorbrewer2", "")

loadcolorscheme(:BuGn_6, SA[
    RGB(0.929,0.973,0.984),
    RGB(0.8,0.925,0.902),
    RGB(0.6,0.847,0.788),
    RGB(0.4,0.761,0.643),
    RGB(0.173,0.635,0.373),
    RGB(0.0,0.427,0.173),
], "colorbrewer2", "")

loadcolorscheme(:BuGn_7, SA[
    RGB(0.929,0.973,0.984),
    RGB(0.8,0.925,0.902),
    RGB(0.6,0.847,0.788),
    RGB(0.4,0.761,0.643),
    RGB(0.255,0.682,0.463),
    RGB(0.137,0.545,0.271),
    RGB(0.0,0.345,0.141),
], "colorbrewer2", "")

loadcolorscheme(:BuGn_8, SA[
    RGB(0.969,0.988,0.992),
    RGB(0.898,0.961,0.976),
    RGB(0.8,0.925,0.902),
    RGB(0.6,0.847,0.788),
    RGB(0.4,0.761,0.643),
    RGB(0.255,0.682,0.463),
    RGB(0.137,0.545,0.271),
    RGB(0.0,0.345,0.141),
], "colorbrewer2", "")

loadcolorscheme(:BuGn_9, SA[
    RGB(0.969,0.988,0.992),
    RGB(0.898,0.961,0.976),
    RGB(0.8,0.925,0.902),
    RGB(0.6,0.847,0.788),
    RGB(0.4,0.761,0.643),
    RGB(0.255,0.682,0.463),
    RGB(0.137,0.545,0.271),
    RGB(0.0,0.427,0.173),
    RGB(0.0,0.267,0.106),
], "colorbrewer2", "")

loadcolorscheme(:YlOrBr_3, SA[
    RGB(1.0,0.969,0.737),
    RGB(0.996,0.769,0.31),
    RGB(0.851,0.373,0.055),
], "colorbrewer2", "")

loadcolorscheme(:YlOrBr_4, SA[
    RGB(1.0,1.0,0.831),
    RGB(0.996,0.851,0.557),
    RGB(0.996,0.6,0.161),
    RGB(0.8,0.298,0.008),
], "colorbrewer2", "")

loadcolorscheme(:YlOrBr_5, SA[
    RGB(1.0,1.0,0.831),
    RGB(0.996,0.851,0.557),
    RGB(0.996,0.6,0.161),
    RGB(0.851,0.373,0.055),
    RGB(0.6,0.204,0.016),
], "colorbrewer2", "")

loadcolorscheme(:YlOrBr_6, SA[
    RGB(1.0,1.0,0.831),
    RGB(0.996,0.89,0.569),
    RGB(0.996,0.769,0.31),
    RGB(0.996,0.6,0.161),
    RGB(0.851,0.373,0.055),
    RGB(0.6,0.204,0.016),
], "colorbrewer2", "")

loadcolorscheme(:YlOrBr_7, SA[
    RGB(1.0,1.0,0.831),
    RGB(0.996,0.89,0.569),
    RGB(0.996,0.769,0.31),
    RGB(0.996,0.6,0.161),
    RGB(0.925,0.439,0.078),
    RGB(0.8,0.298,0.008),
    RGB(0.549,0.176,0.016),
], "colorbrewer2", "")

loadcolorscheme(:YlOrBr_8, SA[
    RGB(1.0,1.0,0.898),
    RGB(1.0,0.969,0.737),
    RGB(0.996,0.89,0.569),
    RGB(0.996,0.769,0.31),
    RGB(0.996,0.6,0.161),
    RGB(0.925,0.439,0.078),
    RGB(0.8,0.298,0.008),
    RGB(0.549,0.176,0.016),
], "colorbrewer2", "")

loadcolorscheme(:YlOrBr_9, SA[
    RGB(1.0,1.0,0.898),
    RGB(1.0,0.969,0.737),
    RGB(0.996,0.89,0.569),
    RGB(0.996,0.769,0.31),
    RGB(0.996,0.6,0.161),
    RGB(0.925,0.439,0.078),
    RGB(0.8,0.298,0.008),
    RGB(0.6,0.204,0.016),
    RGB(0.4,0.145,0.024),
], "colorbrewer2", "")

loadcolorscheme(:PuBuGn_3, SA[
    RGB(0.925,0.886,0.941),
    RGB(0.651,0.741,0.859),
    RGB(0.11,0.565,0.6),
], "colorbrewer2", "")

loadcolorscheme(:PuBuGn_4, SA[
    RGB(0.965,0.937,0.969),
    RGB(0.741,0.788,0.882),
    RGB(0.404,0.663,0.812),
    RGB(0.008,0.506,0.541),
], "colorbrewer2", "")

loadcolorscheme(:PuBuGn_5, SA[
    RGB(0.965,0.937,0.969),
    RGB(0.741,0.788,0.882),
    RGB(0.404,0.663,0.812),
    RGB(0.11,0.565,0.6),
    RGB(0.004,0.424,0.349),
], "colorbrewer2", "")

loadcolorscheme(:PuBuGn_6, SA[
    RGB(0.965,0.937,0.969),
    RGB(0.816,0.82,0.902),
    RGB(0.651,0.741,0.859),
    RGB(0.404,0.663,0.812),
    RGB(0.11,0.565,0.6),
    RGB(0.004,0.424,0.349),
], "colorbrewer2", "")

loadcolorscheme(:PuBuGn_7, SA[
    RGB(0.965,0.937,0.969),
    RGB(0.816,0.82,0.902),
    RGB(0.651,0.741,0.859),
    RGB(0.404,0.663,0.812),
    RGB(0.212,0.565,0.753),
    RGB(0.008,0.506,0.541),
    RGB(0.004,0.392,0.314),
], "colorbrewer2", "")

loadcolorscheme(:PuBuGn_8, SA[
    RGB(1.0,0.969,0.984),
    RGB(0.925,0.886,0.941),
    RGB(0.816,0.82,0.902),
    RGB(0.651,0.741,0.859),
    RGB(0.404,0.663,0.812),
    RGB(0.212,0.565,0.753),
    RGB(0.008,0.506,0.541),
    RGB(0.004,0.392,0.314),
], "colorbrewer2", "")

loadcolorscheme(:PuBuGn_9, SA[
    RGB(1.0,0.969,0.984),
    RGB(0.925,0.886,0.941),
    RGB(0.816,0.82,0.902),
    RGB(0.651,0.741,0.859),
    RGB(0.404,0.663,0.812),
    RGB(0.212,0.565,0.753),
    RGB(0.008,0.506,0.541),
    RGB(0.004,0.424,0.349),
    RGB(0.004,0.275,0.212),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_3, SA[
    RGB(0.988,0.553,0.349),
    RGB(1.0,1.0,0.749),
    RGB(0.6,0.835,0.58),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_4, SA[
    RGB(0.843,0.098,0.11),
    RGB(0.992,0.682,0.38),
    RGB(0.671,0.867,0.643),
    RGB(0.169,0.514,0.729),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_5, SA[
    RGB(0.843,0.098,0.11),
    RGB(0.992,0.682,0.38),
    RGB(1.0,1.0,0.749),
    RGB(0.671,0.867,0.643),
    RGB(0.169,0.514,0.729),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_6, SA[
    RGB(0.835,0.243,0.31),
    RGB(0.988,0.553,0.349),
    RGB(0.996,0.878,0.545),
    RGB(0.902,0.961,0.596),
    RGB(0.6,0.835,0.58),
    RGB(0.196,0.533,0.741),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_7, SA[
    RGB(0.835,0.243,0.31),
    RGB(0.988,0.553,0.349),
    RGB(0.996,0.878,0.545),
    RGB(1.0,1.0,0.749),
    RGB(0.902,0.961,0.596),
    RGB(0.6,0.835,0.58),
    RGB(0.196,0.533,0.741),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_8, SA[
    RGB(0.835,0.243,0.31),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.545),
    RGB(0.902,0.961,0.596),
    RGB(0.671,0.867,0.643),
    RGB(0.4,0.761,0.647),
    RGB(0.196,0.533,0.741),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_9, SA[
    RGB(0.835,0.243,0.31),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.545),
    RGB(1.0,1.0,0.749),
    RGB(0.902,0.961,0.596),
    RGB(0.671,0.867,0.643),
    RGB(0.4,0.761,0.647),
    RGB(0.196,0.533,0.741),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_10, SA[
    RGB(0.62,0.004,0.259),
    RGB(0.835,0.243,0.31),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.545),
    RGB(0.902,0.961,0.596),
    RGB(0.671,0.867,0.643),
    RGB(0.4,0.761,0.647),
    RGB(0.196,0.533,0.741),
    RGB(0.369,0.31,0.635),
], "colorbrewer2", "")

loadcolorscheme(:Spectral_11, SA[
    RGB(0.62,0.004,0.259),
    RGB(0.835,0.243,0.31),
    RGB(0.957,0.427,0.263),
    RGB(0.992,0.682,0.38),
    RGB(0.996,0.878,0.545),
    RGB(1.0,1.0,0.749),
    RGB(0.902,0.961,0.596),
    RGB(0.671,0.867,0.643),
    RGB(0.4,0.761,0.647),
    RGB(0.196,0.533,0.741),
    RGB(0.369,0.31,0.635),
], "colorbrewer2", "")

loadcolorscheme(:YlGn_3, SA[
    RGB(0.969,0.988,0.725),
    RGB(0.678,0.867,0.557),
    RGB(0.192,0.639,0.329),
], "colorbrewer2", "")

loadcolorscheme(:YlGn_4, SA[
    RGB(1.0,1.0,0.8),
    RGB(0.761,0.902,0.6),
    RGB(0.471,0.776,0.475),
    RGB(0.137,0.518,0.263),
], "colorbrewer2", "")

loadcolorscheme(:YlGn_5, SA[
    RGB(1.0,1.0,0.8),
    RGB(0.761,0.902,0.6),
    RGB(0.471,0.776,0.475),
    RGB(0.192,0.639,0.329),
    RGB(0.0,0.408,0.216),
], "colorbrewer2", "")

loadcolorscheme(:YlGn_6, SA[
    RGB(1.0,1.0,0.8),
    RGB(0.851,0.941,0.639),
    RGB(0.678,0.867,0.557),
    RGB(0.471,0.776,0.475),
    RGB(0.192,0.639,0.329),
    RGB(0.0,0.408,0.216),
], "colorbrewer2", "")

loadcolorscheme(:YlGn_7, SA[
    RGB(1.0,1.0,0.8),
    RGB(0.851,0.941,0.639),
    RGB(0.678,0.867,0.557),
    RGB(0.471,0.776,0.475),
    RGB(0.255,0.671,0.365),
    RGB(0.137,0.518,0.263),
    RGB(0.0,0.353,0.196),
], "colorbrewer2", "")

loadcolorscheme(:YlGn_8, SA[
    RGB(1.0,1.0,0.898),
    RGB(0.969,0.988,0.725),
    RGB(0.851,0.941,0.639),
    RGB(0.678,0.867,0.557),
    RGB(0.471,0.776,0.475),
    RGB(0.255,0.671,0.365),
    RGB(0.137,0.518,0.263),
    RGB(0.0,0.353,0.196),
], "colorbrewer2", "")

loadcolorscheme(:YlGn_9, SA[
    RGB(1.0,1.0,0.898),
    RGB(0.969,0.988,0.725),
    RGB(0.851,0.941,0.639),
    RGB(0.678,0.867,0.557),
    RGB(0.471,0.776,0.475),
    RGB(0.255,0.671,0.365),
    RGB(0.137,0.518,0.263),
    RGB(0.0,0.408,0.216),
    RGB(0.0,0.271,0.161),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_3, SA[
    RGB(0.937,0.541,0.384),
    RGB(1.0,1.0,1.0),
    RGB(0.6,0.6,0.6),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_4, SA[
    RGB(0.792,0.0,0.125),
    RGB(0.957,0.647,0.51),
    RGB(0.729,0.729,0.729),
    RGB(0.251,0.251,0.251),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_5, SA[
    RGB(0.792,0.0,0.125),
    RGB(0.957,0.647,0.51),
    RGB(1.0,1.0,1.0),
    RGB(0.729,0.729,0.729),
    RGB(0.251,0.251,0.251),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_6, SA[
    RGB(0.698,0.094,0.169),
    RGB(0.937,0.541,0.384),
    RGB(0.992,0.859,0.78),
    RGB(0.878,0.878,0.878),
    RGB(0.6,0.6,0.6),
    RGB(0.302,0.302,0.302),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_7, SA[
    RGB(0.698,0.094,0.169),
    RGB(0.937,0.541,0.384),
    RGB(0.992,0.859,0.78),
    RGB(1.0,1.0,1.0),
    RGB(0.878,0.878,0.878),
    RGB(0.6,0.6,0.6),
    RGB(0.302,0.302,0.302),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_8, SA[
    RGB(0.698,0.094,0.169),
    RGB(0.839,0.376,0.302),
    RGB(0.957,0.647,0.51),
    RGB(0.992,0.859,0.78),
    RGB(0.878,0.878,0.878),
    RGB(0.729,0.729,0.729),
    RGB(0.529,0.529,0.529),
    RGB(0.302,0.302,0.302),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_9, SA[
    RGB(0.698,0.094,0.169),
    RGB(0.839,0.376,0.302),
    RGB(0.957,0.647,0.51),
    RGB(0.992,0.859,0.78),
    RGB(1.0,1.0,1.0),
    RGB(0.878,0.878,0.878),
    RGB(0.729,0.729,0.729),
    RGB(0.529,0.529,0.529),
    RGB(0.302,0.302,0.302),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_10, SA[
    RGB(0.404,0.0,0.122),
    RGB(0.698,0.094,0.169),
    RGB(0.839,0.376,0.302),
    RGB(0.957,0.647,0.51),
    RGB(0.992,0.859,0.78),
    RGB(0.878,0.878,0.878),
    RGB(0.729,0.729,0.729),
    RGB(0.529,0.529,0.529),
    RGB(0.302,0.302,0.302),
    RGB(0.102,0.102,0.102),
], "colorbrewer2", "")

loadcolorscheme(:RdGy_11, SA[
    RGB(0.404,0.0,0.122),
    RGB(0.698,0.094,0.169),
    RGB(0.839,0.376,0.302),
    RGB(0.957,0.647,0.51),
    RGB(0.992,0.859,0.78),
    RGB(1.0,1.0,1.0),
    RGB(0.878,0.878,0.878),
    RGB(0.729,0.729,0.729),
    RGB(0.529,0.529,0.529),
    RGB(0.302,0.302,0.302),
    RGB(0.102,0.102,0.102),
], "colorbrewer2", "")

loadcolorscheme(:Greys_3, SA[
    RGB(0.941,0.941,0.941),
    RGB(0.741,0.741,0.741),
    RGB(0.388,0.388,0.388),
], "colorbrewer2", "")

loadcolorscheme(:Greys_4, SA[
    RGB(0.969,0.969,0.969),
    RGB(0.8,0.8,0.8),
    RGB(0.588,0.588,0.588),
    RGB(0.322,0.322,0.322),
], "colorbrewer2", "")

loadcolorscheme(:Greys_5, SA[
    RGB(0.969,0.969,0.969),
    RGB(0.8,0.8,0.8),
    RGB(0.588,0.588,0.588),
    RGB(0.388,0.388,0.388),
    RGB(0.145,0.145,0.145),
], "colorbrewer2", "")

loadcolorscheme(:Greys_6, SA[
    RGB(0.969,0.969,0.969),
    RGB(0.851,0.851,0.851),
    RGB(0.741,0.741,0.741),
    RGB(0.588,0.588,0.588),
    RGB(0.388,0.388,0.388),
    RGB(0.145,0.145,0.145),
], "colorbrewer2", "")

loadcolorscheme(:Greys_7, SA[
    RGB(0.969,0.969,0.969),
    RGB(0.851,0.851,0.851),
    RGB(0.741,0.741,0.741),
    RGB(0.588,0.588,0.588),
    RGB(0.451,0.451,0.451),
    RGB(0.322,0.322,0.322),
    RGB(0.145,0.145,0.145),
], "colorbrewer2", "")

loadcolorscheme(:Greys_8, SA[
    RGB(1.0,1.0,1.0),
    RGB(0.941,0.941,0.941),
    RGB(0.851,0.851,0.851),
    RGB(0.741,0.741,0.741),
    RGB(0.588,0.588,0.588),
    RGB(0.451,0.451,0.451),
    RGB(0.322,0.322,0.322),
    RGB(0.145,0.145,0.145),
], "colorbrewer2", "")

loadcolorscheme(:Greys_9, SA[
    RGB(1.0,1.0,1.0),
    RGB(0.941,0.941,0.941),
    RGB(0.851,0.851,0.851),
    RGB(0.741,0.741,0.741),
    RGB(0.588,0.588,0.588),
    RGB(0.451,0.451,0.451),
    RGB(0.322,0.322,0.322),
    RGB(0.145,0.145,0.145),
    RGB(0.0,0.0,0.0),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_3, SA[
    RGB(0.847,0.702,0.396),
    RGB(0.961,0.961,0.961),
    RGB(0.353,0.706,0.675),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_4, SA[
    RGB(0.651,0.38,0.102),
    RGB(0.875,0.761,0.49),
    RGB(0.502,0.804,0.757),
    RGB(0.004,0.522,0.443),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_5, SA[
    RGB(0.651,0.38,0.102),
    RGB(0.875,0.761,0.49),
    RGB(0.961,0.961,0.961),
    RGB(0.502,0.804,0.757),
    RGB(0.004,0.522,0.443),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_6, SA[
    RGB(0.549,0.318,0.039),
    RGB(0.847,0.702,0.396),
    RGB(0.965,0.91,0.765),
    RGB(0.78,0.918,0.898),
    RGB(0.353,0.706,0.675),
    RGB(0.004,0.4,0.369),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_7, SA[
    RGB(0.549,0.318,0.039),
    RGB(0.847,0.702,0.396),
    RGB(0.965,0.91,0.765),
    RGB(0.961,0.961,0.961),
    RGB(0.78,0.918,0.898),
    RGB(0.353,0.706,0.675),
    RGB(0.004,0.4,0.369),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_8, SA[
    RGB(0.549,0.318,0.039),
    RGB(0.749,0.506,0.176),
    RGB(0.875,0.761,0.49),
    RGB(0.965,0.91,0.765),
    RGB(0.78,0.918,0.898),
    RGB(0.502,0.804,0.757),
    RGB(0.208,0.592,0.561),
    RGB(0.004,0.4,0.369),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_9, SA[
    RGB(0.549,0.318,0.039),
    RGB(0.749,0.506,0.176),
    RGB(0.875,0.761,0.49),
    RGB(0.965,0.91,0.765),
    RGB(0.961,0.961,0.961),
    RGB(0.78,0.918,0.898),
    RGB(0.502,0.804,0.757),
    RGB(0.208,0.592,0.561),
    RGB(0.004,0.4,0.369),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_10, SA[
    RGB(0.329,0.188,0.02),
    RGB(0.549,0.318,0.039),
    RGB(0.749,0.506,0.176),
    RGB(0.875,0.761,0.49),
    RGB(0.965,0.91,0.765),
    RGB(0.78,0.918,0.898),
    RGB(0.502,0.804,0.757),
    RGB(0.208,0.592,0.561),
    RGB(0.004,0.4,0.369),
    RGB(0.0,0.235,0.188),
], "colorbrewer2", "")

loadcolorscheme(:BrBG_11, SA[
    RGB(0.329,0.188,0.02),
    RGB(0.549,0.318,0.039),
    RGB(0.749,0.506,0.176),
    RGB(0.875,0.761,0.49),
    RGB(0.965,0.91,0.765),
    RGB(0.961,0.961,0.961),
    RGB(0.78,0.918,0.898),
    RGB(0.502,0.804,0.757),
    RGB(0.208,0.592,0.561),
    RGB(0.004,0.4,0.369),
    RGB(0.0,0.235,0.188),
], "colorbrewer2", "")

loadcolorscheme(:RdPu_3, SA[
    RGB(0.992,0.878,0.867),
    RGB(0.98,0.624,0.71),
    RGB(0.773,0.106,0.541),
], "colorbrewer2", "")

loadcolorscheme(:RdPu_4, SA[
    RGB(0.996,0.922,0.886),
    RGB(0.984,0.706,0.725),
    RGB(0.969,0.408,0.631),
    RGB(0.682,0.004,0.494),
], "colorbrewer2", "")

loadcolorscheme(:RdPu_5, SA[
    RGB(0.996,0.922,0.886),
    RGB(0.984,0.706,0.725),
    RGB(0.969,0.408,0.631),
    RGB(0.773,0.106,0.541),
    RGB(0.478,0.004,0.467),
], "colorbrewer2", "")

loadcolorscheme(:RdPu_6, SA[
    RGB(0.996,0.922,0.886),
    RGB(0.988,0.773,0.753),
    RGB(0.98,0.624,0.71),
    RGB(0.969,0.408,0.631),
    RGB(0.773,0.106,0.541),
    RGB(0.478,0.004,0.467),
], "colorbrewer2", "")

loadcolorscheme(:RdPu_7, SA[
    RGB(0.996,0.922,0.886),
    RGB(0.988,0.773,0.753),
    RGB(0.98,0.624,0.71),
    RGB(0.969,0.408,0.631),
    RGB(0.867,0.204,0.592),
    RGB(0.682,0.004,0.494),
    RGB(0.478,0.004,0.467),
], "colorbrewer2", "")

loadcolorscheme(:RdPu_8, SA[
    RGB(1.0,0.969,0.953),
    RGB(0.992,0.878,0.867),
    RGB(0.988,0.773,0.753),
    RGB(0.98,0.624,0.71),
    RGB(0.969,0.408,0.631),
    RGB(0.867,0.204,0.592),
    RGB(0.682,0.004,0.494),
    RGB(0.478,0.004,0.467),
], "colorbrewer2", "")

loadcolorscheme(:RdPu_9, SA[
    RGB(1.0,0.969,0.953),
    RGB(0.992,0.878,0.867),
    RGB(0.988,0.773,0.753),
    RGB(0.98,0.624,0.71),
    RGB(0.969,0.408,0.631),
    RGB(0.867,0.204,0.592),
    RGB(0.682,0.004,0.494),
    RGB(0.478,0.004,0.467),
    RGB(0.286,0.0,0.416),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_3, SA[
    RGB(0.686,0.553,0.765),
    RGB(0.969,0.969,0.969),
    RGB(0.498,0.749,0.482),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_4, SA[
    RGB(0.482,0.196,0.58),
    RGB(0.761,0.647,0.812),
    RGB(0.651,0.859,0.627),
    RGB(0.0,0.533,0.216),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_5, SA[
    RGB(0.482,0.196,0.58),
    RGB(0.761,0.647,0.812),
    RGB(0.969,0.969,0.969),
    RGB(0.651,0.859,0.627),
    RGB(0.0,0.533,0.216),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_6, SA[
    RGB(0.463,0.165,0.514),
    RGB(0.686,0.553,0.765),
    RGB(0.906,0.831,0.91),
    RGB(0.851,0.941,0.827),
    RGB(0.498,0.749,0.482),
    RGB(0.106,0.471,0.216),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_7, SA[
    RGB(0.463,0.165,0.514),
    RGB(0.686,0.553,0.765),
    RGB(0.906,0.831,0.91),
    RGB(0.969,0.969,0.969),
    RGB(0.851,0.941,0.827),
    RGB(0.498,0.749,0.482),
    RGB(0.106,0.471,0.216),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_8, SA[
    RGB(0.463,0.165,0.514),
    RGB(0.6,0.439,0.671),
    RGB(0.761,0.647,0.812),
    RGB(0.906,0.831,0.91),
    RGB(0.851,0.941,0.827),
    RGB(0.651,0.859,0.627),
    RGB(0.353,0.682,0.38),
    RGB(0.106,0.471,0.216),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_9, SA[
    RGB(0.463,0.165,0.514),
    RGB(0.6,0.439,0.671),
    RGB(0.761,0.647,0.812),
    RGB(0.906,0.831,0.91),
    RGB(0.969,0.969,0.969),
    RGB(0.851,0.941,0.827),
    RGB(0.651,0.859,0.627),
    RGB(0.353,0.682,0.38),
    RGB(0.106,0.471,0.216),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_10, SA[
    RGB(0.251,0.0,0.294),
    RGB(0.463,0.165,0.514),
    RGB(0.6,0.439,0.671),
    RGB(0.761,0.647,0.812),
    RGB(0.906,0.831,0.91),
    RGB(0.851,0.941,0.827),
    RGB(0.651,0.859,0.627),
    RGB(0.353,0.682,0.38),
    RGB(0.106,0.471,0.216),
    RGB(0.0,0.267,0.106),
], "colorbrewer2", "")

loadcolorscheme(:PRGn_11, SA[
    RGB(0.251,0.0,0.294),
    RGB(0.463,0.165,0.514),
    RGB(0.6,0.439,0.671),
    RGB(0.761,0.647,0.812),
    RGB(0.906,0.831,0.91),
    RGB(0.969,0.969,0.969),
    RGB(0.851,0.941,0.827),
    RGB(0.651,0.859,0.627),
    RGB(0.353,0.682,0.38),
    RGB(0.106,0.471,0.216),
    RGB(0.0,0.267,0.106),
], "colorbrewer2", "")

loadcolorscheme(:Dark2_3, SA[
    RGB(0.106,0.62,0.467),
    RGB(0.851,0.373,0.008),
    RGB(0.459,0.439,0.702),
], "colorbrewer2", "")

loadcolorscheme(:Dark2_4, SA[
    RGB(0.106,0.62,0.467),
    RGB(0.851,0.373,0.008),
    RGB(0.459,0.439,0.702),
    RGB(0.906,0.161,0.541),
], "colorbrewer2", "")

loadcolorscheme(:Dark2_5, SA[
    RGB(0.106,0.62,0.467),
    RGB(0.851,0.373,0.008),
    RGB(0.459,0.439,0.702),
    RGB(0.906,0.161,0.541),
    RGB(0.4,0.651,0.118),
], "colorbrewer2", "")

loadcolorscheme(:Dark2_6, SA[
    RGB(0.106,0.62,0.467),
    RGB(0.851,0.373,0.008),
    RGB(0.459,0.439,0.702),
    RGB(0.906,0.161,0.541),
    RGB(0.4,0.651,0.118),
    RGB(0.902,0.671,0.008),
], "colorbrewer2", "")

loadcolorscheme(:Dark2_7, SA[
    RGB(0.106,0.62,0.467),
    RGB(0.851,0.373,0.008),
    RGB(0.459,0.439,0.702),
    RGB(0.906,0.161,0.541),
    RGB(0.4,0.651,0.118),
    RGB(0.902,0.671,0.008),
    RGB(0.651,0.463,0.114),
], "colorbrewer2", "")

loadcolorscheme(:Dark2_8, SA[
    RGB(0.106,0.62,0.467),
    RGB(0.851,0.373,0.008),
    RGB(0.459,0.439,0.702),
    RGB(0.906,0.161,0.541),
    RGB(0.4,0.651,0.118),
    RGB(0.902,0.671,0.008),
    RGB(0.651,0.463,0.114),
    RGB(0.4,0.4,0.4),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_3, SA[
    RGB(0.937,0.541,0.384),
    RGB(0.969,0.969,0.969),
    RGB(0.404,0.663,0.812),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_4, SA[
    RGB(0.792,0.0,0.125),
    RGB(0.957,0.647,0.51),
    RGB(0.573,0.773,0.871),
    RGB(0.02,0.443,0.69),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_5, SA[
    RGB(0.792,0.0,0.125),
    RGB(0.957,0.647,0.51),
    RGB(0.969,0.969,0.969),
    RGB(0.573,0.773,0.871),
    RGB(0.02,0.443,0.69),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_6, SA[
    RGB(0.698,0.094,0.169),
    RGB(0.937,0.541,0.384),
    RGB(0.992,0.859,0.78),
    RGB(0.82,0.898,0.941),
    RGB(0.404,0.663,0.812),
    RGB(0.129,0.4,0.675),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_7, SA[
    RGB(0.698,0.094,0.169),
    RGB(0.937,0.541,0.384),
    RGB(0.992,0.859,0.78),
    RGB(0.969,0.969,0.969),
    RGB(0.82,0.898,0.941),
    RGB(0.404,0.663,0.812),
    RGB(0.129,0.4,0.675),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_8, SA[
    RGB(0.698,0.094,0.169),
    RGB(0.839,0.376,0.302),
    RGB(0.957,0.647,0.51),
    RGB(0.992,0.859,0.78),
    RGB(0.82,0.898,0.941),
    RGB(0.573,0.773,0.871),
    RGB(0.263,0.576,0.765),
    RGB(0.129,0.4,0.675),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_9, SA[
    RGB(0.698,0.094,0.169),
    RGB(0.839,0.376,0.302),
    RGB(0.957,0.647,0.51),
    RGB(0.992,0.859,0.78),
    RGB(0.969,0.969,0.969),
    RGB(0.82,0.898,0.941),
    RGB(0.573,0.773,0.871),
    RGB(0.263,0.576,0.765),
    RGB(0.129,0.4,0.675),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_10, SA[
    RGB(0.404,0.0,0.122),
    RGB(0.698,0.094,0.169),
    RGB(0.839,0.376,0.302),
    RGB(0.957,0.647,0.51),
    RGB(0.992,0.859,0.78),
    RGB(0.82,0.898,0.941),
    RGB(0.573,0.773,0.871),
    RGB(0.263,0.576,0.765),
    RGB(0.129,0.4,0.675),
    RGB(0.02,0.188,0.38),
], "colorbrewer2", "")

loadcolorscheme(:RdBu_11, SA[
    RGB(0.404,0.0,0.122),
    RGB(0.698,0.094,0.169),
    RGB(0.839,0.376,0.302),
    RGB(0.957,0.647,0.51),
    RGB(0.992,0.859,0.78),
    RGB(0.969,0.969,0.969),
    RGB(0.82,0.898,0.941),
    RGB(0.573,0.773,0.871),
    RGB(0.263,0.576,0.765),
    RGB(0.129,0.4,0.675),
    RGB(0.02,0.188,0.38),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_3, SA[
    RGB(0.945,0.639,0.251),
    RGB(0.969,0.969,0.969),
    RGB(0.6,0.557,0.765),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_4, SA[
    RGB(0.902,0.38,0.004),
    RGB(0.992,0.722,0.388),
    RGB(0.698,0.671,0.824),
    RGB(0.369,0.235,0.6),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_5, SA[
    RGB(0.902,0.38,0.004),
    RGB(0.992,0.722,0.388),
    RGB(0.969,0.969,0.969),
    RGB(0.698,0.671,0.824),
    RGB(0.369,0.235,0.6),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_6, SA[
    RGB(0.702,0.345,0.024),
    RGB(0.945,0.639,0.251),
    RGB(0.996,0.878,0.714),
    RGB(0.847,0.855,0.922),
    RGB(0.6,0.557,0.765),
    RGB(0.329,0.153,0.533),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_7, SA[
    RGB(0.702,0.345,0.024),
    RGB(0.945,0.639,0.251),
    RGB(0.996,0.878,0.714),
    RGB(0.969,0.969,0.969),
    RGB(0.847,0.855,0.922),
    RGB(0.6,0.557,0.765),
    RGB(0.329,0.153,0.533),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_8, SA[
    RGB(0.702,0.345,0.024),
    RGB(0.878,0.51,0.078),
    RGB(0.992,0.722,0.388),
    RGB(0.996,0.878,0.714),
    RGB(0.847,0.855,0.922),
    RGB(0.698,0.671,0.824),
    RGB(0.502,0.451,0.675),
    RGB(0.329,0.153,0.533),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_9, SA[
    RGB(0.702,0.345,0.024),
    RGB(0.878,0.51,0.078),
    RGB(0.992,0.722,0.388),
    RGB(0.996,0.878,0.714),
    RGB(0.969,0.969,0.969),
    RGB(0.847,0.855,0.922),
    RGB(0.698,0.671,0.824),
    RGB(0.502,0.451,0.675),
    RGB(0.329,0.153,0.533),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_10, SA[
    RGB(0.498,0.231,0.031),
    RGB(0.702,0.345,0.024),
    RGB(0.878,0.51,0.078),
    RGB(0.992,0.722,0.388),
    RGB(0.996,0.878,0.714),
    RGB(0.847,0.855,0.922),
    RGB(0.698,0.671,0.824),
    RGB(0.502,0.451,0.675),
    RGB(0.329,0.153,0.533),
    RGB(0.176,0.0,0.294),
], "colorbrewer2", "")

loadcolorscheme(:PuOr_11, SA[
    RGB(0.498,0.231,0.031),
    RGB(0.702,0.345,0.024),
    RGB(0.878,0.51,0.078),
    RGB(0.992,0.722,0.388),
    RGB(0.996,0.878,0.714),
    RGB(0.969,0.969,0.969),
    RGB(0.847,0.855,0.922),
    RGB(0.698,0.671,0.824),
    RGB(0.502,0.451,0.675),
    RGB(0.329,0.153,0.533),
    RGB(0.176,0.0,0.294),
], "colorbrewer2", "")

loadcolorscheme(:Paired_3, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_4, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_5, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
    RGB(0.984,0.604,0.6),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_6, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
    RGB(0.984,0.604,0.6),
    RGB(0.89,0.102,0.11),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_7, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
    RGB(0.984,0.604,0.6),
    RGB(0.89,0.102,0.11),
    RGB(0.992,0.749,0.435),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_8, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
    RGB(0.984,0.604,0.6),
    RGB(0.89,0.102,0.11),
    RGB(0.992,0.749,0.435),
    RGB(1.0,0.498,0.0),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_9, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
    RGB(0.984,0.604,0.6),
    RGB(0.89,0.102,0.11),
    RGB(0.992,0.749,0.435),
    RGB(1.0,0.498,0.0),
    RGB(0.792,0.698,0.839),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_10, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
    RGB(0.984,0.604,0.6),
    RGB(0.89,0.102,0.11),
    RGB(0.992,0.749,0.435),
    RGB(1.0,0.498,0.0),
    RGB(0.792,0.698,0.839),
    RGB(0.416,0.239,0.604),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_11, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
    RGB(0.984,0.604,0.6),
    RGB(0.89,0.102,0.11),
    RGB(0.992,0.749,0.435),
    RGB(1.0,0.498,0.0),
    RGB(0.792,0.698,0.839),
    RGB(0.416,0.239,0.604),
    RGB(1.0,1.0,0.6),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Paired_12, SA[
    RGB(0.651,0.808,0.89),
    RGB(0.122,0.471,0.706),
    RGB(0.698,0.875,0.541),
    RGB(0.2,0.627,0.173),
    RGB(0.984,0.604,0.6),
    RGB(0.89,0.102,0.11),
    RGB(0.992,0.749,0.435),
    RGB(1.0,0.498,0.0),
    RGB(0.792,0.698,0.839),
    RGB(0.416,0.239,0.604),
    RGB(1.0,1.0,0.6),
    RGB(0.694,0.349,0.157),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Set2_3, SA[
    RGB(0.4,0.761,0.647),
    RGB(0.988,0.553,0.384),
    RGB(0.553,0.627,0.796),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Set2_4, SA[
    RGB(0.4,0.761,0.647),
    RGB(0.988,0.553,0.384),
    RGB(0.553,0.627,0.796),
    RGB(0.906,0.541,0.765),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Set2_5, SA[
    RGB(0.4,0.761,0.647),
    RGB(0.988,0.553,0.384),
    RGB(0.553,0.627,0.796),
    RGB(0.906,0.541,0.765),
    RGB(0.651,0.847,0.329),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Set2_6, SA[
    RGB(0.4,0.761,0.647),
    RGB(0.988,0.553,0.384),
    RGB(0.553,0.627,0.796),
    RGB(0.906,0.541,0.765),
    RGB(0.651,0.847,0.329),
    RGB(1.0,0.851,0.184),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Set2_7, SA[
    RGB(0.4,0.761,0.647),
    RGB(0.988,0.553,0.384),
    RGB(0.553,0.627,0.796),
    RGB(0.906,0.541,0.765),
    RGB(0.651,0.847,0.329),
    RGB(1.0,0.851,0.184),
    RGB(0.898,0.769,0.58),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Set2_8, SA[
    RGB(0.4,0.761,0.647),
    RGB(0.988,0.553,0.384),
    RGB(0.553,0.627,0.796),
    RGB(0.906,0.541,0.765),
    RGB(0.651,0.847,0.329),
    RGB(1.0,0.851,0.184),
    RGB(0.898,0.769,0.58),
    RGB(0.702,0.702,0.702),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Oranges_3, SA[
    RGB(0.996,0.902,0.808),
    RGB(0.992,0.682,0.42),
    RGB(0.902,0.333,0.051),
], "colorbrewer2", "light to dark orange")

loadcolorscheme(:Oranges_4, SA[
    RGB(0.996,0.929,0.871),
    RGB(0.992,0.745,0.522),
    RGB(0.992,0.553,0.235),
    RGB(0.851,0.278,0.004),
], "colorbrewer2", "light to dark orange")

loadcolorscheme(:Oranges_5, SA[
    RGB(0.996,0.929,0.871),
    RGB(0.992,0.745,0.522),
    RGB(0.992,0.553,0.235),
    RGB(0.902,0.333,0.051),
    RGB(0.651,0.212,0.012),
], "colorbrewer2", "light to dark orange")

loadcolorscheme(:Oranges_6, SA[
    RGB(0.996,0.929,0.871),
    RGB(0.992,0.816,0.635),
    RGB(0.992,0.682,0.42),
    RGB(0.992,0.553,0.235),
    RGB(0.902,0.333,0.051),
    RGB(0.651,0.212,0.012),
], "colorbrewer2", "light to dark orange")

loadcolorscheme(:Oranges_7, SA[
    RGB(0.996,0.929,0.871),
    RGB(0.992,0.816,0.635),
    RGB(0.992,0.682,0.42),
    RGB(0.992,0.553,0.235),
    RGB(0.945,0.412,0.075),
    RGB(0.851,0.282,0.004),
    RGB(0.549,0.176,0.016),
], "colorbrewer2", "light to dark orange")

loadcolorscheme(:Oranges_8, SA[
    RGB(1.0,0.961,0.922),
    RGB(0.996,0.902,0.808),
    RGB(0.992,0.816,0.635),
    RGB(0.992,0.682,0.42),
    RGB(0.992,0.553,0.235),
    RGB(0.945,0.412,0.075),
    RGB(0.851,0.282,0.004),
    RGB(0.549,0.176,0.016),
], "colorbrewer2", "light to dark orange")

loadcolorscheme(:Oranges_9, SA[
    RGB(1.0,0.961,0.922),
    RGB(0.996,0.902,0.808),
    RGB(0.992,0.816,0.635),
    RGB(0.992,0.682,0.42),
    RGB(0.992,0.553,0.235),
    RGB(0.945,0.412,0.075),
    RGB(0.851,0.282,0.004),
    RGB(0.651,0.212,0.012),
    RGB(0.498,0.153,0.016),
], "colorbrewer2", "light to dark orange")

loadcolorscheme(:OrRd_3, SA[
    RGB(0.996,0.91,0.784),
    RGB(0.992,0.733,0.518),
    RGB(0.89,0.29,0.2),
], "colorbrewer2", "orange to red")

loadcolorscheme(:OrRd_4, SA[
    RGB(0.996,0.941,0.851),
    RGB(0.992,0.8,0.541),
    RGB(0.988,0.553,0.349),
    RGB(0.843,0.188,0.122),
], "colorbrewer2", "orange to red")

loadcolorscheme(:OrRd_5, SA[
    RGB(0.996,0.941,0.851),
    RGB(0.992,0.8,0.541),
    RGB(0.988,0.553,0.349),
    RGB(0.89,0.29,0.2),
    RGB(0.702,0.0,0.0),
], "colorbrewer2", "orange to red")

loadcolorscheme(:OrRd_6, SA[
    RGB(0.996,0.941,0.851),
    RGB(0.992,0.831,0.62),
    RGB(0.992,0.733,0.518),
    RGB(0.988,0.553,0.349),
    RGB(0.89,0.29,0.2),
    RGB(0.702,0.0,0.0),
], "colorbrewer2", "orange to red")

loadcolorscheme(:OrRd_7, SA[
    RGB(0.996,0.941,0.851),
    RGB(0.992,0.831,0.62),
    RGB(0.992,0.733,0.518),
    RGB(0.988,0.553,0.349),
    RGB(0.937,0.396,0.282),
    RGB(0.843,0.188,0.122),
    RGB(0.6,0.0,0.0),
], "colorbrewer2", "orange to red")

loadcolorscheme(:OrRd_8, SA[
    RGB(1.0,0.969,0.925),
    RGB(0.996,0.91,0.784),
    RGB(0.992,0.831,0.62),
    RGB(0.992,0.733,0.518),
    RGB(0.988,0.553,0.349),
    RGB(0.937,0.396,0.282),
    RGB(0.843,0.188,0.122),
    RGB(0.6,0.0,0.0),
], "colorbrewer2", "orange to red")

loadcolorscheme(:OrRd_9, SA[
    RGB(1.0,0.969,0.925),
    RGB(0.996,0.91,0.784),
    RGB(0.992,0.831,0.62),
    RGB(0.992,0.733,0.518),
    RGB(0.988,0.553,0.349),
    RGB(0.937,0.396,0.282),
    RGB(0.843,0.188,0.122),
    RGB(0.702,0.0,0.0),
    RGB(0.498,0.0,0.0),
], "colorbrewer2", "orange to red")

loadcolorscheme(:Accent_3, SA[
    RGB(0.498,0.788,0.498),
    RGB(0.745,0.682,0.831),
    RGB(0.992,0.753,0.525),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Accent_4, SA[
    RGB(0.498,0.788,0.498),
    RGB(0.745,0.682,0.831),
    RGB(0.992,0.753,0.525),
    RGB(1.0,1.0,0.6),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Accent_5, SA[
    RGB(0.498,0.788,0.498),
    RGB(0.745,0.682,0.831),
    RGB(0.992,0.753,0.525),
    RGB(1.0,1.0,0.6),
    RGB(0.22,0.424,0.69),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Accent_6, SA[
    RGB(0.498,0.788,0.498),
    RGB(0.745,0.682,0.831),
    RGB(0.992,0.753,0.525),
    RGB(1.0,1.0,0.6),
    RGB(0.22,0.424,0.69),
    RGB(0.941,0.008,0.498),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Accent_7, SA[
    RGB(0.498,0.788,0.498),
    RGB(0.745,0.682,0.831),
    RGB(0.992,0.753,0.525),
    RGB(1.0,1.0,0.6),
    RGB(0.22,0.424,0.69),
    RGB(0.941,0.008,0.498),
    RGB(0.749,0.357,0.09),
], "colorbrewer2", "qualitative")

loadcolorscheme(:Accent_8, SA[
    RGB(0.498,0.788,0.498),
    RGB(0.745,0.682,0.831),
    RGB(0.992,0.753,0.525),
    RGB(1.0,1.0,0.6),
    RGB(0.22,0.424,0.69),
    RGB(0.941,0.008,0.498),
    RGB(0.749,0.357,0.09),
    RGB(0.4,0.4,0.4),
], "colorbrewer2", "qualitative")

loadcolorscheme(:GnBu_3, SA[
    RGB(0.878,0.953,0.859),
    RGB(0.659,0.867,0.71),
    RGB(0.263,0.635,0.792),
], "colorbrewer2", "light green to dark blue")

loadcolorscheme(:GnBu_4, SA[
    RGB(0.941,0.976,0.91),
    RGB(0.729,0.894,0.737),
    RGB(0.482,0.8,0.769),
    RGB(0.169,0.549,0.745),
], "colorbrewer2", "light green to dark blue")

loadcolorscheme(:GnBu_5, SA[
    RGB(0.941,0.976,0.91),
    RGB(0.729,0.894,0.737),
    RGB(0.482,0.8,0.769),
    RGB(0.263,0.635,0.792),
    RGB(0.031,0.408,0.675),
], "colorbrewer2", "light green to dark blue")

loadcolorscheme(:GnBu_6, SA[
    RGB(0.941,0.976,0.91),
    RGB(0.8,0.922,0.773),
    RGB(0.659,0.867,0.71),
    RGB(0.482,0.8,0.769),
    RGB(0.263,0.635,0.792),
    RGB(0.031,0.408,0.675),
], "colorbrewer2", "light green to dark blue")

loadcolorscheme(:GnBu_7, SA[
    RGB(0.941,0.976,0.91),
    RGB(0.8,0.922,0.773),
    RGB(0.659,0.867,0.71),
    RGB(0.482,0.8,0.769),
    RGB(0.306,0.702,0.827),
    RGB(0.169,0.549,0.745),
    RGB(0.031,0.345,0.62),
], "colorbrewer2", "light green to dark blue")

loadcolorscheme(:GnBu_8, SA[
    RGB(0.969,0.988,0.941),
    RGB(0.878,0.953,0.859),
    RGB(0.8,0.922,0.773),
    RGB(0.659,0.867,0.71),
    RGB(0.482,0.8,0.769),
    RGB(0.306,0.702,0.827),
    RGB(0.169,0.549,0.745),
    RGB(0.031,0.345,0.62),
], "colorbrewer2", "light green to dark blue")

loadcolorscheme(:GnBu_9, SA[
    RGB(0.969,0.988,0.941),
    RGB(0.878,0.953,0.859),
    RGB(0.8,0.922,0.773),
    RGB(0.659,0.867,0.71),
    RGB(0.482,0.8,0.769),
    RGB(0.306,0.702,0.827),
    RGB(0.169,0.549,0.745),
    RGB(0.031,0.408,0.675),
    RGB(0.031,0.251,0.506),
], "colorbrewer2", "light green to dark blue")

loadcolorscheme(:PiYG_3, SA[
    RGB(0.914,0.639,0.788),
    RGB(0.969,0.969,0.969),
    RGB(0.631,0.843,0.416),
], "colorbrewer2", "purple to white to green diverging")

loadcolorscheme(:PiYG_4, SA[
    RGB(0.816,0.11,0.545),
    RGB(0.945,0.714,0.855),
    RGB(0.722,0.882,0.525),
    RGB(0.302,0.675,0.149),
], "colorbrewer2", "purple to white to green diverging")

loadcolorscheme(:PiYG_5, SA[
    RGB(0.816,0.11,0.545),
    RGB(0.945,0.714,0.855),
    RGB(0.969,0.969,0.969),
    RGB(0.722,0.882,0.525),
    RGB(0.302,0.675,0.149),
], "colorbrewer2", "purple to white to green diverging")

loadcolorscheme(:PiYG_6, SA[
    RGB(0.773,0.106,0.49),
    RGB(0.914,0.639,0.788),
    RGB(0.992,0.878,0.937),
    RGB(0.902,0.961,0.816),
    RGB(0.631,0.843,0.416),
    RGB(0.302,0.573,0.129),
], "colorbrewer2", "purple to white to green diverging")

loadcolorscheme(:PiYG_7, SA[
    RGB(0.773,0.106,0.49),
    RGB(0.914,0.639,0.788),
    RGB(0.992,0.878,0.937),
    RGB(0.969,0.969,0.969),
    RGB(0.902,0.961,0.816),
    RGB(0.631,0.843,0.416),
    RGB(0.302,0.573,0.129),
], "colorbrewer2", "purple to white to green diverging")

loadcolorscheme(:PiYG_8, SA[
    RGB(0.773,0.106,0.49),
    RGB(0.871,0.467,0.682),
    RGB(0.945,0.714,0.855),
    RGB(0.992,0.878,0.937),
    RGB(0.902,0.961,0.816),
    RGB(0.722,0.882,0.525),
    RGB(0.498,0.737,0.255),
    RGB(0.302,0.573,0.129),
], "colorbrewer2", "purple to white to green diverging")

loadcolorscheme(:PiYG_9, SA[
    RGB(0.773,0.106,0.49),
    RGB(0.871,0.467,0.682),
    RGB(0.945,0.714,0.855),
    RGB(0.992,0.878,0.937),
    RGB(0.969,0.969,0.969),
    RGB(0.902,0.961,0.816),
    RGB(0.722,0.882,0.525),
    RGB(0.498,0.737,0.255),
    RGB(0.302,0.573,0.129),
], "colorbrewer2", "purple to white to green diverging")

loadcolorscheme(:PiYG_10, SA[
    RGB(0.557,0.004,0.322),
    RGB(0.773,0.106,0.49),
    RGB(0.871,0.467,0.682),
    RGB(0.945,0.714,0.855),
    RGB(0.992,0.878,0.937),
    RGB(0.902,0.961,0.816),
    RGB(0.722,0.882,0.525),
    RGB(0.498,0.737,0.255),
    RGB(0.302,0.573,0.129),
    RGB(0.153,0.392,0.098),
], "colorbrewer2", "purple to white to green diverging")

loadcolorscheme(:PiYG_11, SA[
    RGB(0.557,0.004,0.322),
    RGB(0.773,0.106,0.49),
    RGB(0.871,0.467,0.682),
    RGB(0.945,0.714,0.855),
    RGB(0.992,0.878,0.937),
    RGB(0.969,0.969,0.969),
    RGB(0.902,0.961,0.816),
    RGB(0.722,0.882,0.525),
    RGB(0.498,0.737,0.255),
    RGB(0.302,0.573,0.129),
    RGB(0.153,0.392,0.098),
], "colorbrewer2", "purple to white to green diverging")


text:
using Test, DelimitedFiles, GroundMotion

# constants
TEST_GRID_SIZE = 17
WITH_MINPGA = 8
SIMULATION_ARRAY_SIZE = 1000
# load vs30 grid
grid = read_vs30_file("testvs30.txt")
raw_grid = readdlm("testvs30.txt")
grid_dl = read_vs30_dl_file("testvs30dl.txt")
grid_epicenter = [Point_vs30(143.04,51.92,350)]
# set earthquake location
eq_4 = Earthquake(143.04,51.92,13,4)
eq_6 = Earthquake(143.04,51.92,13,6)
eq_7 = Earthquake(143.04,51.92,13,7)
eq_85 = Earthquake(143.04,51.92,13,8.5)

## Auxilary finctions tests
include("test_auxiliary.jl")

## AS2008 GMPE tests
include("test_as2008.jl")

## Si-Midorikawa 1999 GMPE tests
include("test_simidorikawa1999.jl")

## Morikawa-Fujiwara 2013 GMPE tests
include("test_morikawafujiwara2013.jl")

ext: jl


text:
using ITensors,
      Test,
      Suppressor

@testset "Example Codes" begin

  @testset "Basic Ops" begin
    @test_nowarn begin
      @capture_out begin
        include("../examples/basic_ops/basic_ops.jl")
      end
    end
  end

  @testset "DMRG with Observer" begin
    @test_nowarn begin
      @capture_out begin
        include("../examples/dmrg/dmrg_with_observer.jl")
      end
    end
  end

  @testset "Package Compile Code" begin
    @test_nowarn begin
      @capture_out begin
        include("../src/packagecompile/precompile_itensors.jl")
      end
    end
  end

end

nothing


text:
"""
Adapted from sandreza/Learning/sandbox/oceananigans_converter.jl
https://github.com/sandreza/Learning/blob/master/sandbox/oceananigans_converter.jl
"""

using JLD2, NetCDF

struct OceananigansData{𝒮, 𝒯, 𝒰, 𝒱}
    # initial conditions, 4
    T⁰::𝒮
    S⁰::𝒮
    U⁰::𝒮
    V⁰::𝒮

    # fields at each moment in time, 4
    T::𝒯
    S::𝒯
    U::𝒯
    V::𝒯

    # some second order statistics at each moment in time, 5
    wT::𝒯
    wS::𝒯
    uu::𝒯
    vv::𝒯
    ww::𝒯
    tke::𝒯

    # simulation constants, 8
    ρ::𝒰
    α::𝒰
    β::𝒰
    cᵖ::𝒰
    f⁰::𝒰
    g::𝒰
    L::𝒰
    κₑ::𝒰

    # time and grid, 2
    t::𝒮
    z::𝒮

    #top boundary condition data, see string for type of boundary condition, 4
    top_T::𝒰
    top_S::𝒰
    top_U::𝒰
    top_V::𝒰

    #bottom boundary condition data, see string for type of boundary condtion,4
    bottom_T::𝒰
    bottom_S::𝒰
    bottom_U::𝒰
    bottom_V::𝒰

    #info about the simulation, 1
    info::𝒱
end

"""
OceananigansData(filename)
# Description
- Constructor for Oceananigans data type. Loads data from LES
# Fields for the output are
    # initial conditions
    T⁰::𝒮
    S⁰::𝒮
    U⁰::𝒮
    V⁰::𝒮
    # fields at each moment in time
    T::𝒯
    S::𝒯
    U::𝒯
    V::𝒯
    # some second order statistics at each moment in time
    wT::𝒯
    wS::𝒯
    uu::𝒯
    vv::𝒯
    ww::𝒯
    tke::𝒯
    # simulation constants
    ρ::𝒰
    α::𝒰
    β::𝒰
    cᵖ::𝒰
    f⁰::𝒰
    g::𝒰
    # time and grid
    t::𝒮
    z::𝒮
    #top boundary condition data, see string for type of boundary condition
    top_T::𝒰
    top_S::𝒰
    top_U::𝒰
    top_V::𝒰
    #bottom boundary condition data, see string for type of boundary condtion
    bottom_T::𝒰
    bottom_S::𝒰
    bottom_U::𝒰
    bottom_V::𝒰
    #info about the simulation
    info::𝒱
"""
function ReadJLD2_OceananigansData(filename)
    les_data = jldopen(filename, "r")
    les_keys = keys(les_data)
    timeseries_keys = keys(les_data["timeseries"]["t"])

    # hold the entries for easy constructor creation
    container = []

    println(collect(les_data["grid"]["zC"]))

    # size of arrays
    Nz = length(collect(les_data["grid"]["zC"]))
    Nt = length(timeseries_keys)

    ## construct arrays
    #Initial Conditions
    T⁰ = zeros(Nz)
    S⁰ = zeros(Nz)
    U⁰ = zeros(Nz)
    V⁰ = zeros(Nz)

    #Timeseries
    T = zeros(Nz, Nt)
    S = zeros(Nz, Nt)
    U = zeros(Nz, Nt)
    V = zeros(Nz, Nt)
    t = zeros(Nt)

    println(Nz)

    #Second Order Statistics
    wT  = zeros(Nz, Nt)
    wS  = zeros(Nz, Nt)
    uu  = zeros(Nz, Nt)
    vv  = zeros(Nz, Nt)
    ww  = zeros(Nz, Nt)

    # grab arrays
    for j in 1:Nt
        # Fields
        key = timeseries_keys[j]
        println(length(les_data["timeseries"]["T"][key]))
        @. T[:,j] = les_data["timeseries"]["T"][key][2:(end-1)]
        @. S[:,j] = les_data["timeseries"]["S"][key][2:(end-1)]
        @. U[:,j] = les_data["timeseries"]["u"][key][2:(end-1)]
        @. V[:,j] = les_data["timeseries"]["v"][key][2:(end-1)]
        # Second Order Statistics
        @. wT[:,j] = les_data["timeseries"]["wT"][key][2:(end-1)]
        @. wS[:,j] = les_data["timeseries"]["wS"][key][2:(end-1)]
        @. uu[:,j] = les_data["timeseries"]["uu"][key][2:(end-1)]
        @. vv[:,j] = les_data["timeseries"]["vv"][key][2:(end-1)]
        @. ww[:,j] = les_data["timeseries"]["ww"][key][2:(end-1)]

        t[j] = les_data["timeseries"]["t"][key]
    end

    tke = 0.5*(uu.^2 .+ vv.^2 .+ ww.^2) .* 2e8

    # Set initial Conditions
    @. T⁰ = T[:,1]
    @. S⁰ = S[:,1]
    @. U⁰ = U[:,1]
    @. V⁰ = V[:,1]

    # Push initial conditions current stuff into container
    push!(container, T⁰, S⁰, V⁰, U⁰)
    # Push fields into container
    push!(container, T, S, U, V)
    # Push second order statistics into container
    push!(container, wT, wS, uu, vv, ww, tke)

    # Now grab parameter
    ρ = les_data["parameters"]["density"]
    α = les_data["buoyancy"]["equation_of_state"]["α"]
    β = les_data["buoyancy"]["equation_of_state"]["β"]
    cᵖ = les_data["parameters"]["specific_heat_capacity"]
    f⁰ = les_data["coriolis"]["f"]
    g = les_data["buoyancy"]["gravitational_acceleration"]
    L = les_data["grid"]["Lz"]
    κₑ = les_data["parameters"]["diffusivity_T"]

    # b = T .* (g * α)

    # Push parameters to container
    push!(container, ρ, α, β, cᵖ, f⁰, g, L, κₑ)

    # grab domain data
    z = collect(les_data["grid"]["zC"])

    # push
    push!(container, t, z)

    # now grab boundary condition data
    top_T = les_data["boundary_conditions"]["top"]["FT"]
    top_S = 0.0
    top_U = les_data["boundary_conditions"]["top"]["Fu"]
    top_V = 0.0
    #bottom boundary condition data, see string for type of boundary condtion
    bottom_T = les_data["boundary_conditions"]["bottom"]["dTdz"]
    bottom_S = 0.0
    bottom_U = 0.0
    bottom_V = 0.0

    # push to container
    push!(container, top_T, top_S, top_U, top_V, bottom_T, bottom_S, bottom_U, bottom_V)

    # Now construct types
    𝒮 = typeof(T⁰)
    𝒯 = typeof(T)
    𝒰 = typeof(α)
    𝒱 = typeof("string")

    # now create data string
    info_string = "The top boundary conditions are flux boundary conditions \n"
    info_string *= "The  bottom boundary condition for temperature is a gradient boundary condition \n"
    info_string *= "The grid data is assumed to be evenly spaced and a power of two \n"

    # push to container
    push!(container, info_string)
    #return container
    close(les_data)
    return OceananigansData{𝒮, 𝒯, 𝒰, 𝒱}(container...)
end

"""
OceananigansData(filename)
# Description
- Constructor for Oceananigans data type. Loads data from LES
# Fields for the output are
    # initial conditions
    T⁰::𝒮
    S⁰::𝒮
    U⁰::𝒮
    V⁰::𝒮
    # fields at each moment in time
    T::𝒯
    S::𝒯
    U::𝒯
    V::𝒯
    # some second order statistics at each moment in time
    wT::𝒯
    wS::𝒯
    uu::𝒯
    vv::𝒯
    ww::𝒯
    # simulation constants
    ρ::𝒰
    α::𝒰
    β::𝒰
    cᵖ::𝒰
    f⁰::𝒰
    g::𝒰
    # time and grid
    t::𝒮
    z::𝒮
    #top boundary condition data, see string for type of boundary condition
    top_T::𝒰
    top_S::𝒰
    top_U::𝒰
    top_V::𝒰
    #bottom boundary condition data, see string for type of boundary condtion
    bottom_T::𝒰
    bottom_S::𝒰
    bottom_U::𝒰
    bottom_V::𝒰
    #info about the simulation
    info::𝒱
"""
function ReadNetCDF_OceananigansData(filename)

    ncinfo(filename)
    x = Array(NetCDF.open(filename, "yC"))
    y = Array(NetCDF.open(filename, "yC"))
    z = Array(NetCDF.open(filename, "zC"))
    t = Array(NetCDF.open(filename, "time"))
    sim_day = t ./ 86400

    z = (z[2:end] + z[1:end-1]) / 2

    vectify(x) = [x[i] for i in 1:length(x)]
    b = vectify(NetCDF.open(filename, "b"))
    u = vectify(NetCDF.open(filename, "u"))
    v = vectify(NetCDF.open(filename, "v"))
    w = vectify(NetCDF.open(filename, "w"))
    ##

    # T = b./(g*α)
    T = b./(9.81 * 2e-4)

    # hold the entries for easy constructor creation
    container = []

    # size of arrays
    Nz = length(z)
    Nt = length(t)

    ## construct arrays
    #Initial Conditions
    T⁰ = zeros(Nz)
    S⁰ = zeros(Nz)
    U⁰ = zeros(Nz)
    V⁰ = zeros(Nz)
    #Timeseries
    T = zeros(Nz, Nt)
    S = zeros(Nz, Nt)
    U = zeros(Nz, Nt)
    V = zeros(Nz, Nt)
    t = zeros(Nt)

    #Second Order Statistics
    wT = zeros(Nz, Nt)
    wS = zeros(Nz, Nt)
    uu = zeros(Nz, Nt)
    vv = zeros(Nz, Nt)
    ww = zeros(Nz, Nt)

    # grab arrays
    for j in 1:Nt
        # Fields
        key = timeseries_keys[j]
        @. T[:,j] = les_data["timeseries"]["T"][key]
        @. S[:,j] = les_data["timeseries"]["S"][key]
        @. U[:,j] = les_data["timeseries"]["u"][key]
        @. V[:,j] = les_data["timeseries"]["v"][key]
        # Second Order Statistics
        @. wT[:,j] = les_data["timeseries"]["wT"][key]
        @. wS[:,j] = les_data["timeseries"]["wS"][key]
        @. uu[:,j] = les_data["timeseries"]["uu"][key]
        @. vv[:,j] = les_data["timeseries"]["vv"][key]
        @. ww[:,j] = les_data["timeseries"]["ww"][key]

        t[j] = les_data["timeseries"]["t"][key]
    end
    # Set initial Conditions
    @. T⁰ = T[:,1]
    @. S⁰ = S[:,1]
    @. U⁰ = U[:,1]
    @. V⁰ = V[:,1]

    # Push initial conditions current stuff into container
    push!(container, T⁰, S⁰, V⁰, U⁰)
    # Push fields into container
    push!(container, T, S, U, V)
    # Push second order statistics into container
    push!(container, wT, wS, uu, vv, ww)

    # Now grab parameter
    ρ = les_data["parameters"]["density"]
    α = les_data["buoyancy"]["equation_of_state"]["α"]
    β = les_data["buoyancy"]["equation_of_state"]["β"]
    cᵖ = les_data["parameters"]["specific_heat_capacity"]
    f⁰ = les_data["coriolis"]["f"]
    g = les_data["buoyancy"]["gravitational_acceleration"]
    L = les_data["grid"]["Lz"]

    # Push parameters to container
    push!(container, ρ, α, β, cᵖ, f⁰, g, L)

    # grab domain data
    z = collect(les_data["grid"]["zC"])

    # push
    push!(container, t, z)

    # now grab boundary condition data
    top_T = les_data["boundary_conditions"]["top"]["FT"]
    top_S = 0.0
    top_U = les_data["boundary_conditions"]["top"]["Fu"]
    top_V = 0.0
    #bottom boundary condition data, see string for type of boundary condtion
    bottom_T = les_data["boundary_conditions"]["bottom"]["dTdz"]
    bottom_S = 0.0
    bottom_U = 0.0
    bottom_V = 0.0

    # push to container
    push!(container, top_T, top_S, top_U, top_V, bottom_T, bottom_S, bottom_U, bottom_V)

    # Now construct types
    𝒮 = typeof(T⁰)
    𝒯 = typeof(T)
    𝒰 = typeof(α)
    𝒱 = typeof("string")

    # now create data string
    info_string = "The top boundary conditions are flux boundary conditions \n"
    info_string *= "The  bottom boundary condition for temperature is a gradient boundary condition \n"
    info_string *= "The grid data is assumed to be evenly spaced and a power of two \n"

    # push to container
    push!(container, info_string)
    return OceananigansData{𝒮, 𝒯, 𝒰, 𝒱}(container...)
end

# """
# avg(Φ, n)
# # Description
# - Average a field down by n.
# - Requires field to have evenly spaced points. Size of N leq length(Φ).
# - Furthermore requires
# # Arguments
# - `Φ` :(vector) The field, an array
# - `n` :(Int) number of grid points to average down to.
# # Return
# - `Φ2` :(vector) The field with values averaged, an array
# """
# function avg(Φ, n)
#   m = length(Φ)
#   scale = Int(floor(m/n))
#   if ( abs(Int(floor(m/n)) - m/n) > eps(1.0))
#       return error
#   end
#   Φ2 = zeros(n)
#   for i in 1:n
#       Φ2[i] = 0
#           for j in 1:scale
#               Φ2[i] += Φ[scale*(i-1) + j] / scale
#           end
#   end
#   return Φ2
# end

max_stars_repo_name: adelinehillier/LearnConvection

max_issues_repo_name: adelinehillier/LearnConvection

max_forks_repo_name: adelinehillier/LearnConvection


text:
using GeometryTypes, GLVisualize, GLAbstraction, Reactive, GLWindow, GLFW

if !isdefined(:runtests)
window = glscreen()
end
const record_interactive = true

n = 50
n_connections = 100
a = rand(Point2f0, n)*1000f0
indices = Signal(rand(1:n, n_connections))
# for the points, we only need unique indices!
unique_indices = map(unique, indices)
points = visualize((Circle(Point2f0(0), 15f0), a), indices=unique_indices)

const point_robj = points.children[] # temporary way of getting the render object. Shouldn't stay like this
 # best way to get the gpu object. One could also start by creating a gpu array oneself.
 # this is a bit tricky, since not there are three different types.
 # for points and lines you need a GLBuffer. e.g gpu_position = GLBuffer(rand(Point2f0, 50)*1000f0)
const gpu_position = point_robj[:position]
# GPUVector adds functionality like push! and splice!
# now the lines and points share the same gpu object
# for linesegments, you can pass indices, which needs to be of some 32bit int type
lines  = visualize(gpu_position, :linesegment, indices=indices)

# current tuple of renderobject id and index into the gpu array
const m2id = GLWindow.mouse2id(window)
isoverpoint = const_lift(is_same_id, m2id, point_robj)

# inputs are a dict, materialize gets the keys out of it (equivalent to mouseposition = window.inputs[:mouseposition])
@materialize mouse_buttons_pressed, mouseposition = window.inputs

# single left mousekey pressed (while no other mouse key is pressed)
key_pressed = const_lift(GLAbstraction.singlepressed, mouse_buttons_pressed, GLFW.MOUSE_BUTTON_LEFT)
# righ
right_pressed = const_lift(GLAbstraction.singlepressed, mouse_buttons_pressed, GLFW.MOUSE_BUTTON_RIGHT)
# dragg while key_pressed. Drag only starts if isoverpoint is true
mousedragg  = GLAbstraction.dragged(mouseposition, key_pressed, isoverpoint)

# use mousedrag and mouseid + index to actually change the gpu array with the positions
preserve(foldp((value(m2id)..., Point2f0(0)), mousedragg) do v0, dragg
    if dragg == Vec2f0(0) # if drag just started. Not the best way, maybe dragged should return a tuple of (draggvalue, started)
        id, index = value(m2id)
        if id==point_robj.id && length(gpu_position) >= index
            p0 = gpu_position[index]
        else
            p0 = v0[3]
        end
    else
        id, index, p0 = v0
        if id==point_robj.id && length(gpu_position) >= index
            gpu_position[index] = Point2f0(p0) + Point2f0(dragg)
        end

    end
    return id, index, p0
end)
# On right click remove nodes!
preserve(map(right_pressed) do rp
    id, index = value(m2id)
    if rp && id==point_robj.id && length(gpu_position) >= index
        new_indices = Int[]
        indice_val = value(indices)
        for i=1:2:length(indice_val) #filter out indices
            a, b = indice_val[i], indice_val[i+1]
            if a != index && b != index
                push!(new_indices, a, b)
            end
        end
        push!(indices, new_indices) # update indices!
    end
end)
# _view it!
_view(lines, window, camera=:fixed_pixel)
_view(points, window, camera=:fixed_pixel)

if !isdefined(:runtests)
    renderloop(window)
end


text:
"""
`Contractor` represents a `Contractor` from ``\\mathbb{R}^N`` to ``\\mathbb{R}^N``.
Nout is the output dimension of the forward part.
"""
abstract type AbstractContractor end

struct Contractor{N, Nout, F1<:Function, F2<:Function, ex<:Union{Operation,Expr}} <:AbstractContractor
    variables::Vector{Symbol}  # input variables
    forward::GeneratedFunction{F1}
    backward::GeneratedFunction{F2}
    expression::ex
end

struct BasicContractor{F1<:Function, F2<:Function} <:AbstractContractor
    forward::F1
    backward::F2
end

function Contractor(variables::Vector{Symbol}, top, forward, backward, expression)

    # @show variables
    # @show top

    N = length(variables)  # input dimension

    local Nout  # number of outputs

    if isa(top, Symbol)
        Nout = 1

    elseif isa(top, Expr) && top.head == :tuple
        Nout = length(top.args)

    else
        Nout = length(top)
    end

    Contractor{N, Nout, typeof(forward.f), typeof(backward.f), typeof(expression)}(variables, forward, backward, expression)
end

function Base.show(io::IO, C::Contractor{N,Nout,F1,F2,ex}) where {N,Nout,F1,F2,ex}
    println(io, "Contractor in $(N) dimensions:")
    println(io, "  - forward pass contracts to $(Nout) dimensions")
    println(io, "  - variables: $(C.variables)")
    print(io, "  - expression: $(C.expression)")
end

    (C::Contractor)(X) = C.forward(X)[1]
    (C::BasicContractor)(X) = C.forward(X)[1]

function contract(C::AbstractContractor, A::IntervalBox{Nout,T}, X::IntervalBox{N,T})where {N,Nout,T}

    output, intermediate = C.forward(X)
    # @show output
    # @show intermediate

    output_box = IntervalBox(output)
    constrained = output_box ∩ A

    # if constrained is already empty, eliminate call to backward propagation:

    if isempty(constrained)
        return emptyinterval(X)
    end

    # @show X
    # @show constrained
    # @show intermediate
    # @show C.backward(X, constrained, intermediate)
    return IntervalBox{N,T}(C.backward(X, constrained, intermediate) )

end

function (C::Contractor)(A::IntervalBox{Nout,T}, X::IntervalBox{N,T})where {N,Nout,T}
    return contract(C, A, X)
end

# allow 1D contractors to take Interval instead of IntervalBox for simplicty:
(C::Contractor)(A::Interval{T}, X::IntervalBox{N,T}) where {N,T} = C(IntervalBox(A), X)

function (C::BasicContractor)(A::IntervalBox{Nout,T}, X::IntervalBox{N,T})where {N,Nout,T}
    return contract(C, A, X)
end

# allow 1D contractors to take Interval instead of IntervalBox for simplicty:
(C::BasicContractor)(A::Interval{T}, X::IntervalBox{N,T}) where {N,Nout,T} = C(IntervalBox(A), X)

""" Contractor can also be construct without the use of macros
 vars = @variables x y z
 C = Contractor(x + y , vars)
 C(-Inf..1, IntervalBox(0.5..1.5,3))
 """

function Contractor(variables, expr::Operation)

    var = [i.op.name for i in variables]
    top, linear_AST = flatten(expr, var)

    forward_code, backward_code  = forward_backward(linear_AST)

    # @show top

    if isa(top, Symbol)
        top = [top]
    end

    forward = eval(forward_code)
    backward = eval(backward_code)

    Contractor(linear_AST.variables,
                    top,
                    GeneratedFunction(forward, forward_code),
                    GeneratedFunction(backward, backward_code),
                    expr)

end

function BasicContractor(variables, expr::Operation)

    var = [i.op.name for i in variables]
    top, linear_AST = flatten(expr, var)

    forward_code, backward_code  = forward_backward(linear_AST)

    forward = eval(forward_code)
    backward = eval(backward_code)

    BasicContractor{typeof(forward), typeof(backward)}(forward, backward)
end

function Base.show(io::IO, C::BasicContractor{F1,F2}) where {F1,F2}
    println(io, " Basic version of Contractor")
end

BasicContractor(expr::Operation) = BasicContractor([], expr::Operation)

BasicContractor(vars::Union{Vector{Operation}, Tuple{Vararg{Operation,N}}}, g::Function) where N = BasicContractor(vars, g(vars...)) #Contractor can be constructed by function name only

BasicContractor(vars, f::Function) = BasicContractor([Variable(Symbol(i))() for i in vars], f([Variable(Symbol(i))() for i in vars]...))#if vars is not vector of Operation

Contractor(expr::Operation) = Contractor([], expr::Operation)

Contractor(vars::Union{Vector{Operation}, Tuple{Vararg{Operation,N}}}, g::Function) where N = Contractor(vars, g(vars...)) #Contractor can be constructed by function name only

Contractor(vars, f::Function) = Contractor([Variable(Symbol(i))() for i in vars], f([Variable(Symbol(i))() for i in vars]...))#if vars is not vector of Operation

function make_contractor(expr::Expr, var = [])
    # println("Entering Contractor(ex) with ex=$ex")
    # expr, constraint_interval = parse_comparison(ex)

    # if constraint_interval != entireinterval()
    #     warn("Ignoring constraint; include as first argument")
    # end

    top, linear_AST = flatten(expr, var)

    #  @show expr
    #  @show top
    #  @show linear_AST

    forward_code, backward_code  = forward_backward(linear_AST)
    # @show top

    if isa(top, Symbol)
        top = [top]

    elseif isa(top, Expr) && top.head == :tuple
        top = top.args

    end
    # @show forward_code
    # @show backward_code

    :(Contractor($(linear_AST.variables),
                    $top,
                    GeneratedFunction($forward_code, $(Meta.quot(forward_code))),
                    GeneratedFunction($backward_code, $(Meta.quot(backward_code))),
                    $(Meta.quot(expr))))

end

"""Usage:
```
C = @contractor(x^2 + y^2)
A = -∞..1  # the constraint interval
x = y = @interval(0.5, 1.5)
C(A, x, y)

`@contractor` makes a function that takes as arguments the variables contained in the expression, in lexicographic order
```

TODO: Hygiene for global variables, or pass in parameters
"""
macro contractor(ex, variables=[])
    isa(variables, Array) ? var = [] : var = variables.args
    make_contractor(ex, var)
end


text:
selty = sizeof($(elty))
px = convert(Ptr{$(elty)},x) + (ix-1)*selty
py = convert(Ptr{$(elty)},y) + (iy-1)*selty
ccall(:memcpy, Ptr{Void}, (Ptr{Void}, Ptr{Void}, Uint),
    px, py, n*selty)


text:
# What do we do if the struct has a nested structure?

using BenchmarkTools, CSV, Statistics
using StructArrays

struct Fare
    fare_amount::Float64
    extra::Float64
    mta_tax::Float64
    tip_amount::Float64
    tolls_amount::Float64
    improvement_surcharge::Float64
    total_amount::Float64
end

struct TripPayment
    vendor_id::Int
    tpep_pickup_datetime::String
    tpep_dropoff_datetime::String
    passenger_count::Int
    trip_distance::Float64
    fare::Fare
end

# Use CVS.jl to parse the file into a vecot or TripPayment objects
function read_trip_payment_file(file)
    f = CSV.File(file, datarow = 3)
    records = Vector{TripPayment}(undef, length(f))
    for (i, row) in enumerate(f)
        records[i] = TripPayment(row.VendorID,
                                 row.tpep_pickup_datetime,
                                 row.tpep_dropoff_datetime,
                                 row.passenger_count,
                                 row.trip_distance,
                                 Fare(row.fare_amount,
                                      row.extra,
                                      row.mta_tax,
                                      row.tip_amount,
                                      row.tolls_amount,
                                      row.improvement_surcharge,
                                      row.total_amount))
    end
    return records
end

records = read_trip_payment_file("yellow_tripdata_2018-12_100k.csv");
records[1]
#=
julia> records = read_trip_payment_file("yellow_tripdata_2018-12_100k.csv");

julia> records[1]
TripPayment(1, "2018-12-01 00:28:22", "2018-12-01 00:44:07", 2, 2.5, Fare(12.0, 0.5, 0.5, 3.95, 0.0, 0.3, 17.25))
=#

sa = StructArray(records);
sa.fare.fare_amount
# Doesn't work if we play the same trick as before
#=
julia> sa = StructArray(records);

julia> sa.fare.fare_amount
ERROR: type Array has no field fare_amount
=#

# How?
sa = StructArray(records, unwrap = t -> t <: Fare);
sa.fare.fare_amount
#=
julia> sa = StructArray(records, unwrap = t -> t <: Fare);

julia> sa.fare.fare_amount
100000-element Array{Float64,1}:
 12.0
 13.0
  2.5
 12.5
 45.0
 50.5
=#

# It has good performance as expected
@btime mean(sa.fare.fare_amount)
#=
julia> @btime mean(sa.fare.fare_amount)
  27.198 μs (1 allocation: 16 bytes)
=#


text:
export LakeShoreF71GaussMeter, LakeShoreF71GaussMeterParams, LakeShoreF71GaussMeterConnectionModes,
       F71_CM_TCP, F71_CM_USB, F71_MM_AC, F71_MM_DC, F71_MM_HIFR, setMeasurementMode

@enum LakeShoreF71GaussMeterConnectionModes begin
  F71_CM_TCP
  F71_CM_USB
end

function convert(::Type{LakeShoreF71GaussMeterConnectionModes}, x::String)
  if uppercase(x) == "TCP"
    return F71_CM_TCP
  elseif uppercase(x) == "USB"
    return F71_CM_USB
  else
    throw(ScannerConfigurationError("The given connection mode `$x` for the LakeShore F71 gaussmeter is not valid. Please use `TCP` or `USB`."))
  end
end

@enum LakeShoreF71GaussMeterMeasurementModes begin
  F71_MM_DC
  F71_MM_AC
  F71_MM_HIFR
end

function convert(::Type{LakeShoreF71GaussMeterMeasurementModes}, x::String)
  if uppercase(x) == "DC"
    return F71_MM_DC
  elseif uppercase(x) == "AC"
    return F71_MM_AC
  elseif uppercase(x) == "HIFR"
    F71_MM_HIFR
  else
    throw(ScannerConfigurationError("The given measurement mode `$x` for the LakeShore F71 gaussmeter is not valid. Please use `DC`, `AC` or `HIFR`."))
  end
end

Base.@kwdef struct LakeShoreF71GaussMeterParams <: DeviceParams
  connectionMode::LakeShoreF71GaussMeterConnectionModes = F71_CM_USB
  ip::IPAddr = ip"192.168.2.2"
  port::Integer = 7777
  comport::String = "COM4"
  baudrate::Integer = 115200

  measurementMode::LakeShoreF71GaussMeterMeasurementModes = F71_MM_DC

  coordinateTransformation::Matrix{Float64} = Matrix{Float64}(I,(3,3))
end
LakeShoreF71GaussMeterParams(dict::Dict) = params_from_dict(LakeShoreF71GaussMeterParams, dict)

"""

"""
Base.@kwdef mutable struct LakeShoreF71GaussMeter <: GaussMeter
  "Unique device ID for this device as defined in the configuration."
  deviceID::String
  "Parameter struct for this devices read from the configuration."
  params::LakeShoreF71GaussMeterParams
  "Flag if the device is optional."
	optional::Bool = false
  "Flag if the device is present."
  present::Bool = false
  "Vector of dependencies for this device."
  dependencies::Dict{String, Union{Device, Missing}}

  driver::Union{SCPIInstrument, Missing} = missing
end

function init(gauss::LakeShoreF71GaussMeter)
  @debug "Initializing LakeShore F71 gaussmeter unit with ID `$(gauss.deviceID)`."
  if gauss.params.connectionMode == F71_CM_TCP
    gauss.driver = TCPSCPIInstrument(gauss.params.ip, gauss.params.port)
  elseif gauss.params.connectionMode == F71_CM_USB
    gauss.driver = SerialSCPIInstrument(gauss.params.comport, gauss.params.baudrate, flow_control=true)
  else
    throw(ScannerConfigurationError("The configured connection mode `$(gauss.params.connectionMode)` is not supported by the LakeShore F71 gaussmeter."))
  end

  setMeasurementMode(gauss, gauss.params.measurementMode)

  # Always use Tesla
  command(gauss.driver, "UNIT:FIELD TESLA")

  gauss.present = true
end

neededDependencies(::LakeShoreF71GaussMeter) = []
optionalDependencies(::LakeShoreF71GaussMeter) = []

Base.close(gauss::LakeShoreF71GaussMeter) = close(gauss.driver)

ipaddress(gauss::LakeShoreF71GaussMeter) = gauss.params.ip

function setMeasurementMode(gauss::LakeShoreF71GaussMeter, mode::LakeShoreF71GaussMeterMeasurementModes)
  if mode == F71_MM_DC
    command(gauss.driver, "SENS:MODE DC")
  elseif mode == F71_MM_AC
    command(gauss.driver, "SENS:MODE AC")
  elseif mode == F71_MM_HIFR
    command(gauss.driver, "SENS:MODE HIFR")
  else
    error("Unsupported measurement mode `$mode`.")
  end
end

getXValue(gauss::LakeShoreF71GaussMeter) = getXYZValues(gauss)[1]
getYValue(gauss::LakeShoreF71GaussMeter) = getXYZValues(gauss)[2]
getZValue(gauss::LakeShoreF71GaussMeter) = getXYZValues(gauss)[3]

function getXYZValues(gauss::LakeShoreF71GaussMeter)
  if gauss.params.measurementMode == F71_MM_DC
    values = parse.(Float64, split(query(gauss.driver, "FETCH:DC? ALL"), ","))[2:4]u"T"
  else
    values = parse.(Float64, split(query(gauss.driver, "FETCH:RMS? ALL"), ","))[2:4]u"T"
  end
  return gauss.params.coordinateTransformation*values
end

getTemperature(gauss::LakeShoreF71GaussMeter) = parse(Float64, query(gauss.driver, "FETCH:TEMP?"))u"°C"

function getFrequency(gauss::LakeShoreF71GaussMeter)
  if gauss.params.measurementMode == F71_MM_DC
    return 0.0u"Hz"
  else
    return parse(Float64, query(gauss.driver, "FETCH:FREQ?"))u"Hz"
  end
end

calculateFieldError(gauss::LakeShoreF71GaussMeter, magneticField::Vector{<:Unitful.BField}) = 0.0u"mT"


text:
"""
# Description

A logical node that represents an order by operation. It has two fields:

1. `source`: A node describing a relation that will be ordered.
2. `expressions`: A tuple of `Expression` objects that define the ordering.
"""
struct OrderBy <: LogicalNode
    source::Any
    expressions::Tuple
end

function Base.print(io::IO, node::OrderBy)
    println(io, "OrderBy LogicalNode")
    println(io, type(node.source))
    for e in node.expressions
        println(io, e)
    end
end


text:
+(t1::NamedTuple, t2::NamedTuple) = merge(t1,t2)
-(t1::NamedTuple, t2::NamedTuple) = Base.structdiff(t1,t2)
-(t1::NamedTuple, s::Symbol) = Base.structdiff(t1, nt(s))
-(t1::NamedTuple, ss::AbstractVector{Symbol}) = Base.structdiff(t1, sum(nt.(ss)))
-(t1::NamedTuple, ss::Tuple{Vararg{Symbol}}) = Base.structdiff(t1, sum(nt.(ss)))

#    _|                          _|
#  _|_|_|_|  _|    _|  _|_|_|    _|    _|_|
#    _|      _|    _|  _|    _|  _|  _|_|_|_|
#    _|      _|    _|  _|    _|  _|  _|
#      _|_|    _|_|_|  _|_|_|    _|    _|_|_|
#                      _|
#                      _|

pars(ps::NamedTuple, isfree::Bool) = isfree==true ? ps : ∅
#
selectintersect(p::NamedTuple, from_p::NamedTuple) = selectpars(from_p, intersect(keys(p), keys(from_p)))

updatevalueorflag(p::NamedTuple, s::Symbol, isfree::Bool, v=getproperty(pars(p),s)) =
    isfree==true ? NamedTuple{keys(p)}(p+nt(s,v)) : # join and replace the old value
    throw(ArgumentError("Not able to fix, release parameters since parameters are held by a NamedTuple!"))

#              _|                                      _|
#    _|_|_|  _|_|_|_|  _|  _|_|  _|    _|    _|_|_|  _|_|_|_|
#  _|_|        _|      _|_|      _|    _|  _|          _|
#      _|_|    _|      _|        _|    _|  _|          _|
#  _|_|_|        _|_|  _|          _|_|_|    _|_|_|      _|_|

struct FlaggedNamedTuple{R}
    allpars::NamedTuple{R}
    whichfixed::Tuple{Vararg{Symbol}}
end
allpars(ps::FlaggedNamedTuple) = getfield(ps,:allpars)
whichfixed(ps::FlaggedNamedTuple) = getfield(ps,:whichfixed)

keys(ps::FlaggedNamedTuple) = keys(allpars(ps))
keys(ps::FlaggedNamedTuple, isfree::Bool) = isfree==false ? whichfixed(ps) : Base.diff_names(keys(allpars(ps)), whichfixed(ps))
pars(ps::FlaggedNamedTuple, isfree::Bool) = NamedTuple{keys(ps, isfree)}(allpars(ps))

getproperty(ps::FlaggedNamedTuple, s::Symbol) = hasproperty(freepars(ps), s) ? getproperty(freepars(ps), s) : getproperty(fixedpars(ps), s)

# inner working
updatednamedtuple(p::NamedTuple, s::Symbol, v) = NamedTuple{keys(p)}(p+nt(s,v))
mustinclude(whichfixed::Tuple{Vararg{Symbol}},s) = s ∈ whichfixed ? whichfixed : (whichfixed...,s)
mustexclude(whichfixed::Tuple{Vararg{Symbol}},s) = s ∈ whichfixed ? Base.diff_names(whichfixed, (s,)) : whichfixed
function updateflag(whichfixed::Tuple{Vararg{Symbol}}, s::Symbol, isfree::Bool)
    isfree ? mustexclude(whichfixed,s) : mustinclude(whichfixed,s)
end

"""
    updatevalueorflag(p::FlaggedNamedTuple, s::Symbol, isfree::Bool, v=getproperty(pars(p),s))

Implementation of the main update method for `FlaggedNamedTuple` parameters.
"""
function updatevalueorflag(p::FlaggedNamedTuple, s::Symbol, isfree::Bool, v=getproperty(pars(p),s))
    return FlaggedNamedTuple(
        updatednamedtuple(allpars(p),s,v),
        updateflag(whichfixed(p), s, isfree))
end
+(s1::FlaggedNamedTuple, s2::FlaggedNamedTuple) =
    FlaggedNamedTuple(allpars(s1)+allpars(s2), (whichfixed(s1)...,whichfixed(s2)...))
+(s1::FlaggedNamedTuple, s2::NamedTuple) = s1+FlaggedNamedTuple(s2)
+(s1::NamedTuple, s2::FlaggedNamedTuple) = FlaggedNamedTuple(s1)+s2
#
FlaggedNamedTuple(t::NamedTuple) = FlaggedNamedTuple(t,())
FlaggedNamedTuple(ps::FlaggedNamedTuple) = FlaggedNamedTuple(allpars(ps),whichfixed(ps))
FlaggedNamedTuple(; kw...) = FlaggedNamedTuple((;kw...))
#
const ParTypes = Union{NamedTuple,FlaggedNamedTuple}
#
pars(ps::ParTypes) = NamedTuple{keys(ps)}(pars(ps, true) + pars(ps, false))
freepars(d::ParTypes) = pars(d, true)
fixedpars(d::ParTypes) = pars(d, false)
#


text:
function count_overlap(A::SparseMatrixCSC{Int64,Int64},B::SparseMatrixCSC{Int64,Int64},mi::Array{Int64,2})

A = A[li[mi],li[mi]]
B = B[lj[mi],lj[mi]]
overlap = div(nnz(A.*B),2)
return overlap

end


text:
#random numbers from the same distribution should have small ks dist
@test ApproxBayes.ksdist(rand(10^5), rand(10^5)) < 0.01


text:
using Test, LTMSim
using SimpleHypergraphs, StatsBase
using Random
using DataStructures
import LightGraphs

h1 = Hypergraph{Float64}(5,4)
h1[1:3,1] .= 1.5
h1[3,4] = 2.5
h1[2,3] = 3.5
h1[4,3:4] .= 4.5
h1[5,4] = 5.5
h1[5,2] = 6.5

@testset "some test" begin
	@test 2+2 == 4
	@test 1+1 == 2
end;


text:
#!/usr/bin/env julia
using Dierckx
using Grid

macro timen(ex, n)
    quote
        local t0 = time_ns()
        for i = 1:$(esc(n))
            local val = $(esc(ex))
        end
        local t1 = time_ns()
        (t1 - t0) / 1.e9 / $(esc(n))
    end
end

function fmt_time(t)
    if t < 1.e-6
        return @sprintf "%7.2f ns" t*1.e9
    elseif t < 1.e-3
        return @sprintf "%7.2f us" t*1.e6
    elseif t < 1.
        return @sprintf "%7.2f ms" t*1.e3
    end
    @sprintf "%7.2f s" t
end

println("Grid.jl     ", Pkg.installed("Grid"))
println("Dierckx.jl  ", Pkg.installed("Dierckx"))
println()
println("| benchmark               | Grid.jl    | Dierckx.jl | ratio |")
println("|-------------------------|------------|------------|-------|")

for n=[10, 1000, 100_000]
    @printf "| eval 1-d grid n=%-7s | " "$(n)"
    nloops = div(10_000_000, n)
    x = Float64[1:n;]
    y = sin(x)
    xi = Float64[1.5:0.5:(n/2. + 1.);]

    g = CoordInterpGrid(1:n, y, BCnearest, InterpQuadratic)
    g[xi]
    t_grid = @timen g[xi] nloops
    print(fmt_time(t_grid), " | ")

    # Dierckx.jl
    spl = Spline1D(x, y; k=2)
    evaluate(spl, xi)
    t_dierckx = @timen evaluate(spl, xi) nloops
    print(fmt_time(t_dierckx), " | ")

    # ratio
    @printf "%5.2f |\n" t_grid/t_dierckx
end

for n=[10, 100, 1000]
    @printf "| eval 2-d grid %-9s | " "$(n)x$(n)"

    nloops = div(10_000_000, n*n)

    x = Float64[1:n;]
    z = Float64[sin(i)+sin(j) for i in x, j in x]
    xi = Float64[1.5:0.5:(n/2. + 1.);]

    # Grid.jl
    g = CoordInterpGrid((1:n, 1:n), z, BCnearest, InterpQuadratic)
    g[xi, xi]
    t_grid = @timen g[xi,xi] nloops
    print(fmt_time(t_grid), " | ")

    # Dierckx.jl
    spl = Spline2D(x, x, z; kx=2, ky=2)
    evalgrid(spl, xi, xi)
    t_dierckx = @timen evalgrid(spl, xi, xi) nloops
    print(fmt_time(t_dierckx), " | ")

    # ratio
    @printf "%5.2f |\n" t_grid/t_dierckx
end