Skip to content

Commit

Permalink
Merge branch 'master' into version-from-archive
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvansebille authored Aug 24, 2018
2 parents e3a53ae + 857c7f2 commit fe1df4f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ parcels.plotting module
:members:
:undoc-members:

scripts.plotParticles module
----------------------------
scripts.plottrajectoriesfile module
-----------------------------------

.. automodule:: scripts.plotParticles
.. automodule:: scripts.plottrajectoriesfile
:members:
:undoc-members:

Expand Down
3 changes: 1 addition & 2 deletions parcels/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TimeExtrapolationError(RuntimeError):
"""Utility error class to propagate erroneous time extrapolation sampling"""

def __init__(self, time, field=None):
if field is not None and field.grid.time_origin:
if field is not None and field.grid.time_origin and time is not None:
time = field.grid.time_origin + np.timedelta64(int(time), 's')
message = "%s sampled outside time domain at time %s." % (
field.name if field else "Field", time)
Expand Down Expand Up @@ -349,7 +349,6 @@ def from_netcdf(cls, filenames, variable, dimensions, indices=None, grid=None,
ti += len(tslice)
else:
grid.defer_load = True
grid.time_full = grid.time
grid.ti = -1
data = None

Expand Down
1 change: 1 addition & 0 deletions parcels/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, lon, lat, time, time_origin, mesh):
self.lon = lon
self.lat = lat
self.time = np.zeros(1, dtype=np.float64) if time is None else time
self.time_full = self.time # needed for deferred_loaded Fields
if not self.lon.dtype == np.float32:
logger.warning_once("Casting lon data to np.float32")
self.lon = self.lon.astype(np.float32)
Expand Down
2 changes: 1 addition & 1 deletion parcels/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, fieldset, ptype, pyfunc=None, funcname=None,
funccode=None, py_ast=None, funcvars=None, c_include=""):
self.fieldset = fieldset
self.ptype = ptype
self._lib = None

# Derive meta information from pyfunc, if not given
self.funcname = funcname or pyfunc.__name__
Expand Down Expand Up @@ -117,7 +118,6 @@ def __init__(self, fieldset, ptype, pyfunc=None, funcname=None,
self.src_file = "%s.c" % basename
self.lib_file = "%s.%s" % (basename, 'dll' if platform == 'win32' else 'so')
self.log_file = "%s.log" % basename
self._lib = None

def __del__(self):
# Clean-up the in-memory dynamic linked libraries.
Expand Down
4 changes: 2 additions & 2 deletions parcels/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def execute(self, pyfunc=AdvectionRK4, endtime=None, runtime=None, dt=1.,
# Set particle.time defaults based on sign of dt, if not set at ParticleSet construction
for p in self:
if np.isnan(p.time):
mintime, maxtime = self.fieldset.gridset.dimrange('time')
mintime, maxtime = self.fieldset.gridset.dimrange('time_full')
p.time = mintime if dt >= 0 else maxtime

# Derive _starttime and endtime from arguments or fieldset defaults
Expand All @@ -309,7 +309,7 @@ def execute(self, pyfunc=AdvectionRK4, endtime=None, runtime=None, dt=1.,
if runtime is not None:
endtime = _starttime + runtime * np.sign(dt)
elif endtime is None:
mintime, maxtime = self.fieldset.gridset.dimrange('time')
mintime, maxtime = self.fieldset.gridset.dimrange('time_full')
endtime = maxtime if dt >= 0 else mintime

if abs(endtime-_starttime) < 1e-5 or dt == 0 or runtime == 0:
Expand Down
2 changes: 1 addition & 1 deletion parcels/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def plotparticles(particles, with_particles=True, show_time=None, field=None, do
if isinstance(show_time, delta):
show_time = show_time.total_seconds()
if np.isnan(show_time):
show_time, _ = particles.fieldset.gridset.dimrange('time')
show_time, _ = particles.fieldset.gridset.dimrange('time_full')

if field is None:
spherical = True if particles.fieldset.U.grid.mesh == 'spherical' else False
Expand Down

0 comments on commit fe1df4f

Please sign in to comment.