OpenDrift / opendrift

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

Is there any way i can run o.write_netcdf_radionuclide_density_map? #1116

Closed ledgint closed 1 year ago

ledgint commented 1 year ago

I tryed running example-radionuclides-py with postpocessing feature, but for me its no resoults. I have errors as "'NoneType' object is not subscriptable" or 'Reader' object has no attribute 'land_binary_mask' Do you have any solution to apply?

knutfrode commented 1 year ago

Can you describe more precisely what you did, and what was the output?

ledgint commented 1 year ago

I am trying to use uncomment postprocessing part in example file "example_radionuclides.py", i suppose cannot uncomment code properly to make postprocessing part work but log says o.conc_mask = reader_norkyst.land_binary_mask ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Reader' object has no attribute 'land_binary_mask'

or another error

Traceback (most recent call last): File "c:\Users\skota\Documents\work\opendrift\example_radionuclides.py", line 152, in o.write_netcdf_radionuclide_density_map('radio_conc.nc', pixelsize_m=200., File "c:\Users\skota\Documents\work\opendrift\opendrift\models\radionuclides.py", line 1069, in write_netcdf_radionuclide_density_map pixel_mean_depth = self.get_pixel_mean_depth(lon_array, lat_array) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\skota\Documents\work\opendrift\opendrift\models\radionuclides.py", line 1350, in get_pixel_mean_depth lat_grd = self.conc_lat[:nx,:ny]


TypeError: 'NoneType' object is not subscriptable
knutfrode commented 1 year ago

I confirm I get the same error when uncommenting these lines.

@magnesim Can these uncommented lines in example_radionucleides be updated so that they work, or eventually be deleted from this example script?

ledgint commented 1 year ago

But i am also interested in using postpocessing of this model in another file. If it ever will be possible, of course

knutfrode commented 1 year ago

Magne has now updated example_readionucleides (https://github.com/OpenDrift/opendrift/commit/544a7308febb4f0d612310a9edc7e82636417610), and it seem to work now: https://opendrift.github.io/gallery/example_radionuclides.html#sphx-glr-gallery-example-radionuclides-py

Note that last command does not produce a plot, but a netCDF-file with concentrations, that can be viewed with e.g. ncview

ledgint commented 1 year ago

i used this script but changed dataset to Barents sea: reader_norkyst = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/fou-hi/barents_eps_zdepth_be')

i did only this change!

But i had error:

File "C:\GIT\opendrift\opendrift\models\basemodel.py", line 2910, in run raise ValueError( ValueError: No more active or scheduled elements, quitting.

12:31:19 INFO opendrift.models.basemodel:2949: "Missing variables: ['x_sea_water_velocity', 'y_sea_water_velocity', 'sea_floor_depth_below_sea_level']", 'The simulation stopped before requested end time was reached.'

12:31:19 INFO opendrift.models.basemodel:2952: ======================== Traceback (most recent call last): File "C:\GIT\opendrift\opendrift\models\basemodel.py", line 2910, 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 "C:\GIT\opendrift\projects\example_radionuclides (1).py", line 102, in o.run(steps=24*2, time_step=1800, time_step_output=3600) File "C:\GIT\opendrift\opendrift\models\basemodel.py", line 2956, in run raise ValueError('Simulation stopped within ' ValueError: Simulation stopped within first timestep. "Missing variables: ['x_sea_water_velocity', 'y_sea_water_velocity', 'sea_floor_depth_below_sea_level']", 'The simulation stopped before requested end time was reached.'

I suppose dataset doesnt have variables, but it probably does. Can I fix it somehow?

knutfrode commented 1 year ago

The Barents ocean model has a different coverage in both time and space, so if you replace that, you would also need to update your script accordingly. If you use loglevel=0 you can see in the log the details about what happens.

ledgint commented 1 year ago

Its now on loglevel=0 it covers seeds area but error says dataset doesnt have variables, if i understand it right