Skip to content

Commit

Permalink
Read only lon,lat,depth
Browse files Browse the repository at this point in the history
  • Loading branch information
VeckoTheGecko committed Sep 18, 2024
1 parent 6c0f524 commit db3dc49
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions parcels/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,6 @@ def __init__(
time_origin = TimeConverter(0)
self.grid = Grid.create_grid(lon, lat, depth, time, time_origin=time_origin, mesh=mesh)
self.igrid = -1
# self.lon, self.lat, self.depth and self.time are not used any more in parcels.
# self.grid should be used instead.
# Those variables are still defined for backwards compatibility with users codes.
self.lon = self.grid.lon
self.lat = self.grid.lat
self.depth = self.grid.depth
self.fieldtype = self.name if fieldtype is None else fieldtype
self.to_write = to_write
if self.grid.mesh == "flat" or (self.fieldtype not in unitconverters_map.keys()):
Expand Down Expand Up @@ -307,6 +301,21 @@ def __init__(
if len(kwargs) > 0:
raise SyntaxError(f'Field received an unexpected keyword argument "{list(kwargs.keys())[0]}"')

@property
def lon(self):
"""Lon defined on the Grid object"""
return self.grid.lon

@property
def lat(self):
"""Lat defined on the Grid object"""
return self.grid.lat

@property
def depth(self):
"""Depth defined on the Grid object"""
return self.grid.depth

@classmethod
def get_dim_filenames(cls, filenames, dim):
if isinstance(filenames, str) or not isinstance(filenames, collections.abc.Iterable):
Expand Down Expand Up @@ -1542,8 +1551,6 @@ def add_periodic_halo(self, zonal, meridional, halosize=5, data=None):
(data[:, :, :, -halosize:], data, data[:, :, :, 0:halosize]), axis=len(data.shape) - 1
)
assert data.shape[3] == self.grid.xdim, "Fourth dim must be x."
self.lon = self.grid.lon
self.lat = self.grid.lat
if meridional:
if len(data.shape) == 3:
data = lib.concatenate((data[:, -halosize:, :], data, data[:, 0:halosize, :]), axis=len(data.shape) - 2)
Expand All @@ -1553,7 +1560,6 @@ def add_periodic_halo(self, zonal, meridional, halosize=5, data=None):
(data[:, :, -halosize:, :], data, data[:, :, 0:halosize, :]), axis=len(data.shape) - 2
)
assert data.shape[2] == self.grid.ydim, "Third dim must be y."
self.lat = self.grid.lat
if dataNone:
self.data = data
else:
Expand Down

0 comments on commit db3dc49

Please sign in to comment.