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

Colorbar levels as list/array in gridmap & small fixes #176

Merged
merged 16 commits into from
Apr 2, 2024
Merged

Conversation

vindelico
Copy link
Contributor

@vindelico vindelico commented Mar 21, 2024

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
    • This PR fixes small bugs
  • (If applicable) Documentation has been added / updated (for bug fixes / features).
  • (If applicable) Tests have been added.
  • CHANGES.rst has been updated (with summary of main changes).
    • Link to issue (:issue:number) and pull request (:pull:number) has been added.

What kind of change does this PR introduce?

  • make deepcopy of input dict to avoid changing it; (util.py)
  • keep reference to a Dataset if data is passed as DataArray (plot.py)
  • allow passing predefined colorbar levels as list/np.ndarray.
  • rename extend->extent (plot.py)

Does this PR introduce a breaking change?

No.

Other information:

Copy link

github-actions bot commented Mar 21, 2024

Welcome, new contributor!

It appears that this is your first Pull Request. To give credit where it's due, we ask that you add your information to the AUTHORS.rst and .zenodo.json:

  • The relevant author information has been added to AUTHORS.rst and .zenodo.json.

Please make sure you've read our contributing guide. We look forward to reviewing your Pull Request shortly ✨

@Zeitsperre
Copy link
Contributor

@vindelico if you want to not run into formatting issues, run:

$ mamba install pre-commit
$ pre-commit install

@vindelico vindelico changed the title Colorbar levels as list/array & small fixes Colorbar levels as list/array in gridmap & small fixes Mar 21, 2024
CHANGES.rst Outdated Show resolved Hide resolved
Co-authored-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com>
)
if levels is not None:
if isinstance(levels, Iterable):
lin = levels
Copy link
Contributor

Choose a reason for hiding this comment

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

fyi, it was already possible to pass a list through plot_kw={'levels':[290,294,298,302]}, but nice to access it also directly here.

I am wondering if we should change to example in the notebook for this instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to see the option!

if isinstance(data, xr.DataArray):
plot_data = data
data = xr.Dataset({plot_data.name: plot_data})
Copy link
Contributor

Choose a reason for hiding this comment

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

why does it need to be a dataset ?
what if it doesn't have a name ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH, it's been a while that I added that so don't quite remember 🤔 ...

It was something missing on the plot if the dataset was not there.

Copy link
Contributor

Choose a reason for hiding this comment

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

haha ok!

@@ -749,8 +753,8 @@ def gridmap(
im = plot_data.plot.contourf(**plot_kw)

if ax:
if extend:
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch!

Copy link
Collaborator

@sarahclaude sarahclaude left a comment

Choose a reason for hiding this comment

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

Looks good, thanks Marco!

CHANGES.rst Outdated
@@ -19,6 +19,7 @@ Contributors to this version: Sarah-Claude Bourdeau-Goulet (:user:`Sarahclaude`)

New features and enhancements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Use list or ndarray as levels for colorbar in gridmap and small bug fixes (:pull:`176`).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Use list or ndarray as levels for colorbar in gridmap and small bug fixes (:pull:`176`).
* Use list or ndarray as levels for colorbar in gridmap and small bug fixes (:pull:`176`).

This should be under v4.0

@vindelico vindelico merged commit b5fa714 into main Apr 2, 2024
19 checks passed
@vindelico vindelico deleted the small_fixes branch April 2, 2024 19:41
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

Successfully merging this pull request may close these issues.

None yet

4 participants