Skip to content

Check Geostrophic_Velocities_from_Sea_Level.ipynb - #707

Merged
julia-neme merged 5 commits into
COSIMA:mainfrom
julia-neme:jn-geos-vels
Aug 24, 2026
Merged

julia-neme merged 5 commits into
COSIMA:mainfrom
julia-neme:jn-geos-vels

Conversation

@julia-neme

@julia-neme julia-neme commented Jul 6, 2026 •

Copy link
Copy Markdown
Collaborator

This one was comparing geostrophic surface velocities from sea level to those of the first cell instead of usurf vsurf, but otherwise OK. I've also updated intake loading.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request onΒ  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@julia-neme julia-neme mentioned this pull request Jul 6, 2026
19 of 37 tasks
@review-notebook-app

review-notebook-app Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

anton-seaice commented on 2026-07-16T02:00:18Z
----------------------------------------------------------------

Have you tested this with MOM6 ?

I guess you also need to get the right combination of

Β Β Β Β Β Β dxCu: # dxCu is delta x at u points [L ~> m]

Β Β Β Β Β Β dyCu: # dyCu is delta y at u points [L ~> m]

Β Β Β Β Β Β dxCv: # dxCv is delta x at v points [L ~> m]

Β Β Β Β Β Β dyCv: # dyCv is delta y at v points [L ~> m]

instead of dxu and dyu

it looks like uo and vo are 3d fields as well ?


julia-neme commented on 2026-07-20T02:49:38Z
----------------------------------------------------------------

True! I can replace with SSU and SSV,but I don't think they're available for any run. I'll add the caveat.

And regarding the right combination, since discovering that I can use .derivative() you don't need to think about combining interp and diff, so I might change the script to use that.

(see comment below)

anton-seaice commented on 2026-07-20T03:27:41Z
----------------------------------------------------------------

I think using .derivative would calculate quanitites at the cell centre, so the model velocities need to be interpolated to cell centres then?

SSU and SSV are just the top layer in uo and vo right? So it's ok to use them, just note it in the table ?

julia-neme commented on 2026-07-27T00:22:14Z
----------------------------------------------------------------

Ok, so now I've included more information on how to adapt to mom6 ! Also changed to using .derivative()

@review-notebook-app

review-notebook-app Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

anton-seaice commented on 2026-07-16T02:00:20Z
----------------------------------------------------------------

Why id boundary = 'extend' ?

I think boundary = None might work


julia-neme commented on 2026-07-27T00:21:43Z
----------------------------------------------------------------

I am not aware of this condition, I only know extend (that just copies the nearest value) or fill (fills with something of your choice). I've actually changed it to fill with nans.

@review-notebook-app

review-notebook-app Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

anton-seaice commented on 2026-07-19T23:31:51Z
----------------------------------------------------------------

can these two lines be combined ?

variable=['dxu','dyu']

these are just merged below anyway ?


julia-neme commented on 2026-07-20T02:47:29Z
----------------------------------------------------------------

I wanted that yes! But intake only opened one of them. So I had to open 1by1 and merge.

@review-notebook-app

review-notebook-app Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

anton-seaice commented on 2026-07-19T23:31:52Z
----------------------------------------------------------------

Line #2.    detadx = grid.interp(grid.diff(ds['sea_level'], 'X', boundary='extend'), 'Y', boundary='extend') / ds['dxu']

It's a bit hard to follow this, but it looks like this:

  1. takes the diff of the 'sea_level' field. This should interpolate to the middle of the top face.
  2. interpolates those to the middle of the cell
  3. then divides by the dxu - but surely dxu is the width of the top face?

shouldn't step 3 be either:

a. divide by dxt - the width across the middle of the cell, or

b. moved to between steps 1 and 2

(Assuming B-grid)

This calculation presumably would need changing for C-grid, to get rid of the .interp ?


anton-seaice commented on 2026-07-19T23:59:12Z
----------------------------------------------------------------

Hangon - i dont have that correct, ill revisit

anton-seaice commented on 2026-07-20T01:00:17Z
----------------------------------------------------------------

sea_level is a tracer/center point quantity, so this:

  1. takes a diff across two center points to get the quantity in the middle of a face,
  2. interpolates across two middle of face quantities to get the cell corner
  3. divides by the width/length of the corner cell

so that is correct for B-grid,

julia-neme commented on 2026-07-20T02:48:10Z
----------------------------------------------------------------

Maybe I should change this to use the .derivative() function instead!

Copy link
Copy Markdown
Collaborator

Hangon - i dont have that correct, ill revisit


View entire conversation on ReviewNB

@review-notebook-app

review-notebook-app Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

anton-seaice commented on 2026-07-20T00:51:13Z
----------------------------------------------------------------

ο»Ώ@charles-turner-1ο»Ώ - this only works on older intake-catalogs, the new ones gives this error:

ESMDataSourceError: Failed to load dataset with key='ocean.fx.xu_ocean:3600.yu_ocean:2700.point'
                 You can use cat['ocean.fx.xu_ocean:3600.yu_ocean:2700.point'].df to inspect the assets/files for this key.


anton-seaice commented on 2026-07-20T01:05:57Z
----------------------------------------------------------------

I think there is a workaround for this already ?

charles-turner-1 commented on 2026-07-20T02:49:58Z
----------------------------------------------------------------

Yeah, there should be - in fact, I think it should already be in the newest environments.

I’ll double check when I’m off the plane. The code needs a more sophisticated fix anyway which is already on the todo list

julia-neme commented on 2026-07-27T00:22:48Z
----------------------------------------------------------------

This works in the current stable analysis for me?

Copy link
Copy Markdown
Collaborator

sea_level is a tracer/center point quantity, so this:

  1. takes a diff across two center points to get the quantity in the middle of a face,
  2. interpolates across two middle of face quantities to get the cell corner
  3. divides by the width/length of the corner cell

so that is correct for B-grid,


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator

I am not sure what to do for C-grid / MOM6

This recipe calculates the geostrophic velocities at the cell corner (b-grid) point and compares to model speed at the cell corner.

So for C-grid, to calculate speed, should we also interpolate to the model velocities to the corner point to calculate speed?

Copy link
Copy Markdown
Collaborator

I think there is a workaround for this already ?


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator Author

I wanted that yes! But intake only opened one of them. So I had to open 1by1 and merge.


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator Author

So no change needed?


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator Author

True! I can replace with SSU and SSV,but I don't think they're available for any run. I'll add the caveat.

And regarding the right combination, since discovering that I can use .derivative() you don't need to think about combining interp and diff, so I might change the script to use that.

(see comment below)


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator

Yeah, there should be - in fact, I think it should already be in the newest environments.

I’ll double check when I’m off the plane. The code needs a more sophisticated fix anyway which is already on the todo list


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator

I think using .derivative would calculate quanitites at the cell centre, so the model velocities need to be interpolated to cell centres then?

SSU and SSV are just the top layer in uo and vo right? So it's ok to use them, just note it in the table ?


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator Author

I am not aware of this condition, I only know extend (that just copies the nearest value) or fill (fills with something of your choice). I've actually changed it to fill with nans.


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator Author

Ok, so now I've included more information on how to adapt to mom6 ! Also changed to using .derivative()


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator Author

This works in the current stable analysis for me?


View entire conversation on ReviewNB

@julia-neme

Copy link
Copy Markdown
Collaborator Author

Thanks for the review @anton-seaice ! I've more info on mom6 adaptation and switched to using derivative.

@review-notebook-app

review-notebook-app Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

anton-seaice commented on 2026-07-27T23:36:43Z
----------------------------------------------------------------

If the experiments you want to use do not have surface velocities as available diagnostics, you can use the 3D velocity fields and select the top cell. Technically, this represents an average of velocities within that first cell, and it is not exactly velocity at the surface, but it might be good enough for your purposes.

I'm moderately confident there's no difference in model world between average velocities in the top layer and surface velocities.

Also, does this need a dot point to say you need to interpolation the velocities to the corner point with MOM6 output ?


julia-neme commented on 2026-07-28T04:21:46Z
----------------------------------------------------------------

Ahh I thought surface velocity was evaluated at the surface, didn't know it was the cell average. I'll remove that bit. Re the interpolation with mom6, I'll correct that too, but its up to the user where they want to do the interpolation to.

@review-notebook-app

review-notebook-app Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

anton-seaice commented on 2026-07-27T23:36:44Z
----------------------------------------------------------------

did you try boundary = 'none' ?


julia-neme commented on 2026-07-28T04:22:30Z
----------------------------------------------------------------

Yeah, but it just fills the boundary with values and I'm not quite sure how its doing that since I couldn't find it in the documentation. Filling with nans seems the more cautious approach.

Copy link
Copy Markdown
Collaborator Author

Ahh I thought surface velocity was evaluated at the surface, didn't know it was the cell average. I'll remove that bit. Re the interpolation with mom6, I'll correct that too, but its up to the user where they want to do the interpolation to.


View entire conversation on ReviewNB

Copy link
Copy Markdown
Collaborator Author

Yeah, but it just fills the boundary with values and I'm not quite sure how its doing that since I couldn't find it in the documentation. Filling with nans seems the more cautious approach.


View entire conversation on ReviewNB

@julia-neme
julia-neme requested a review from anton-seaice July 28, 2026 04:24
@review-notebook-app

review-notebook-app Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

anton-seaice commented on 2026-08-14T00:11:53Z
----------------------------------------------------------------

This step is kind of confusing. Whether or not its needed just depends on the limits above for u points and t points. I don't really have a good suggestion for it though


@anton-seaice anton-seaice left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @julia-neme

This looks good.

This notebook is complicated and has lots of changes between B-grid and C-grid models. If we are serious about it being usable on C-grid, I think it needs a B-grid and a C-grid version of the notebook

@julia-neme
julia-neme merged commit 6278c5b into COSIMA:main Aug 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants