Skip to content

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

License

Notifications You must be signed in to change notification settings

annarufas/ocean-data-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOI

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 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 version R2021a or later installed.
  • Third-party functions downloaded from MATLAB's File Exchange: worstcase, m_map, brewermap and subaxis. Once downloaded, place these in the ./resources/external/ directory.
  • CO2SYS algorithm for carbonate system calculations. Once downloaded, place it in the ./resources/external/ directory.
  • SEAWATER toolbox 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.
  • Jupyter Notebook, included in the latest Anaconda Python distribution.

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) Data Store Ocean biogeochemistry, ocean physics and ocean colour
Earth System Grid Federation (ESGF) Climate data from Coupled Model Intercomparison Projects phase 6 (CMIP6)
ESA Biological Pump and Carbon Exchange Processes (BICEP) project Ocean colour and ocean biogeochemistry
ESA GlobColour project Ocean colour
ESA Sea Ice Climate Change Initiative (ESA-CCI) Sea ice concentration
ESA Ocean Colour Climate Change Initiative (OC-CCI) Ocean colour
General Bathymetric Chart of the Ocean (GEBCO) Bathymetry
Global Ocean Data Analysis Project (GLODAP) Ocean biogeochemistry, physics and carbonate system variables
Institut Français de Recherche pour l'Exploitation de la Mer (IFREMER) Mixed Layer Depth Climatology website Mixed layer depth
NASA Ocean Color website Ocean colour
NOAA National Centers for Environmental Information (NCEI) AVHRR Pathfinder SST Sea surface temperature
NOAA National Centers for Environmental Information (NCEI) World Ocean Atlas Ocean biogeochemistry and ocean physics
Oregon State University's Ocean Productivity Site Net primary production

Datasets Used

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

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 Carr2002algorithm.m Called by script createGriddedNPPclimatologyFromCarrAlgorithm.m
33 processSensorDataFromNASA.m Called by scripts ncreadChlaFromNASAandOCCCI.m, ncreadKdFromNASA.m and ncreadPAR0fromNASA.m
34 prepareDataForPlotting.m Creates figures to show monthly climatological data (figures with _monthly_ infix)
35 plotCrossSourceComparisonMaps.m Creates figures to show comparisons of the same variable across datasets (figures with _comparison_ infix)
36 submit_zoo_regridding.sh Submits script regridZooplanktonConcentrationFromCMIP6.m to the SLURM job scheduler