Skip to content

Commit db3dc49

Browse files
committed
Read only lon,lat,depth
1 parent 6c0f524 commit db3dc49

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

parcels/field.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ def __init__(
190190
time_origin = TimeConverter(0)
191191
self.grid = Grid.create_grid(lon, lat, depth, time, time_origin=time_origin, mesh=mesh)
192192
self.igrid = -1
193-
# self.lon, self.lat, self.depth and self.time are not used any more in parcels.
194-
# self.grid should be used instead.
195-
# Those variables are still defined for backwards compatibility with users codes.
196-
self.lon = self.grid.lon
197-
self.lat = self.grid.lat
198-
self.depth = self.grid.depth
199193
self.fieldtype = self.name if fieldtype is None else fieldtype
200194
self.to_write = to_write
201195
if self.grid.mesh == "flat" or (self.fieldtype not in unitconverters_map.keys()):
@@ -307,6 +301,21 @@ def __init__(
307301
if len(kwargs) > 0:
308302
raise SyntaxError(f'Field received an unexpected keyword argument "{list(kwargs.keys())[0]}"')
309303

304+
@property
305+
def lon(self):
306+
"""Lon defined on the Grid object"""
307+
return self.grid.lon
308+
309+
@property
310+
def lat(self):
311+
"""Lat defined on the Grid object"""
312+
return self.grid.lat
313+
314+
@property
315+
def depth(self):
316+
"""Depth defined on the Grid object"""
317+
return self.grid.depth
318+
310319
@classmethod
311320
def get_dim_filenames(cls, filenames, dim):
312321
if isinstance(filenames, str) or not isinstance(filenames, collections.abc.Iterable):
@@ -1542,8 +1551,6 @@ def add_periodic_halo(self, zonal, meridional, halosize=5, data=None):
15421551
(data[:, :, :, -halosize:], data, data[:, :, :, 0:halosize]), axis=len(data.shape) - 1
15431552
)
15441553
assert data.shape[3] == self.grid.xdim, "Fourth dim must be x."
1545-
self.lon = self.grid.lon
1546-
self.lat = self.grid.lat
15471554
if meridional:
15481555
if len(data.shape) == 3:
15491556
data = lib.concatenate((data[:, -halosize:, :], data, data[:, 0:halosize, :]), axis=len(data.shape) - 2)
@@ -1553,7 +1560,6 @@ def add_periodic_halo(self, zonal, meridional, halosize=5, data=None):
15531560
(data[:, :, -halosize:, :], data, data[:, :, 0:halosize, :]), axis=len(data.shape) - 2
15541561
)
15551562
assert data.shape[2] == self.grid.ydim, "Third dim must be y."
1556-
self.lat = self.grid.lat
15571563
if dataNone:
15581564
self.data = data
15591565
else:

0 commit comments

Comments
 (0)