0

I'm trying to merge multiple NETCDF files into one. They all have the files in one directory and have the same starting name so I used this script:

import xarray
ds = xarray.open_mfdataset(r'D:\copernicus-tmp-data\2019\CMEMS*.nc',combine = 'by_coords', concat_dim="time")
ds.to_netcdf(r'D:\copernicus-tmp-data\2019\CMEMS_2019_merged_currents.nc')

The problem is that it's throwing an error and I couldn't figure out how to fix it:

ValueError: cannot reindex or align along dimension 'lat' because the index has duplicate values

Can you please help me?

Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • This sounds like a data problem. Sounds like the file is structured in a way that xarray does not like. Check if it is cf-compliant by uploading a file here https://pumatest.nerc.ac.uk/cgi-bin/cf-checker.pl. – Robert Wilson May 31 '22 at 08:22
  • Please provide enough code so others can better understand or reproduce the problem. – Community May 31 '22 at 08:44

0 Answers0