Skip to content

Conversation

@erikvansebille
Copy link
Member

This PR support creating a ParticlseSet without a FieldSet, or with fieldset=None.

This fixes #867 and addresses #618, to deconvolute Parcels class dependencies

@erikvansebille erikvansebille requested a review from CKehl July 3, 2020 07:12
Copy link
Contributor

@CKehl CKehl left a comment

Choose a reason for hiding this comment

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

The adaptations appear to be complete and the unit tests all pass, so that's good. I think with the changes in 'test_kernel_language.py', it becomes apparent why this is a good idea - no matter what we do to the FieldSet at some point, those tests are not affected by it. And on the other hand, if there is a question if a fail is die to FieldSet or ParticleSet, this class now gives ample info to decide on that question.

and propagates attribute access."""

def __init__(self, fieldset, ptype):
def __init__(self, fieldset=None, ptype=JITParticle):
Copy link
Contributor

Choose a reason for hiding this comment

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

okay, so you decided to keep this parameter order, and then also rather just define 'JITParticle' as ptype standard. Yeah, fine - relieves you from a lot of tiny adaptions in the other files, I agree.

Comment on lines +119 to +120
logger.warning_once("No FieldSet provided in ParticleSet generation. "
"This breaks most Parcels functionality")
Copy link
Contributor

Choose a reason for hiding this comment

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

good to set a warning. The formulation is very user-centric, but that's probably how it should be.

for v in self.ptype.variables:
if v.name in ['xi', 'yi', 'zi', 'ti']:
self.particle_data[v.name] = np.empty((len(lon), fieldset.gridset.size), dtype=v.dtype)
ngrid = fieldset.gridset.size if fieldset is not None else 1
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't that be 0 if no fieldset is given ?

if v.name in ['xi', 'yi', 'zi', 'ti']:
self.particle_data[v.name] = np.empty((len(lon), fieldset.gridset.size), dtype=v.dtype)
ngrid = fieldset.gridset.size if fieldset is not None else 1
self.particle_data[v.name] = np.empty((len(lon), ngrid), dtype=v.dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

ah, okay, now I see why 'ngrid' should not be 0 ... the variable naming semantic here is a bit misleading then, but I understand the purpose.

@erikvansebille erikvansebille merged commit 1985845 into master Jul 3, 2020
hrsdawson pushed a commit to hrsdawson/parcels that referenced this pull request Jul 29, 2020
…nelgenerator

Support for creating a ParticleSet with empty FieldSet
@erikvansebille erikvansebille deleted the refactoring_kernelgenerator branch June 23, 2023 12:52
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.

KernelGenerator with empty FieldSet

3 participants