pycantphi


Namepycantphi JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA Python library for calculating anthropogenic carbon in the North Atlantic Ocean
upload_time2025-01-03 10:42:24
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords oceanography carbon climate-science ocean-carbon anthropogenic-carbon
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyCantPhi

PyCantPhi is a Python package for calculating anthropogenic carbon (Cant) in the North Atlantic Ocean using the φ CT° (Phi) method, and cStar and Troca methods. The cStar and Troca methods can be applyied globally for general purpose.

## Features

- Implementation of the φ CT° method for anthropogenic carbon calculation
- Integration with Mauna Loa CO2 data
- Support for water mass analysis using Optimum MultiParameter (OMP)
- Preformed alkalinity calculations
- Mediterranean water influence calculations
- CO2 system calculations using PyCO2SYS

## Installation

You can install PyCantPhi using pip:

```bash
pip install pycantphi
```

## Quick Start

```python
import numpy as np
import pandas as pd
import xarray as xr
from pycantphi import cantphi, CantCalculator


# Define dimensions for dataset
loc = ["loc1", "loc2", "loc3"]
pressure = [0, 250, 2000]  # in dbar
time = pd.date_range(start='2020', end='2023', freq='Y')
lon = [-10, -20, -40]
lat = [10, 20, 65]

# Create coordinate data for xarray
coords = {
    "location": loc,
    "pressure": pressure,
    "time": time,
    "longitude": ("location", lon),
    "latitude": ("location", lat), 
    "year": ("time", time.year),   
}

# Note that it's also possible to have no location variable (here, we're creating a three-dimensional dataset) and rely solely on longitude or latitude. The other variable (longitude or latitude) is always required as a function of the first. 

# Generate synthetic data arrays 
data_vars = {
    "theta": (["location", "pressure", "time"], np.random.uniform(1, 15, (3, 3, 3))),  # in Celsius
    "salinity": (["location", "pressure", "time"], np.random.uniform(30, 37, (3, 3, 3))),    # in PSU
    "alkalinity": (["location", "pressure", "time"], np.random.uniform(2200, 2400, (3, 3, 3))),  # in µmol/kg
    "oxygen": (["location", "pressure", "time"], np.random.uniform(310, 330, (3, 3, 3))),  # in µmol/kg
    "carbon": (["location", "pressure", "time"], np.random.uniform(1800, 2100, (3, 3, 3))), # in µmol/kg
    "phosphate": (["location", "pressure", "time"], np.random.uniform(0, 3, (3, 3, 3))),   # in µmol/kg
    "nitrate": (["location", "pressure", "time"], np.random.uniform(0, 40, (3, 3, 3))),    # in µmol/kg
    "silicate": (["location", "pressure", "time"], np.random.uniform(0, 150, (3, 3, 3)))   # in µmol/kg
}

# Create the xarray Dataset
ds = xr.Dataset(data_vars, coords=coords)

# Display the dataset
ds

# Initialize the calculator
calc = cantphi(ds)

# Process the dataset
results = calc.process()

# Access the calculated Cant values
cant_phi = results.cAntPhiCt0ML
cant_troca = results.cAntTroca
cant_cstar = results.cStar

# Access only the Cant calculator for the different methods. They can be run outside but required specific parameters. 

CantCalculator.calculate_cstar(ct, aou, ct_preformed, delta_ca_corrected)
CantCalculator.calculate_ctroca(ct, at, oxygen, theta)
CantCalculator.calculate_cphi(calc.ds)

```

## Required Data Format

Your input dataset should include the following variables:
- longitude
- latitude
- pressure
- theta (potential temperature)
- salinity
- oxygen
- silicate
- nitrate
- phosphate
- carbon
- alkalinity
- year

## Documentation

The documentation is in progress. For detailed documentation, examples, and API reference, visit our [documentation page](https://pyphi.readthedocs.io) once finished.
```

## Contributing

Contributions are welcome! I'm working on generating pytests before taking new contributions into account. If you encounter a problem with the package, please raise an issue.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Citation

If you use this package in your research, please cite both the original CantPhiCt0 paper and this implementation in python:

For the method:

```
@article{vázquez2009anthropogenic,
  title={Anthropogenic carbon distributions in the Atlantic Ocean: data-based estimates from the Arctic to the Antarctic},
  author={V{\'a}zquez-Rodr{\'\i}guez, M and Touratier, F and Lo Monaco, C and Waugh, DW and Padin, XA and Bellerby, RGJ and Goyet, C and Metzl, N and R{\'\i}os, AF and P{\'e}rez, FF},
  journal={Biogeosciences},
  volume={6},
  number={3},
  pages={439--451},
  year={2009},
  doi={10.5194/bg-6-439-2009},
  publisher={Copernicus GmbH}
}
```

For the software:

```
@software{pyphi2024,
  title = {PyCantPhi: A Python implementation of the φ CT° method for anthropogenic carbon calculation},
  author = {Bajon R.},
  year = {2024},
  version = {0.0.0},
  url = {https://github.com/RaphaelBajon/pyphi}
}
```

## Acknowledgments

The implementation is based on the φ CT° method described in Vázquez-Rodríguez et al. (2009).


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pycantphi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "oceanography, carbon, climate-science, ocean-carbon, anthropogenic-carbon",
    "author": null,
    "author_email": "Rapha\u00ebl Bajon <raphael.bajon@ifremer.fr>",
    "download_url": "https://files.pythonhosted.org/packages/32/94/1292ee6218b820343f76b7e6b175f084e0aa460b6fe206e845e31d21bfe4/pycantphi-0.1.0.tar.gz",
    "platform": null,
    "description": "# PyCantPhi\n\nPyCantPhi is a Python package for calculating anthropogenic carbon (Cant) in the North Atlantic Ocean using the \u03c6 CT\u00b0 (Phi) method, and cStar and Troca methods. The cStar and Troca methods can be applyied globally for general purpose.\n\n## Features\n\n- Implementation of the \u03c6 CT\u00b0 method for anthropogenic carbon calculation\n- Integration with Mauna Loa CO2 data\n- Support for water mass analysis using Optimum MultiParameter (OMP)\n- Preformed alkalinity calculations\n- Mediterranean water influence calculations\n- CO2 system calculations using PyCO2SYS\n\n## Installation\n\nYou can install PyCantPhi using pip:\n\n```bash\npip install pycantphi\n```\n\n## Quick Start\n\n```python\nimport numpy as np\nimport pandas as pd\nimport xarray as xr\nfrom pycantphi import cantphi, CantCalculator\n\n\n# Define dimensions for dataset\nloc = [\"loc1\", \"loc2\", \"loc3\"]\npressure = [0, 250, 2000]  # in dbar\ntime = pd.date_range(start='2020', end='2023', freq='Y')\nlon = [-10, -20, -40]\nlat = [10, 20, 65]\n\n# Create coordinate data for xarray\ncoords = {\n    \"location\": loc,\n    \"pressure\": pressure,\n    \"time\": time,\n    \"longitude\": (\"location\", lon),\n    \"latitude\": (\"location\", lat), \n    \"year\": (\"time\", time.year),   \n}\n\n# Note that it's also possible to have no location variable (here, we're creating a three-dimensional dataset) and rely solely on longitude or latitude. The other variable (longitude or latitude) is always required as a function of the first. \n\n# Generate synthetic data arrays \ndata_vars = {\n    \"theta\": ([\"location\", \"pressure\", \"time\"], np.random.uniform(1, 15, (3, 3, 3))),  # in Celsius\n    \"salinity\": ([\"location\", \"pressure\", \"time\"], np.random.uniform(30, 37, (3, 3, 3))),    # in PSU\n    \"alkalinity\": ([\"location\", \"pressure\", \"time\"], np.random.uniform(2200, 2400, (3, 3, 3))),  # in \u00b5mol/kg\n    \"oxygen\": ([\"location\", \"pressure\", \"time\"], np.random.uniform(310, 330, (3, 3, 3))),  # in \u00b5mol/kg\n    \"carbon\": ([\"location\", \"pressure\", \"time\"], np.random.uniform(1800, 2100, (3, 3, 3))), # in \u00b5mol/kg\n    \"phosphate\": ([\"location\", \"pressure\", \"time\"], np.random.uniform(0, 3, (3, 3, 3))),   # in \u00b5mol/kg\n    \"nitrate\": ([\"location\", \"pressure\", \"time\"], np.random.uniform(0, 40, (3, 3, 3))),    # in \u00b5mol/kg\n    \"silicate\": ([\"location\", \"pressure\", \"time\"], np.random.uniform(0, 150, (3, 3, 3)))   # in \u00b5mol/kg\n}\n\n# Create the xarray Dataset\nds = xr.Dataset(data_vars, coords=coords)\n\n# Display the dataset\nds\n\n# Initialize the calculator\ncalc = cantphi(ds)\n\n# Process the dataset\nresults = calc.process()\n\n# Access the calculated Cant values\ncant_phi = results.cAntPhiCt0ML\ncant_troca = results.cAntTroca\ncant_cstar = results.cStar\n\n# Access only the Cant calculator for the different methods. They can be run outside but required specific parameters. \n\nCantCalculator.calculate_cstar(ct, aou, ct_preformed, delta_ca_corrected)\nCantCalculator.calculate_ctroca(ct, at, oxygen, theta)\nCantCalculator.calculate_cphi(calc.ds)\n\n```\n\n## Required Data Format\n\nYour input dataset should include the following variables:\n- longitude\n- latitude\n- pressure\n- theta (potential temperature)\n- salinity\n- oxygen\n- silicate\n- nitrate\n- phosphate\n- carbon\n- alkalinity\n- year\n\n## Documentation\n\nThe documentation is in progress. For detailed documentation, examples, and API reference, visit our [documentation page](https://pyphi.readthedocs.io) once finished.\n```\n\n## Contributing\n\nContributions are welcome! I'm working on generating pytests before taking new contributions into account. If you encounter a problem with the package, please raise an issue.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Citation\n\nIf you use this package in your research, please cite both the original CantPhiCt0 paper and this implementation in python:\n\nFor the method:\n\n```\n@article{v\u00e1zquez2009anthropogenic,\n  title={Anthropogenic carbon distributions in the Atlantic Ocean: data-based estimates from the Arctic to the Antarctic},\n  author={V{\\'a}zquez-Rodr{\\'\\i}guez, M and Touratier, F and Lo Monaco, C and Waugh, DW and Padin, XA and Bellerby, RGJ and Goyet, C and Metzl, N and R{\\'\\i}os, AF and P{\\'e}rez, FF},\n  journal={Biogeosciences},\n  volume={6},\n  number={3},\n  pages={439--451},\n  year={2009},\n  doi={10.5194/bg-6-439-2009},\n  publisher={Copernicus GmbH}\n}\n```\n\nFor the software:\n\n```\n@software{pyphi2024,\n  title = {PyCantPhi: A Python implementation of the \u03c6 CT\u00b0 method for anthropogenic carbon calculation},\n  author = {Bajon R.},\n  year = {2024},\n  version = {0.0.0},\n  url = {https://github.com/RaphaelBajon/pyphi}\n}\n```\n\n## Acknowledgments\n\nThe implementation is based on the \u03c6 CT\u00b0 method described in V\u00e1zquez-Rodr\u00edguez et al. (2009).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python library for calculating anthropogenic carbon in the North Atlantic Ocean",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/RaphaelBajon/pyphi/issues",
        "Documentation": "https://cantphi.readthedocs.io",
        "Homepage": "https://github.com/RaphaelBajon/PyPhi",
        "Repository": "https://github.com/RaphaelBajon/pyphi.git"
    },
    "split_keywords": [
        "oceanography",
        " carbon",
        " climate-science",
        " ocean-carbon",
        " anthropogenic-carbon"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "085dc439eb506c858abdab95809000629e409045ae62e4726eb52d9126689d3c",
                "md5": "011d5eb20c4da8de5e5c5886c32a48d3",
                "sha256": "9fac319e2ecfec974bd66a9a2605ce6955ca3c90d8769b2620b1a7604ebafb96"
            },
            "downloads": -1,
            "filename": "pycantphi-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "011d5eb20c4da8de5e5c5886c32a48d3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5144,
            "upload_time": "2025-01-03T10:42:22",
            "upload_time_iso_8601": "2025-01-03T10:42:22.538692Z",
            "url": "https://files.pythonhosted.org/packages/08/5d/c439eb506c858abdab95809000629e409045ae62e4726eb52d9126689d3c/pycantphi-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32941292ee6218b820343f76b7e6b175f084e0aa460b6fe206e845e31d21bfe4",
                "md5": "5411f638d57ddd7cfa99a09c1a83d89f",
                "sha256": "d1d27a184e73391ab6010ebff733ca942624afe600e361ad13f4577ffb7f8b8b"
            },
            "downloads": -1,
            "filename": "pycantphi-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5411f638d57ddd7cfa99a09c1a83d89f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5313,
            "upload_time": "2025-01-03T10:42:24",
            "upload_time_iso_8601": "2025-01-03T10:42:24.960425Z",
            "url": "https://files.pythonhosted.org/packages/32/94/1292ee6218b820343f76b7e6b175f084e0aa460b6fe206e845e31d21bfe4/pycantphi-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-03 10:42:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RaphaelBajon",
    "github_project": "pyphi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pycantphi"
}
        
Elapsed time: 0.35300s