MOM6-community / sectionate

compute section in ocean models
GNU General Public License v3.0
8 stars 7 forks source link

Improved "broken line" and "normal transport" algorithms and refactored API #16

Closed hdrake closed 1 year ago

hdrake commented 1 year ago

Major changes

hdrake commented 1 year ago

@MDTocean, I am working on merging your function for adding grid cell widths (and accumulating the distance along a section), but I think it makes sense to just add this functionality directly into the convergent_transport and extract_tracer functions, possibly as an optional kwarg.

hdrake commented 1 year ago

As I've mentioned to you both in person (@raphaeldussin and @MDTocean), I think it is worth making some breaking changes now and trying to solidify an API around just a few core functions (esp. infer_grid_path, create_section, convergent_transport, and extract_tracer).

I am more than happy to work with you do update any scripts / notebooks to use the new API. The breaking changes are pretty straightforward to accomodate, mostly just changing function names and adding some arguments (e.g. symmetric) and setting optional keyword arguments (although I've tried to set their defaults to be consistent with the old API).

hdrake commented 1 year ago

The last commit (a2e8392) is a first pass at merging @MDTocean's method for computing the widths of cells along the section and aggregating them to give an along-section distance coordinate as well.

I still need to add in functionality for the cell-thickness and the cell-area (product of width and thickness), which are needed to compute the average velocities (as opposed to just transports) across the section. As mentioned in this comment, I think we are better off explicitly using the thkcello diagnostic to do this accurately regardless of the vertical coordinate of the diagnostics.

hdrake commented 1 year ago

@raphaeldussin, I think in cfedb2b9da1b482f2ee66a90648ee3a0e7bef101 I fixed the small bug in the new normal_transport algorithm that you had previously mentioned. I was able to exactly reproduce the results of my implementation of the old_algo (indexing point by point within a for loop) with the new xarray-enabled one.

hdrake commented 1 year ago

Closing in favor of https://github.com/raphaeldussin/sectionate/pull/19, which includes all of these changes.