How to add new variable to xarray dataset

  Numpy, Python
pr_data['PrTot']=xr.DataArray(PrTot.astype(np.float32), 
                              coords=pr_data.coords, 
                              dims=pr_data.tp.dims, 
                              attrs=pr_data.attrs)
pr_data['R1mm']=xr.DataArray(R1mm.astype(np.int16), 
                              coords=pr_data.coords, 
                              dims=pr_data.tp.dims, 
                              attrs=pr_data.attrs)
pr_data['R10mm']=xr.DataArray(R10mm.astype(np.int16), 
                              coords=pr_data.coords, 
                              dims=pr_data.tp.dims, 
                              attrs=pr_data.attrs)
pr_data['R20mm']=xr.DataArray(R20mm.astype(np.int16), 
                              coords=pr_data.coords, 
                              dims=pr_data.tp.dims, 
                              attrs=pr_data.attrs)
pr_data['SDII']=xr.DataArray(SDII.astype(np.float32), 
                              coords=pr_data.coords, 
                              dims=pr_data.tp.dims, 
                              attrs=pr_data.attrs)
pr_data['Rx1day']=xr.DataArray(Rx1day.astype(np.float32), 
                              coords=pr_data.coords, 
                              dims=pr_data.tp.dims, 
                              attrs=pr_data.attrs)
pr_data['Rx5day']=xr.DataArray(Rx5day.astype(np.float32), 
                              coords=pr_data.coords, 
                              dims=pr_data.tp.dims, 
                              attrs=pr_data.attrs)
See example code:
/media/Data1/OnClimate/Precipitation_indexes_EAR5_GreatLakesRegion.ipynb

Pay attention to line:

dims=pr_data.tp.dims,