How to extract data from .nc file based on latitude, longitude, time and temperature?

15 次查看(过去 30 天)
This is my first time trying to pull data from an netCDF file using MATLAB
here's what I did
clear all
close all
ncid = netcdf.open('uwnd.sig995.2016.nc','NC_NOWRITE');
lat = netcdf.getVar(ncid,0);
whos lat
lon = netcdf.getVar(ncid,1);
whos lon
time = netcdf.getVar(ncid,2);
whos time
wind = netcdf.getVar(ncid,3); %var3 wind 4x day
whos wind
I dont know how to extrat one year
and the temperature for these lat lon and time
Any help?
Thx in advance! Regards.
Below the data:
Source:
C:\Users\admin\MATLAB\Projects\ure\my1948.nc
Format:
netcdf4_classic
Global Attributes:
Conventions = 'COARDS'
title = 'mean daily NMC reanalysis (1948)'
description = 'Data is from NMC initialized reanalysis
(4x/day). These are the 0.9950 sigma level values.'
platform = 'Model'
history = 'created 99/05/11 by Hoop (netCDF2.3)
Converted to chunked, deflated non-packed NetCDF4 2014/09'
dataset_title = 'NCEP-NCAR Reanalysis 1'
References = 'http://www.psl.noaa.gov/data/gridded/data.ncep.reanalysis.html'
Dimensions:
lon = 144
lat = 73
time = 366 (UNLIMITED)
Variables:
lat
Size: 73x1
Dimensions: lat
Datatype: single
Attributes:
units = 'degrees_north'
actual_range = [90 -90]
long_name = 'Latitude'
standard_name = 'latitude'
axis = 'Y'
lon
Size: 144x1
Dimensions: lon
Datatype: single
Attributes:
units = 'degrees_east'
long_name = 'Longitude'
actual_range = [0 357.5]
standard_name = 'longitude'
axis = 'X'
time
Size: 366x1
Dimensions: time
Datatype: double
Attributes:
long_name = 'Time'
delta_t = '0000-00-01 00:00:00'
avg_period = '0000-00-01 00:00:00'
standard_name = 'time'
axis = 'T'
units = 'hours since 1800-01-01 00:00:0.0'
actual_range = [1297320 1306080]
air
Size: 144x73x366
Dimensions: lon,lat,time
Datatype: single
Attributes:
long_name = 'mean Daily Air temperature at sigma level 995'
units = 'degK'
precision = 2
least_significant_digit = 1
GRIB_id = 11
GRIB_name = 'TMP'
var_desc = 'Air temperature'
dataset = 'NCEP Reanalysis Daily Averages'
level_desc = 'Surface'
statistic = 'Mean'
parent_stat = 'Individual Obs'
missing_value = -9.969209968386869e+36
actual_range = [188.29 315.3]
valid_range = [185.16 331.16]

回答(1 个)

KSSV
KSSV 2020-7-13
There is a easier netCDF toolbox available. REad about ncdisp, ncread. These two commands are more than enough ti read data from the netCDF file.
ncfile = "C:\Users\admin\MATLAB\Projects\ure\my1948.nc" ;
lon = ncread(ncfile,'lon') ;
lat = ncread(ncfile,'lat') ;
time = ncread(ncfile,'time') ;
air = ncread(ncfile,'air') ;
  4 个评论

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by