An open API service indexing awesome lists of open source software.

https://github.com/annarufas/ocean-data-lab

MATLAB code for reading, formatting and visualising popular, freely-available oceanographic datasets.
https://github.com/annarufas/ocean-data-lab

cmems cmip6-data-download co2sys esa gebco globcolour glodap lops-ifremer matlab nasa-data noaa-data occci ocean-data ocean-productivity-site world-ocean-atlas

Last synced: 2 months ago
JSON representation

MATLAB code for reading, formatting and visualising popular, freely-available oceanographic datasets.

Awesome Lists containing this project

README

          

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14544997.svg)](https://doi.org/10.5281/zenodo.14544997)

# MATLAB Tools to Work with Oceanographic Datasets

This repository contains a collection of MATLAB scripts that I have developed for reading, formatting and visualising freely-available oceanographic datasets stored in `.nc` (NetCDF) files. It includes tools to organise data into a four-dimensional structure: `latitudes x longitudes x depth levels x 12 months`, essentially creating a climatology. This structure facilitates further data processing, such as data-model validation or model input preparation. Developed across various projects, I actively maintain and update these scripts to meet evolving research needs.

![fig_monthly_npp_carr2002_modis_zeuc02](https://github.com/user-attachments/assets/575ce382-6daf-4242-b8e5-d00b324a0245)
*Monthly climatology of net primary production (NPP) using the Carr 2002 algorithm forced with chla and PAR0 from NASA's Aqua-MODIS sensor, SST from AVHRR Pathfinder, and euphotic zone calculated from the algorithm proposed in Carr 2002.*

## Requirements

*⚠️ Note: These instructions are designed and tested specifically for macOS. While they may work on other operating systems (e.g., Windows or Linux), you might need to adapt the installation code accordingly.*

To use the content of this repository, ensure you have the following.
- [MATLAB](https://mathworks.com/products/matlab.html) version R2021a or later installed.
- Third-party functions downloaded from [MATLAB's File Exchange](https://mathworks.com/matlabcentral/fileexchange/): `worstcase`, `m_map`, `brewermap` and `subaxis`. Once downloaded, place these in the `./resources/external/` directory.
- [CO2SYS algorithm](https://www.ncei.noaa.gov/access/ocean-carbon-acidification-data-system/oceans/CO2SYS/co2rprt.html) for carbonate system calculations. Once downloaded, place it in the `./resources/external/` directory.
- [SEAWATER toolbox](https://www.cmar.csiro.au/datacentre/ext_docs/seawater.html) to calculate seawater density. Once downloaded, place it in the `./resources/external/` directory.
- `copernicusmarine` toolbox, essential for downloading oceanographic data from the Copernicus Marine Environmental Monitoring Service (CMEMS). Installation instructions are in this related [repository](https://github.com/annarufas/jupyter-matlab-ocean-satellite-data-toolbox).
- Jupyter Notebook, included in the latest [Anaconda Python distribution](https://www.anaconda.com/).

## Repository Structure

- `./code/`: scripts for downloading, reading, formating and visualising data (*provided, see "Scripts Overview"*)
- `./matlab/`: MATLAB scripts
- `./jupyter/`: Jupyter Notebooks
- `./bash/`: bash scripts
- `./data/`
- `./raw/`: raw data downloaded from source URLs (*not provided, see below for details*).
- `./processed/`: processed data generated by code (*not provided, see below for details*).
- `./resources/`
- `./external/`: third-party resources for plotting and functions (*see "Requirements" section*).
- `./internal/`: custom MATLAB functions generated specifically for plotting (*provided*).
- `./figures/`: figures generated from processed data (*not ptovided*).

Due to large file sizes and variety of licenses that limit re-distribution of data in various ways, raw data are not hosted in `./data/raw/`. Instead, the links for manually obtaining these data (`.nc` files) are provided in the "Data Sources" section below as well as within the MATLAB scripts in `./code/`. If manual access is difficult, we iclude scripts to download data programmatically. Note that data URLs may change over time, potentially interrupting access. The processed data created by the MATLAB scripts (`.mat`) are in `./data/processed/` but cannot be provided due to their large size.

## Data Sources

The oceanographic datasets used in this repository are sourced from the following open-access resources:

| Open-access resource | Sector |
|-----------------------------------------------------|------------------------------------|
| Copernicus Marine Environmental Monitoring Service ([CMEMS](https://data.marine.copernicus.eu/products)) Data Store | Ocean biogeochemistry, ocean physics and ocean colour |
| Earth System Grid Federation ([ESGF](https://aims2.llnl.gov/search/cmip6/?mip_era=CMIP6)) | Climate data from Coupled Model Intercomparison Projects phase 6 (CMIP6) |
| ESA Biological Pump and Carbon Exchange Processes ([BICEP](https://bicep-project.org/About.html)) project | Ocean colour and ocean biogeochemistry |
| ESA [GlobColour project](https://hermes.acri.fr) | Ocean colour |
| ESA Sea Ice Climate Change Initiative ([ESA-CCI](https://climate.esa.int/en/projects/sea-ice/)) | Sea ice concentration |
| ESA Ocean Colour Climate Change Initiative ([OC-CCI](https://www.oceancolour.org)) | Ocean colour |
| General Bathymetric Chart of the Ocean ([GEBCO](https://www.gebco.net/data_and_products/gridded_bathymetry_data/#global)) | Bathymetry |
| Global Ocean Data Analysis Project ([GLODAP](https://glodap.info)) | Ocean biogeochemistry, physics and carbonate system variables |
| Institut Français de Recherche pour l'Exploitation de la Mer (IFREMER) [Mixed Layer Depth Climatology](https://cerweb.ifremer.fr/deboyer/mld/home.php) website | Mixed layer depth |
| NASA [Ocean Color](https://oceancolor.gsfc.nasa.gov) website | Ocean colour |
| NOAA National Centers for Environmental Information (NCEI) [AVHRR Pathfinder SST](https://www.ncei.noaa.gov/products/avhrr-pathfinder-sst) | Sea surface temperature |
| NOAA National Centers for Environmental Information (NCEI) [World Ocean Atlas](https://www.ncei.noaa.gov/products/world-ocean-atlas) | Ocean biogeochemistry and ocean physics |
| Oregon State University's [Ocean Productivity Site](http://orca.science.oregonstate.edu/npp_products.php) | Net primary production |

## Datasets Used

The specific oceanographic datasets accessed and processed by this repository include:

- Aeolian dust deposition
- CMIP6 [NCAR-CESM2 historical simulation](https://aims2.llnl.gov/search/cmip6/)
- Bathymetry
- [GEBCO](https://www.gebco.net/data_and_products/gridded_bathymetry_data/#global)
- Carbonate system variables (carbonate ion concentration, omega calcite and omega aragonite)
- [GLODAPv2.2016b](https://www.nodc.noaa.gov/archive/arc0107/0162565/2.2/data/0-data/mapped/)/[CO2SYS](https://www.ncei.noaa.gov/access/ocean-carbon-acidification-data-system/oceans/CO2SYS/co2rprt.html)
- Chlorophyll *a* (chla) concentration
- [NASA Aqua-MODIS sensor](https://oceancolor.gsfc.nasa.gov/about/missions/aqua/)
- [NASA SeaWiFS sensor](https://oceancolor.gsfc.nasa.gov/about/missions/seawifs/)
- [OC-CCI](https://www.oceancolour.org/thredds/ncss/cci/v6.0-release/geographic/monthly/chlor_a/)
- [CMEMS global BGC reanalysis](https://data.marine.copernicus.eu/product/OCEANCOLOUR_GLO_BGC_L4_MY_009_104/description)
- Cloud cover
- [Pincus et al. (2008)](https://doi.org/10.1029/2007JD009334)
- Diffuse attenuation coefficient at 490 nm (kd(490))
- [NASA Aqua-MODIS sensor](https://oceancolor.gsfc.nasa.gov/about/missions/aqua/)
- [CMEMS global BGC reanalysis](https://data.marine.copernicus.eu/product/OCEANCOLOUR_GLO_BGC_L4_MY_009_104/description)
- Dynamic viscosity of seawater
- Calculated from salinity and temperature [World Ocean Atlas 2023](https://www.ncei.noaa.gov/access/world-ocean-atlas-2023/) using [MIT seawater properties library routines](https://web.mit.edu/seawater/))
- Euphotic layer depth (zeu)
- Calculated from (1) kd(490) from [CMEMS global BGC reanalysis](https://data.marine.copernicus.eu/product/OCEANCOLOUR_GLO_BGC_L4_MY_009_104/description) or [NASA Aqua-MODIS sensor](https://oceancolor.gsfc.nasa.gov/about/missions/aqua/), and (2) MLD from CMEMS global BGC reanalysis or [IFREMER](https://cerweb.ifremer.fr/deboyer/data/mld_DReqDTm02_c1m_reg2.0.nc) using the equations of in Fox et al. ([2024](https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2024GB008149)), after Morel & Maritorena (2001), Morel et al. (2007) and Buesseler et al. (2020)
- Mixed layer depth (MLD)
- [CMEMS global PHYS reanalysis](https://data.marine.copernicus.eu/product/GLOBAL_MULTIYEAR_PHY_001_030/description)
- [IFREMER](https://cerweb.ifremer.fr/deboyer/data/mld_DReqDTm02_c1m_reg2.0.nc)
- Net primary production (NPP)
- [Oregon State University's Ocean Productivity Site](http://orca.science.oregonstate.edu/npp_products.php) (VGPM, CbPM, CAFE)
- [BICEP](https://catalogue.ceda.ac.uk/uuid/69b2c9c6c4714517ba10dab3515e4ee6/)
- [CMEMS global BGC reanalysis](https://data.marine.copernicus.eu/product/OCEANCOLOUR_GLO_BGC_L4_MY_009_104/description)
- Carr ([2002](https://doi.org/10.1016/S0967-0645(01)00094-7)) model
- Nutrients (nitrate, silicate, phosphate and dissolved oxygen concentration)
- [World Ocean Atlas 2023](https://www.ncei.noaa.gov/access/world-ocean-atlas-2023/)
- Photosynthetic active radiation at the surface ocean (PAR0)
- [NASA Aqua-MODIS sensor](https://oceancolor.gsfc.nasa.gov/about/missions/aqua/)
- [NASA SeaWiFS sensor](https://oceancolor.gsfc.nasa.gov/about/missions/seawifs/)
- [GlobColour merged sensors](https://hermes.acri.fr/index.php?class=archive)
- Calculated using astronomic/trigonometric equations and data inputs of sea ice fraction from [CMEMS global PHYS reanalysis](https://data.marine.copernicus.eu/product/GLOBAL_MULTIYEAR_PHY_001_030/description) and cloud cover fraction from [Pincus et al. (2008)](https://doi.org/10.1029/2007JD009334)
- Particulate organic carbon flux at export depth (a.k.a. export production)
- [BICEP](https://catalogue.ceda.ac.uk/uuid/a6fc730d88fd4935b59d64903715d891)
- Phytoplankton carbon (Cphyto)
- [BICEP](https://catalogue.ceda.ac.uk/uuid/6a6ccbb8ef2645308a60dc47e9b8b5fb/)
- Salinity
- [World Ocean Atlas 2023](https://www.ncei.noaa.gov/access/world-ocean-atlas-2023/)
- Sea ice concentration
- [CMEMS global PHYS reanalysis](https://data.marine.copernicus.eu/product/GLOBAL_MULTIYEAR_PHY_001_030/description)
- [ESA-CCI](https://climate.esa.int/en/projects/sea-ice/)
- Sea surface temperature (SST)
- NOAA National Centers for Environmental Information (NCEI) [AVHRR Pathfinder SST](https://www.ncei.noaa.gov/products/avhrr-pathfinder-sst)
- Seawater density
- Calculated from salinity and temperature from [World Ocean Atlas 2023](https://www.ncei.noaa.gov/access/world-ocean-atlas-2023/) using the [Gibbs-SeaWater (GSW) Oceanographic Toolbox](https://www.teos-10.org/))
- Seawater temperature
- [World Ocean Atlas 2023](https://www.ncei.noaa.gov/access/world-ocean-atlas-2023/)
- [CMEMS global PHYS reanalysis](https://data.marine.copernicus.eu/product/GLOBAL_MULTIYEAR_PHY_001_030/description)
- Mesozooplankton concentration
- CMIP6 [IPSL-PISCES historical simulation](https://aims2.llnl.gov/search/cmip6/)
- CMIP6 [GFDL-COBALT historical simulation](https://aims2.llnl.gov/search/cmip6/)
- CMIP6 [UKESM-MEDUSA historical simulation](https://aims2.llnl.gov/search/cmip6/)

## Scripts Overview

The following scripts are available in the `./code/` folder. Notice all datasets produced are `latitudes x longitudes x (depth levels) x 12 months`.

| Num| Script name | Script action |
|----|------------------------------------------------|----------------------------------------------------------
| 1 | downloadBGCandPHYSfromCMEMS.ipynb | Downloads BGC and PHYS L4 data from CMEMS. Must be run before script 6 |
| 2 | downloadChlaFromOCCCI.m | Downloads merged-sensor, L3 chla data from OC-CCI. Must be run before `ncreadChlaFromNASAandOCCCI.m` |
| 3 | downloadOCfromGlobColour.ipynb | Downloads merged-sensor, L3 PAR0 data from GlobColour. Must be run before `ncreadPAR0fromGlobColour.m` |
| 4 | downloadSeaIceFromESACCI.ipynb | Downloads sea ice concentration climate data record from the AMSR-E and AMSR-2 instruments at 25 km grid spacing from ESA-CCI. Must be run before `ncreadSeaIceFromESACCI.m` |
| 5 | ncreadAerosolDustDepositionFromCMIP6.m | Creates `dustflux_cmip6_ncarcesm2.mat` (192 x 288 x 12) |
| 6 | ncreadBathymetryFromGEBCO.m | Creates `bathymetry_gebco.mat` (1080 x 2160) |
| 7 | ncreadBGCandPHYSfromCMEMS.m | Creates `chla_cmems_bgc.mat`, `kd_cmems_bgc.mat`, `mld_cmems_phys.mat`, `icefrac_cmems_phys.mat` (1080 x 2160 x 12) and `temp_cmems_phys.mat` (1080 x 2160 x 50 x 12) |
| 8 | ncreadBGCandPHYSfromWOA.m | Creates `nit_monthly_woa23.mat`, `phos_monthly_woa23.mat`, `sil_monthly_woa23.mat`, `oxy_monthly_woa23.mat`, `temp_monthly_woa23.mat`, `sal_monthly_woa23.mat` (180 x 360 x 102 x 12) and `temp_annual_woa23.mat` (180 x 360 x 102) |
| 9 | ncreadChlaFromNASAandOCCCI.m | Creates `chla_modis.mat` (4320 x 8640 x 12), `chla_seawifs.mat` (2160 x 4320 x 12) and `chla_occci.mat` (4320 x 8640 x 12) |
| 10 | ncreadCloudCoverFromPincus.m | Creates `cloudcover_pincus.mat` (72 x 144 x 12) |
| 11 | ncreadExportFluxFromBICEP.m | Creates `export_flux_bicep.mat` (2160 x 4320 x 12) |
| 12 | ncreadKdFromNASA.m | Creates `kd_modis.mat` (4320 x 8640 x 12) |
| 13 | ncreadNPPfromBICEP.m | Creates `npp_bicep.mat` (2160 x 4320 x 12) |
| 14 | ncreadNPPfromOceanProductivitySite.m | Creates `npp_cafe_seawifs.mat`, `npp_cafe_modis.mat`, `npp_cbpm_modis.mat` and `npp_vgpm_modis.mat` (1080 x 2160 x 12) |
| 15 | ncreadMLDfromIFREMER.m | Creates `mld_ifremer.mat` (90 x 180 x 12) |
| 16 | ncreadPAR0fromGlobColour.m | Creates `par0_globcolour.mat` (180 x 360 x 12) |
| 17 | ncreadPAR0fromNASA.m | Creates `par0_modis.mat` (4320 x 8640 x 12) and `par0_seawifs.mat` (2160 x 4320 x 12) |
| 18 | ncreadSeaIceFromESACCI.m | Creates `seaice_esacci.mat` (4320 x 8640 x 12) |
| 19 | ncreadSSTfromPathfinder.m | Creates `sst_pathfinder_v5.mat` (4096 x 8192 x 12) |
| 20 | ncreadZooplanktonFromCMIP6.m | Creates `mesozoo_cmip6_pisces.mat` (64 x 128 x 75), `mesozoo_cmip6_cobalt.mat` (180 x 360 x 35) and `mesozoo_cmip6_medusa.mat` (64 x 128 x 75) |
| 21 | createGridFromBathymetricData.m | Creates `grid_GEBCO_2160_1080.mat` (1080 x 2160 x 500) and `grid_GEBCO_360_180.mat` (180 x 360 x 500). Must be run after script 5. |
| 22 | createGriddedCarbonateSystemClimatology.m | Calculates carbonate system variables using CO2SYS and creates `co3ion_co2sys.mat`, `omegacalcite_co2sys.mat` and `omegaaragonite_co2sys.mat` (180 x 360 x 33 x 12) |
| 23 | createGriddedDensityClimatology.m | Calculates seawater density from temperature and salinity using Gibbs-SeaWater (GSW) Oceanographic Toolbox and creates `rho_calculated_woa23.mat` (180 x 360 x 102 x 12) |
| 24 | createGriddedDynamicViscosityClimatology.m | Calculates seawater dynamic viscosity from temperature and salinity using MIT seawater properties library routines and creates `dynamicvisco_calculated_woa23.mat` (180 x 360 x 102 x 12) |
| 25 | createGriddedPAR0climatology.m | Calculates PAR0 from cloud and ice cover data and creates `par0_monthly_calculated.mat` (180 x 360 x 12) and `par0_daily_calculated.mat` (180 x 360 x 365). Must be run after scripts `ncreadBGCandPHYSfromCMEMS.m`, 9 and 18 |
| 26 | createGriddedZeuClimatology.m | Calculates zeu from kd(490) and MLD and creates `zeu_calculated_kdcmems_mldcmems_pointonepercentpar0.mat`, `zeu_calculated_kdmodis_mldcmems_pointonepercentpar0.mat` (1080 x 2160 x 12). Must be run after scripts `ncreadBGCandPHYSfromCMEMS.m` and `ncreadKdFromNASA.m` |
| 27 | createGriddedNPPclimatologyFromCarrAlgorithm.m | Calculates NPP from chla, PAR0 and SST and creates `npp_carr2002_seawifs_pathfinder_zeuc02.mat`, `npp_carr2002_seawifs_pathfinder_zeub97.mat`, `npp_carr2002_modis_pathfinder_zeuc02.mat` and `npp_carr2002_modis_pathfinder_zeub97.mat` (180 x 360 x 12). Must be run after scripts `ncreadChlaFromNASAandOCCCI.m`, `ncreadPAR0fromNASA.m` and `ncreadSSTfromPathfinder.m` |
| 28 | regridZooplanktonConcentrationFromCMIP6.m | Called by script `ncreadZooplanktonFromCMIP6.m` |
| 29 | calculatePAR0fromTrigonometricEquations.m | Called by script `createGriddedPAR0climatology.m` |
| 30 | calculateZeuFromKdAndMLD.m | Called by script `createGriddedZeuClimatology.m` |
| 31 | calculateZeuFromChlaAndMLD.m | Called by script `createGriddedZeuClimatology.m` |
| 32 | calculatePftProbsFromBicepProduct.m | Processes BICEP phytoplankton carbon (Cphyto) data and calculates PFT relative probabilities |
| 33 | Carr2002algorithm.m | Called by script `createGriddedNPPclimatologyFromCarrAlgorithm.m` |
| 34 | processSensorDataFromNASA.m | Called by scripts `ncreadChlaFromNASAandOCCCI.m`, `ncreadKdFromNASA.m` and `ncreadPAR0fromNASA.m` |
| 35 | prepareDataForPlotting.m | Creates figures to show monthly climatological data (figures with `_monthly_` infix)|
| 36 | plotCrossSourceComparisonMaps.m | Creates figures to show comparisons of the same variable across datasets (figures with `_comparison_` infix) |
| 37 | submit_zoo_regridding.sh | Submits script `regridZooplanktonConcentrationFromCMIP6.m` to the SLURM job scheduler |