knaughten / mitgcm_python

Python scripts designed for my Weddell Sea and Amundsen Sea configurations of MITgcm.
25 stars 17 forks source link

Interpolation error traced to grid extension in SOSEGrid.__init__ #14

Open DaniJonesOcean opened 3 years ago

DaniJonesOcean commented 3 years ago

Hi Kaitlin. I believe that I have traced my interpolation error (https://github.com/so-wise/so-wise-gyre/issues/8) to the vertical grid extension in the SOSEGrid class. I thought I should note the issue here as well.

When the SOSE grid is first read in, which occurs in SOSEGrid.__init__, it looks fine:

In [11]: self.z[0:2]
Out[11]: array([ -5. , -15.5])

In [12]: self.z_edges[0:2]
Out[12]: array([  0., -10.])

which matches the values in RC and RF, as expected. Further down __init__, we see the model grid values:

z_shallow = model_grid.z[0]
z_deep = model_grid.z[-1]

which are

In [21]: z_shallow
Out[21]: -2.5

In [22]: z_deep
Out[22]: -6034.5500000000002

This is consistent with the first few vertical levels of the model_grid:

In [9]: model_grid.z[0:4]
Out[9]: array([ -2.5 ,  -7.6 , -12.85, -18.25])

In [10]: model_grid.z_edges[0:4]
Out[10]: array([  0. ,  -5. , -10.2, -15.5])

After the extension (lines 563-737 in the file grid.py, the sose_grid vertical levels are padded with extra zeros:

In [6]: sose_grid.z[0:4]
Out[6]: array([  0. ,  -5. , -15.5, -27. ])

In [7]: sose_grid.z_edges[0:4]
Out[7]: array([  0.,   0., -10., -21.])

Is this an error? It seems odd to have two zero values for the first two edges. That seems to have come from the zero padding to extend the grid.

As a test, I changed my topmost vertical level to match the SOSE grid (10 m thickness), and my error (https://github.com/so-wise/so-wise-gyre/issues/8) went away. The command sose_ics does not crash if the model grid has the same top cell thickness as the SOSE grid. This is fine for now, but eventually I'd like to be able to add thinner vertical levels to the top cells.

As always, any advice/thoughts are appreciated. : )

knaughten commented 3 years ago

As I suggested in the other thread, try padding SOSE at the surface not with 0 but with something like +10, does that fix the issue?

DaniJonesOcean commented 3 years ago

Hi @knaughten. Thanks again for the suggestions. Unfortunately, that didn't fix the issue. I tried +10 and +1. In both cases, the values of `Zl' were nonsensical, and the sea ice interpolation error happened just the same as before.