Skip to content

Conversation

nakul-py
Copy link
Contributor

@nakul-py nakul-py commented Aug 29, 2025

Description

Addresses #881

Currently, Color Ramp Type only supports Divergent colors such as balance, delta , curl, diff and tarn so other colormaps are still show type unknown. Enable users to set a minimum and maximum value for the colormap.


Checklist

  • PR has a descriptive title and content.
  • PR description contains references to any issues the PR resolves, e.g. Resolves #XXX.
  • PR has one of the labels: documentation, bug, enhancement, feature, maintenance
  • Checks are passing.
    Failing lint checks can be resolved with:
    • pre-commit run --all-files
    • jlpm run lint

📚 Documentation preview: https://jupytergis--912.org.readthedocs.build/en/912/
💡 JupyterLite preview: https://jupytergis--912.org.readthedocs.build/en/912/lite

Copy link
Contributor

Binder 👈 Launch a Binder on branch nakul-py/jupytergis/divergent

Copy link
Contributor

github-actions bot commented Aug 29, 2025

Integration tests report: appsharing.space

@nakul-py nakul-py changed the title Wip: Supporting divergent colomaps with critical value Supporting divergent colomaps with critical value Sep 2, 2025
@nakul-py nakul-py marked this pull request as ready for review September 2, 2025 12:16
Copy link
Contributor Author

@nakul-py nakul-py left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmocean's "balance" is cool :)

@mfisher87 mfisher87 added the enhancement New feature or request label Sep 3, 2025
Copy link
Member

@mfisher87 mfisher87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Nakul! This looks really good so far! I have some thoughts on the implementation details, most importantly around saving the min & max into the project file as symbologyState.min, symbologyState.max and updating singleband pseudocolor (for raster data) to share the same behavior. We can definitely share a common component!

@mfisher87 mfisher87 changed the title Supporting divergent colomaps with critical value Support divergent color ramps Sep 3, 2025
@mfisher87 mfisher87 requested a review from arjxn-py September 3, 2025 16:13
@nakul-py nakul-py marked this pull request as draft September 5, 2025 08:53
@nakul-py nakul-py marked this pull request as ready for review September 9, 2025 11:02
@nakul-py nakul-py requested a review from mfisher87 September 9, 2025 11:02
@mfisher87
Copy link
Member

Hey @nakul-py I'm a bit overwhelmed with interviewing folks for an internship program. I may be a bit delayed!

Co-authored-by: Nakul Verma <nakulverma.py@gmail.com>
Co-authored-by: Nakul Verma <nakulverma.py@gmail.com>
Copy link
Member

@mfisher87 mfisher87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nakul and I worked on this together for a little bit today. Just leaving some thoughts we talked about -- I'll get to a more comprehensive review on Monday!

Comment on lines 56 to 57
const [selectedMode, setSelectedMode] = useState('');
const [numberOfShades, setNumberOfShades] = useState('');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR: These should be typed better! numberOfShades should be number and selectedMode should be a union of string literals.

nakul-py and others added 13 commits October 1, 2025 19:25
Co-authored-by: Yao-Ting Yao <94820616+YaoTingYao@users.noreply.github.com>
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
Co-authored-by: Yao-Ting Yao <94820616+YaoTingYao@users.noreply.github.com>
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
Co-authored-by: Yao-Ting Yao <94820616+YaoTingYao@users.noreply.github.com>
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
Co-authored-by: Yao-Ting Yao <94820616+YaoTingYao@users.noreply.github.com>
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
* Only display when in equal interval mode -- harder to calculate
  critical value in other modes
* Dynamically calculate critical value instead of displaying 50%
* Move under color ramp selector

Co-authored-by: Yao-Ting Yao <94820616+YaoTingYao@users.noreply.github.com>
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
Co-authored-by: Yao-Ting Yao <94820616+YaoTingYao@users.noreply.github.com>
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
Reverse is successfully being loaded from the shared model, but not
min/max :(

Co-authored-by: Yao-Ting Yao <94820616+YaoTingYao@users.noreply.github.com>
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
@mfisher87
Copy link
Member

mfisher87 commented Oct 3, 2025

Thoughts on saving band-level min/max values: Should we use the state DB? Or should we use the shared document? (@martinRenou @arjxn-py @gjmooney would love your thoughts)

I'm leaning towards the shared document. This would require some changes to the shared document schema. See Issue #946.

This should not be part of this PR. It's mostly a performance concern. If the user clicks "Use actual range" and it looks at the data to find the min/max for the selected band at that time, it'd be a touch slower. But I think that's fine.

For this PR: Remove the use of the global state DB and look at the data to find the dataMin/dataMax values for the "use actual range button". We'll make it faster later!

We should also remove the min/max fields on the geotiff new layer dialog so we don't ask the user to input min/max in two places! Currently in this PR, for singleband pseudocolor, the min/max in the source parameters affects rendering. E.g. setting the source minimum to 2000 in the geotiff example file doesn't work the same as setting the symbology minimum to 2000. This can be seen in which pixels are transparent. Related #946

Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
@mfisher87
Copy link
Member

The symbology "OK" button sometimes doesn't work when manually changing the min and max. Changing the min and max again can re-enable the "OK" button. I'm not sure what the pattern is yet :)

It was failing because symbologyState was not populated in the shared
document at this point.

Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
@mfisher87
Copy link
Member

mfisher87 commented Oct 3, 2025

For singleband pseudocolor, the classification stops don't load on the 2nd, 3rd, etc. opens of the symbology menu. This is a pre-existing bug. Ignore this comment :) #947

return {
...addNoData(sourceInfo),
min: sourceInfo.min,
max: sourceInfo.max,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be the difference in the rendering. We probably need to hook up the user's selected min/max values here. Testing...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This fixes the problem: 5eb2a4c

mfisher87 and others added 2 commits October 3, 2025 11:50
Co-authored-by: Nakul Verma <173621577+nakul-py@users.noreply.github.com>
@mfisher87
Copy link
Member

cf7fe08 removes the min/max source input fields. But now the rendering is non-deterministic. Try clicking classify, then OK, then re-open symbology, re-classify, and click OK. The rendered data can look different each time.

@mfisher87
Copy link
Member

mfisher87 commented Oct 3, 2025

443d195 resolves the initialization of the OpenLayers Source object's min/max values from the symbology info. This is follow-on work resolving problems introduced in cf7fe08. We still need to initialize the symbology info from the file at initialization time (here, if symbologyState isn't defined, look at the data to find the min and max and save it into symbology state: https://github.com/nakul-py/jupytergis/blob/443d19524930b610859583a03f6d3f2f93d5b68a/packages/base/src/mainview/mainView.tsx#L798-L799)

@nakul-py
Copy link
Contributor Author

nakul-py commented Oct 4, 2025

4755f5e this commit fixes that we always get 0/100 fallback values as min/max. Now we got min/max from actual data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants