爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 21251|回复: 15

[程序设计] MATLAB读取nc文件的一部分数据

[复制链接]

新浪微博达人勋

发表于 2016-2-11 09:18:37 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
各位大神
老师要求用NCEP再分析资料计算Z850的变化趋势,我在http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis.pressure.html下载了hgt.mon.mean.nc,高度分层是分别是:(单位:mb)
        1000
         925
         850
         700
         600
         500
         400
         300
         250
         200
         150
         100
          70
          50
          30
          20
          10
用MATLAB2013b,只想读850mb的数据(内存不够,读不出来全部
ncid=netcdf.open('F:\data\NCEP\geopotential height_monthly mean\hgt.mon.mean.nc')
geo_850 = netcdf.getVar(ncid,4,[0 0 2 0],[144 73 1 817]);geo850(:,:,:)=geo_850(:,:,1,:);geo850(145,:,:)=geo850(1,:,:);
但是读出来之后和ECMWF的数据差别很大,排除了下载错误,猜测可能是读的不对
恳请各位大神帮忙指点一下错在哪里了呢?
谢谢!
谢谢!
谢谢!
(重要的事情说三遍)

下面是ncdisp的结果
Source:
           F:\大一暑假\NCEP\geopotential height_monthly mean\hgt.mon.mean.nc
Format:
           netcdf4_classic
Global Attributes:
           description = ' Data from NCEP initialized reanalysis (4x/day).  These are interpolated to pressure surfaces from model (sigma) surfaces.'
           platform    = 'Model'
           Conventions = 'COARDS'
           NCO         = '20121012'
           history     = 'Created by NOAA-CIRES Climate Diagnostics Center (SAC) from the NCEP
                         reanalysis data set on 07/07/97 by calc.mon.mean.year.f using
                         /Datasets/nmc.reanalysis.derived/pressure/hgt.mon.mean.nc
                         from /Datasets/nmc.reanalysis/pressure/hgt.79.nc to hgt.95.nc
                         Converted to chunked, deflated non-packed NetCDF4 2014/09'
           title       = 'monthly mean hgt from the NCEP Reanalysis'
           References  = 'http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis.derived.html'
Dimensions:
           level = 17
           lat   = 73
           lon   = 144
           time  = 817   (UNLIMITED)
Variables:
    level
           Size:       17x1
           Dimensions: level
           Datatype:   single
           Attributes:
                       units        = 'millibar'
                       long_name    = 'Level'
                       positive     = 'down'
                       GRIB_id      = 100
                       GRIB_name    = 'hPa'
                       actual_range = [1.00e+03 1.00e+01]
                       axis         = 'Z'
    lat  
           Size:       73x1
           Dimensions: lat
           Datatype:   single
           Attributes:
                       units         = 'degrees_north'
                       actual_range  = [9.00e+01 -9.00e+01]
                       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.00e+00 3.58e+02]
                       standard_name = 'longitude'
                       axis          = 'X'
    time
           Size:       817x1
           Dimensions: time
           Datatype:   double
           Attributes:
                       long_name       = 'Time'
                       delta_t         = '0000-01-00 00:00:00'
                       avg_period      = '0000-01-00 00:00:00'
                       prev_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    = [1.30e+06 1.89e+06]
    hgt  
           Size:       144x73x17x817
           Dimensions: lon,lat,level,time
           Datatype:   single
           Attributes:
                       long_name               = 'Monthly mean geopotential height'
                       valid_range             = [-7.00e+02  3.50e+04]
                       units                   = 'm'
                       add_offset              = 0
                       scale_factor            = 1
                       missing_value           = -9.97e+36
                       precision               = 0
                       least_significant_digit = 0
                       GRIB_id                 = 7
                       GRIB_name               = 'HGT'
                       var_desc                = 'Geopotential height'
                       level_desc              = 'Multiple levels'
                       statistic               = 'Mean'
                       parent_stat             = 'Other'
                       dataset                 = 'NCEP Reanalysis Derived Products'
                       actual_range            = [-3.35e+02  3.23e+04]
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 成长值: 32430
发表于 2016-2-11 12:23:45 | 显示全部楼层
我一般用的是ncread,建议楼主也去试试,还是蛮好用的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-2-11 14:55:16 | 显示全部楼层
二爷名声在外 发表于 2016-2-11 12:23
我一般用的是ncread,建议楼主也去试试,还是蛮好用的

谢谢!刚刚试了一下ncread,不过和原来读出来的数据一样。。。
看来不是读错了。。。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 成长值: 32430
发表于 2016-2-11 15:04:01 | 显示全部楼层
南国的佳人 发表于 2016-2-11 14:55
谢谢!刚刚试了一下ncread,不过和原来读出来的数据一样。。。
看来不是读错了。。。

可以根据help中的参数定义重新进行下后面范围的设置,应该没问题的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-2-11 17:01:13 | 显示全部楼层
你是不是读取的经纬度范围出问题了,核实下数据经纬度的起止
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-2-13 17:55:01 | 显示全部楼层
后续:
谢谢大家在过年期间关注回答
后来我查出问题了,出在别的地方
读数的方法是正确的
谢谢大家
祝大家新的一年开心顺利
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-4-20 21:19:38 | 显示全部楼层
南国的佳人 发表于 2016-2-13 17:55
后续:
谢谢大家在过年期间关注回答
后来我查出问题了,出在别的地方

博主能分享下是哪里出了问题吗
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-4-22 13:38:02 | 显示全部楼层
热爱学习 发表于 2016-4-20 21:19
博主能分享下是哪里出了问题吗

上面的读取数据是对的
是我自己后来计算的时候把数据代错了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-4-22 13:38:07 | 显示全部楼层
热爱学习 发表于 2016-4-20 21:19
博主能分享下是哪里出了问题吗

上面的读取数据是对的
是我自己后来计算的时候把数据代错了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-7-8 11:16:20 | 显示全部楼层
{:5_213:}{:5_213:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表