# bmi_dbseabed
[![Documentation Status](https://readthedocs.org/projects/bmi_dbseabed/badge/?version=latest)](https://bmi-dbseabed.readthedocs.io/en/latest/)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/gantian127/bmi_dbseabed/blob/master/LICENSE.md)
bmi_dbseabed provides a set of functions that allow downloading of
the dataset from [dbSEABED](https://instaar.colorado.edu/~jenkinsc/dbseabed/),
a system for marine substrates datasets across the globe.
This system uses very large amounts of diverse observational data and
applies math methods to integrate/harmonize those
and produces gridded data on the major properties of the seabed.
The scope is the global ocean and across all depth zones.
The current page serves only the data for the Gulf of Mexico region.
The entire collection of data is available at
[this webpage](https://csdms.colorado.edu/wiki/Data:DBSEABED). Please note that
the data will be updated from time to time, approximately annually.
bmi_dbseabed also includes a [Basic Model Interface (BMI)](https://bmi.readthedocs.io/en/latest/),
which converts the dbSEABED datasets into a reusable,
plug-and-play data component ([pymt_dbseabed](https://pymt-dbseabed.readthedocs.io/)) for
the [PyMT](https://pymt.readthedocs.io/en/latest/?badge=latest) modeling framework developed
by Community Surface Dynamics Modeling System ([CSDMS](https://csdms.colorado.edu/wiki/Main_Page)).
If you have any suggestion to improve the current function, please create a github issue
[here](https://github.com/gantian127/bmi_dbseabed/issues).
### Install package
#### Stable Release
The bmi_dbseabed package and its dependencies can be installed with pip
```
$ pip install bmi_dbseabed
```
or with conda.
```
$ conda install -c conda-forge bmi_dbseabed
```
#### From Source
After downloading the source code, run the following command from top-level folder
to install bmi_dbseabed.
```
$ pip install -e .
```
### Quick Start
Below shows how to use two methods to download the datasets.
You can learn more details from the [tutorial notebook](notebooks/bmi_dbseabed.ipynb).
[//]: # (To run this notebook, please go to the [CSDMS EKT Lab]())
[//]: # (and follow the instruction in the "Lab notes" section.)
#### Example 1: use DbSeabed class to download data (Recommended method)
```python
import matplotlib.pyplot as plt
from bmi_dbseabed import DbSeabed
# get data from dbSEABED
dbseabed = DbSeabed()
data = dbseabed.get_data(
var_name="carbonate",
west=-98,
south=18,
east=-80,
north=31,
output="download.tif",
)
# show metadata
for key, value in dbseabed.metadata.items():
print(f"{key}: {value}")
# plot data
data.plot(figsize=(9, 5))
plt.title("dbSEABED dataset (Carbonate in %)")
```
![tif_plot](docs/source/_static/ts_plot.png)
#### Example 2: use BmiDbSseabed class to download data (Demonstration of how to use BMI)
```python
import matplotlib.pyplot as plt
import numpy as np
from bmi_dbseabed import BmiDbSeabed
# initiate a data component
data_comp = BmiDbSeabed()
data_comp.initialize("config_file.yaml")
# get variable info
var_name = data_comp.get_output_var_names()[0]
var_unit = data_comp.get_var_units(var_name)
var_location = data_comp.get_var_location(var_name)
var_type = data_comp.get_var_type(var_name)
var_grid = data_comp.get_var_grid(var_name)
print(f"{var_name=} \n{var_unit=} \n{var_location=} \n{var_type=} \n{var_grid=}")
# get variable grid info
grid_rank = data_comp.get_grid_rank(var_grid)
grid_size = data_comp.get_grid_size(var_grid)
grid_shape = np.empty(grid_rank, int)
data_comp.get_grid_shape(var_grid, grid_shape)
grid_spacing = np.empty(grid_rank)
data_comp.get_grid_spacing(var_grid, grid_spacing)
grid_origin = np.empty(grid_rank)
data_comp.get_grid_origin(var_grid, grid_origin)
print(f"{grid_rank=} \n{grid_size=} \n{grid_shape=} \n{grid_spacing=} \n{grid_origin=}")
# get variable data
data = np.empty(grid_size, var_type)
data_comp.get_value(var_name, data)
data_2D = data.reshape(grid_shape)
# get X, Y extent for plot
min_y, min_x = grid_origin
max_y = min_y + grid_spacing[0] * (grid_shape[0] - 1)
max_x = min_x + grid_spacing[1] * (grid_shape[1] - 1)
dy = grid_spacing[0] / 2
dx = grid_spacing[1] / 2
extent = [min_x - dx, max_x + dx, min_y - dy, max_y + dy]
# plot data
fig, ax = plt.subplots(1, 1, figsize=(9, 5))
im = ax.imshow(data_2D, extent=extent)
fig.colorbar(im)
plt.xlabel("X")
plt.ylabel("Y")
plt.title("dbSEABED dataset (Carbonate in %)")
# finalize data component
data_comp.finalize()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "bmi-dbseabed",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Tian Gan <jamy127@foxmail.com>",
"keywords": "BMI, Basic Model Interface, dbSEABED",
"author": null,
"author_email": "Tian Gan <jamy127@foxmail.com>, Chris Jenkins <jenkinsc0@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/6a/a5/68560e42400cbead3f1e9e3ff4e424de57e6f989ef847d0be24786f4cbc2/bmi_dbseabed-0.1.0.tar.gz",
"platform": null,
"description": "# bmi_dbseabed\n[![Documentation Status](https://readthedocs.org/projects/bmi_dbseabed/badge/?version=latest)](https://bmi-dbseabed.readthedocs.io/en/latest/)\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/gantian127/bmi_dbseabed/blob/master/LICENSE.md)\n\n\n\nbmi_dbseabed provides a set of functions that allow downloading of\nthe dataset from [dbSEABED](https://instaar.colorado.edu/~jenkinsc/dbseabed/),\na system for marine substrates datasets across the globe.\nThis system uses very large amounts of diverse observational data and\napplies math methods to integrate/harmonize those\nand produces gridded data on the major properties of the seabed.\nThe scope is the global ocean and across all depth zones.\n\nThe current page serves only the data for the Gulf of Mexico region.\nThe entire collection of data is available at\n[this webpage](https://csdms.colorado.edu/wiki/Data:DBSEABED). Please note that\nthe data will be updated from time to time, approximately annually.\n\nbmi_dbseabed also includes a [Basic Model Interface (BMI)](https://bmi.readthedocs.io/en/latest/),\nwhich converts the dbSEABED datasets into a reusable,\nplug-and-play data component ([pymt_dbseabed](https://pymt-dbseabed.readthedocs.io/)) for\nthe [PyMT](https://pymt.readthedocs.io/en/latest/?badge=latest) modeling framework developed\nby Community Surface Dynamics Modeling System ([CSDMS](https://csdms.colorado.edu/wiki/Main_Page)).\n\nIf you have any suggestion to improve the current function, please create a github issue\n[here](https://github.com/gantian127/bmi_dbseabed/issues).\n\n### Install package\n\n#### Stable Release\n\nThe bmi_dbseabed package and its dependencies can be installed with pip\n```\n$ pip install bmi_dbseabed\n```\nor with conda.\n```\n$ conda install -c conda-forge bmi_dbseabed\n```\n#### From Source\n\nAfter downloading the source code, run the following command from top-level folder\nto install bmi_dbseabed.\n```\n$ pip install -e .\n```\n\n### Quick Start\nBelow shows how to use two methods to download the datasets.\n\nYou can learn more details from the [tutorial notebook](notebooks/bmi_dbseabed.ipynb).\n\n[//]: # (To run this notebook, please go to the [CSDMS EKT Lab]())\n\n[//]: # (and follow the instruction in the \"Lab notes\" section.)\n\n#### Example 1: use DbSeabed class to download data (Recommended method)\n\n```python\nimport matplotlib.pyplot as plt\nfrom bmi_dbseabed import DbSeabed\n\n# get data from dbSEABED\ndbseabed = DbSeabed()\ndata = dbseabed.get_data(\n var_name=\"carbonate\",\n west=-98,\n south=18,\n east=-80,\n north=31,\n output=\"download.tif\",\n)\n\n# show metadata\nfor key, value in dbseabed.metadata.items():\n print(f\"{key}: {value}\")\n\n\n# plot data\ndata.plot(figsize=(9, 5))\nplt.title(\"dbSEABED dataset (Carbonate in %)\")\n```\n![tif_plot](docs/source/_static/ts_plot.png)\n\n\n#### Example 2: use BmiDbSseabed class to download data (Demonstration of how to use BMI)\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom bmi_dbseabed import BmiDbSeabed\n\n\n# initiate a data component\ndata_comp = BmiDbSeabed()\ndata_comp.initialize(\"config_file.yaml\")\n\n# get variable info\nvar_name = data_comp.get_output_var_names()[0]\nvar_unit = data_comp.get_var_units(var_name)\nvar_location = data_comp.get_var_location(var_name)\nvar_type = data_comp.get_var_type(var_name)\nvar_grid = data_comp.get_var_grid(var_name)\n\nprint(f\"{var_name=} \\n{var_unit=} \\n{var_location=} \\n{var_type=} \\n{var_grid=}\")\n\n# get variable grid info\ngrid_rank = data_comp.get_grid_rank(var_grid)\n\ngrid_size = data_comp.get_grid_size(var_grid)\n\ngrid_shape = np.empty(grid_rank, int)\ndata_comp.get_grid_shape(var_grid, grid_shape)\n\ngrid_spacing = np.empty(grid_rank)\ndata_comp.get_grid_spacing(var_grid, grid_spacing)\n\ngrid_origin = np.empty(grid_rank)\ndata_comp.get_grid_origin(var_grid, grid_origin)\n\nprint(f\"{grid_rank=} \\n{grid_size=} \\n{grid_shape=} \\n{grid_spacing=} \\n{grid_origin=}\")\n\n# get variable data\ndata = np.empty(grid_size, var_type)\ndata_comp.get_value(var_name, data)\ndata_2D = data.reshape(grid_shape)\n\n# get X, Y extent for plot\nmin_y, min_x = grid_origin\nmax_y = min_y + grid_spacing[0] * (grid_shape[0] - 1)\nmax_x = min_x + grid_spacing[1] * (grid_shape[1] - 1)\ndy = grid_spacing[0] / 2\ndx = grid_spacing[1] / 2\nextent = [min_x - dx, max_x + dx, min_y - dy, max_y + dy]\n\n# plot data\nfig, ax = plt.subplots(1, 1, figsize=(9, 5))\nim = ax.imshow(data_2D, extent=extent)\nfig.colorbar(im)\nplt.xlabel(\"X\")\nplt.ylabel(\"Y\")\nplt.title(\"dbSEABED dataset (Carbonate in %)\")\n\n# finalize data component\ndata_comp.finalize()\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Fetch ocean seabed datasets from the dbSEABED system https://instaar.colorado.edu/~jenkinsc/dbseabed/",
"version": "0.1.0",
"project_urls": {
"documentation": "https://github.com/gantian127/bmi_dbseabed",
"homepage": "https://github.com/gantian127/bmi_dbseabed",
"repository": "https://github.com/gantian127/bmi_dbseabed"
},
"split_keywords": [
"bmi",
" basic model interface",
" dbseabed"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6aa568560e42400cbead3f1e9e3ff4e424de57e6f989ef847d0be24786f4cbc2",
"md5": "3b74beb6e8d41d39891ed2ea289abcd9",
"sha256": "eb1213241ca7694c26b8ec4de7e3f883d76db76bec7d9d0a80ddbf3e14b39e08"
},
"downloads": -1,
"filename": "bmi_dbseabed-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "3b74beb6e8d41d39891ed2ea289abcd9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 13753,
"upload_time": "2024-04-15T20:59:26",
"upload_time_iso_8601": "2024-04-15T20:59:26.484885Z",
"url": "https://files.pythonhosted.org/packages/6a/a5/68560e42400cbead3f1e9e3ff4e424de57e6f989ef847d0be24786f4cbc2/bmi_dbseabed-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-15 20:59:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gantian127",
"github_project": "bmi_dbseabed",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "bmipy",
"specs": []
},
{
"name": "click",
"specs": []
},
{
"name": "netcdf4",
"specs": []
},
{
"name": "numpy",
"specs": []
},
{
"name": "owslib",
"specs": []
},
{
"name": "pyyaml",
"specs": []
},
{
"name": "requests",
"specs": []
},
{
"name": "rioxarray",
"specs": []
},
{
"name": "xarray",
"specs": []
}
],
"lcname": "bmi-dbseabed"
}