Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New surface temperature colormap #457

Open
1 task
anayeaye opened this issue Jan 30, 2025 · 3 comments
Open
1 task

New surface temperature colormap #457

anayeaye opened this issue Jan 30, 2025 · 3 comments
Assignees

Comments

@anayeaye
Copy link
Collaborator

anayeaye commented Jan 30, 2025

What

Add a new custom linear colormap for surface temperature datasets. The example below uses specific values for transition stops in the mapping--ultimately what is needed is a continuous linear transition between the color stops.

Matplotlib

#Create colormap:
def interpolate_color(color1, color2, fraction):
    r1, g1, b1 = mcolors.hex2color(color1)
    r2, g2, b2 = mcolors.hex2color(color2)
    r = r1 + fraction * (r2 - r1)
    g = g1 + fraction * (g2 - g1)
    b = b1 + fraction * (b2 - b1)
    return (r, g, b)
def temp_colormap():
    temp_colormap = []
    stops = [
        "#3CCBCE",   # -30
        "#C5F8FF",   # -20
        "#FEC5FF",   # -10
        "#E079FB",   # 0
        "#094FC9",   # 10
        "#009FFF",   # 20
        "#44E2FF",   # 30
        "#147F4F",   # 40
        "#79B32C",   # 50
        "#FDFE00",   # 60
        "#FF8700",   # 70
        "#FF0F00",   # 80
        "#9D0F2B",   # 90
        "#4D0000",   # 100
        "#BA2E6D",   # 110
    ]
    for i in range(len(stops) - 1):
        color1 = stops[i]
        color2 = stops[i + 1]
        for j in range(10):
            fraction = j / 10.0
            interpolated_color = interpolate_color(color1, color2, fraction)
            temp_colormap.append(interpolated_color)
    return mcolors.ListedColormap(temp_colormap)

Sample visualization

Image

AC

  • named custom surface temperature colormap can be used in tile xyz requests
@smohiudd
Copy link
Contributor

@acblackford what collection is this colormap associated with? Do you have a sample file I can test out?

@smohiudd smohiudd self-assigned this Feb 10, 2025
@acblackford
Copy link

@smohiudd This colormap will be associated with MERRA2 and ERA5 2 meter temperature reanalysis data for five select blizzard case dates. I do not have them ingested into STAC yet (will be done soon) but they are in the s3 bucket veda-data-store-staging/Blizzards/ with the general name structures ERA5_2m_Temp_cog_YYYY-MM-DDTHH:MM:SSZ.tif and MERRA2_2m_Temp_cog_YYYY-MM-DDTHH:MM:SSZ.tif .

@acblackford
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants