OpenDrift / opendrift

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

Issues with trajectories across the plot and adding wind (PlastDrift) #1156

Open Nebelgeist opened 1 year ago

Nebelgeist commented 1 year ago

Hello there,

I am trying to simulate the global movement of macroplastics in the oceans over a time span of 27 years using Plast-Drift. Now I have come up against four different problems that I cannot solve.

First, when I print the loaded variables with print(p) (p=PlastDrift(loglevel=30)), the following variables are missing:

Readers not added for the following variables: 
  land_binary_mask
  ocean_vertical_diffusivity
  sea_floor_depth_below_sea_level
  x_wind
  y_wind

I can't get my model to use wind data (x_wind, y_wind and windspeed). I have the data for the corresponding time period stored locally, I can also add them using generic readers, but they are not taken into account in the model run.

The second problem concerns trajectories. I noticed that in the plots generated from my model runs, trajectories are drawn across the whole plot (even over land), although no particles have moved there.

Plot_ex

Both, the gif below and the plot above were generated using data from the same run.

Gif_ex

Additionally I wanted to ask if it is possible to dye the trajectories in the colour of the origin marker and if its possible to get the plots in another projection (for example the Mollweide projection), because the plot is distorted so much in the Mercator projection.

Could someone give me advice on how to fix these issues?

knutfrode commented 1 year ago

Hei,

If you use loglevel=0, the log should tell why wind and other variables are not used.

For the global plots, the built-in plotting method does not support well crossing of the dateline. The built-in methods are easy to use, but it is difficult to make them work well for all possible cases. Thus you will get more flexibility (e.g. to use other projections than Mercator) if you create your own plots from scratch in Cartopy (or other plotting toolbox).

Dying the elements is possible by adding color='origin_marker' as in this example: https://opendrift.github.io/gallery/example_multi_seed.html

Nebelgeist commented 11 months ago

Hi, thank you very much for the answer.

loglevel=0 causes crashes in my code within a very short time, so I usually use 30 or 50. I have now shortened the simulation time period a lot, so I can look at the log and this is the output:

15:26:54 DEBUG   opendrift.readers.basereader:172: Variable mapping: ['sea_floor_depth_below_sea_level'] -> ['land_binary_mask'] is not activated
15:26:58 INFO    opendrift.readers.reader_netCDF_CF_generic:92: Opening dataset: ../Daten/Wellendaten/Mm_CMEMS-GLOBAL_001_032-VHM0_VSDX_VSDY-2020.nc
15:26:59 DEBUG   opendrift.readers.reader_netCDF_CF_generic:109: Finding coordinate variables.
15:26:59 INFO    opendrift.readers.reader_netCDF_CF_generic:253: Grid coordinates are detected, but proj4 string not given: assuming latlong
15:26:59 DEBUG   opendrift.readers.reader_netCDF_CF_generic:310: Skipped variables without standard_name: ['time_bnds']
15:26:59 DEBUG   opendrift.readers.basereader.variables:548: Setting buffer size 586 for reader ../Daten/Wellendaten/Mm_CMEMS-GLOBAL_001_032-VHM0_VSDX_VSDY-2020.nc, assuming a maximum average speed of 5 m/s and time span of 30 days, 0:00:00
15:26:59 DEBUG   opendrift.readers.basereader:172: Variable mapping: ['sea_floor_depth_below_sea_level'] -> ['land_binary_mask'] is not activated
15:26:59 INFO    opendrift.readers.reader_netCDF_CF_generic:92: Opening dataset: ../Daten/CMEMS-GLOBAL_001_030-several_vars-1993_2020(nur_OF).nc
15:26:59 DEBUG   opendrift.readers.reader_netCDF_CF_generic:109: Finding coordinate variables.
15:26:59 INFO    opendrift.readers.reader_netCDF_CF_generic:253: Grid coordinates are detected, but proj4 string not given: assuming latlong
15:26:59 DEBUG   opendrift.readers.basereader.variables:548: Setting buffer size 1380 for reader ../Daten/CMEMS-GLOBAL_001_030-several_vars-1993_2020(nur_OF).nc, assuming a maximum average speed of 5 m/s and time span of 29 days, 12:00:00
15:26:59 INFO    opendrift.readers.basereader:162: Variable y_sea_water_velocity will be rotated from northward_sea_water_velocity
15:26:59 INFO    opendrift.readers.basereader:162: Variable x_sea_water_velocity will be rotated from eastward_sea_water_velocity
15:26:59 DEBUG   opendrift.readers.basereader:172: Variable mapping: ['sea_floor_depth_below_sea_level'] -> ['land_binary_mask'] is not activated
15:26:59 INFO    opendrift.readers.reader_netCDF_CF_generic:92: Opening dataset: ../Daten/Winddaten/x_wind.sig995.mon.mean.nc
15:26:59 DEBUG   opendrift.readers.reader_netCDF_CF_generic:109: Finding coordinate variables.
15:26:59 INFO    opendrift.readers.reader_netCDF_CF_generic:253: Grid coordinates are detected, but proj4 string not given: assuming latlong
15:26:59 DEBUG   opendrift.readers.reader_netCDF_CF_generic:310: Skipped variables without standard_name: ['x_wind']
15:26:59 DEBUG   opendrift.readers.basereader.variables:548: Setting buffer size 51 for reader ../Daten/Winddaten/x_wind.sig995.mon.mean.nc, assuming a maximum average speed of 5 m/s and time span of 31 days, 0:00:00
15:26:59 DEBUG   opendrift.readers.basereader:172: Variable mapping: ['sea_floor_depth_below_sea_level'] -> ['land_binary_mask'] is not activated
15:26:59 INFO    opendrift.readers.reader_netCDF_CF_generic:92: Opening dataset: ../Daten/Winddaten/y_wind.sig995.mon.mean.nc
15:26:59 DEBUG   opendrift.readers.reader_netCDF_CF_generic:109: Finding coordinate variables.
15:26:59 INFO    opendrift.readers.reader_netCDF_CF_generic:253: Grid coordinates are detected, but proj4 string not given: assuming latlong
15:26:59 DEBUG   opendrift.readers.reader_netCDF_CF_generic:310: Skipped variables without standard_name: ['y_wind']
15:26:59 DEBUG   opendrift.readers.basereader.variables:548: Setting buffer size 51 for reader ../Daten/Winddaten/y_wind.sig995.mon.mean.nc, assuming a maximum average speed of 5 m/s and time span of 31 days, 0:00:00
15:26:59 DEBUG   opendrift.readers.basereader:172: Variable mapping: ['sea_floor_depth_below_sea_level'] -> ['land_binary_mask'] is not activated
15:26:59 DEBUG   opendrift.models.basemodel:952: Added reader global_landmask
15:26:59 DEBUG   opendrift.readers.basereader.variables:548: Setting buffer size 119 for reader ../Daten/Wellendaten/Mm_CMEMS-GLOBAL_001_032-VHM0_VSDX_VSDY-2020.nc, assuming a maximum average speed of 1 m/s and time span of 30 days, 0:00:00
15:26:59 DEBUG   opendrift.models.basemodel:952: Added reader ../Daten/Wellendaten/Mm_CMEMS-GLOBAL_001_032-VHM0_VSDX_VSDY-2020.nc
15:26:59 DEBUG   opendrift.readers.basereader.variables:548: Setting buffer size 278 for reader ../Daten/CMEMS-GLOBAL_001_030-several_vars-1993_2020(nur_OF).nc, assuming a maximum average speed of 1 m/s and time span of 29 days, 12:00:00
15:26:59 DEBUG   opendrift.models.basemodel:952: Added reader ../Daten/CMEMS-GLOBAL_001_030-several_vars-1993_2020(nur_OF).nc
15:26:59 DEBUG   opendrift.readers.basereader.variables:548: Setting buffer size 12 for reader ../Daten/Winddaten/x_wind.sig995.mon.mean.nc, assuming a maximum average speed of 1 m/s and time span of 31 days, 0:00:00
15:26:59 DEBUG   opendrift.models.basemodel:952: Added reader ../Daten/Winddaten/x_wind.sig995.mon.mean.nc
15:26:59 DEBUG   opendrift.readers.basereader.variables:548: Setting buffer size 12 for reader ../Daten/Winddaten/y_wind.sig995.mon.mean.nc, assuming a maximum average speed of 1 m/s and time span of 31 days, 0:00:00
15:26:59 DEBUG   opendrift.models.basemodel:952: Added reader ../Daten/Winddaten/y_wind.sig995.mon.mean.nc
15:26:59 INFO    opendrift.models.oceandrift:336: Setting config: drift:vertical_advection -> False
15:26:59 INFO    opendrift.models.oceandrift:336: Setting config: drift:vertical_mixing -> False

I have renamed the wind data so that they are called x_wind and y_wind and no longer uwnd and vwnd, but this has unfortunately not led to any change.

I will have a look at Cartopy, thank you very much.

knutfrode commented 11 months ago

Hi, The log warning Skipped variables without standard_name: ['x_wind'] shows that you have not specified the standard_name attribute of your variables. The variable names do not matter, it is the standard name attribute which has to be from the CF standard name table, e.g. x_wind

Nebelgeist commented 11 months ago

And how can I change that name?

knutfrode commented 11 months ago

This is explained in e.g. this post: https://github.com/OpenDrift/opendrift/issues/745

Nebelgeist commented 11 months ago

Thanks a lot. Now the model is finally using the winddata.