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

Clean up Field.__init__(..., kwargs) #1906

Open
VeckoTheGecko opened this issue Mar 3, 2025 · 1 comment
Open

Clean up Field.__init__(..., kwargs) #1906

VeckoTheGecko opened this issue Mar 3, 2025 · 1 comment
Labels

Comments

@VeckoTheGecko
Copy link
Contributor

Some of the kwargs in the Field initialiser (e.g., dataFiles) aren't used in the codebase, or they're used for tasks that will be implemented via other means in the v4 codebase.

@VeckoTheGecko
Copy link
Contributor Author

or they're used for tasks that will be implemented via other means in the v4 codebase.

An example is the checking for duplicated Grids. This will be handled via a different, more durable mechanism in v4

Parcels/parcels/fieldset.py

Lines 438 to 462 in aba423c

# check if grid has already been processed (i.e. if other fields have same filenames, dimensions and indices)
for procvar, _ in fields.items():
procdims = dimensions[procvar] if procvar in dimensions else dimensions
procinds = indices[procvar] if (indices and procvar in indices) else indices
procpaths = filenames[procvar] if isinstance(filenames, dict) and procvar in filenames else filenames
nowpaths = filenames[var] if isinstance(filenames, dict) and var in filenames else filenames
if procdims == dims and procinds == inds:
possibly_samegrid = True
if not possibly_samegrid:
break
if "depth" in dims and dims["depth"] == "not_yet_set":
break
processedGrid = False
if (not isinstance(filenames, dict)) or filenames[procvar] == filenames[var]:
processedGrid = True
elif isinstance(filenames[procvar], dict):
processedGrid = True
for dim in ["lon", "lat", "depth"]:
if dim in dimensions:
processedGrid *= filenames[procvar][dim] == filenames[var][dim]
if processedGrid:
grid = fields[procvar].grid
if procpaths == nowpaths:
dFiles = fields[procvar]._dataFiles
break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Status: Backlog
Development

No branches or pull requests

1 participant