# To extract coordinates values from a datatable using xarray
import xarray as xr
import numpy as np
import pandas as pd
# This sectin creates a dummy data
years=range(1982,1986)
time = pd.date_range('14/1/' + str(years_arr[0]) + ' 12:00:00', periods=len(years_arr), freq=pd.DateOffset(years=1))
lon = range(20,24)
lat = range(10,14)
arr1 = xr.DataArray(data, coords=[time, lat, lon], dims=['time', 'latitude', 'longitude'])
# This section performs the extraction
# extract coordinate value of the lon
arr1.coords['lon'] # gives you longitude as a xarray.DataArray, and
arr1.coords['lon'].values # gives you the values as a numpy array.
# extract all coordinates (time, lat, lon) values
time, lat, lon = arr1.indexes.values()