\n",
"\n",
"Data downloaded from https://download.gebco.net/\n",
"\n",
"The file can be found on in the `data_raw` folder in our Shared Drive."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "56e18c69",
"metadata": {},
"outputs": [],
"source": [
"from netCDF4 import Dataset\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import cmocean\n",
"import geopandas as gpd\n",
"from mpl_toolkits.axes_grid1 import make_axes_locatable"
]
},
{
"cell_type": "markdown",
"id": "3c78377e",
"metadata": {},
"source": [
"Get the bathymetry data. The data is stored in [GEBCO_21_Jun_2022_33f5e5f23185](https://drive.google.com/drive/folders/1ttZKiyWJtAEASUhNS-XC-UmpiEVbUz_5?usp=sharing)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3a5039d5",
"metadata": {},
"outputs": [],
"source": [
"fname = \"GEBCO_21_Jun_2022_33f5e5f23185/gebco_2021_n8.0_s1.0_w-90.0_e-85.0.nc\""
]
},
{
"cell_type": "markdown",
"id": "42245341",
"metadata": {},
"source": [
"Inspect the netCDF4 file."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c07ac384",
"metadata": {},
"outputs": [],
"source": [
"fh = Dataset(fname, 'r')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "339f2c8f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\n",
"root group (NETCDF3_CLASSIC data model, file format NETCDF3):\n",
" title: The GEBCO_2021 Grid - a continuous terrain model for oceans and land at 15 arc-second intervals\n",
" summary: The GEBCO_2021 Grid is a continuous, global terrain model for ocean and land with a spatial resolution of 15 arc seconds.The grid uses as a 'base-map' Version 2.2 of the SRTM15+ data set (Tozer et al, 2019). This data set is a fusion of land topography with measured and estimated seafloor topography. It is augmented with gridded bathymetric data sets developed as part of the Nippon Foundation-GEBCO Seabed 2030 Project.\n",
" keywords: BATHYMETRY/SEAFLOOR TOPOGRAPHY, DIGITAL ELEVATION/DIGITAL TERRAIN MODELS\n",
" Conventions: CF-1.6, ACDD-1.3\n",
" id: DOI: 10.5285/c6612cbe-50b3-0cff-e053-6c86abc09f8f\n",
" naming_authority: https://dx.doi.org\n",
" history: Information on the development of the data set and the source data sets included in the grid can be found in the data set documentation available from https://www.gebco.net\n",
" source: The GEBCO_2021 Grid is the latest global bathymetric product released by the General Bathymetric Chart of the Oceans (GEBCO) and has been developed through the Nippon Foundation-GEBCO Seabed 2030 Project. This is a collaborative project between the Nippon Foundation of Japan and GEBCO. The Seabed 2030 Project aims to bring together all available bathymetric data to produce the definitive map of the world ocean floor and make it available to all.\n",
" comment: The data in the GEBCO_2021 Grid should not be used for navigation or any purpose relating to safety at sea.\n",
" license: The GEBCO Grid is placed in the public domain and may be used free of charge. Use of the GEBCO Grid indicates that the user accepts the conditions of use and disclaimer information: https://www.gebco.net/data_and_products/gridded_bathymetry_data/gebco_2019/grid_terms_of_use.html\n",
" date_created: 2021-07-01\n",
" creator_name: GEBCO through the Nippon Foundation-GEBCO Seabed 2030 Project\n",
" creator_email: gdacc@seabed2030.org\n",
" creator_url: https://www.gebco.net\n",
" institution: On behalf of the General Bathymetric Chart of the Oceans (GEBCO), the data are held at the British Oceanographic Data Centre (BODC).\n",
" project: Nippon Foundation - GEBCO Seabed2030 Project\n",
" creator_type: International organisation\n",
" geospatial_bounds: [-180. -90. 180. 90.]\n",
" geospatial_bounds_crs: WGS84\n",
" geospatial_bounds_vertical_crs: EPSG:5831\n",
" geospatial_lat_min: -90.0\n",
" geospatial_lat_max: 90.0\n",
" geospatial_lat_units: degrees_north\n",
" geospatial_lat_resolution: 0.004166666666666667\n",
" geospatial_lon_min: -180.0\n",
" geospatial_lon_max: 180.0\n",
" geospatial_lon_units: degrees_east\n",
" geospatial_lon_resolution: 0.004166666666666667\n",
" geospatial_vertical_min: -10977.0\n",
" geospatial_vertical_max: 8685.0\n",
" geospatial_vertical_units: meters\n",
" geospatial_vertical_resolution: 1.0\n",
" geospatial_vertical_positive: up\n",
" identifier_product_doi: DOI: 10.5285/c6612cbe-50b3-0cff-e053-6c86abc09f8f\n",
" references: DOI: 10.5285/c6612cbe-50b3-0cff-e053-6c86abc09f8f\n",
" node_offset: 1.0\n",
" dimensions(sizes): lat(1680), lon(1200)\n",
" variables(dimensions): float64 lat(lat), float64 lon(lon), int16 elevation(lat, lon)\n",
" groups: "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fh"
]
},
{
"cell_type": "markdown",
"id": "1aba6c2c",
"metadata": {},
"source": [
"Look into specific variables."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "bd6b43a6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\n",
"int16 elevation(lat, lon)\n",
" standard_name: height_above_mean_sea_level\n",
" long_name: Elevation relative to sea level\n",
" units: m\n",
" grid_mapping: crs\n",
" sdn_parameter_urn: SDN:P01::ALATZZ01\n",
" sdn_parameter_name: Sea floor height (above mean sea level) {bathymetric height}\n",
" sdn_uom_urn: SDN:P06::ULAA\n",
" sdn_uom_name: Metres\n",
"unlimited dimensions: \n",
"current shape = (1680, 1200)\n",
"filling on, default _FillValue of -32767 used"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fh.variables[\"elevation\"]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b2cb8e83",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\n",
"float64 lon(lon)\n",
" standard_name: longitude\n",
" long_name: longitude\n",
" units: degrees_east\n",
" axis: X\n",
" sdn_parameter_urn: SDN:P01::ALONZZ01\n",
" sdn_parameter_name: Longitude east\n",
" sdn_uom_urn: SDN:P06::DEGE\n",
" sdn_uom_name: Degrees east\n",
"unlimited dimensions: \n",
"current shape = (1200,)\n",
"filling on, default _FillValue of 9.969209968386869e+36 used"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fh.variables[\"lon\"]"
]
},
{
"cell_type": "markdown",
"id": "91a97e00",
"metadata": {},
"source": [
"Import the specific variables."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "43eb83aa",
"metadata": {},
"outputs": [],
"source": [
"z = fh.variables[\"elevation\"][:].data\n",
"lon = fh.variables[\"lon\"][:].data\n",
"lat = fh.variables[\"lat\"][:].data"
]
},
{
"cell_type": "markdown",
"id": "07834e18",
"metadata": {},
"source": [
"Grid longitude and latitude for `pcolor` plot."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "eccbda42",
"metadata": {},
"outputs": [],
"source": [
"Lon, Lat = np.meshgrid(lon, lat)"
]
},
{
"cell_type": "markdown",
"id": "be3fb291",
"metadata": {},
"source": [
"