read variable lon and lat in group larvae in netcdf4 a.nc
8 次查看(过去 30 天)
显示 更早的评论
I want to read the lat and lon in the group larvae. Is there a way to read this with the buildin function ncread? A ncdump -h of the file a.nc is
ncdump -h a.nc
netcdf a {
dimensions:
lat = 335 ;
lon = 115 ;
level = 9 ;
variables:
float latitudes(lat, lon) ;
float longitudes(lat, lon) ;
// global attributes:
:grid_dimensions = 335L, 115L, 9L ;
group: ocean {
dimensions:
time = UNLIMITED ; // (1 currently)
reltime = 1 ;
variables:
int model_time(time, reltime) ;
float u_velocity(time, level, lat, lon) ;
float v_velocity(time, level, lat, lon) ;
float w_velocity(time, level, lat, lon) ;
float temperature(time, level, lat, lon) ;
float salinity(time, level, lat, lon) ;
// group attributes:
:time_step = 360L ;
:step = 1L ;
} // group ocean
group: larvae {
dimensions:
time = UNLIMITED ; // (1 currently)
reltime = 1 ;
npart = 441 ;
variables:
int model_time(time, reltime) ;
float lat(time, npart) ;
float lon(time, npart) ;
float depth(time, npart) ;
float total_body_burden(time, npart) ;
float mortality(time, npart) ;
float size(time, npart) ;
float weight(time, npart) ;
// group attributes:
:step = 1L ;
} // group larvae
}
2 个评论
回答(1 个)
AJ von Alt
2014-1-20
编辑:AJ von Alt
2014-1-20
You can read a variable 'variablename' in a group '/groupname/' using '/groupname/variablename' as the argument for the varname field in the function ncread.
This code should produce the desired results for an input file 'ncfilename.nc':
lat = ncread( 'ncfilename.nc' , '/larvae/lat')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NetCDF 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!