Cannot find variable with ncread
10 views (last 30 days)
Show older comments
Hi, I am trying to extract data from an .nc file using the below code:
ncdisp('Marconi_v02_map_5years.nc')
The output that is given is:
Source:
C:\Users\ekili\Documents\Studie\2021-2022\Kwartiel 4\Building with Nature\Project\MarconiModel_2022\Plots\Marconi_v02_map_5years.nc
Format:
classic
Global Attributes:
institution = 'Deltares'
references = 'http://www.deltares.nl'
source = 'D-Flow FM 1.1.192.50903. Model:'
history = 'Created on 2022-07-01T19:54:36+0200, D-Flow FM'
date_created = '2022-07-01T19:54:36+0200'
date_modified = '2022-07-01T19:54:36+0200'
Conventions = 'CF-1.6 UGRID-1.0/Deltares-0.8'
Dimensions:
nmesh2d_node = 9794
nmesh2d_edge = 20346
nmesh2d_Two = 2
nmesh2d_face = 10553
max_nmesh2d_face_nodes = 4
time = 241 (UNLIMITED)
Variables:
mesh2d
Size: 1x1
Dimensions:
Datatype: int32
Attributes:
cf_role = 'mesh_topology'
long_name = 'Topology data of 2D network'
topology_dimension = 2
node_coordinates = 'mesh2d_node_x mesh2d_node_y'
node_dimension = 'nmesh2d_node'
max_face_nodes_dimension = 'max_nmesh2d_face_nodes'
edge_node_connectivity = 'mesh2d_edge_nodes'
edge_dimension = 'nmesh2d_edge'
edge_coordinates = 'mesh2d_edge_x mesh2d_edge_y'
face_node_connectivity = 'mesh2d_face_nodes'
face_dimension = 'nmesh2d_face'
face_coordinates = 'mesh2d_face_x mesh2d_face_y'
projected_coordinate_system
Size: 1x1
Dimensions:
Datatype: int32
Attributes:
name = 'Unknown projected'
epsg = 0
grid_mapping_name = 'Unknown projected'
longitude_of_prime_meridian = 0
semi_major_axis = 6378137
semi_minor_axis = 6356752.3142
inverse_flattening = 298.2572
EPSG_code = 'EPSG:0'
value = 'value is equal to EPSG code'
mesh2d_node_x
Size: 9794x1
Dimensions: nmesh2d_node
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_x_coordinate'
long_name = 'x-coordinate of mesh nodes'
mesh = 'mesh2d'
location = 'node'
mesh2d_node_y
Size: 9794x1
Dimensions: nmesh2d_node
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_y_coordinate'
long_name = 'y-coordinate of mesh nodes'
mesh = 'mesh2d'
location = 'node'
mesh2d_node_z
Size: 9794x1
Dimensions: nmesh2d_node
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'node'
coordinates = 'mesh2d_node_x mesh2d_node_y'
standard_name = 'altitude'
long_name = 'z-coordinate of mesh nodes'
units = 'm'
grid_mapping = ''
_FillValue = -999
mesh2d_edge_nodes
Size: 2x20346
Dimensions: nmesh2d_Two,nmesh2d_edge
Datatype: int32
Attributes:
cf_role = 'edge_node_connectivity'
mesh = 'mesh2d'
location = 'edge'
long_name = 'Mapping from every edge to the two nodes that it connects'
start_index = 1
_FillValue = -999
mesh2d_edge_x
Size: 20346x1
Dimensions: nmesh2d_edge
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_x_coordinate'
long_name = 'characteristic x-coordinate of the mesh edge (e.g., midpoint)'
mesh = 'mesh2d'
location = 'edge'
bounds = 'mesh2d_edge_x_bnd'
mesh2d_edge_y
Size: 20346x1
Dimensions: nmesh2d_edge
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_y_coordinate'
long_name = 'characteristic y-coordinate of the mesh edge (e.g., midpoint)'
mesh = 'mesh2d'
location = 'edge'
bounds = 'mesh2d_edge_y_bnd'
mesh2d_edge_x_bnd
Size: 2x20346
Dimensions: nmesh2d_Two,nmesh2d_edge
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_x_coordinate'
long_name = 'x-coordinate bounds of 2D mesh edge (i.e. end point coordinates)'
mesh = 'mesh2d'
location = 'edge'
mesh2d_edge_y_bnd
Size: 2x20346
Dimensions: nmesh2d_Two,nmesh2d_edge
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_y_coordinate'
long_name = 'y-coordinate bounds of 2D mesh edge (i.e. end point coordinates)'
mesh = 'mesh2d'
location = 'edge'
mesh2d_face_nodes
Size: 4x10553
Dimensions: max_nmesh2d_face_nodes,nmesh2d_face
Datatype: int32
Attributes:
cf_role = 'face_node_connectivity'
mesh = 'mesh2d'
location = 'face'
long_name = 'Mapping from every face to its corner nodes (counterclockwise)'
start_index = 1
_FillValue = -999
mesh2d_face_x
Size: 10553x1
Dimensions: nmesh2d_face
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_x_coordinate'
long_name = 'Characteristic x-coordinate of mesh face'
mesh = 'mesh2d'
location = 'face'
bounds = 'mesh2d_face_x_bnd'
mesh2d_face_y
Size: 10553x1
Dimensions: nmesh2d_face
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_y_coordinate'
long_name = 'Characteristic y-coordinate of mesh face'
mesh = 'mesh2d'
location = 'face'
bounds = 'mesh2d_face_y_bnd'
mesh2d_face_x_bnd
Size: 4x10553
Dimensions: max_nmesh2d_face_nodes,nmesh2d_face
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_x_coordinate'
long_name = 'x-coordinate bounds of 2D mesh face (i.e. corner coordinates)'
mesh = 'mesh2d'
location = 'face'
_FillValue = -999
mesh2d_face_y_bnd
Size: 4x10553
Dimensions: max_nmesh2d_face_nodes,nmesh2d_face
Datatype: double
Attributes:
units = 'm'
standard_name = 'projection_y_coordinate'
long_name = 'y-coordinate bounds of 2D mesh face (i.e. corner coordinates)'
mesh = 'mesh2d'
location = 'face'
_FillValue = -999
mesh2d_edge_type
Size: 20346x1
Dimensions: nmesh2d_edge
Datatype: int32
Attributes:
mesh = 'mesh2d'
location = 'edge'
coordinates = 'mesh2d_edge_x mesh2d_edge_y'
cell_methods = 'nmesh2d_edge: mean'
standard_name = ''
long_name = 'edge type (relation between edge and flow geometry)'
units = ''
_FillValue = -999
flag_values = [0 1 2 3]
flag_meanings = 'internal_closed internal boundary boundary_closed'
mesh2d_flowelem_ba
Size: 10553x1
Dimensions: nmesh2d_face
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = 'cell_area'
long_name = ''
units = 'm2'
grid_mapping = ''
_FillValue = -999
mesh2d_flowelem_bl
Size: 10553x1
Dimensions: nmesh2d_face
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = 'altitude'
long_name = 'flow element center bedlevel (bl)'
units = 'm'
grid_mapping = ''
_FillValue = -999
time
Size: 241x1
Dimensions: time
Datatype: double
Attributes:
standard_name = 'Time'
units = 'seconds since 2012-01-01 00:00:00'
timestep
Size: 241x1
Dimensions: time
Datatype: double
Attributes:
long_name = 'Latest computational timestep size in each output interval'
units = 's'
mesh2d_Numlimdt
Size: 10553x241
Dimensions: nmesh2d_face,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = ''
long_name = 'Number of times flow element was Courant limiting'
units = '1'
grid_mapping = ''
_FillValue = -999
mesh2d_s1
Size: 10553x241
Dimensions: nmesh2d_face,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = 'sea_surface_height'
long_name = 'Water level'
units = 'm'
grid_mapping = ''
_FillValue = -999
mesh2d_waterdepth
Size: 10553x241
Dimensions: nmesh2d_face,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = 'sea_floor_depth_below_sea_surface'
long_name = 'Water depth at pressure points'
units = 'm'
grid_mapping = ''
_FillValue = -999
mesh2d_s0
Size: 10553x241
Dimensions: nmesh2d_face,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = 'sea_surface_height'
long_name = 'Water level on previous timestep'
units = 'm'
grid_mapping = ''
_FillValue = -999
mesh2d_u1
Size: 20346x241
Dimensions: nmesh2d_edge,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'edge'
coordinates = 'mesh2d_edge_x mesh2d_edge_y'
cell_methods = 'nmesh2d_edge: mean'
standard_name = ''
long_name = 'Normal velocity at velocity point'
units = 'm s-1'
grid_mapping = ''
_FillValue = -999
comment = 'Positive direction is from first to second neighbouring face (flow element).'
mesh2d_u0
Size: 20346x241
Dimensions: nmesh2d_edge,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'edge'
coordinates = 'mesh2d_edge_x mesh2d_edge_y'
cell_methods = 'nmesh2d_edge: mean'
standard_name = ''
long_name = 'Normal velocity at velocity point at previous time step'
units = 'm s-1'
grid_mapping = ''
_FillValue = -999
comment = 'Positive direction is from first to second neighbouring face (flow element).'
mesh2d_ucx
Size: 10553x241
Dimensions: nmesh2d_face,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = 'sea_water_x_velocity'
long_name = 'Flow element center velocity vector, x-component'
units = 'm s-1'
grid_mapping = ''
_FillValue = -999
mesh2d_ucy
Size: 10553x241
Dimensions: nmesh2d_face,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = 'sea_water_y_velocity'
long_name = 'Flow element center velocity vector, y-component'
units = 'm s-1'
grid_mapping = ''
_FillValue = -999
mesh2d_q1
Size: 20346x241
Dimensions: nmesh2d_edge,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'edge'
coordinates = 'mesh2d_edge_x mesh2d_edge_y'
cell_methods = 'nmesh2d_edge: mean'
standard_name = 'discharge'
long_name = 'Discharge through flow link at current time'
units = 'm3 s-1'
grid_mapping = ''
_FillValue = -999
comment = 'Positive direction is from first to second neighbouring face (flow element).'
mesh2d_taus
Size: 10553x241
Dimensions: nmesh2d_face,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = ''
long_name = 'Total bed shear stress'
units = 'N m-2'
grid_mapping = ''
_FillValue = -999
mesh2d_czs
Size: 10553x241
Dimensions: nmesh2d_face,time
Datatype: double
Attributes:
mesh = 'mesh2d'
location = 'face'
coordinates = 'mesh2d_face_x mesh2d_face_y'
cell_methods = 'nmesh2d_face: mean'
standard_name = ''
long_name = 'Chezy roughness'
units = 'm0.5s-1'
grid_mapping = ''
_FillValue = -999
Where from above I want to extraxt 'mesh2d_taus'.
tau = ncread('Marconi_v02_his_5years.nc','mesh2d_taus')
Which gives the following error:
Error using internal.matlab.imagesci.nc/getGroupAndVarid
Could not find variable or group 'mesh2d_taus' in file.
Error in internal.matlab.imagesci.nc/read (line 632)
[gid, varid] = getGroupAndVarid(this, location);
Error in ncread (line 74)
vardata = ncObj.read(varName, varargin{:});
Error in plotthindams (line 5)
tau = ncread('Marconi_v02_his_5years.nc','mesh2d_taus')
Does anyone know how to extract the variable?
1 Comment
dpb
on 2 Jul 2022
Can you read any variable?
We'd have to have the file to try out anything here...attach it w/ paperclip icon.
Answers (1)
Ayush Kumar Jaiswal
on 2 Jul 2022
You are using different file name to retrieve contents. It should instead be:
tau = ncread('Marconi_v02_map_5years.nc','mesh2d_taus')
0 Comments
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!