aachar5 / 3rdassignment

0 stars 0 forks source link

Xarray Datasets vs DataArrays #5

Closed pdirmeyer closed 1 year ago

pdirmeyer commented 1 year ago

Your variable da_anoms is a DataSet as defined, not a DataArray. That is why it has no "shape" in your plotting loop.

DataArrays are arrays - they correspond to variables with one or more dimensions. A Dataset is a collection of such DataArrays (it could even be a "collection" of only one).

It is important to keep these concepts clear when working with xarray.

aachar5 commented 1 year ago

previously i missed this step of selecting the same time for temperature data as QBO index

da_temp = ds_temp.t.sel(time=slice(da_index['time'][0],da_index['time'][-1])) da_temp

This returned a xarray daraArray and then I calculated the anomaly giving da_temp as data which returned (da_anoms) as a dataArray.