import xarray as xr import numpy as np import pandas as pd # Create temperature data with missing values temperature = np.random.rand(365, 50, 50) * 20 + 10 temperature[0:10, :, :] = np.nan # Set the first 10 days as missing values # Create time, latitude, and longitude coordinate arrays times = pd.date_range('2023-01-01', periods=365, freq='D') latitudes = np.linspace(-90, 90, 50) longitudes = np.linspace(-180, 180, 50) # Create an Xarray data array with missing values da = xr.DataArray( temperature, dims=['time', 'latitude', 'longitude'], coords={'time': times, 'latitude': latitudes, 'longitude': longitudes} ) # Count the number of missing values along the time dimension missing_count = da.isnull().sum(dim='time') # Print missing values print(missing_count) >>> array([[10, 10, 10, ..., 10, 10, 10], [10, 10, 10, ..., 10, 10, 10], [10, 10, 10, ..., 10, 10, 10], ..., [10, 10, 10, ..., 10, 10, 10], [10, 10, 10, ..., 10, 10, 10], [10, 10, 10, ..., 10, 10, 10]]) Coordinates: * latitude (latitude) float64 -90.0 -86.33 -82.65 ... 82.65 86.33 90.0 * longitude (longitude) float64 -180.0 -172.7 -165.3 ... 165.3 172.7 180.0