Skip to content

Remove 'mesh' arg from add_constant_field - #2880

Merged
VeckoTheGecko merged 2 commits into
Parcels-code:mainfrom
VeckoTheGecko:add-constant-field
Sep 3, 2026
Merged

Remove 'mesh' arg from add_constant_field#2880
VeckoTheGecko merged 2 commits into
Parcels-code:mainfrom
VeckoTheGecko:add-constant-field

Conversation

@VeckoTheGecko

Copy link
Copy Markdown
Contributor

Description

Since we have fieldset.mesh in #2848, we no longer need this argument.

Checklist

AI Disclosure

None used

Comment thread src/parcels/_core/fieldset.py Outdated
raise ValueError(f"mesh must be one of ['flat', 'spherical']. Got {mesh!r}.")

if self.constant_model is None:
mesh = "flat" if isinstance(self.mesh, FlatMesh) else self.mesh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why can't mesh be FlatMesh here? Why does it need to be a string only for flat meshes, and an object otherwise?

@VeckoTheGecko VeckoTheGecko Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since within create_empty_constant_field_model, from_sgrid_conventions expects mesh: Literal['flat', spherical'] | SphericalMesh (FlatMesh is not part out our public API, and is instead created internally from the "flat" keyword).

I have moved this cast statement to be in create_empty_constant_field_model now so its closer to the part that needs it

@VeckoTheGecko
VeckoTheGecko merged commit db79e51 into Parcels-code:main Sep 3, 2026
22 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Parcels development Sep 3, 2026
@VeckoTheGecko
VeckoTheGecko deleted the add-constant-field branch September 3, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Error out when combining fieldsets of different mesh types

2 participants