-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding xarray dataset option to ROMS reader
- Loading branch information
Showing
2 changed files
with
116 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
""" | ||
ROMS native reader | ||
================================== | ||
""" | ||
|
||
import numpy as np | ||
from opendrift.readers import reader_ROMS_native | ||
from opendrift.models.oceandrift import OceanDrift | ||
import xarray as xr | ||
|
||
o = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information | ||
|
||
#%% | ||
filename = (o.test_data_folder() + | ||
'2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc') | ||
|
||
# Creating and adding reader for Nordic 4km current dataset | ||
|
||
ds = xr.open_dataset(filename, decode_times=False) | ||
nordic_native = reader_ROMS_native.Reader(ds) | ||
o.add_reader(nordic_native) | ||
|
||
#%% | ||
# Seed elements at defined positions, depth and time | ||
o.seed_elements(lon=12.0, lat=68.3, radius=0, number=10, | ||
z=np.linspace(0, -150, 10), time=nordic_native.start_time) | ||
|
||
#%% | ||
# Running model | ||
o.run(time_step=3600) | ||
|
||
#%% | ||
# Print and plot results, with lines colored by particle depth | ||
print(o) | ||
o.plot(linecolor='z', fast=True) | ||
#o.animation() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters