1. Read TESEO’s domain files

Open In Colab

  1. Read bathymetry and coastline from TESEO’s format files

  2. Select one polygon of the coastline by its index

  3. Plot bathymetry, coastline and the selected polygon

[12]:
import warnings
warnings.simplefilter(action='ignore')

from matplotlib import pyplot as plt
from matplotlib import Path
from pyteseo.io import read_grid, read_coastline
[13]:
import pyteseo.tests as tests_
data_path = Path(tests_.__file__).parent / "data"
grid_path = data_path / "grid.dat"
coastline_path = data_path / "coastline.dat"
[14]:
grid = read_grid(grid_path, nan_value=-9999)
coast = read_coastline(coastline_path)
[15]:
# Select polygon index
i=4
coast.loc[[i]]
[15]:
lon lat
polygon point
4 14683 NaN NaN
14684 -3.770457 43.465932
14685 -3.770418 43.465974
14686 -3.770389 43.465960
14687 -3.770315 43.465903
14688 -3.770242 43.465847
14689 -3.770271 43.465790
14690 -3.770286 43.465737
14691 -3.770301 43.465684
14692 -3.770389 43.465634
14693 -3.770467 43.465588
14694 -3.770545 43.465542
14695 -3.770610 43.465502
14696 -3.770675 43.465461
14697 -3.770740 43.465421
14698 -3.770779 43.465350
14699 -3.770858 43.465290
14700 -3.770936 43.465230
14701 -3.771029 43.465177
14702 -3.771121 43.465123
14703 -3.771200 43.465069
14704 -3.771278 43.465015
14705 -3.771356 43.464960
14706 -3.771444 43.464925
14707 -3.771512 43.464921
14708 -3.771581 43.464918
14709 -3.771654 43.464939
14710 -3.771727 43.464960
14711 -3.771737 43.465038
14712 -3.771776 43.465109
14713 -3.771698 43.465166
14714 -3.771813 43.465145
14715 -3.771927 43.465123
14716 -3.772042 43.465102
14717 -3.772157 43.465081
14718 -3.772177 43.465148
14719 -3.772196 43.465216
14720 -3.772079 43.465242
14721 -3.771962 43.465268
14722 -3.771844 43.465294
14723 -3.771750 43.465320
14724 -3.771656 43.465346
14725 -3.771561 43.465372
14726 -3.771502 43.465438
14727 -3.771444 43.465504
14728 -3.771385 43.465570
14729 -3.771297 43.465588
14730 -3.771209 43.465606
14731 -3.771146 43.465645
14732 -3.771082 43.465684
14733 -3.770989 43.465717
14734 -3.770897 43.465751
14735 -3.770804 43.465785
14736 -3.770711 43.465818
14737 -3.770626 43.465856
14738 -3.770542 43.465894
14739 -3.770457 43.465932
[16]:
# Plot grid and coastline
ax = grid.plot.scatter(x="lon", y="lat", c="depth", figsize=(16,9))
# plt.fill(coast["lon"], coast["lat"], color="grey")
coast.plot.line(ax=ax, x="lon", y="lat", color="grey", label="coastline")
coast.loc[[i]].plot.line(ax=ax, x="lon", y="lat", color="r", label=f"coastline - polygon {i}")
ax.axis("equal")
[16]:
(-3.878859987333, -3.6949486337070003, 43.363319567585, 43.524003830115)
../_images/notebooks_01_read_domain_6_1.png