import random import xarray as xr from tqdm import tqdm listofarrays = [] Select the…
- User
import random import xarray as xr from tqdm import tqdm
list_of_arrays = []
Select the required data points using the mask selected_data = germany_test[0] selected_single_data = germany_single[0]
Extract the required variables using vectorized operations time_array = selected_data.time.values lat_array = selected_data.latitude.values lon_array = selected_data.longitude.values
z_array = selected_data.z.sel(isobaricInhPa=[1000, 925, 850]).values q_array = selected_data.q.sel(isobaricInhPa=[1000, 925, 850]).values t_array = selected_data.t.sel(isobaricInhPa=[1000, 925, 850]).values u_array = selected_data.u.sel(isobaricInhPa=[1000, 925, 850]).values v_array = selected_data.v.sel(isobaricInhPa=[1000, 925, 850]).values w_array = selected_data.w.sel(isobaricInhPa=[1000, 925, 850]).values
msl_array = selected_single_data.msl.values lsm_array = selected_single_data.lsm.values t2m_array = selected_single_data.t2m.values u10_array = selected_single_data.u10.values v10_array = selected_single_data.v10.values u100_array = selected_single_data.u100.values v100_array = selected_single_data.v100.values
print(time_array.shape) print(lat_array.shape) print(lon_array.shape) print(z_array.shape) print(q_array.shape) print(t_array.shape) print(u_array.shape) print(v_array.shape) print(w_array.shape) print(msl_array.shape) print(lsm_array.shape) print(t2m_array.shape) print(u10_array.shape) print(v10_array.shape) print(u100_array.shape) print(v100_array.shape)(32,) (30,) (37,) (32, 3, 30, 37) (32, 3, 30, 37) (32, 3, 30, 37) (32, 3, 30, 37) (32, 3, 30, 37) (32, 3, 30, 37) (32, 30, 37) (32, 30, 37) (32, 30, 37) (32, 30, 37) (32, 30, 37) (32, 30, 37) (32, 30, 37) can you combine these into a list of arrays where each array has a time, a lat and lon. then the rest of the values. The goal is for this operation to be fast and resuult in 323037 seperate arrays
- Assistant