OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
249 stars 120 forks source link

Fail on dtype #161

Closed hidden-ja closed 3 years ago

hidden-ja commented 5 years ago

hi everyone, This week I’ve been having a problem with the software, being impossible to perform the simulations. I’ve been repeating sequences that last week worked perfectly but this week for some reason the same simulation routine doesn’t work. I removed the cache, the add-ons and I have reloaded all the files, and still have the same problem. I don’t know what is the solution to this problem and I hope you can help me. The error is caused by the input files (netcdf), and the error is this:

11:34:08 INFO: OpenDriftSimulation initialised (version 1.0.7) 11:34:08 INFO: Opening dataset: Mp_2018.nc 11:34:08 INFO: Opening file with Dataset 11:34:09 INFO: 'gls_cmu0' 11:34:09 INFO: Did not find complete set of GLS parameters Traceback (most recent call last): File "aysen_enero.py", line 48, in mosa_native=reader_ROMS_native.Reader(filename_nc,gridfile=gridfile) File "/home/lmod/software/MPI/intel/2019.2.187-GCC-8.2.0-2.31.1/impi/2019.2.187/Python/3.7.2/lib/python3.7/site-packages/OpenDrift-1.0.7-py3.7.egg/opendrift/readers/reader_ROMS_native.py", line 181, in init for OT in ocean_time.data] File "/home/lmod/software/MPI/intel/2019.2.187-GCC-8.2.0-2.31.1/impi/2019.2.187/Python/3.7.2/lib/python3.7/site-packages/OpenDrift-1.0.7-py3.7.egg/opendrift/readers/reader_ROMS_native.py", line 181, in for OT in ocean_time.data] TypeError: ufunc subtract cannot use operands with types dtype('float32') and dtype('<M8[s]')

any suggestions?

knutfrode commented 5 years ago

I wonder if this problem is due to xarray. If you have xarray installed, could your try to uninstall it?

hidden-ja commented 5 years ago

I already unistall it, but still the same problem.

knutfrode commented 5 years ago

Ok. Googling your error message indicates a numpy-matplotlib-pandas-problem: https://github.com/matplotlib/matplotlib/issues/9610 Do you have Pandas installed?

hidden-ja commented 5 years ago

Yes i have pandas installed, matplotlib and numpy

knutfrode commented 5 years ago

Can you then try to uninstall panda. And if that does not work, try to update/downgrade matplotib to another version.

hidden-ja commented 5 years ago

I already unistall pandas, and update/downgrade matplotlib and the error persists

knutfrode commented 5 years ago

Can you make available this netCDF-file (or a subset), so that we can have a look at it?

hidden-ja commented 5 years ago

new.nc.zip

This file contains one day

knutfrode commented 5 years ago

This file seems to contain the output from an OpenDrift simulation, and not an imput ROMS file. Could you make available the ROMS input file (Mp_2018.nc)?

hidden-ja commented 5 years ago

mp_2018.zip

Im sorry my bad, this is a subset of a day. And I have a grid file for start simulation

knutfrode commented 5 years ago

In this file, the unit of time is second:

float ocean_time(time) ;
        ocean_time:_FillValue = NaNf ;
        ocean_time:long_name = "time since initialization" ;
        ocean_time:units = "second" ;
        ocean_time:field = "time, scalar, series" ;
        ocean_time:standard_name = "time" ;
        ocean_time:axis = "T" ;

To be able to convert this to Python datetimes, the unit must instead be something like "seconds since 1970-01-01 00:00:00"

hidden-ja commented 5 years ago

and grid file affect this? grid_2018.zip

knutfrode commented 5 years ago

I had forgotten: there is already a fix in the ROMS reader to deal with ROMS-Agrif, using an artificial start time of 1 Jan 2000 for this case with no real time unit.

But if I run these lines:

from opendrift.readers.reader_ROMS_native import Reader
r = Reader('mp_2018.nc', gridfile='grid_2018.nc')
print(r)

I get the following output:

===========================
Reader: roms native
Projection: 
  None
Coverage: [pixels]
  xmin: 0.000000   xmax: 230.000000   step: 1   numx: 231
  ymin: 0.000000   ymax: 8.000000   step: 1   numy: 9
  Corners (lon, lat):
    (-75.39, -46.91)  (-72.19, -46.91)
    (-75.39, -46.99)  (-72.19, -46.99)
Vertical levels [m]: 
  Not specified
Available time range:
  start: 2018-01-01 00:59:44   end: 2018-01-01 08:59:44   step: 0:59:44
    9 times (0 missing)
Variables:
  x_sea_water_velocity
  y_sea_water_velocity
  sea_surface_height
===========================

Does this not work for you?

hidden-ja commented 5 years ago

Still not working, I was thinking that the loaded modules were the problem, so I’ll leave the list of the loaded modules to find out if there’s a problem with them image

thanks for the time!

knutfrode commented 5 years ago

I am not sure what could be the cause of this error. Anyway, there has been quite a bit of updates lately, so perhaps the problem would be solved if you make a fresh installation of the latest version of OpenDrift as described here: https://opendrift.github.io/install.html