I have four different variables that I want to add to one single array for plotting. They all come from a list of previously generated tuples called 'list_of_tuples'. There are thousands of values for each variable, so this is a large array:
variable_1 = np.array([x[0] for x in list_of_tuples])
variable_2 = np.array([x[1] for x in list_of_tuples])
variable_3 = np.array([x[2] for x in list_of_tuples])
time = np.array([x[3] for x in list_of_tuples])
I then take these variables and add them to an xarray dataset:
xarray_object = xr.Dataset({'variable_1': (['time'], variable_1), 'variable_2': (['time'], variable_2), 'variable_3': (['time'], variable_3), 'time': (['time'], time)})
This xarray object is so large, however, that it takes almost an hour to build the dataset. Do you have any suggestions for speeding things up?