def add_dep(dataset):
if 'LAYER_INTERFACE' in dataset:
print("LAYER_INTERFACE property alread in DataSet, renaming it to depth...")
else:
print("Calculating depth of interfaces...")
depth = dataset.S1
depth.values = dataset.DP0.values[:] + dataset.S1.values[:]
# depth_center =depth_center.assign_attrs({"unit": "m", "long_name": "Depth at Sigma-layer centers"})
depth = depth.assign_attrs({"unit": "m", "long_name": "Depth at zeta"})
dataset['dep'] = depth
return dataset
def makevel(dataset, transpose=True):
vel = dataset.U1
angel = dataset.V1
u = dataset.U1.values
v = dataset.V1.values
vel.values = np.sqrt(u**2+v**2)
angel.values = np.degrees(np.arctan(u/v))
vel = vel.assign_attrs({"unit": "m/s", "long_name": "Depth at zeta"})
angel = angel.assign_attrs({"unit": "°", "long_name": "Depth at zeta"})
dataset['vel'] = vel
dataset['angel'] = angel
return dataset