{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Radionuclides\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from opendrift.readers import reader_netCDF_CF_generic\nfrom opendrift.models.radionuclides import RadionuclideDrift\nfrom datetime import timedelta, datetime\nimport numpy as np\n\n\no = RadionuclideDrift(loglevel=0, seed=0) # Set loglevel to 0 for debug information\n\n# Norkyst\n#reader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '/14Jan2016_NorKyst_z_3d/NorKyst-800m_ZDEPTHS_his_00_3Dsubset.nc')\nreader_norkyst = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be')\n\no.add_reader([reader_norkyst])\n\n\n\n# Adjusting some configuration\no.set_config('drift:vertical_mixing', True)\n#o.set_config('vertical_mixing:diffusivitymodel','constant') # include settling without vertical turbulent mixing\no.set_config('vertical_mixing:diffusivitymodel','environment') # apply vertical diffusivity from ocean model\n# Vertical mixing requires fast time step\no.set_config('vertical_mixing:timestep', 600.) # seconds\no.set_config('drift:horizontal_diffusivity', 10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o.set_config('radionuclide:particle_diameter',5.e-6) # m\n\no.set_config('radionuclide:sediment:resuspension_depth',2.)\no.set_config('radionuclide:sediment:resuspension_depth_uncert',0.1)\no.set_config('radionuclide:sediment:resuspension_critvel',0.15)\n\n\n#\no.set_config('radionuclide:isotope', '137Cs')\no.set_config('radionuclide:specie_setup','LMM + Rev')\n\n# By default, radionuclides do not strand towards coastline\no.set_config('general:coastline_action', 'previous')\no.set_config('general:seafloor_action','lift_to_seafloor')\n\n\no.set_config('seed:LMM_fraction',.45)\no.set_config('seed:particle_fraction',.55)\n\no.list_configspec()\n\n\n\n# SEEDING\n\ntd=datetime.today()\ntime = datetime(td.year, td.month, td.day, 0)\n\nlatseed= 60.0; lonseed= 4.5 \n\nntraj=5000\niniz=np.random.rand(ntraj) * -10. # seeding the radionuclides in the upper 10m\n\no.seed_elements(lonseed, latseed, z=iniz, radius=1000,number=ntraj,\n time=time, \n )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Running model\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o.run(steps=24*2, time_step=1800, time_step_output=3600)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Print and plot results\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(o)\nprint('Final speciation:')\nfor isp,sp in enumerate(o.name_species):\n print ('{:32}: {:>6}'.format(sp,sum(o.elements.specie==isp)))\n\nprint('Number of transformations:')\nfor isp in range(o.nspecies):\n print('{}'.format(['{:>9}'.format(np.int32(item)) for item in o.ntransformations[isp,:]]) )\n\no.animation(color='specie',\n vmin=0,vmax=o.nspecies-1,\n colorbar=False,\n legend=[o.specie_num2name(i) for i in range(o.nspecies)],\n fast = True\n )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o.plot_vertical_distribution()\n#o.plot_property('specie')\no.animation_profile(color='specie',\n vmin=0,vmax=o.nspecies-1,\n legend=[o.specie_num2name(i) for i in range(o.nspecies)],\n legend_loc =3,\n# markersize=10\n )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o.plot(linecolor='specie',vmin=0,vmax=o.nspecies-1,fast=True,)\n\n\n\n# # Postprocessing: write to concentration netcdf file"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
".. code:\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o.write_netcdf_radionuclide_density_map('radio_conc.nc', pixelsize_m=500.,\n zlevels=[-2.],\n activity_unit='Bq',\n horizontal_smoothing=True,\n smoothing_cells=1,\n time_avg_conc=True,\n deltat=2., # hours\n# llcrnrlon=4.4, llcrnrlat=59.9,\n# urcrnrlon=4.8, urcrnrlat=60.2,\n )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}