python - How to convert from multidimensional data nc file data to three column format -
does can me, read data .nc (netcdf) file in matlab r2013b. , kind of variable
variables: time size: 1x1 dimensions: time datatype: double attributes: units = 'hours since 0001-01-01 01:00:00.0' calendar = 'gregorian' latitude size: 801x1 dimensions: latitude datatype: single attributes: units = 'degrees_north' longitude size: 1501x1 dimensions: longitude datatype: single attributes: units = 'degrees_east' den size: 1501x801x1 dimensions: longitude,latitude,time datatype: single attributes: least_significant_digit = 1 long_name = 'density' units = 'density index' hgh size: 1501x801x1 dimensions: longitude,latitude,time datatype: single attributes: least_significant_digit = 1 long_name = 'high level' units = 'm' ....etc
and need format this:
longitude, latitude = den .... .... ... .... .... ... .... .... ...
to of data.
i can read every single variable longitude or den, such den , hgh has 3 dimensional don't know how merge longitude, latitude , value in den or hgh.
do have suggestion, in case if have solution in python or r please give way read nc file also.
thanks in advance
edit: typos
i'd recommend python this.
import netcdf4 filename = '/your/filename.nc' # read in file ncfile = netcdf4.dataset(filename, 'r') lat = ncfile.variables['latitude'][:,0] lon = ncfile.variables['longitude'][:,0] den = ncfile.variables['den'][:,:,0] nlat, nlon = len(lat), len(lon) # den 2d y in range(nlat): x in range(nlon): print('lat:{0}, lon:{1}, den:{2}'.format(lat[y], lon[x], den[x,y])) ncfile.close()
Comments
Post a Comment