from pathlib import Path
import fsspec
import numpy as np
import geopandas as gpd
import xarray as xr
import matplotlib.pyplot as plt
from shapely.geometry import box
import cartopy.crs as ccrs
import cartopy.io.img_tiles as cimgt
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import echopype as ep
from echopype.qc import exist_reversed_time
import warnings
"ignore", category=DeprecationWarning) warnings.simplefilter(
Exploring ship echosounder data from the Pacific Hake survey
Jupyter notebook accompanying the manuscript:
Echopype: A Python library for interoperable and scalable processing of ocean sonar data for biological information
Authors: Wu-Jung Lee, Emilio Mayorga, Landung Setiawan, Kavin Nguyen, Imran Majeed, Valentina Staneva
Introduction
Goals
- Illustrate a common workflow for echosounder data conversion, calibration and use. This workflow leverages the standardization applied by echopype and the power, ease of use and familiarity of libraries in the scientific Python ecosystem.
- Extract and visualize data with relative ease using geospatial and temporal filters.
Description
This notebook uses EK60 echosounder data collected during the 2017 Joint U.S.-Canada Integrated Ecosystem and Pacific Hake Acoustic Trawl Survey (‘Pacific Hake Survey’) to illustrate a common workflow for data conversion, calibration and analysis using echopype
and core scientific Python software packages, particularly xarray
, GeoPandas
, pandas
and NumPy
.
Two days of cloud-hosted .raw
data files are accessed by echopype directly from an Amazon Web Services (AWS) S3 “bucket” maintained by the NOAA NCEI Water-Column Sonar Data Archive. The total data used are 170 .raw
files at approximately 25 MB each (1 Hz pinging rate from first light to dusk), corresponding to approximately 4.2 GB. With echopype
, each file is converted to a standardized representation based on the SONAR-netCDF4 v1.0 convention and saved to the cloud-optimized Zarr format.
Data stored in the netCDF-based SONAR-netCDF4 convention can be conveniently and intuitively manipulated with xarray
in combination with related scientific Python packages. Mean Volume Backscattering Strength (MVBS) is computed with echopype
from each raw data file and exported to a netCDF file. Here, we define two geographical bounding boxes encompassing two ship tracks and use these to extract corresponding timestamp intervals from the GPS data, and then the corresponding MVBS data based on those intervals. Finally, these extracted MVBS subsets are plotted as track echograms.
Outline
- Establish AWS S3 file system connection and generate list of target EK60
.raw
files - Process S3-hosted raw files with
echopype
: convert, calibrate and export to standardized files - Extract and process GPS locations from the
Platform
group of converted raw files - Read MVBS and plot track echograms for time periods corresponding to two ship tracks
Running the notebook
This notebook can be run with a conda environment created using the conda environment file https://github.com/OSOceanAcoustics/echopype-examples/blob/main/binder/environment.yml. The notebook creates two directories, if not already present: ./exports/hakesurvey_convertedzarr
and ./exports/hakesurvey_calibratednc
. netCDF and Zarr files will be exported there.
Note
We encourage importing echopype
as ep
for consistency.
from dask.distributed import Client
= Client() client
client
Client
Client-0457e919-0407-11ef-80d7-820f588673e5
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: /user/leewujung/proxy/8787/status |
Cluster Info
Cluster Info
LocalCluster
5abba2b3
Dashboard: /user/leewujung/proxy/8787/status | Workers: 4 |
Total threads: 8 | Total memory: 31.34 GiB |
Status: running | Using processes: True |
Scheduler Info
Scheduler
Scheduler-b7dda29b-c5bc-4ea7-ab66-7890b5e5cc79
Comm: tcp://127.0.0.1:38903 | Workers: 4 |
Dashboard: /user/leewujung/proxy/8787/status | Total threads: 8 |
Started: Just now | Total memory: 31.34 GiB |
Workers
Workers
Worker: 0
Worker: 0
Comm: tcp://127.0.0.1:43205 | Total threads: 2 |
Dashboard: /user/leewujung/proxy/43023/status | Memory: 7.84 GiB |
Nanny: tcp://127.0.0.1:40977 | |
Local directory: /tmp/dask-scratch-space/worker-8hk9umex |
Worker: 1
Worker: 1
Comm: tcp://127.0.0.1:33021 | Total threads: 2 |
Dashboard: /user/leewujung/proxy/33901/status | Memory: 7.84 GiB |
Nanny: tcp://127.0.0.1:43227 | |
Local directory: /tmp/dask-scratch-space/worker-rtm3hewa |