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

Unreliable Field.fieldtype constant #1690

Open
VeckoTheGecko opened this issue Sep 5, 2024 · 2 comments
Open

Unreliable Field.fieldtype constant #1690

VeckoTheGecko opened this issue Sep 5, 2024 · 2 comments
Labels
cleanup Cleaning up legacy code

Comments

@VeckoTheGecko
Copy link
Contributor

In the Field constructor:

Parcels/parcels/field.py

Lines 106 to 107 in 5fff42c

fieldtype : str
Type of Field to be used for UnitConverter (either 'U', 'V', 'Kh_zonal', 'Kh_meridional' or None)

However the underlying behaviour looks to be a bit different.

self.fieldtype = self.name if fieldtype is None else fieldtype

This leads to strange stuff like:

>>> field = Field("newfld", fieldset.U.data, lon=fieldset.U.lon, lat=fieldset.U.lat)
>>> fieldset.add_field(field)
>>> print(fieldset.newfld.fieldtype)
"newfld"

I don't think this is a bug per-se (doubt it affects interpolation), but it is worth cleaning up to be None in this case.

@VeckoTheGecko VeckoTheGecko added cleanup Cleaning up legacy code good first issue Good for new parcels developers labels Sep 5, 2024
@VeckoTheGecko
Copy link
Contributor Author

VeckoTheGecko commented Sep 5, 2024

This will likely be moved to the internal API/scheduled for removal anyway. .units already provides unit information

@VeckoTheGecko VeckoTheGecko removed the good first issue Good for new parcels developers label Sep 5, 2024
@erikvansebille
Copy link
Member

Good catch; yes this can certainly be cleaned up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Cleaning up legacy code
Projects
Status: Ready
Development

No branches or pull requests

2 participants