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

Error exists when Reader sea_water_velocity from MET-Norway #1453

Open
dayeno opened this issue Dec 4, 2024 · 5 comments
Open

Error exists when Reader sea_water_velocity from MET-Norway #1453

dayeno opened this issue Dec 4, 2024 · 5 comments

Comments

@dayeno
Copy link

dayeno commented Dec 4, 2024

Hi,

I am trying to simulate iceberg drift with Openberg Module. But at the very beginning, the input of the forcing data from MET-Norway always shows error. The script and log file are shown below. I have tried other forcing data files, but the errors shown are all related to the missing sea_water_velocity information.

### Script:

import matplotlib.pyplot as plt
import numpy as np
from opendrift.models.openberg import OpenBerg
from opendrift.readers import reader_netCDF_CF_generic
from datetime import datetime,timedelta

o = OpenBerg()

o.set_config('drift:vertical_profile', False) # use surface currents for this test

ocean_reader = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/romshindcast/barents2500_2010/daily_average/2013/01/barents_avg_zdepth_20130131_m00_HC_24h.nc')
print(ocean_reader.variables)
#ocean_reader.plot(variable = 'x_sea_water_velocity')
ocean_reader.plot(variable = 'sea_water_speed')

o.add_reader(ocean_reader)

o.seed_elements(lon = 60, lat = 72, time = datetime.now(), number = 1, radius = 500, sail = 10, draft = 50, length = 90, width = 40)

o.run(steps=1)
o.plot(fast = True)

### Log file:

15:20:39 INFO opendrift.models.basemodel:2140: "Missing variables: ['x_sea_water_velocity', 'y_sea_water_velocity']", 'The simulation stopped before requested end time was reached.'

15:20:39 INFO opendrift.models.basemodel:2143: ========================
Traceback (most recent call last):
File "/home/daye/Code/OpenDrift/opendrift/opendrift/models/basemodel/init.py", line 2101, in run
raise ValueError(
ValueError: No more active or scheduled elements, quitting.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/daye/Code/OpenDrift/Gallery/Test/example_openberg.py", line 43, in
o.run(steps=1)
File "/home/daye/Code/OpenDrift/opendrift/opendrift/models/basemodel/init.py", line 111, in inner
r = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/daye/Code/OpenDrift/opendrift/opendrift/models/basemodel/init.py", line 2147, in run
raise ValueError('Simulation stopped within '
ValueError: Simulation stopped within first timestep. "Missing variables: ['x_sea_water_velocity', 'y_sea_water_velocity']", 'The simulation stopped before requested end time was reached.'

@knutfrode
Copy link
Collaborator

Hi,
I recommend using loglevel=0 to get the full debug log, so that you can see what goes wrong.
But I guess it is here related to the fact that you are seeding icebergs "now", whereas this single current file covers only a very specific time (single timestep) on a specific date in 2013.

@dayeno
Copy link
Author

dayeno commented Dec 4, 2024

Hi again,

Thanks for your quick help. The attachment is the full log file. It seems that the "x_sea_water_velocity" and "y_sea_water_velocity" are "Nan" values. According the log file, "x_sea_water_velocity" and "y_sea_water_velocity" are derived by rotating "eastward_sea_water_velocity" and "northward_sea_water_velocity". Could the error be occurring here?

I also tried many other time-period data files and they all showed the same error. Moreover, even without running Openberg, the error occurs immediately when I try to display "x_sea_water_velocity" after reading the data (Command : ocean_reader.plot(variable = 'x_sea_water_velocity')). But displaying "eastward_sea_water_velocity" works fine.

Thanks again.
logfile.txt

@knutfrode
Copy link
Collaborator

knutfrode commented Dec 4, 2024

As you can see from the log, the reader is discarded since it is only valid for 31 Jan 2013, whereas you have seeded elements on 4th Dec 2024.

13:44:02 DEBUG   opendrift.models.basemodel.environment:498: Discarding reader (ends before simuation is finished): https://thredds.met.no/thredds/dodsC/romshindcast/barents2500_2010/daily_average/2013/01/barents_avg_zdepth_20130131_m00_HC_24h.nc

@dayeno
Copy link
Author

dayeno commented Dec 4, 2024

Hi again,

After adjusting the time, the error related to ‘x_sea_water_velocity' still exists. Attached 'logfile_new.txt' is the new log file.
logfile_new.txt

I also tried only loading the netCDF file and then plot. When the variable is 'x_sea_water_velocity', it throws an error. The script and log file are shown below. While displaying "eastward_sea_water_velocity" works fine.

### Script:
import matplotlib.pyplot as plt
import numpy as np
from opendrift.models.openberg import OpenBerg
from opendrift.readers import reader_netCDF_CF_generic
from datetime import datetime,timedelta

ocean_reader = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/romshindcast/barents2500_2010/daily_average/2013/01/barents_avg_zdepth_20130131_m00_HC_24h.nc')

print(ocean_reader.variables)
ocean_reader.plot(variable = 'x_sea_water_velocity')

### Logfile:

Assuming time step of 1 hour for https://thredds.met.no/thredds/dodsC/romshindcast/barents2500_2010/daily_average/2013/01/barents_avg_zdepth_20130131_m00_HC_24h.nc
['sea_floor_depth_below_sea_level', 'sea_binary_mask', 'sea_surface_height', 'eastward_sea_water_velocity', 'northward_sea_water_velocity', 'upward_sea_water_velocity', 'sea_water_temperature', 'sea_water_salinity', 'ocean_vertical_diffusivity', 'longitude', 'latitude', 'sea_ice_area_fraction', 'sea_ice_thickness', 'eastward_sea_ice_velocity', 'northward_sea_ice_velocity', 'x_sea_water_velocity', 'y_sea_water_velocity', 'sea_ice_x_velocity', 'sea_ice_y_velocity', 'sea_ice_speed', 'sea_water_speed']
Traceback (most recent call last):
File "/home/daye/Code/OpenDrift/Gallery/Test/Test_Case/test_2.py", line 16, in
ocean_reader.plot(variable = 'x_sea_water_velocity')
File "/home/daye/Code/OpenDrift/opendrift/opendrift/readers/basereader/init.py", line 342, in plot
data = self.get_variables(variable, time, rx, ry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/daye/Code/OpenDrift/opendrift/opendrift/readers/reader_netCDF_CF_generic.py", line 552, in get_variables
lon, lat, variables[vectorpair[0]], variables[vectorpair[1]],
~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'y_sea_water_velocity'

@knutfrode
Copy link
Collaborator

That file/URL is only valid for a very specific time, so it cannot be used for a simulation.
You need to use a dataset with a time coverge, e.g. an aggregate
https://thredds.met.no/thredds/dodsC/fou-hi/barents_eps_zdepth_be

And also this dataset does not cover the position you have selected. This you can read from the log.

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