COSIMA / cosima-recipes

A cookbook of recipes (i.e., examples) for analysing ocean and sea ice model output
https://cosima-recipes.readthedocs.io
Apache License 2.0
46 stars 66 forks source link

Convert the Surface Water Mass Transformation example to be model-agnostic #402

Open willaguiar opened 4 months ago

willaguiar commented 4 months ago

Closes #277 Closes #341

This is an attempt to make the surface water mass transformation partially model agnostic. I used cf-xarray to deal with operations along dimensions. To deal with the different diagnostics required by each model I added an embedded dictionary to the save_SWMT function. The function also spits the specific dictionary for that model so it can be used later for shelf masking.

Shelf masking requires the input isobath file. Currently we have these isobath files only for OM2 and Panans. Panan isobath is on @schmidt-christina disk. Perhaps we can move them to ik11 to avoid permission issues? For mom5 I also changed the diag to use pme_net instead of pme_river, according to issue #341

review-notebook-app[bot] commented 4 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

navidcy commented 4 months ago

Panan isobath is on @schmidt-christina disk. Perhaps we can move them to ik11 to avoid permission issues?

We definitely don't want our examples to be dependent on data that lives on user's personal home or g/data directories

review-notebook-app[bot] commented 4 months ago

View / edit / reply to this conversation on ReviewNB

navidcy commented on 2024-07-07T04:22:42Z ----------------------------------------------------------------

Line #1.    def save_SWMT(expt, session, start_time, end_time, outpath,model='mom6', lat_north = -59, n = None):

space after commas


review-notebook-app[bot] commented 4 months ago

View / edit / reply to this conversation on ReviewNB

navidcy commented on 2024-07-07T04:22:42Z ----------------------------------------------------------------

Line #215.        ds[SST.cf['latitude'].name].attrs= {'standard_name':'latitude'}

space after colons


review-notebook-app[bot] commented 4 months ago

View / edit / reply to this conversation on ReviewNB

navidcy commented on 2024-07-07T04:22:43Z ----------------------------------------------------------------

Line #228.        resolution = str(0.01/(pme_net.cf['longitude'].size/3600))[2:]

what is this here doing? reads strange to me


_willaguiar commented on 2024-07-07T06:37:56Z_ ----------------------------------------------------------------

This is an attempt to automatically get the resolution of the model, assuming a global square-cell grid. This is necessary so we can identify the correct name of the isobath file for panan (contains 3 resolutions) . So this lines calculates there resolution and convert it to string to use it on...

contour_dir = "/home/142/cs6673/work/mom6_comparison/Antarctic_slope_contours/Antarctic_slope_contour_1000m_MOM6_" + resolution + "deg.nc"

Happy to improve if you have a suggestion

_adele-morrison commented on 2024-07-07T06:49:58Z_ ----------------------------------------------------------------

Maybe a dictionary with experiment names mapped to resolution is best? This wouldn't work for a regional model right?

_willaguiar commented on 2024-07-07T07:01:10Z_ ----------------------------------------------------------------

True, it wouldn't if the regional model is not circumpolar. How would we map the dict to the experiment name? something like...

if expt='panant-01-zstar-ACCESSyr2': resolution='01'

? Or maybe only extracting the 01 string from the name for experiments starting with 'panant'?

_schmidt-christina commented on 2024-07-08T00:54:08Z_ ----------------------------------------------------------------

I extract the resolution from the experiment name, but that assumes we keep the naming convention:

resolution = expt.split('-')[1]

_willaguiar commented on 2024-08-15T05:01:48Z_ ----------------------------------------------------------------

I haven't changed that one