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

Issue with datetime #11

Closed
fascani opened this issue Jun 4, 2015 · 3 comments
Closed

Issue with datetime #11

fascani opened this issue Jun 4, 2015 · 3 comments

Comments

@fascani
Copy link

fascani commented Jun 4, 2015

Hello, I finally succeeded to install everything (octant, pyproj, etc) but I am getting an issue about a comparison between datetime and an array when I performed the tests you provided. For instance:

In [1]: from test_rect import *
/Users/fascani/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py:133: MatplotlibDeprecationWarning: The matplotlib.delaunay module was deprecated in version 1.4. Use matplotlib.tri.Triangulation instead.
  warnings.warn(message, mplDeprecation, stacklevel=1)

In [2]: test_run_2d_ll()
building grid took: 5.96046447754e-06
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-0fb1b50e64f5> in <module>()
----> 1 test_run_2d_ll()

/Users/fascani/programs/python/TracPy/tests/test_rect.pyc in test_run_2d_ll()
     81     # tp._readgrid()
     82 
---> 83     lonp, yp, zp, t, T0, U, V = tracpy.run.run(tp, date, lon0, lat0)
     84 
     85     ## check the results:

/Users/fascani/programs/python/TracPy/tracpy/run.pyc in run(tp, date, lon0, lat0, T0, U, V)
     33 
     34     # Initialize everything for a simulation
---> 35     tinds, nc, t0save, xend, yend, zend, zp, ttend, flag = tp.prepare_for_model_run(date, lon0, lat0)
     36 
     37     timer.addtime('1: Preparing for simulation   ')

/Users/fascani/programs/python/TracPy/tracpy/tracpy_class.pyc in prepare_for_model_run(self, date, lon0, lat0)
    217 
    218         # Figure out what files will be used for this tracking
--> 219         nc, tinds = tracpy.inout.setupROMSfiles(self.currents_filename, date, self.ff, self.tout, self.time_units, tstride=self.tstride)
    220 
    221         # Read in grid parameters into dictionary, grid, if haven't already

/Users/fascani/programs/python/TracPy/tracpy/inout.pyc in setupROMSfiles(loc, date, ff, tout, time_units, tstride)
     62         if ff == 1: #forward in time
     63             dates = nc.variables['ocean_time'][:] # don't stride here, need all times to make index determinations
---> 64             ilow = date >= dates
     65             # time index with time value just below datenum_in (relative to file ifile)
     66             istart = dates[ilow].size - 1

TypeError: can't compare datetime.datetime to numpy.ndarray

I see some workaround on the web like using np.less_than() or np.greater_than() functions instead but maybe you know the reason of that mistake.

Thanks

Francois

@kthyng
Copy link
Owner

kthyng commented Jun 4, 2015

Ah! Thanks. I'll try to fix that now and get back to you.

@kthyng
Copy link
Owner

kthyng commented Jun 4, 2015

Ok it is working for me now. What about for you?

@fascani
Copy link
Author

fascani commented Jun 5, 2015

It works for me as well! Thanks a bunch!

@kthyng kthyng closed this as completed Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants