OpenDrift / opendrift

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

Problem reading from NC file once downloaded? #190

Closed Caffa closed 3 years ago

Caffa commented 4 years ago

I downloaded the .nc file from the thredds with the command nccopy http://thredds.met.no/thredds/dodsC/sea/nordic4km/zdepths1h/aggregate_be?X[0:1:1020],Y[0:1:577],depth[0:1:16],forecast_reference_time,h[0:1:0][0:1:0],hc,latitude[0:1:0][0:1:0],longitude[0:1:0][0:1:0],mask[0:1:0][0:1:0],polar_stereographic,aice[0:1:0][0:1:0][0:1:0],hice[0:1:0][0:1:0][0:1:0],salinity[0:1:0][0:1:0][0:1:0][0:1:0],temperature[0:1:0][0:1:0][0:1:0][0:1:0],time[0:1:28200],u[0:1:0][0:1:0][0:1:0][0:1:0],ubar[0:1:0][0:1:0][0:1:0],v[0:1:0][0:1:0][0:1:0][0:1:0],vbar[0:1:0][0:1:0][0:1:0],zeta[0:1:0][0:1:0][0:1:0] nordic.nc

which I checked with print(reader) and got the same printout as the reader from the thredds server.

But when I tried to run this, I got the following error:

WARNING:py.warnings:/Users/Caffae/Documents/GitLab/FindingDories/Conference/opendrift/opendrift/models/basemodel.py:3236: UserWarning: Tight layout not applied. The left and right margins cannot be made large enough to accommodate all axes decorations. 
  plt.savefig(filename)

Traceback (most recent call last):
  File "/Users/Caffae/Documents/GitLab/FindingDories/Conference/opendrift/opendrift/models/basemodel.py", line 2241, in run
    self.update()
  File "/Users/Caffae/Documents/GitLab/FindingDories/Conference/myCode/Testing Cache/modLeeway.py", line 461, in update
    self.plot(background=['x_sea_water_velocity', 'y_sea_water_velocity'], filename= filename[self.currentPlotCount] + '_background.png')
  File "/Users/Caffae/Documents/GitLab/FindingDories/Conference/opendrift/opendrift/models/basemodel.py", line 3178, in plot
    self.get_map_background(ax, background, time=time)
  File "/Users/Caffae/Documents/GitLab/FindingDories/Conference/opendrift/opendrift/models/basemodel.py", line 3287, in get_map_background
    background, time, reader_x, reader_y, None, block=True)
  File "/Users/Caffae/Documents/GitLab/FindingDories/Conference/opendrift/opendrift/readers/reader_netCDF_CF_generic.py", line 425, in get_variables
    variables[par] = var[indxTime, indz, indy, indx]
  File "netCDF4/_netCDF4.pyx", line 4327, in netCDF4._netCDF4.Variable.__getitem__
  File "/Users/Caffae/miniconda3/envs/my_opendrift/lib/python3.7/site-packages/netCDF4/utils.py", line 267, in _StartCountStride
    raise IndexError(msg)
IndexError: integer index exceeds dimension size

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "UsedCacheDataGen.py", line 563, in <module>
    optimizedTests([10.2, 13.8], [68.7, 69.3], "JsonData", [2000])
  File "UsedCacheDataGen.py", line 494, in optimizedTests
    SimpleTest(maxlon, maxlat, i, True)
  File "UsedCacheDataGen.py", line 401, in SimpleTest
    AreaTests(i, maxlat, makeLatDiff = makeLatDiff)
  File "UsedCacheDataGen.py", line 341, in AreaTests
    multipleFixedSeedsPlot()
  File "UsedCacheDataGen.py", line 324, in multipleFixedSeedsPlot
    plotLW(InputListSeeds, 3)
  File "UsedCacheDataGen.py", line 231, in plotLW
    lw.run(steps=numSteps, time_step=timeStep, time_step_output = timeStep, outfile = fileName +".nc")
  File "/Users/Caffae/Documents/GitLab/FindingDories/Conference/opendrift/opendrift/models/basemodel.py", line 2274, in run
    'first timestep. ' + self.get_messages())
ValueError: Simulation stopped within first timestep. 'The simulation stopped before requested end time was reached.'

It seems to be able to seed but then stops.

is there a better way to download the .nc files?

knutfrode commented 4 years ago

Hi,

Not sure, but perhaps your subsetting removes some vital information. When downloading from thredds, I normally use ncks with subsetting with -d, which works fine.

However, why not run the simulation directly from thredds?