Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Variables in MFDataset are missing name attribute #1153

Closed
jblarsen opened this issue Feb 14, 2022 · 1 comment
Closed

Some Variables in MFDataset are missing name attribute #1153

jblarsen opened this issue Feb 14, 2022 · 1 comment

Comments

@jblarsen
Copy link

The example code below fails with an AttributeError that "name" does not exist for the time variable in the MFDataset. In a more realistic dataset I noticed that the "name" attribute was present for the latitude and longitude variables which were not aggregated but not present for the time variable and air temperature.

import netCDF4

f1 = 'test1.nc'
f2 = 'test2.nc'

nc1 = netCDF4.Dataset(f1, 'w', format='NETCDF4_CLASSIC')
nc2 = netCDF4.Dataset(f2, 'w', format='NETCDF4_CLASSIC')

nc1.createDimension('time', None)
t1 = nc1.createVariable('time', "f8", ("time",))
t1[:] = [0]                   
print(t1.name)

nc2.createDimension('time', None)
t2 = nc2.createVariable('time', "f8", ("time",))
t2[:] = [1]                   
print(t2.name)

nc1.close()
nc2.close()

nc = netCDF4.MFDataset([f1, f2])
t = nc.variables['time']          
print(t[:])
print(t._name)
print(t.name)
@jswhit
Copy link
Collaborator

jswhit commented Feb 15, 2022

easy fix (PR #1154)

@jswhit jswhit closed this as completed Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants