DEV Community

Cover image for Sea surface currents derived from OSCAR
Jordan Bell
Jordan Bell

Posted on • Edited on

3 1

Sea surface currents derived from OSCAR

Sea surface currents derived from OSCAR

import xarray as xr
import numpy as np
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

with xr.open_dataset('oscar_vel2020.nc.gz') as ds:
    print(ds)

    plt.figure(figsize=(18, 9))

    ax = plt.axes(projection=ccrs.PlateCarree()) # plate carrée projection

    dec = 10

    lon = ds.longitude.values[::dec]

    lon[lon > 180] = lon[lon > 180] - 360

    mymap = plt.streamplot(
        lon,
        ds.latitude.values[::dec],
        ds.u.values[0, 0, ::dec, ::dec],
        ds.v.values[0, 0, ::dec, ::dec],
        8,
        transform = ccrs.PlateCarree()
    )

    ax.coastlines()

    plt.title('Sea surface currents derived from OSCAR')

    plt.savefig("currents18x9.png", dpi=150)

    plt.show()
Enter fullscreen mode Exit fullscreen mode

Lightly modified from "How to plot Ocean Currents with Cartopy". Reply by Jody Klymak. Oct 20, 2019

Ocean Surface Current Analyses Real-time (OSCAR)

NASA Earth Science Data Systems (ESDS)

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay