I can open a netdcf file with xarray. Then, get a slice of a varible (wrfout_zz_tavg) in the netcdf file. When I try to print this variable, it gives me some extra details (like coordinates and etc.). How can I get just an array of float numbers with no more details?
Here is my code:
import xarray as xr
fin = xr.open_dataset("test.nc")
zz_tavg = fin.wrfout_zz_tavg
slice_zz = zz_tavg[0:28,77,23]
print(slice_zz)
This is my screen output:
<xarray.DataArray 'wrfout_zz_tavg' (bottom_top: 28)>
array([1267.2994, 1320.5454, 1378.9381, 1442.8959, 1512.8885, 1589.4257,
1673.0416, 1764.3097, 1863.855 , 1972.3475, 2090.519 , 2219.19 ,
2359.26 , 2511.6719, 2677.3743, 2857.3916, 3052.9136, 3265.276 ,
3495.9197, 3746.4136, 4018.517 , 4314.2246, 4635.806 , 4985.8716,
5367.4385, 5783.9033, 6239.008 , 6736.876 ], dtype=float32)
Coordinates:
XLAT float32 ...
XLONG float32 ...
Dimensions without coordinates: bottom_top
What I want to get is:
[1267.2994, 1320.5454, 1378.9381, 1442.8959, 1512.8885, 1589.4257,
1673.0416, 1764.3097, 1863.855 , 1972.3475, 2090.519 , 2219.19 ,
2359.26 , 2511.6719, 2677.3743, 2857.3916, 3052.9136, 3265.276 ,
3495.9197, 3746.4136, 4018.517 , 4314.2246, 4635.806 , 4985.8716,
5367.4385, 5783.9033, 6239.008 , 6736.876 ]