Skip to content

Demo III - Visualization

import pathlib
import sys

# define the top level directory
PROJECT_PATH = pathlib.Path("/media/disk/erc/papers/2019_ML_OCN/")
CODE_PATH = PROJECT_PATH.joinpath("ml4ocean")
sys.path.append(str(CODE_PATH))

# ml4ocean packages
from src.utils import get_paths
from src.data.world import get_full_data, world_features
from src.features.world import subset_independent_floats

PATHS = get_paths()

# standard pacakges
import numpy as np
import pandas as pd

# plottling
import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER

%matplotlib inline
%load_ext autoreload
%autoreload 2
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

Data

!ls {PATHS.data_interim}
inputs.csv  isprs2020.csv  outputs.csv soca2016.csv
inputs_df = pd.read_csv(f"{PATHS.data_interim.joinpath('inputs.csv')}")
outputs_df = pd.read_csv(f"{PATHS.data_interim.joinpath('outputs.csv')}")
soca2016_df = pd.read_csv(f"{PATHS.data_interim.joinpath('soca2016.csv')}")
isprs2020_df = pd.read_csv(f"{PATHS.data_interim.joinpath('isprs2020.csv')}")

Plot I - Float Locations

soca2016_locations = soca2016_df.copy().reset_index()[['wmo', 'lat', 'lon']].drop_duplicates()
input_locations = inputs_df.copy().reset_index()[['wmo', 'lat', 'lon']].drop_duplicates()
isprs2020_locations = isprs2020_df.copy().reset_index()[['wmo', 'lat', 'lon']].drop_duplicates()

First Attempt

fig = plt.figure(figsize=(24, 12))

ax = plt.axes(projection=ccrs.Mollweide())

# SOCA2016
pts1 = plt.scatter(
    x=soca2016_locations.lon, 
    y=soca2016_locations.lat, 
    s=80,
    marker='+',
    color="darkorange",
    transform=ccrs.PlateCarree(),
    label='SOCA2016', zorder=3)
# ISPRS2020
pts2 = plt.scatter(
    x=isprs2020_locations.lon, 
    y=isprs2020_locations.lat, 
    s=80,
    marker='+',
    color="yellow",
    transform=ccrs.PlateCarree(),
    label='ISPRS2020', zorder=3,)
# INPUTS
pts3 = plt.scatter(
    x=input_locations.lon, 
    y=input_locations.lat, 
    s=50,
    marker='+',
    color="#528B8B",
    transform=ccrs.PlateCarree(),
    label='Input Data')


ax.coastlines()
ax.add_feature(cartopy.feature.LAND, zorder=0, facecolor='dimgray')
ax.add_feature(cartopy.feature.LAKES, zorder=1, facecolor='white', edgecolor='black')
ax.add_feature(cartopy.feature.RIVERS, zorder=2, edgecolor='black')

# gridlines
gl = ax.gridlines(
    crs=ccrs.PlateCarree(), 
    color='black', 
    alpha=0.9, 
    linewidth=1, 
    linestyle='--', 
    zorder=4
)

ax.legend(fontsize=30, ncol=2, markerscale=3, loc='upper right')
plt.tight_layout()
plt.show()