# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenDrift.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2015, Knut-Frode Dagestad, MET Norway

import argparse
import numpy as np
import opendrift

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("filename1", help="<OpenDrift filename (netCDF) of first file>")
    parser.add_argument(dest="filename2", nargs="?", help="<OpenDrift filename (netCDF) of second file>")
    parser.add_argument("-b", dest="buffer", default=1.0, help="Buffer around plot in degrees lon/lat.")

    args = parser.parse_args()

    o1 = opendrift.open(args.filename1)
    print o1

    if args.filename2 is None:
        o1.animation_profile()
    else:
        o2 = opendrift.open(args.filename2)
        print o2

        # Animate and compare the two runs
        o1.animation_profile(compare=o2, legend=[args.filename1, args.filename2])
예제 #2
0
# You should have received a copy of the GNU General Public License
# along with OpenDrift.  If not, see <https://www.gnu.org/licenses/>.
#
# Copyright 2015, Knut-Frode Dagestad, MET Norway

import sys
import argparse
import numpy as np
sys.path.append("..")

import opendrift

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('filename',
                        help='<OpenDrift output filename (netCDF)>')
    parser.add_argument('-b',
                        dest='buffer',
                        default=0.1,
                        help='Buffer around plot in degrees lon/lat.')
    parser.add_argument('-f',
                        dest='outfile',
                        default=None,
                        help='Save plot to filename.')

    args = parser.parse_args()

    o = opendrift.open(args.filename)
    print(o)
    o.plot(buffer=float(args.buffer), filename=args.outfile)
예제 #3
0
lat = 60.1
time = reader_norkyst.start_time
o.seed_elements(lon, lat, radius=1000, number=100, time=time)
o.set_2d()

o.run(steps=50 * 4, time_step=900, time_step_output=3600, outfile=ncfile)

#%%
# Print and plot results
print(o)
o.plot(buffer=.2, fast=True)

##%%
# Backward run:
# Import forward run, and seed elements at final positions and time
o = opendrift.open(ncfile)
elements_final = o.elements
time_final = o.time
del o
o = OceanDrift(loglevel=20)  # Set loglevel to 0 for debug information
o.fallback_values['land_binary_mask'] = 0
o.add_reader(reader_norkyst)
o.schedule_elements(elements_final, time_final)
o.set_2d()

#%%
# Running model backwards from end of forward simulation
o.run(steps=50 * 4, time_step=-900, time_step_output=3600)

#%%
# Check if backwards simulation brings elements back to their starting position. Some numerical error is expected.
예제 #4
0
#!/usr/bin/env python
"""
Importing file
==================================
"""

import os

import opendrift


if not os.path.exists('openoil.nc'):
    raise ValueError('Please run example.py first to generate a '
                     'netCDF file to be imported.')

o = opendrift.open('openoil.nc')
print(o)

o.plot()
o.plot_property('mass_oil')
예제 #5
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with OpenDrift.  If not, see <http://www.gnu.org/licenses/>.
# 
# Copyright 2015, Knut-Frode Dagestad, MET Norway

import sys
import argparse
import numpy as np
sys.path.append("..")

import opendrift

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('filename',
                        help='<OpenDrift output filename (netCDF)>')
    parser.add_argument('-b', dest='buffer',
                        default=0.1,
                        help='Buffer around plot in degrees lon/lat.')

    args = parser.parse_args()


    o = opendrift.open(args.filename)
    print o
    o.plot(buffer=np.float(args.buffer))
예제 #6
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('filename1',
                        help='<OpenDrift filename (netCDF) of first file>')
    parser.add_argument(dest='filename2', nargs='?',
                        help='<OpenDrift filename (netCDF) of second file>')
    parser.add_argument('-b', dest='buffer',
                        default=1.0,
                        help='Buffer around plot in degrees lon/lat.')
    parser.add_argument('-f', dest='outfile',
                        default=None, help='Save animation to filename.')
    parser.add_argument('-c', dest='color',
                        default=False, help='Color elements with this parameter.')

    args = parser.parse_args()


    o1 = opendrift.open(args.filename1)
    print o1

    if args.filename2 is None:
        o1.animation(filename=args.outfile, color=args.color)
    else:
        o2 = opendrift.open(args.filename2)
        print o2

        # Animate and compare the two runs
        o1.animation(compare=o2, legend=[args.filename1, args.filename2],
                     filename=args.outfile, color=args.color)
예제 #7
0
#!/usr/bin/env python

import os

import opendrift


if not os.path.exists('openoil.nc'):
    raise ValueError('Please run example.py first to generate a '
                     'netCDF file to be imported.')

o = opendrift.open('openoil.nc')
print o

o.plot()
o.plot_property('mass_oil')