Friday, March 11, 2016

Matlab: MODIS Products

Introduction

这里整理一些MODIS产品可以通用的代码。
月值数据从文件名称返回年月信息:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% Created by LI Xu
% Version 1.0
% March 11, 2016

% Description:
% Recognize the sample time in YYYYMM format

% If you have any question about this code,
% please do not hesitate to contact me via E-mail: 
% jeremy456@163.com

% Blog:
% http://blog.sciencenet.cn/u/lixujeremy
% http://lixuworld.blogspot.com/

function yymm=ReYYMM(filename)

    yymm=strsplit(filename, '.');
    yymm=yymm{2};
    yymm(1)=[];
    yy=yymm(1:4);
    yy=str2num(yy);
    mm=yymm(end-2:end);
    mm=str2num(mm);
    
    for ii=1:12
        dd=eomday(yy, ii);
        mm=mm-dd;
        if mm<0
            break;
        end
        
    end
    yymm=yy*100+ii;

end

No comments:

Post a Comment