how to open many datasets using xarray

Solutions on MaxInterview for how to open many datasets using xarray by the best coders in the world

showing results for - "how to open many datasets using xarray"
Simona
11 Jan 2018
1import xarray as xr, glob
2
3netcdf_file_list = [netcdf_file_1, netcdf_file_2, netcdf_file_3, netcdf_file_n]
4xr.open_mfdataset(netcdf_file_list)
5
6#now that you have all the datasets opened you can perform computations on this
7#for example you can get a median plot based on a subset of information found
8#in all the datasets which can then be used to make one median dataset for
9#example
10
11#for example:
12glob_pattern = glob.glob(/directory_path/*.nc)
13
14#take all the nc files in the directory and combine them
15#based on the coordinates
16mfds = xr.open_mfdataset(netcdf_file_list,
17                        glob_pattern,
18                        combine='by_coords' #for example
19                        )
similar questions
queries leading to this page
how to open many datasets using xarray