python nc group variables

Solutions on MaxInterview for python nc group variables by the best coders in the world

showing results for - "python nc group variables"
Veronica
21 Sep 2018
1import netCDF4
2import numpy as np
3
4str_out = netCDF4.stringtochar(np.array(['test'], 'S4'))
5
6nc = netCDF4.Dataset('./test.nc', 'w', format='NETCDF4_CLASSIC')
7nc.createDimension('lat', 1)
8nc.createDimension('lon', 1)
9nc.createDimension('nchar', 4)
10
11lat = nc.createVariable('lat', 'f4', ('lat',))
12lon = nc.createVariable('lon', 'f4', ('lon',))
13place = nc.createVariable('place', 'S1', ('nchar'))
14
15lat[:] = 17.002
16lon[:] = -81.501
17place[:] = str_out
18
19nc.close()
Sofie
23 Jan 2020
1nc_f0 = Dataset('path_to_nc','r')
2var = nc_f0.groups['group_name'].variables['var_name']
Darren
22 Apr 2016
1# Create the unlimited time dimension:
2dim_t = f.createDimension('time', None)