SST in NetCDF output vs post-processing

Hi,

How do you extract the SST from your simulation? Is there a way to write it directly into the NetCDF outputs (I didn’t find it), or do you compute it afterwards:

  • using croco_tools / pytools? If so, how do you proceed?
  • or with your own routines?

I think it would be a useful diagnostic variable to include in the NetCDF outputs (with a True/False option in croco.in).

PS: When I refer to SST, I don’t mean the temperature in the Kmax cell, but the temperature at a fixed depth (e.g. 1 m).

Thanks a lot four your answers and your help!
Camille

I know that it can be viewed in croco_tools (at constant z), but in my case, the idea is to extract the SST variable to compare it with other data.

Currently, I am using my own scripts, but I think there may be a simpler way that has already been done, and above all, it could be useful to other people if it were possible to easily extract this diagnostic

Hi @cmazoyer,
croco_pytools/xcroco can perform vertical interpolation of any CROCO variable here is how:

I assume libraries are imported such as in tuto_xcroco.ipynb,

  • Add metrics to dataset
# create the grid
drop_variables = []
ds = io.open_files(
    croco,
    gridname,
    filenames,
    grid_metrics=2,
    drop_variables=drop_variables,
    chunks={"t": 1},
    # chunks={'t':1, 's':1, 's_w':1},
)
  • create the grid
ds1 = ds.sel(t=seldate, method="nearest")
grid = gop.fast_xgcm_grid(ds1, croco, grid_metrics=2)
ds1
  • Vertical interpolation

The appropriate function to perform vertical interpolation is gop.isoslice()

The naming is a bit funny because we should be able to interpolate variables onto another coordinate than depth (ex: density) but this feature is for the next release :slight_smile:

First we need to get vertical coordinates of the variable we want to interpolate. There a function gop.get_z() for that.

And here is the action:

depth = -1

# depths at rho-points
z_r = gop.get_z(croco, ds=ds1, z_sfc=ds1.z_sfc, xgrid=grid, hgrid="r")

# vertical interpolation
z_temp = gop.isoslice(ds1.temp, depth, grid, target_data=z_r, axis="z")

kwargs = {"vmin": -1, "vmax": 1, "extend": "both"}
cplt.plotfig(z_temp)  # , **kwargs)

I created a branch 103-croco-basic-operators with a notebook xcroco/tuto_operators.ipynb

Hope this helps,
Jeremy