Display data of a particular variable present in a netcdf file
Show older comments
Hello people!
I am a newbie in MATLAB who has just started to use for the past month or so am facing issue while learning to work with oceanic netcdf files for my project purpose.
I have a netcdf file as an output from my oceanographic simulation and I want to get a single ouput for a particular variable from my output file for a specific latitude longitude, time index and depth.
eg: I want to get the value of u momentum velocity from the variable u for latitude "-8.22426367031282" and longitude "115.309657931722" , level index = 1 (for my s_rho value) , and a specific oceantime say " 01-Apr-2008-15:00:00" or any such timestep, when I input all these values say u_vel[115.309657931722 ,-8.22426367031282, 1 , '01-Apr-2008-15:00:00'] , I hope to get an ouput like 0.25477523 (any units).
Here are my dimension of the output file and the variable:
Output file: Dimensions:
xi_rho = 100
xi_u = 99
xi_v = 100
xi_psi = 99
eta_rho = 50
eta_u = 50
eta_v = 49
eta_psi = 49
N = 15
s_rho = 15
s_w = 16
tracer = 1
boundary = 4
ocean_time = 7 (UNLIMITED)
u
Size: 99x50x15x273
Dimensions: xi_u,eta_u,s_rho,ocean_time
Datatype: single
Attributes:
long_name = 'u-momentum component'
units = 'meter second-1'
time = 'ocean_time'
grid = 'grid'
location = 'edge1'
coordinates = 'lon_u lat_u s_rho ocean_time'
v
Size: 100x49x15x7
Dimensions: xi_v,eta_v,s_rho,ocean_time
Datatype: single
Attributes:
long_name = 'v-momentum component'
units = 'meter second-1'
time = 'ocean_time'
grid = 'grid'
location = 'edge2'
coordinates = 'lon_v lat_v s_rho ocean_time'
field = 'v-velocity, scalar, series'
I wrote a code for an attempt but every time I execute my MATLAB crashes and also I am not sure if what I am doing will give me any result as well: If anybody please suggest me the right script for my intended job, that would be of great great help.
file = 'Lombok_roms_his.nc';
latitude = ncread(file,'lat_u');
longitude = ncread(file,'lon_u');
mask = ncread(file,'mask_rho');
time = ncread(file,'ocean_time');
u_vel = ncread(file,'u');
v_vel = ncread(file,'v');
%% this is the part which I try to exceute in command window%%
u_vel[115.309657931722 ,-8.22426367031282, 1 , '01-Apr-2008-15:00:00']
v_vel[115.309657931722 ,-8.22426367031282, 1 , '01-Apr-2008-15:00:00']
Accepted Answer
More Answers (0)
Categories
Find more on Coordinate Reference Systems 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!
