爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6871|回复: 2

如何用MATLAB读取批量从laads web上下载的MOD08_M3产品的HDF文件

[复制链接]

新浪微博达人勋

发表于 2016-4-16 22:23:56 | 显示全部楼层 |阅读模式
MATLAB
问题截图:
问题概况: 如何用MATLAB读取批量从laads web上下载的MOD08_M3(月平均数据)产品的HDF文件,每个文件230M左右,绘出多个月AOD值得变化曲线。类似下面这样(这是别人做的,我不会)
我看过提问的智慧: 看过
自己思考时长(天): 2
系统平台: MATLAB

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

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

x
看别人论文是这样写的:
本文所用的大气气溶胶光学厚度月平均数据的数据集为Optical_Depth_Land_And_Ocean_Mean_Mean: Aerosol Optical Thickness at 0.55 microns for both Ocean (best) and land (corrected):Mean of Daily Mean,数据处理平台为MATLAB
MYD08_M3.A2003001.051.2008335065851.hdf为例,将Optical_Depth_Land_And_Ocean_Mean_Mean导入MATLAB   
Optical_Depth_Land_And_Ocean_Mean_Mean = hdfread (' MYD08_M3.A2003001.051.2008335065851.hdf', '/mod08/Data Fields/Optical_Depth_Land_And_Ocean_Mean_Mean', 'Index', {[1  1],[1  1],[180  360]});
Optical_Depth_Land_And_Ocean_Mean_Mean中的数值与气溶胶光学厚度值的对应关系为:
Optical_Depth_MO_Value=Optical_Depth_Land_And_Ocean_Mean_Mean
*scale_factor                             (3-3)
式中Optical_Depth_MO_Value为月平均气溶胶光学厚度值, scale_factor为常数,值为0.001
本文对MYD08_M3数据进行了提取和处理,分别从月分布、季节分布及AOD值比例分布三方面分析了2003年至201210年间AOD的变化。
应该是我没看懂,我照着做总报错,求指导
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-4-17 09:48:22 | 显示全部楼层
批量读取nc文件的方法:
clc;  %清屏
clear; %清空
datadir='D:\data\降水数据\CPC Unified Gauge-Based Analysis of Daily Precipitation over CONUS\'; %指定批量数据所在的文件夹
filelist=dir([datadir,'*.nc']); %指定批量数据的类型
a=filelist(1).name; %查看你要读取的文件的编号。filelist(1).name在window下为第一个标号数据
b=filelist(2).name; %查看你要读取的文件的编号。filelist(2).name在window下为第二个标号数据
k=length(filelist);
for s=1:k
  filename=[datadir,filelist(s).name];
  ncid=netcdf.open(filename,'NC_NOWRITE');
  ncdisp('D:\data\降水数据\CPC Unified Gauge-Based Analysis of Daily Precipitation over CONUS\precip.V1.0.1948.nc'); %在命令窗中显示nc文件的变量
  %任意取其中一个来看数据中所包含的变量特征,以为下面读取数据变量做铺垫
  % ncid = netcdf.open('D:\data\降水数据\CPC Unified Gauge-Based Analysis of Daily Precipitation over CONUS\precip.V1.0.1948.nc','NOWRITE'); %打开nc文件
  % ncdisp('D:\data\降水数据\CPC Unified Gauge-Based Analysis of Daily Precipitation over CONUS\precip.V1.0.1948.nc'); %在命令窗中显示nc文件的变量
  PrecipData  = ncread(filename,'precip'); %读入变量precip
  TimeData  = ncread(filename,'time'); %读入变量time
  LonData  = ncread(filename,'lon'); %读入变量lon
  LatData  = ncread(filename,'lat'); %读入变量lat
  netcdf.close(ncid);   % 关闭文件
end;

这是.nc格式文件批处理的程序 .hdf也类似,楼主可以参考一下。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-4-18 10:27:03 | 显示全部楼层
xiao豆豆 发表于 2016-4-17 09:48
批量读取nc文件的方法:
clc;  %清屏
clear; %清空

首先感谢你的回答,可能我是小白,大致改了一下还是报错,程序如下:
clc;  %清屏
clear; %清空
datadir='D:\Data Fields\MODISTerra Aerosol Cloud Water Vapor Ozone Daily L3 Global 1Deg CMG\'; %指定批量数据所在的文件夹
filelist=dir([datadir,'*.hdf']); %指定批量数据的类型
a=filelist(1).name; %查看你要读取的文件的编号。filelist(1).name在window下为第一个标号数据
b=filelist(2).name; %查看你要读取的文件的编号。filelist(2).name在window下为第二个标号数据
k=length(filelist);
for s=1:k
  filename=[datadir,filelist(s).name];
  sd_id=hdfread('D:\Data Fields\MODISTerra Aerosol Cloud Water Vapor Ozone Daily L3 Global 1Deg CMG\MOD08_M3.A2006001.051.2010307062519.hdf',datadir);
  hdfdisp('D:\Data Fields\MODISTerra Aerosol Cloud Water Vapor Ozone Daily L3 Global 1Deg CMG\MOD08_M3.A2006001.051.2010307062519.hdf');
  PrecipData  = hdfread(filename,'precip'); %读入变量precip
  TimeData  = hdfread(filename,'time'); %读入变量time
  LonData  = hdfread(filename,'lon'); %读入变量lon
  LatData  = hdfread(filename,'lat'); %读入变量lat
  netcdf.close(ncid);   % 关闭文件
end;
如果方便的话,请帮我看看
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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