Compare Hycom3d with a GDP drifter¶
In this notebook, we show :
how to decode dataset so that it is easy to access generic coordinates and variables,
how to compute depths from layer thicknesses,
how to interpolate currents from U and V positions to T position on an arakawa C grid,
how to perform a 4D interpolation with a variable depth coordinate to random positions,
how to make an horizontal slice of a 4D variable with a variable depth coordinate.
Initialisations¶
[1]:
import numpy as np
import xarray as xr
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import xoa
from xoa.grid import dz2depth, shift
from xoa.regrid import grid2loc, regrid1d
import xoa.cf as xcf
import xoa.geo as xgeo
Register the xoa xarray accessor :
[2]:
xoa.register_accessors()
Register the Hycom naming specifications:
[3]:
xcf.register_cf_specs(xoa.get_data_sample("hycom.cfg"))
Here is what these CF specifications contain:
[4]:
with open(xoa.get_data_sample("hycom.cfg")) as f:
print(''.join([line for line in f if len(line) > 1]))
[register]
name=hycom
[[attrs]]
nsigma = "[0-9]"
[vertical]
positive=down
type=dz
[data_vars]
[[bathy]]
name=bathymetry
[[dz]]
name=h
[coords]
[[x]]
name=X
[[y]]
name=Y
[[z]]
name=lev
Note that most of these specifications are not needed to decode the dataset, i.e to find known variables and coordinates, since the default specifications help for that.
Read and decode the datasets¶
Hycom velocities¶
U and V are stored in separate files at U and V locations on the Hycom Arakawa C-Grid. We choose to rename the dataset contents so that we can use generic names to access it. We call for that the decode method the xoa accessor.
[5]:
# U velocity component
u_hycom = xoa.open_data_sample("hycom.gdp.u.nc").xoa.decode().u.squeeze(drop=True)
# V velocity component
v_hycom = xoa.open_data_sample("hycom.gdp.v.nc").xoa.decode().v.squeeze(drop=True)
# Layer thicknesses
hycom = xoa.open_data_sample("hycom.gdp.h.nc").xoa.decode().squeeze(drop=True)
We now compute the depths from the layer thicknesses at the T location thanks to the xoa.grid.dz2depth function: we make integrate from a null SSH and interpolate the depth from W locations to T locations.
[6]:
hycom.coords["depth"] = dz2depth(hycom.dz, centered=True)
Now we interpolate the velocity components to the T location with the xoa.grid.shift function.
[7]:
ut_hycom = shift(u_hycom, {"x": "left", "y": "left"})
vt_hycom = shift(v_hycom, {"x": "left", "y": "left"})
hycom["u"] = ut_hycom.assign_coords(**hycom.coords)
hycom["v"] = vt_hycom.assign_coords(**hycom.coords)
So, finally we obtain:
[8]:
hycom
[8]:
<xarray.Dataset>
Dimensions: (time: 50, x: 13, y: 11, z: 6)
Coordinates:
lon (y, x) float32 -3.2 -3.125 -3.05 -2.975 ... -2.45 -2.375 -2.3
lat (y, x) float32 44.69 44.69 44.69 44.69 ... 45.22 45.22 45.22 45.22
* z (z) int32 1 2 3 4 5 6
* time (time) datetime64[ns] 2021-03-01 ... 2021-03-25T12:00:00
depth (time, z, y, x) float32 1.511 1.511 1.51 ... 20.11 20.09 20.06
Dimensions without coordinates: x, y
Data variables:
bathy (y, x) float32 3.453e+03 3.422e+03 3.131e+03 ... 130.4 128.2 124.3
dz (time, z, y, x) float32 3.021 3.021 3.02 3.019 ... 5.22 5.216 5.209
u (time, z, y, x) float32 0.03078 0.02984 0.03803 ... 0.1292 0.1364
v (time, z, y, x) float32 0.0497 0.07527 0.1111 ... 0.0498 0.05054
Attributes: (12/26)
history: Fri Apr 9 12:15:22 2021: ncrcat -d X,472,508,...
Conventions: COARDS
nhybrd: 20
nsigma: 19
kapref: 2
hybflg: 0
... ...
dp00ft: [1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 ...
dp00xt: [21.874 21.414 21.414 13.197 7.85 3.85 4....
ds00t: [3.555 3.026 3.026 1.547 0.828 0.828 0.968 0.8...
ds00ft: [1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 ...
ds00xt: [21.874 21.414 21.414 7.197 3.85 3.85 4....
nco_openmp_thread_number: 1- time: 50
- x: 13
- y: 11
- z: 6
- lon(y, x)float32-3.2 -3.125 -3.05 ... -2.375 -2.3
- long_name :
- Longitude
- units :
- degree_east
- standard_name :
- longitude
array([[-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ], [-3.2 , -3.125, -3.05 , -2.975, -2.9 , -2.825, -2.75 , -2.675, -2.6 , -2.525, -2.45 , -2.375, -2.3 ]], dtype=float32) - lat(y, x)float3244.69 44.69 44.69 ... 45.22 45.22
- long_name :
- Latitude
- units :
- degree_north
- standard_name :
- latitude
array([[44.685276, 44.685276, 44.685276, 44.685276, 44.685276, 44.685276, 44.685276, 44.685276, 44.685276, 44.685276, 44.685276, 44.685276, 44.685276], [44.738575, 44.738575, 44.738575, 44.738575, 44.738575, 44.738575, 44.738575, 44.738575, 44.738575, 44.738575, 44.738575, 44.738575, 44.738575], [44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 , 44.79183 ], [44.845028, 44.845028, 44.845028, 44.845028, 44.845028, 44.845028, 44.845028, 44.845028, 44.845028, 44.845028, 44.845028, 44.845028, 44.845028], [44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 , 44.89818 ], [44.951283, 44.951283, 44.951283, 44.951283, 44.951283, 44.951283, 44.951283, 44.951283, 44.951283, 44.951283, 44.951283, 44.951283, 44.951283], [45.004333, 45.004333, 45.004333, 45.004333, 45.004333, 45.004333, 45.004333, 45.004333, 45.004333, 45.004333, 45.004333, 45.004333, 45.004333], [45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 , 45.05734 ], [45.110294, 45.110294, 45.110294, 45.110294, 45.110294, 45.110294, 45.110294, 45.110294, 45.110294, 45.110294, 45.110294, 45.110294, 45.110294], [45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 , 45.1632 ], [45.216057, 45.216057, 45.216057, 45.216057, 45.216057, 45.216057, 45.216057, 45.216057, 45.216057, 45.216057, 45.216057, 45.216057, 45.216057]], dtype=float32) - z(z)int321 2 3 4 5 6
- long_name :
- Level
- positive :
- down
array([1, 2, 3, 4, 5, 6], dtype=int32)
- time(time)datetime64[ns]2021-03-01 ... 2021-03-25T12:00:00
- long_name :
- Time
- standard_name :
- time
- axis :
- T
array(['2021-03-01T00:00:00.000000000', '2021-03-01T12:00:00.000000000', '2021-03-02T00:00:00.000000000', '2021-03-02T12:00:00.000000000', '2021-03-03T00:00:00.000000000', '2021-03-03T12:00:00.000000000', '2021-03-04T00:00:00.000000000', '2021-03-04T12:00:00.000000000', '2021-03-05T00:00:00.000000000', '2021-03-05T12:00:00.000000000', '2021-03-06T00:00:00.000000000', '2021-03-06T12:00:00.000000000', '2021-03-07T00:00:00.000000000', '2021-03-07T12:00:00.000000000', '2021-03-08T00:00:00.000000000', '2021-03-08T12:00:00.000000000', '2021-03-09T00:00:00.000000000', '2021-03-09T12:00:00.000000000', '2021-03-10T00:00:00.000000000', '2021-03-10T12:00:00.000000000', '2021-03-11T00:00:00.000000000', '2021-03-11T12:00:00.000000000', '2021-03-12T00:00:00.000000000', '2021-03-12T12:00:00.000000000', '2021-03-13T00:00:00.000000000', '2021-03-13T12:00:00.000000000', '2021-03-14T00:00:00.000000000', '2021-03-14T12:00:00.000000000', '2021-03-15T00:00:00.000000000', '2021-03-15T12:00:00.000000000', '2021-03-16T00:00:00.000000000', '2021-03-16T12:00:00.000000000', '2021-03-17T00:00:00.000000000', '2021-03-17T12:00:00.000000000', '2021-03-18T00:00:00.000000000', '2021-03-18T12:00:00.000000000', '2021-03-19T00:00:00.000000000', '2021-03-19T12:00:00.000000000', '2021-03-20T00:00:00.000000000', '2021-03-20T12:00:00.000000000', '2021-03-21T00:00:00.000000000', '2021-03-21T12:00:00.000000000', '2021-03-22T00:00:00.000000000', '2021-03-22T12:00:00.000000000', '2021-03-23T00:00:00.000000000', '2021-03-23T12:00:00.000000000', '2021-03-24T00:00:00.000000000', '2021-03-24T12:00:00.000000000', '2021-03-25T00:00:00.000000000', '2021-03-25T12:00:00.000000000'], dtype='datetime64[ns]') - depth(time, z, y, x)float321.511 1.511 1.51 ... 20.09 20.06
- positive :
- down
- long_name :
- Depth
- standard_name :
- ocean_layer_depth
- units :
- m
array([[[[ 1.5105977, 1.5105633, 1.5102059, ..., 1.5083613, 1.5078 , 1.5067827], [ 1.5108202, 1.5104996, 1.5099431, ..., 1.5091175, 1.5086483, 1.5083889], [ 1.5106035, 1.5104802, 1.5105064, ..., 1.5090628, 1.5080673, 1.5068965], ..., [ 1.5048223, 1.5069485, 1.5022234, ..., 1.4243428, 1.4233588, 1.4208953], [ 1.5027441, 1.5030969, 1.4926589, ..., 1.4244939, 1.4227725, 1.4197924], [ 1.5022792, 1.4862367, 1.4777415, ..., 1.4226158, 1.4210298, 1.4180841]], [[ 4.7583847, 4.7582765, 4.7571507, ..., 4.7513404, 4.7495723, 4.7463675], [ 4.7590857, 4.7580757, 4.756323 , ..., 4.753722 , 4.752244 , 4.7514267], [ 4.7584033, 4.7580147, 4.758097 , ..., 4.7535496, 4.750414 , 4.746726 ], ... [15.850237 , 15.866872 , 15.830021 , ..., 15.238062 , 15.231867 , 15.214603 ], [15.833722 , 15.83661 , 15.756068 , ..., 15.240509 , 15.228562 , 15.207348 ], [15.8302555, 15.706268 , 15.641436 , ..., 15.227915 , 15.216875 , 15.195684 ]], [[20.989738 , 20.98936 , 20.985582 , ..., 20.966002 , 20.960209 , 20.949936 ], [20.992035 , 20.988613 , 20.982742 , ..., 20.97388 , 20.969166 , 20.966604 ], [20.989582 , 20.988224 , 20.988438 , ..., 20.973309 , 20.96318 , 20.951134 ], ..., [20.928938 , 20.950905 , 20.902222 , ..., 20.120533 , 20.112396 , 20.089611 ], [20.907127 , 20.91092 , 20.804552 , ..., 20.123796 , 20.108017 , 20.080006 ], [20.902534 , 20.738808 , 20.65319 , ..., 20.107111 , 20.092545 , 20.064571 ]]]], dtype=float32)
- bathy(y, x)float32...
- long_name :
- Bath
- units :
- m
- reference :
- unknown
- standard_name :
- model_sea_floor_depth_below_sea_level
array([[3453.463 , 3422.108 , 3130.7961 , 2598.1763 , 2316.4597 , 2201.4438 , 2346.258 , 2588.2224 , 2670.431 , 2406.0422 , 2176.1406 , 1988.0868 , 1715.7496 ], [3667.9546 , 3365.6436 , 2947.7202 , 2654.5015 , 2492.4238 , 2471.245 , 2653.909 , 2871.0186 , 2882.8499 , 2745.9492 , 2487.5015 , 2286.8127 , 2185.7598 ], [3460.2036 , 3350.5095 , 3371.2104 , 3291.2966 , 3192.047 , 3170.7417 , 3151.1177 , 3041.8728 , 2921.712 , 2708.36 , 2461.9087 , 2075.713 , 1742.7968 ], [3516.36 , 3417.8958 , 3416.196 , 3364.0862 , 3282.7856 , 3134.8384 , 2981.859 , 2849.8115 , 2681.0994 , 2631.2544 , 2408.4106 , 2117.3376 , 1410.3574 ], [3401.9617 , 3248.4927 , 3190.2017 , 3197.6428 , 3058.5046 , 2988.6497 , 2787.9282 , 2723.7742 , 2524.0962 , 2378.0117 , 2111.351 , 1673.3955 , 1031.9037 ], [3296.9314 , 3029.7302 , 2987.9783 , 2993.9626 , 2873.4949 , 2583.1587 , 2473.6934 , 1965.5464 , 2148.4019 , 1987.5488 , 1402.0848 , 1207.6687 , 567.7147 ], [2890.198 , 2463.2754 , 2418.0369 , 2611.2705 , 2331.875 , 1834.768 , 2009.2542 , 1119.6342 , 1536.5723 , 1337.8826 , 860.33124 , 421.40686 , 194.99301 ], [2078.9453 , 2092.5938 , 1515.2701 , 1982.7937 , 1420.6642 , 1295.5057 , 1235.05 , 815.4198 , 654.49176 , 561.7368 , 278.25348 , 143.8061 , 125.816536], [1351.2816 , 1754.8899 , 1052.2115 , 829.1499 , 700.1455 , 406.76447 , 389.5578 , 381.6595 , 158.63466 , 148.03163 , 132.55002 , 131.20462 , 127.797806], [1097.7317 , 1134.3828 , 571.70886 , 220.7907 , 214.80359 , 147.92644 , 146.62086 , 145.9339 , 138.96715 , 135.71753 , 132.96855 , 130.52051 , 126.44504 ], [1054.6719 , 436.1972 , 331.9374 , 158.7134 , 149.86499 , 146.4979 , 144.06357 , 140.83615 , 137.43343 , 134.09024 , 130.388 , 128.21399 , 124.298935]], dtype=float32) - dz(time, z, y, x)float323.021 3.021 3.02 ... 5.216 5.209
- long_name :
- Hauteur de couche
- units :
- m
- standard_name :
- ocean_layer_thickness
array([[[[3.021195, ..., 3.013565], ..., [3.004558, ..., 2.836168]], ..., [[6.07673 , ..., 6.061374], ..., [6.043266, ..., 5.704574]]], ..., [[[2.709108, ..., 2.703966], ..., [2.697821, ..., 2.58975 ]], ..., [[5.448768, ..., 5.438431], ..., [5.426143, ..., 5.20857 ]]]], dtype=float32) - u(time, z, y, x)float320.03078 0.02984 ... 0.1292 0.1364
- long_name :
- Vitesse u
- units :
- m/s
- standard_name :
- sea_water_x_velocity
array([[[[ 3.07803266e-02, 2.98443586e-02, 3.80342789e-02, ..., -7.37402663e-02, -8.43679085e-02, -8.12648013e-02], [ 1.23701449e-02, 1.50961587e-02, 2.51475759e-02, ..., -8.63678008e-02, -9.64591652e-02, -9.71947759e-02], [-2.01056171e-02, -1.51812695e-02, -7.60994107e-03, ..., -1.04295269e-01, -1.11405112e-01, -1.16363972e-01], ..., [-1.86786056e-01, -1.92343920e-01, -1.91840127e-01, ..., -4.37256359e-02, -4.79313172e-03, 2.02975124e-02], [-8.44000950e-02, -9.42860246e-02, -1.04314610e-01, ..., -6.28997944e-03, 1.32650631e-02, 2.37311684e-02], [-1.09446114e-02, -1.14631336e-02, -8.14653561e-03, ..., -3.59939924e-03, 7.38532003e-03, 1.33131407e-02]], [[ 6.42867833e-02, 6.30945042e-02, 7.08920658e-02, ..., -4.50024009e-02, -5.63585386e-02, -5.36041260e-02], [ 4.58098724e-02, 4.82856184e-02, 5.79220057e-02, ..., -5.82552478e-02, -6.90473169e-02, -7.00490624e-02], [ 1.31664537e-02, 1.78481676e-02, 2.49275826e-02, ..., -7.75371417e-02, -8.52220803e-02, -9.02658775e-02], ... 6.44243807e-02, 7.08721802e-02, 9.57764313e-02], [ 5.73750660e-02, 7.53838420e-02, 8.89588445e-02, ..., 9.83436257e-02, 1.12002969e-01, 1.25799879e-01], [ 7.45991394e-02, 7.39198104e-02, 5.32239005e-02, ..., 1.12308770e-01, 1.21438876e-01, 1.26601607e-01]], [[ 7.66025558e-02, 7.91236162e-02, 8.51806626e-02, ..., 7.95919001e-02, 5.71442246e-02, 3.63367498e-02], [ 7.70758837e-02, 8.07250887e-02, 8.66632089e-02, ..., 8.10713619e-02, 5.81611805e-02, 3.89986746e-02], [ 5.60702831e-02, 5.84706031e-02, 6.19785115e-02, ..., 7.06868023e-02, 5.87118492e-02, 4.91954908e-02], ..., [ 3.61942127e-02, 6.22709654e-02, 1.01690136e-01, ..., 7.09709600e-02, 8.12221915e-02, 1.08293243e-01], [ 7.15760887e-02, 8.79125968e-02, 9.64225307e-02, ..., 1.06446214e-01, 1.22505680e-01, 1.38580650e-01], [ 8.76261443e-02, 8.40416402e-02, 5.80096468e-02, ..., 1.18424088e-01, 1.29247770e-01, 1.36384845e-01]]]], dtype=float32) - v(time, z, y, x)float320.0497 0.07527 ... 0.0498 0.05054
- long_name :
- Vitesse v
- units :
- m/s
- standard_name :
- sea_water_y_velocity
array([[[[ 4.97023165e-02, 7.52704889e-02, 1.11131877e-01, ..., 7.91832805e-02, 7.62774199e-02, 1.04399264e-01], [ 5.38848564e-02, 7.82120526e-02, 1.10495999e-01, ..., 8.16905573e-02, 8.01997781e-02, 1.14215605e-01], [ 5.36554828e-02, 7.57163391e-02, 1.04583308e-01, ..., 8.54983255e-02, 8.87226909e-02, 1.35595590e-01], ..., [-3.41334864e-02, -1.91510096e-02, 1.25478897e-02, ..., 2.53730595e-01, 3.11987460e-01, 3.56549680e-01], [-1.27417697e-02, -9.09249298e-04, 1.86932981e-02, ..., 3.42758715e-01, 3.59581411e-01, 3.49791050e-01], [ 1.76920630e-02, 1.98636353e-02, 3.61612402e-02, ..., 3.30308557e-01, 3.40638369e-01, 3.32737267e-01]], [[ 3.93992625e-02, 6.49572387e-02, 1.00841828e-01, ..., 6.86022788e-02, 6.54570460e-02, 9.31400955e-02], [ 4.34958637e-02, 6.78260326e-02, 1.00162163e-01, ..., 7.14119673e-02, 6.96520656e-02, 1.03205480e-01], [ 4.31915745e-02, 6.52866066e-02, 9.42960829e-02, ..., 7.58976787e-02, 7.87815750e-02, 1.25173926e-01], ... 4.94288541e-02, 6.68922067e-02, 6.85972199e-02], [-1.23431720e-02, -1.48646347e-02, -1.64564513e-02, ..., 6.50904328e-02, 6.92444891e-02, 7.40035027e-02], [-2.41432413e-02, -1.88930798e-02, 3.19821760e-04, ..., 6.35775700e-02, 5.64160347e-02, 5.92747182e-02]], [[ 4.56579253e-02, 3.75903696e-02, 1.77128147e-02, ..., -1.35674747e-03, -7.02120364e-04, 9.24564619e-03], [ 3.97472978e-02, 3.14787701e-02, 1.36627657e-02, ..., 5.27477497e-03, 6.79129036e-03, 7.84658547e-03], [ 3.53498533e-02, 2.85887234e-02, 1.40653811e-02, ..., 1.60547346e-02, 1.77752674e-02, -9.39795282e-04], ..., [ 1.92652829e-02, 1.25741400e-02, -1.17698535e-02, ..., 3.19656245e-02, 4.92104366e-02, 5.21415211e-02], [-2.07268391e-02, -2.40352675e-02, -2.78665666e-02, ..., 5.48286512e-02, 5.90183996e-02, 6.31100833e-02], [-3.81186306e-02, -3.44323739e-02, -1.85017586e-02, ..., 5.84849007e-02, 4.98032235e-02, 5.05406260e-02]]]], dtype=float32)
- history :
- Fri Apr 9 12:15:22 2021: ncrcat -d X,472,508,3 -d Y,93,123,3 -d lev,0,5 -d time,,,12 -O /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/25992/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/25993/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/25994/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/25995/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/25996/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/25997/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/25998/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/25999/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26000/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26001/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26002/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26003/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26004/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26005/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26006/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26007/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26008/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26009/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26010/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26011/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26012/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26013/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26014/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26015/h_3D.nc /ftmpdir/operhycom/MoutonV2.3_MANGA/Sorties/RESA/MANGA/26016/h_3D.nc /ftmpdir/sraynaud/Data/XOA/GDP/hycom.gdp.h.nc created by HYCOM/ncput3d
- Conventions :
- COARDS
- nhybrd :
- 20
- nsigma :
- 19
- kapref :
- 2
- hybflg :
- 0
- kapnum :
- 1
- thbase :
- 25.0
- isotop :
- 5.0
- dp00i :
- 209985.69
- thkmin :
- 12.0
- sigma :
- [25. 25.0001 25.0002 25.0003 25.0004 25.0005 25.0006 25.0007 25.0008 25.0009 25.001 25.0011 25.0012 25.0013 25.0014 26.91686 27.027563 27.028734 27.033524 27.084042 27.133852 27.153852 27.199217 27.25795 27.331116 27.434666 27.491602 27.554497 27.590364 27.620623 27.658016 27.706873 27.731169 27.765394 27.787722 27.807936 27.836752 27.851051 27.876644 27.89 ]
- saln0 :
- 35.0
- bldmin :
- 0.0
- bldmax :
- 1200.0
- thkbot :
- 50.0
- sigjmp :
- 0.02
- tmljmp :
- 0.2
- salmin :
- 0.0
- dp00t :
- [3.555 3.026 3.026 2. 1.5 0.828 0.968 0.829 1.131 1.815 2.972 4.192]
- dp00ft :
- [1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15]
- dp00xt :
- [21.874 21.414 21.414 13.197 7.85 3.85 4.506 3.859 5.261 8.443 13.828 22.428]
- ds00t :
- [3.555 3.026 3.026 1.547 0.828 0.828 0.968 0.829 1.131 1.815 2.972 4.192]
- ds00ft :
- [1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15]
- ds00xt :
- [21.874 21.414 21.414 7.197 3.85 3.85 4.506 3.859 5.261 8.443 13.828 22.428]
- nco_openmp_thread_number :
- 1
GDP drifter¶
The drifter comes as a csv file and we read it as pandas.DataFrame instance.
[9]:
drifter = xoa.open_data_sample("gdp-6203641.csv", header=0, skiprows=[1], parse_dates=[2], index_col=2)
Since the sampling is not that nice, we resample it to 3-hour intervals.
[10]:
drifter = drifter.resample("3H").mean()
We convert it to and xarray.Dataset, fix time and decode it.
[11]:
drifter = drifter.to_xarray().assign_coords(time=drifter.index.values).xoa.decode()
We drop missing values.
[12]:
drifter = drifter.where(~drifter.lon.isnull() & ~drifter.lat.isnull(), drop=True)
We add a constant depth of 15 m.
[13]:
drifter.coords["depth"] = drifter.lon*0 + 15
Here is what we obtain.
[14]:
drifter
[14]:
<xarray.Dataset>
Dimensions: (time: 159)
Coordinates:
* time (time) datetime64[ns] 2021-03-03T18:00:00 ... 2021-03-24T0...
lat (time) float64 44.68 44.72 44.72 44.72 ... 44.72 44.71 44.71
lon (time) float64 -2.544 -2.583 -2.592 ... -2.523 -2.514 -2.505
depth (time) float64 15.0 15.0 15.0 15.0 ... 15.0 15.0 15.0 15.0
Data variables:
platform_code (time) float64 6.204e+06 6.204e+06 ... 6.204e+06 6.204e+06
sst (time) float64 13.09 12.79 12.77 12.78 ... 12.56 12.53 12.61
slp (time) float64 1.027e+03 1.024e+03 ... 1.025e+03 1.026e+03
lon360 (time) float64 357.5 357.4 357.4 357.4 ... 357.5 357.5 357.5- time: 159
- time(time)datetime64[ns]2021-03-03T18:00:00 ... 2021-03-...
- standard_name :
- time
- long_name :
- Time
- axis :
- T
array(['2021-03-03T18:00:00.000000000', '2021-03-04T03:00:00.000000000', '2021-03-04T06:00:00.000000000', '2021-03-04T09:00:00.000000000', '2021-03-04T12:00:00.000000000', '2021-03-04T15:00:00.000000000', '2021-03-04T18:00:00.000000000', '2021-03-05T00:00:00.000000000', '2021-03-05T03:00:00.000000000', '2021-03-05T06:00:00.000000000', '2021-03-05T09:00:00.000000000', '2021-03-05T12:00:00.000000000', '2021-03-05T15:00:00.000000000', '2021-03-05T18:00:00.000000000', '2021-03-06T00:00:00.000000000', '2021-03-06T03:00:00.000000000', '2021-03-06T06:00:00.000000000', '2021-03-06T09:00:00.000000000', '2021-03-06T12:00:00.000000000', '2021-03-06T15:00:00.000000000', '2021-03-06T18:00:00.000000000', '2021-03-07T00:00:00.000000000', '2021-03-07T03:00:00.000000000', '2021-03-07T06:00:00.000000000', '2021-03-07T09:00:00.000000000', '2021-03-07T12:00:00.000000000', '2021-03-07T15:00:00.000000000', '2021-03-07T18:00:00.000000000', '2021-03-07T21:00:00.000000000', '2021-03-08T00:00:00.000000000', '2021-03-08T03:00:00.000000000', '2021-03-08T06:00:00.000000000', '2021-03-08T09:00:00.000000000', '2021-03-08T18:00:00.000000000', '2021-03-08T21:00:00.000000000', '2021-03-09T00:00:00.000000000', '2021-03-09T03:00:00.000000000', '2021-03-09T06:00:00.000000000', '2021-03-09T09:00:00.000000000', '2021-03-09T12:00:00.000000000', '2021-03-09T15:00:00.000000000', '2021-03-09T18:00:00.000000000', '2021-03-09T21:00:00.000000000', '2021-03-10T00:00:00.000000000', '2021-03-10T03:00:00.000000000', '2021-03-10T06:00:00.000000000', '2021-03-10T09:00:00.000000000', '2021-03-10T12:00:00.000000000', '2021-03-10T15:00:00.000000000', '2021-03-10T18:00:00.000000000', '2021-03-10T21:00:00.000000000', '2021-03-11T00:00:00.000000000', '2021-03-11T03:00:00.000000000', '2021-03-11T06:00:00.000000000', '2021-03-11T09:00:00.000000000', '2021-03-11T12:00:00.000000000', '2021-03-11T15:00:00.000000000', '2021-03-11T18:00:00.000000000', '2021-03-11T21:00:00.000000000', '2021-03-12T00:00:00.000000000', '2021-03-12T03:00:00.000000000', '2021-03-12T06:00:00.000000000', '2021-03-12T09:00:00.000000000', '2021-03-12T12:00:00.000000000', '2021-03-12T15:00:00.000000000', '2021-03-12T18:00:00.000000000', '2021-03-12T21:00:00.000000000', '2021-03-13T00:00:00.000000000', '2021-03-13T03:00:00.000000000', '2021-03-13T06:00:00.000000000', '2021-03-13T09:00:00.000000000', '2021-03-13T12:00:00.000000000', '2021-03-13T15:00:00.000000000', '2021-03-13T18:00:00.000000000', '2021-03-13T21:00:00.000000000', '2021-03-14T00:00:00.000000000', '2021-03-14T03:00:00.000000000', '2021-03-14T06:00:00.000000000', '2021-03-14T09:00:00.000000000', '2021-03-14T12:00:00.000000000', '2021-03-14T15:00:00.000000000', '2021-03-14T18:00:00.000000000', '2021-03-14T21:00:00.000000000', '2021-03-15T00:00:00.000000000', '2021-03-15T03:00:00.000000000', '2021-03-15T06:00:00.000000000', '2021-03-15T09:00:00.000000000', '2021-03-15T12:00:00.000000000', '2021-03-15T15:00:00.000000000', '2021-03-15T18:00:00.000000000', '2021-03-15T21:00:00.000000000', '2021-03-16T00:00:00.000000000', '2021-03-16T03:00:00.000000000', '2021-03-16T06:00:00.000000000', '2021-03-16T09:00:00.000000000', '2021-03-16T12:00:00.000000000', '2021-03-16T15:00:00.000000000', '2021-03-16T18:00:00.000000000', '2021-03-16T21:00:00.000000000', '2021-03-17T00:00:00.000000000', '2021-03-17T03:00:00.000000000', '2021-03-17T06:00:00.000000000', '2021-03-17T09:00:00.000000000', '2021-03-17T12:00:00.000000000', '2021-03-17T15:00:00.000000000', '2021-03-17T18:00:00.000000000', '2021-03-17T21:00:00.000000000', '2021-03-18T00:00:00.000000000', '2021-03-18T03:00:00.000000000', '2021-03-18T06:00:00.000000000', '2021-03-18T09:00:00.000000000', '2021-03-18T12:00:00.000000000', '2021-03-18T15:00:00.000000000', '2021-03-18T18:00:00.000000000', '2021-03-18T21:00:00.000000000', '2021-03-19T00:00:00.000000000', '2021-03-19T03:00:00.000000000', '2021-03-19T06:00:00.000000000', '2021-03-19T09:00:00.000000000', '2021-03-19T12:00:00.000000000', '2021-03-19T15:00:00.000000000', '2021-03-19T18:00:00.000000000', '2021-03-19T21:00:00.000000000', '2021-03-20T00:00:00.000000000', '2021-03-20T03:00:00.000000000', '2021-03-20T06:00:00.000000000', '2021-03-20T09:00:00.000000000', '2021-03-20T12:00:00.000000000', '2021-03-20T15:00:00.000000000', '2021-03-20T18:00:00.000000000', '2021-03-20T21:00:00.000000000', '2021-03-21T00:00:00.000000000', '2021-03-21T03:00:00.000000000', '2021-03-21T06:00:00.000000000', '2021-03-21T09:00:00.000000000', '2021-03-21T12:00:00.000000000', '2021-03-21T15:00:00.000000000', '2021-03-21T18:00:00.000000000', '2021-03-21T21:00:00.000000000', '2021-03-22T00:00:00.000000000', '2021-03-22T03:00:00.000000000', '2021-03-22T06:00:00.000000000', '2021-03-22T09:00:00.000000000', '2021-03-22T12:00:00.000000000', '2021-03-22T15:00:00.000000000', '2021-03-22T18:00:00.000000000', '2021-03-22T21:00:00.000000000', '2021-03-23T00:00:00.000000000', '2021-03-23T03:00:00.000000000', '2021-03-23T06:00:00.000000000', '2021-03-23T09:00:00.000000000', '2021-03-23T12:00:00.000000000', '2021-03-23T15:00:00.000000000', '2021-03-23T18:00:00.000000000', '2021-03-23T21:00:00.000000000', '2021-03-24T00:00:00.000000000', '2021-03-24T03:00:00.000000000', '2021-03-24T06:00:00.000000000', '2021-03-24T09:00:00.000000000'], dtype='datetime64[ns]') - lat(time)float6444.68 44.72 44.72 ... 44.71 44.71
- standard_name :
- latitude
- long_name :
- Latitude
- units :
- degrees_north
array([44.6818 , 44.71565 , 44.71986667, 44.72003333, 44.72956667, 44.74686667, 44.7563 , 44.7776 , 44.7972 , 44.81646667, 44.83446667, 44.84816667, 44.86086667, 44.87615 , 44.91896667, 44.93383333, 44.94643333, 44.96605 , 44.98026667, 44.99436667, 45.0015 , 45.04143333, 45.05143333, 45.06066667, 45.0705 , 45.08283333, 45.0959 , 45.10366667, 45.1109 , 45.12213333, 45.13053333, 45.1368 , 45.1395 , 45.15715 , 45.15896667, 45.16093333, 45.16426667, 45.1644 , 45.16576667, 45.16636667, 45.16766667, 45.1679 , 45.16866667, 45.1718 , 45.1748 , 45.1758 , 45.17806667, 45.182125 , 45.18346667, 45.18035 , 45.17976667, 45.17746667, 45.16813333, 45.1568 , 45.1515 , 45.14886667, 45.13813333, 45.11926667, 45.10593333, 45.1038 , 45.1006 , 45.0921 , 45.081 , 45.07783333, 45.07323333, 45.0586 , 45.04493333, 45.04286667, 45.045225 , 45.0357 , 45.02013333, 45.0122 , 45.01386667, 45.00783333, 44.9893 , 44.9774 , 44.97706667, 44.9787 , 44.968175 , 44.9609 , 44.95883333, 44.95736667, 44.9467 , 44.93816667, 44.93806667, 44.93643333, 44.92676667, 44.92073333, 44.91616667, 44.9059 , 44.8922 , 44.88263333, 44.87966667, 44.87463333, 44.86286667, 44.8526 , 44.85026667, 44.84723333, 44.83813333, 44.82306667, 44.811 , 44.80103333, 44.7916 , 44.78716667, 44.7801 , 44.7701 , 44.75246667, 44.73803333, 44.7389 , 44.75036667, 44.75426667, 44.748 , 44.7322 , 44.7187 , 44.7255 , 44.73826667, 44.742 , 44.73523333, 44.729075 , 44.733 , 44.7472 , 44.7559 , 44.75916667, 44.7572 , 44.7596 , 44.7604 , 44.7599 , 44.75996667, 44.76006667, 44.75846667, 44.7519 , 44.7477 , 44.75213333, 44.75673333, 44.75293333, 44.7468 , 44.7438 , 44.74153333, 44.74223333, 44.7469 , 44.7501 , 44.74653333, 44.74113333, 44.7393 , 44.74253333, 44.74456667, 44.74113333, 44.7382 , 44.73953333, 44.73883333, 44.737 , 44.73553333, 44.73253333, 44.72793333, 44.72223333, 44.71746667, 44.71516667, 44.71193333, 44.70813333]) - lon(time)float64-2.544 -2.583 ... -2.514 -2.505
- standard_name :
- longitude
- long_name :
- Longitude
- units :
- degrees_east
array([-2.5441 , -2.58325 , -2.5923 , -2.61683333, -2.65533333, -2.686 , -2.71203333, -2.8073 , -2.8493 , -2.88676667, -2.92306667, -2.9583 , -2.9952 , -3.02655 , -3.08103333, -3.09346667, -3.10923333, -3.1251 , -3.1354 , -3.1421 , -3.147 , -3.15563333, -3.15253333, -3.14866667, -3.149 , -3.14716667, -3.14236667, -3.1345 , -3.1317 , -3.12733333, -3.12333333, -3.1194 , -3.1151 , -3.11825 , -3.1125 , -3.10753333, -3.10403333, -3.1048 , -3.0987 , -3.09246667, -3.0954 , -3.09936667, -3.09203333, -3.07893333, -3.07296667, -3.07906667, -3.0787 , -3.0679 , -3.06093333, -3.0598 , -3.05056667, -3.0297 , -3.01493333, -3.0156 , -3.0103 , -2.9897 , -2.9667 , -2.95813333, -2.9563 , -2.935225 , -2.8972 , -2.8793 , -2.86023333, -2.83683333, -2.808 , -2.78533333, -2.77383333, -2.7609 , -2.7333 , -2.711 , -2.70156667, -2.69533333, -2.67886667, -2.65583333, -2.64605 , -2.64183333, -2.63286667, -2.61726667, -2.598825 , -2.5901 , -2.58053333, -2.5657 , -2.5514 , -2.5405 , -2.5296 , -2.51556667, -2.50403333, -2.4927 , -2.47406667, -2.46163333, -2.45733333, -2.45693333, -2.44566667, -2.42983333, -2.4207 , -2.42166667, -2.41773333, -2.40676667, -2.39713333, -2.3961 , -2.39816667, -2.4025 , -2.4096 , -2.41613333, -2.41933333, -2.42153333, -2.428 , -2.4507 , -2.4783 , -2.48643333, -2.47993333, -2.47283333, -2.47836667, -2.50596667, -2.5356 , -2.54716667, -2.54416667, -2.5495 , -2.571625 , -2.60003333, -2.6216 , -2.62546667, -2.62996667, -2.64335 , -2.6616 , -2.66225 , -2.66606667, -2.67446667, -2.68123333, -2.67883333, -2.6787 , -2.69153333, -2.70006667, -2.69276667, -2.6814 , -2.67933333, -2.6759 , -2.6747 , -2.67526667, -2.67486667, -2.66483333, -2.65236667, -2.64406667, -2.64426667, -2.6402 , -2.62563333, -2.6109 , -2.6029 , -2.5973 , -2.58583333, -2.57346667, -2.55883333, -2.54593333, -2.537 , -2.53153333, -2.5275 , -2.52273333, -2.5142 , -2.5048 ]) - depth(time)float6415.0 15.0 15.0 ... 15.0 15.0 15.0
array([15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15., 15.])
- platform_code(time)float646.204e+06 6.204e+06 ... 6.204e+06
array([6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641., 6203641.]) - sst(time)float6413.09 12.79 12.77 ... 12.53 12.61
- standard_name :
- sea_surface_temperature
- long_name :
- Sea surface temperature
- units :
- degrees_celsius
array([13.09 , 12.795 , 12.76666667, 12.78333333, 12.88 , 12.91333333, 12.80666667, 12.7 , 12.65333333, 12.62666667, 12.63333333, 12.65333333, 12.66 , 12.64 , 12.63666667, 12.62666667, 12.61 , 12.6 , 12.61666667, 12.63 , 12.61 , 12.57666667, 12.56333333, 12.55666667, 12.55333333, 12.60333333, 12.62333333, 12.55 , 12.53333333, 12.52 , 12.50666667, 12.49666667, 12.5 , 12.5 , 12.48666667, 12.47 , 12.46333333, 12.46 , 12.47 , 12.59 , 12.69666667, 12.65 , 12.57666667, 12.5 , 12.47666667, 12.46 , 12.47333333, 12.4925 , 12.48 , 12.47 , 12.48 , 12.48 , 12.48 , 12.48 , 12.48666667, 12.50333333, 12.51666667, 12.49666667, 12.47666667, 12.47 , 12.47 , 12.455 , 12.48 , 12.51666667, 12.5 , 12.46333333, 12.45 , 12.44333333, 12.45 , 12.45 , 12.45666667, 12.47 , 12.47333333, 12.46 , 12.45 , 12.44666667, 12.44333333, 12.44 , 12.48 , 12.51 , 12.53666667, 12.48333333, 12.46666667, 12.46 , 12.46 , 12.45 , 12.47 , 12.49333333, 12.5 , 12.48 , 12.46 , 12.46 , 12.45333333, 12.45666667, 12.51666667, 12.72666667, 12.71666667, 12.64333333, 12.53333333, 12.49333333, 12.48 , 12.47333333, 12.52666667, 12.62666667, 12.63666667, 12.58 , 12.55 , 12.5 , 12.46333333, 12.45333333, 12.46333333, 12.50666667, 12.51666667, 12.48666667, 12.48666667, 12.47666667, 12.47333333, 12.46666667, 12.4625 , 12.47 , 12.455 , 12.43333333, 12.41 , 12.4 , 12.39 , 12.41 , 12.43333333, 12.44666667, 12.44333333, 12.41333333, 12.40666667, 12.40333333, 12.40333333, 12.40333333, 12.44333333, 12.51333333, 12.51 , 12.47666667, 12.45666667, 12.44 , 12.42333333, 12.41 , 12.48 , 12.62666667, 12.71666667, 12.54666667, 12.49 , 12.46666667, 12.43666667, 12.43 , 12.49333333, 12.73 , 12.88666667, 12.74333333, 12.68333333, 12.61333333, 12.56 , 12.53333333, 12.60666667]) - slp(time)float641.027e+03 1.024e+03 ... 1.026e+03
array([1027.1 , 1023.7 , 1023.3 , 1023.23333333, 1022.5 , 1020.7 , 1020.36666667, 1021.03333333, 1020.66666667, 1021.16666667, 1022.5 , 1023.23333333, 1023.43333333, 1024.25 , 1025.96666667, 1025.5 , 1025.86666667, 1026.65 , 1026.13333333, 1025.2 , 1025.1 , 1024.2 , 1023. , 1022.7 , 1022.3 , 1021.16666667, 1020.36666667, 1020.93333333, 1021. , 1020.5 , 1019.86666667, 1020.46666667, 1021.35 , 1022.65 , 1023.3 , 1023.13333333, 1022.5 , 1022.83333333, 1024.26666667, 1023.4 , 1022.56666667, 1023.26666667, 1023.23333333, 1022.43333333, 1021.16666667, 1021.53333333, 1021.66666667, 1019.875 , 1018.6 , 1018.8 , 1018.43333333, 1017.16666667, 1016.63333333, 1016.9 , 1018.56666667, 1018.76666667, 1019.6 , 1021.8 , 1022.7 , 1021.575 , 1020.3 , 1021.2 , 1022.33333333, 1021.86666667, 1020.93333333, 1020.93333333, 1020.46666667, 1018.83333333, 1017.275 , 1017.4 , 1018.5 , 1018.6 , 1018.66666667, 1019.9 , 1021.65 , 1022.3 , 1022.7 , 1024.83333333, 1027.775 , 1028.25 , 1028.26666667, 1029.26666667, 1030.03333333, 1029.76666667, 1028.36666667, 1028.66666667, 1030.03333333, 1029.56666667, 1029.2 , 1030.26666667, 1031.63333333, 1032.1 , 1031.46666667, 1032.46666667, 1034.1 , 1033.96666667, 1033.33333333, 1033.26666667, 1034.13333333, 1033.33333333, 1032.26666667, 1033.26666667, 1034.43333333, 1033.56666667, 1032.03333333, 1031.43333333, 1030.83333333, 1029.56666667, 1028.53333333, 1028.86666667, 1029.53333333, 1028.4 , 1026.46666667, 1025.63333333, 1025.23333333, 1023.46666667, 1021.1 , 1019.16666667, 1018.875 , 1019.73333333, 1020.65 , 1021.86666667, 1024.1 , 1025.85 , 1028.1 , 1027.9 , 1029.66666667, 1029.8 , 1029. , 1029. , 1029.63333333, 1029.43333333, 1028.56666667, 1029.13333333, 1029.73333333, 1029.1 , 1027.56666667, 1027.53333333, 1027.53333333, 1027. , 1026.4 , 1026.53333333, 1027. , 1026.63333333, 1025.83333333, 1025.83333333, 1025.83333333, 1025.06666667, 1024.3 , 1024.7 , 1025.8 , 1025.43333333, 1024.4 , 1024.4 , 1024.8 , 1024.63333333, 1024.63333333, 1025.3 , 1026.16666667]) - lon360(time)float64357.5 357.4 357.4 ... 357.5 357.5
array([357.4559 , 357.41675 , 357.4077 , 357.38316667, 357.34466667, 357.314 , 357.28796667, 357.1927 , 357.1507 , 357.11323333, 357.07693333, 357.0417 , 357.0048 , 356.97345 , 356.91896667, 356.90653333, 356.89076667, 356.8749 , 356.8646 , 356.8579 , 356.853 , 356.84436667, 356.84746667, 356.85133333, 356.851 , 356.85283333, 356.85763333, 356.8655 , 356.8683 , 356.87266667, 356.87666667, 356.8806 , 356.8849 , 356.88175 , 356.8875 , 356.89246667, 356.89596667, 356.8952 , 356.9013 , 356.90753333, 356.9046 , 356.90063333, 356.90796667, 356.92106667, 356.92703333, 356.92093333, 356.9213 , 356.9321 , 356.93906667, 356.9402 , 356.94943333, 356.9703 , 356.98506667, 356.9844 , 356.9897 , 357.0103 , 357.0333 , 357.04186667, 357.0437 , 357.064775 , 357.1028 , 357.1207 , 357.13976667, 357.16316667, 357.192 , 357.21466667, 357.22616667, 357.2391 , 357.2667 , 357.289 , 357.29843333, 357.30466667, 357.32113333, 357.34416667, 357.35395 , 357.35816667, 357.36713333, 357.38273333, 357.401175 , 357.4099 , 357.41946667, 357.4343 , 357.4486 , 357.4595 , 357.4704 , 357.48443333, 357.49596667, 357.5073 , 357.52593333, 357.53836667, 357.54266667, 357.54306667, 357.55433333, 357.57016667, 357.5793 , 357.57833333, 357.58226667, 357.59323333, 357.60286667, 357.6039 , 357.60183333, 357.5975 , 357.5904 , 357.58386667, 357.58066667, 357.57846667, 357.572 , 357.5493 , 357.5217 , 357.51356667, 357.52006667, 357.52716667, 357.52163333, 357.49403333, 357.4644 , 357.45283333, 357.45583333, 357.4505 , 357.428375 , 357.39996667, 357.3784 , 357.37453333, 357.37003333, 357.35665 , 357.3384 , 357.33775 , 357.33393333, 357.32553333, 357.31876667, 357.32116667, 357.3213 , 357.30846667, 357.29993333, 357.30723333, 357.3186 , 357.32066667, 357.3241 , 357.3253 , 357.32473333, 357.32513333, 357.33516667, 357.34763333, 357.35593333, 357.35573333, 357.3598 , 357.37436667, 357.3891 , 357.3971 , 357.4027 , 357.41416667, 357.42653333, 357.44116667, 357.45406667, 357.463 , 357.46846667, 357.4725 , 357.47726667, 357.4858 , 357.4952 ])
Compute and interpolate velocities¶
We compute the drifter velocity components
[15]:
drifter["u"] = drifter.lon.differentiate("time", datetime_unit="s") * xgeo.EARTH_RADIUS*np.pi/180
drifter["u"] *= np.cos(np.radians(drifter.lat.values))
drifter["v"] = drifter.lat.differentiate("time", datetime_unit="s") * xgeo.EARTH_RADIUS*np.pi/180
We interpolate the Hycom velocity to the drifter positions with xoa.regrid.grid2loc. note that this is a 4D linear interpolation.
[16]:
uloc = grid2loc(hycom["u"], drifter)
vloc = grid2loc(hycom["v"], drifter)
Instead of just showing the velocities along the drifter positions, we can plot the mean model velocities over the same period as a background. So we interpolate them at 15 m with xoa.regrid.regrid1d and compute a time average.
[17]:
d15 = xr.DataArray([15.], dims="depth", name="depth")
uh15 = regrid1d(hycom["u"], d15).squeeze(drop=True).mean(dim="time")
vh15 = regrid1d(hycom["v"], d15).squeeze(drop=True).mean(dim="time")
Plot¶
The geographic extent is easily computed with the xoa.geo.get_extent function.
[18]:
pmerc = ccrs.Mercator()
pcarr = ccrs.PlateCarree()
fig, ax = plt.subplots(figsize=(7, 7), subplot_kw={"facecolor": "teal", "projection": pmerc})
ax.gridlines(draw_labels=True, dms=True)
ax.set_extent(xgeo.get_extent(uh15))
kwqv = dict(scale_units="dots", scale=0.1/20, units="dots", transform=pcarr)
qv = ax.quiver(uh15.lon.values, uh15.lat.values, uh15.values, vh15.values,
width=3, color="w", alpha=0.3, **kwqv)
ax.quiver(uloc.lon.values, uloc.lat.values, uloc.values, vloc.values,
color="w", width=2, label="Model", **kwqv)
ax.plot(drifter.lon.values, drifter.lat.values, '-', color="C1", transform=pcarr, lw=.5)
ax.quiver(drifter.lon.values, drifter.lat.values, drifter.u.values, drifter.v.values,
color="C1", label="Drifter", width=2, **kwqv)
plt.quiverkey(qv, 0.1, 1.06, 0.1, r"0.1 $m\,s^{-1}$", color="k", alpha=1, labelpos="E")
plt.legend();
[18]:
<matplotlib.legend.Legend at 0x7f1bf4926b20>