pyoceans / pyCO2

pyCO2 Seawater-Carbon Calculator for Python
MIT License
6 stars 10 forks source link

Converted CO2SYs to python #6

Closed brorfred closed 7 years ago

brorfred commented 8 years ago

Hi Filipe,

I've just converted most of CO2SYS to python from matlab. Would you be interested in adding the conversion here?

ocefpaf commented 8 years ago

Sure. That was the goal of this project, but I never got the time to do it. Are you OK with GitHub and PRs?

brorfred commented 8 years ago

Yep!

Do you have a preferred API structure? Currently I’ve divided the project into two modules, one with all functions to calculate constants and one with a class to calculate the carbonate system. You use it by creating an instance as follows:

co = co2sys.calculations.CarbonateSystem(salt=35,temp=25,pres=1000,pCO2=600,pH=8)

all values are accessible in the resulting instance.

/B

On Apr 5, 2016, at 11:24, Filipe notifications@github.com wrote:

Sure. That was the goal of this project, but I never got the time to do it. Are you OK with GitHub and PRs?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/pyoceans/pyCO2/issues/6#issuecomment-205856708

ocefpaf commented 8 years ago

Looks good to me. Maybe I would just drop 1-level

co2sys.CarbonateSystem(salt=35,temp=25,pres=1000,pCO2=600,pH=8)

to reduced the verbosity, but that can be done later.

brorfred commented 8 years ago

OK, I changed it to

import co2sys co = co2sys.calc_co2_system(35,20,pH=8,pCO2=400)

The code is pushed to https://github.com/brorfred/pyCO2

I need to turn on other K1/K2 methods than Millero 2010, clean up the code a bit, move references around, and write the documentation. Will do a pull request after that.

/B

On Apr 5, 2016, at 11:36, Filipe notifications@github.com wrote:

Looks good to me. Maybe I would just drop 1-level

co2sys.CarbonateSystem(salt=35,temp=25,pres=1000,pCO2=600,pH=8)

to reduced the verbosity, but that can be done later.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/pyoceans/pyCO2/issues/6#issuecomment-205861022

ocefpaf commented 8 years ago

Thanks @brorfred! That looks awesome. I will do some boilerplate once your PR is here to prepare it for packaging. I want to ping @emiliom and @juoceano here who are interested in seeing this package out in the wild.

emiliom commented 8 years ago

Fantastic, @brorfred!

FYI, a few months ago @ocefpaf and I worked on improving the Python wrapper for mocsy, another carbonate system package.

emiliom commented 8 years ago

I'm using this existing issue to update and hopefully link up efforts.

@jamesorr mentioned to me this week that a group in New Zealand has converted CO2SYS to Python. Jim, could you give us a link to that effort, if one exists? I Googled for it and didn't find anything.

@brorfred, based on your Princeton affiliation (per your github profile), I'm assuming your own conversion effort is independent. If that's the case, maybe we can help unify and promote efforts.

oscarbranson commented 7 years ago

Hi Folks,

I've just written a Python module for calculating seawater C and B speciation and B isotopes.

A lot of it is CO2SYS inspired, and it uses the same zero-finding algorithms for C speciation.

It uses Mathis Hain's MyAMI model to adjust Ks for [Mg] and [Ca], so might be of particular interest to the palaeo-community.

In testing, it gives identical (to within error) results to CO2SYS analysis of the GLODAPv2 bottle data.

In retrospect, this might be a bit of a duplication of effort... but hopefully the Mg and Ca effects on Ks and inclusion of B chemistry adds something useful!

Any thoughts/comments welcome!

ocefpaf commented 7 years ago

In retrospect, this might be a bit of a duplication of effort..

I believe it is worth it. Thanks for letting us know.

BTW this project here is stuck mostly due to lack of free time to work on time. I guess that it will never get written unless there is some funding source for it.

oscarbranson commented 7 years ago

I know the feeling... Perhaps if we all coordinated our efforts into one module, we might produce something useful?

ocefpaf commented 7 years ago

I know the feeling... Perhaps if we all coordinated our efforts into one module, we might produce something useful?

:+1:

I should probably close this to avoid attracting people to this repo. I will check with others in order to that that. (I cannot promise, but I'll take a look at your project and see if I can contribute with something.)

emiliom commented 7 years ago

That looks like a great effort, @oscarbranson! Thanks for letting us know. I wish I had more time myself in the near future to contribute something, but I don't ...

I should probably close this to avoid attracting people to this repo.

That makes sense. On the other hand, this empty repo has served nicely as a meeting point for people interested in carbonate-system code in Python!

ocefpaf commented 7 years ago

By closing the repo I mean remove code, lock the issues/PRs, and add a link in the README to guide people to the preferred version. I would not remove it entirely.

oscarbranson commented 7 years ago

True - this is high up the google search list. One of the first things I found when starting to look into this. I leave closing the repo to your discretion, but won't complain if you want to point people my way 😄.

IF any of you are interested / have time to contribute to cbsyst, that'd be awesome. I'm putting together a TODO.md There are a range of bite-sized (byte-sized?!) tasks that can usefully be done listed in the Issues section of my repo. If not, no worries - I'll forge ahead in my spare time!

As an incentive, I was thinking of putting a quick methods paper once it's a bit more complete - any contributions would obv be recognised with authorship/acknowledgement (depending on scale of contribution).

emiliom commented 7 years ago

@oscarbranson, I'd be interested in being pinged again around August, about contributing.

pearseb commented 7 years ago

@oscarbranson I'd also be interested in helping out. Although I'm not active on my github account, I've had a fair introduction to carbon chemistry by coding it into a global ocean biogeochemical model. And I've got python skills, although I've never created my own packages.

If you need someone to help out with those "byte"-sized tasks, then give me a shout.

oscarbranson commented 7 years ago

Fabulous, @emiliom and @pearseb. I'll be in touch.

Very little github / module knowledge required - I can help with that. Just python literacy! You can probably point out all the things I've done wrong in my code 😃 !

For the moment, I ditched the TODO list in favour of just using issues. If you ever find yourself wanting to do some useful python, take a look at the Issues list to find out what needs doing.

Going to stop commenting on here now, and ping you both on live issues.

ocefpaf commented 7 years ago

@oscarbranson I just updated to README, see https://github.com/pyoceans/pyCO2/blob/master/README.rst

I will add a .github with the same message for both new issues and PRs soon.

Thanks for you efforts on cbsyst. If I can some free time I can definitely help with some boilerplate stuff like testing, auto docs publishing, etc.

oscarbranson commented 7 years ago

Thanks @ocefpaf. It would be great to have you on board. I'm fairly new to writing Python modules and everything it entails, so any tips/suggestions would be very welcome.