lat = -16.3  # Australia

time = datetime.utcnow()
duration = timedelta(days=3)
bufferlat = duration.total_seconds() / 111000
bufferlon = bufferlat * np.cos(lat * np.pi / 180)

#%% Fetching current data from CMEMS
# By intialisation, only an XML-file with the contents is downloaded.
# The netCDF file with data is downloaded later, after the simulation is started,
# when necessary coverage (time/space) is known ( <reader>.prepare() )

cmems = reader_cmems.Reader(
    dataset='global-analysis-forecast-phy-001-024-hourly-merged-uv',
    variable_mapping={  # Overriding the mapping in reader_cmems.py
        'utotal': 'x_sea_water_velocity',
        'vtotal': 'y_sea_water_velocity',
        'utide': 'sea_ice_x_velocity',  # Fake mapping, as standard_name
        'vtide': 'sea_ice_y_velocity'
    })  # must be unique for a reader

o = OceanDrift()

o.add_reader(cmems)
# Alternatively, use OPeNDAP directly:
# https://help.marine.copernicus.eu/en/articles/5182598-how-to-consume-the-opendap-api-and-cas-sso-using-python
#o.add_readers_from_list(['https://nrt-dev.cmems-du.eu/thredds/dodsC/global-analysis-forecast-phy-001-024-hourly-merged-uv'])

o.seed_elements(lon=lon, lat=lat, number=5000, radius=1000, time=time)
o.run(duration=duration)

# Although total current (SMOC) has been used as forcing, we plot the tidal current as background field, disguised as ice velocity
Esempio n. 2
0
time = datetime.now()
duration = timedelta(days=3)
bufferlat = duration.total_seconds() / 111000
bufferlon = bufferlat * np.cos(lat * np.pi / 180)

# Fetching current data from CMEMS
cmems_file = 'opendrift_cmems_download.nc'
if os.path.exists(cmems_file):
    # Reuising downloaded file, if existing. Delete it to force update.
    cmems = reader_netCDF_CF_generic.Reader(cmems_file)
else:
    cmems = reader_cmems.Reader(username=username,
                                password=password,
                                lon_min=lon - bufferlon,
                                lon_max=lon + bufferlon,
                                lat_min=lat - bufferlat,
                                lat_max=lat + bufferlat,
                                time_start=time - timedelta(hours=3),
                                time_end=time + duration)

o = OceanDrift()

o.add_reader(cmems)
o.seed_elements(lon=lon, lat=lat, number=5000, radius=1000, time=time)
o.run(duration=duration)
o.animation(fast=True)

#%%
# .. image:: /gallery/animations/example_cmems_0.gif
Esempio n. 3
0
time = datetime.now()
duration = timedelta(days=3)
bufferlat = duration.total_seconds()/111000 
bufferlon = bufferlat*np.cos(lat*np.pi/180)

# Fetching current data from CMEMS
cmems_file = 'opendrift_cmems_download.nc'
if os.path.exists(cmems_file):
    # Reuising downloaded file, if existing. Delete it to force update.
    cmems = reader_netCDF_CF_generic.Reader(cmems_file)
else:
    cmems = reader_cmems.Reader(username=username, password=password,
                                motu=motu_client,
                                lon_min = lon - bufferlon,
                                lon_max = lon + bufferlon,
                                lat_min = lat - bufferlat,
                                lat_max = lat + bufferlat,
                                time_start = time,
                                time_end = time + duration)

# Fetching wind data from NCEP
reader_ncep = reader_netCDF_CF_generic.Reader('http://oos.soest.hawaii.edu/thredds/dodsC/hioos/model/atm/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd')

o = Leeway()
o.add_reader([cmems, reader_ncep])
o.seed_elements(lon=lon, lat=lat, number=5000, time=time)
o.run(duration=duration, outfile='cmems.nc',
      time_step=600, time_step_output=3600)
o.animation()