... | ... | @@ -96,6 +96,43 @@ Generate tidal open boundary conditions (from TOPEX/Poseidon TPXO 7.2) |
|
|
|
|
|
In order to include more complicated data structures in SLIM, such as HYCOM model outputs, no easy slim module exists. You need to extract data value for each node (or boundary node). The time steps for data values do not have to be the same as the one for the simulation (a temporal linear interpolation will be done at runtime).
|
|
|
|
|
|
However, other models such as HYCOM might have a coarser resolution than SLIM and therefore have some missing values (near coastlines for instance). Here is thus a pretty useful function to fill the missing entries of scalar field.
|
|
|
|
|
|
```python
|
|
|
def get_nearest(tab,i,j):
|
|
|
val = np.zeros((tab.shape[0],))
|
|
|
n=0
|
|
|
if i>0:
|
|
|
if tab[0,i-1,j] is not np.ma.masked:
|
|
|
val[:] += tab[:,i-1,j]
|
|
|
n += 1
|
|
|
if i<tab.shape[1]-1:
|
|
|
if tab[0,i+1,j] is not np.ma.masked:
|
|
|
val[:] += tab[:,i+1,j]
|
|
|
n += 1
|
|
|
if j>0:
|
|
|
if tab[0,i,j-1] is not np.ma.masked:
|
|
|
val[:] += tab[:,i,j-1]
|
|
|
n += 1
|
|
|
if j<tab.shape[2]-1:
|
|
|
if tab[0,i,j+1] is not np.ma.masked:
|
|
|
val[:] += tab[:,i,j+1]
|
|
|
n += 1
|
|
|
return val/n if n>0 else np.ma.array(val,mask=True)
|
|
|
|
|
|
def fill_mask(tab):
|
|
|
n=0
|
|
|
val=tab.copy()
|
|
|
while (np.ma.is_masked(val)) and n<8:
|
|
|
n+=1
|
|
|
orig = val.copy()
|
|
|
for i in range(val.shape[1]):
|
|
|
for j in range(val.shape[2]):
|
|
|
if val[0,i,j] is np.ma.masked:
|
|
|
val[:,i,j] = get_nearest(orig,i,j)
|
|
|
return val
|
|
|
```
|
|
|
|
|
|
Here is a (not so) dumb example to get the sea surface height at a single time step from a netCDF file produced by HYCOM.
|
|
|
|
|
|
```python
|
... | ... | |