% %% 真实NDVI时间序列% y = [1459,1594,1479,1345,1714,1813,1654,1668,2375,2766,4348,5446,8045,8489,7373,7158,6205,4613,2401,2076,1045,1568,1459];% yr = iHANTS_chenjiu(y, 'nf',4,   'per',365, 'ts',1:16:353, ...%     'HiLo','Low', 'low',0,  'high',10000, 'scale_factor',0.0001,...%     'fet',500,'dod',0,'looplim',0,'delta',0.5,...%     'double_period',1, 'dynamic_weight',0, 'poly_order',0);%% 读取excel中的 daily NDVI 与 16d NDVI,并绘图clc;clear all;close all;%% 读取存储2019年NDVI数据的exceldata_year = 2019;data_year_str = num2str(data_year);% 存储 所有POI 一年 的CGLS与GLASS产品的FAPAR值、以及POI的LC类型值excel_name = '2019_h27v05_POI_daily_NDVI.xlsx'; % 待读取的excel路径%% 读取 16d NDVINDVI_16d_sheet_name = [data_year_str, '_16d_NDVI'];NDVI_16d_data = xlsread(excel_name, NDVI_16d_sheet_name);NDVI_16d_data = NDVI_16d_data*0.0001; % 比例因子缩放[h1,w1]=size(NDVI_16d_data);ts_16d = 1:16:353;%% 读取 daily NDVINDVI_daily_sheet_name = [data_year_str, '_daily_NDVI'];NDVI_daily_data = xlsread(excel_name, NDVI_daily_sheet_name);[h2,w2]=size(NDVI_daily_data);% 判断是平年还是闰年isLeapYear = (mod(data_year,400)==0)||(mod(data_year,4)==0 && mod(data_year,100)~=0);if isLeapYear==1    ts_daily=1:1:366;else    ts_daily=1:1:365;end%% 读取土地覆被类型LC_sheet_name = 'LC_IGBP';LC_data= xlsread(excel_name, LC_sheet_name);h3=length(LC_data);%% 读取FID,即兴趣点的编号FID_sheet_name = 'FID';FID = xlsread(excel_name, FID_sheet_name);h=min(h1,h2);h=min(h,h3);%% 土地覆被类型存储在一个cell中供索引LC_type_IGBP_cell={'Evergreen Needleleaf Forests','Evergreen Broadleaf Forests','Deciduous Needleleaf Forests',...    'Deciduous Broadleaf Forests','Mixed Forests','Closed Shrublands',...    'Open Shrublands','Woody Savannas','Savannas',...    'Grasslands','Permanent Wetlands','Croplands',...    'Urban and Built-up Lands','Cropland/Natural Vegetation Mosaics','Permanent Snow and Ice',...    'Barren','Water Bodies','Unclassified'};%% 创建存放重建序列的数据矩阵yr_16d = zeros(h1,w1);yr_daily = zeros(h2,w2);%% 循环读取并绘图for poi=1:h    %% 判断该POI的LC类型,确定title    if LC_data(poi)==255        LC_name = LC_type_IGBP_cell{end};    else        LC_name = LC_type_IGBP_cell{LC_data(poi)};    end    %% ihants时间序列重建    nf = 5;    yr_daily(poi,:) = iHANTS_chenjiu( NDVI_daily_data(poi,:),...        'nf',nf,   'per',365, 'ts',1:1:365, ...        'HiLo','Low', 'low',0,  'high',1, 'scale_factor',1, 'delta',0.5,...        'double_period',1, 'dynamic_weight',0, 'poly_order',0);    yr_16d(poi,:) = iHANTS_chenjiu( NDVI_16d_data(poi,:), ...        'nf',nf,   'per',365, 'ts',1:16:353, ...        'HiLo','Low', 'low',0,  'high',1, 'scale_factor',1,'delta',0.5,...        'double_period',1, 'dynamic_weight',0, 'poly_order',0);    %% 绘制时间序列对比图    fig = figure('Visible','off'); % 不显示绘图图窗    set(gcf,'Position',get(0,'ScreenSize')); % 设置绘图为全屏绘制    set(gca,'FontSize',12); % 设置plot横纵轴数字字体大小,注意这是全局字体大小设置,需要在标题大小设置的前面,否则会覆盖    set(gca,'FontName','Times New Roman','FontSize',12,'LineWidth',1.5); % 设置坐标轴的字体和大小    %% 绘制 daily NDVI 的时间序列图    p1=plot(ts_daily,NDVI_daily_data(poi,:),':*k','MarkerSize',6,'MarkerFaceColor','k');         % 'MarkerSize'设置绘图符号的大小;'MarkerFaceColor',设置绘图符号的填充颜色    p1.LineWidth=1;    title_name = ['NDVI Time Series Reconstraction Comparison: Daily vs 16d (POI-',num2str(FID(poi)+1),', ',LC_name,')'];    title(title_name,'fontname','Times New Roman','FontSize',25);        % 字体是Times New Roman,颜色是蓝色('b'即blue),字体大小是20号。    xlabel(['Day of Year(',data_year_str,')'],'FontSize',22);     ylabel('NDVI','FontSize',22); %设置横纵轴名称及字体大小    xlim=[0,366]; ylim=[0,1];    set(gca,'xtick',0:10:360) % handles可以指定具体坐标轴的句柄    set(gca,'ytick',0:0.1:1) % handles可以指定具体坐标轴的句柄    axis([0 366 0 1]);%axis([xmin xmax ymin ymax]),设置绘制区域的范围    %% 绘制 daily NDVI 的重建时间序列图    hold on;    p2=plot(ts_daily,yr_daily(poi,:),'-.ob','MarkerSize',3,'MarkerFaceColor','b');    p2.LineWidth=1;    %% 绘制 16d NDVI 时间序列图    hold on;    p3=plot(ts_16d,NDVI_16d_data(poi,:),'--*g','MarkerSize',6,'MarkerFaceColor','g');    p3.LineWidth=2;    %% 绘制 16d NDVI 重建时间序列图    hold on;    p4=plot(ts_16d,yr_16d(poi,:),'-sr','MarkerSize',6,'MarkerFaceColor','r');    p4.LineWidth=2;    %% 绘制图例    leg=legend({'Original(Daily)',...        'Reconstracted(Daily)',...        'Original(16d)',...        'Reconstracted(16d)'},...        'Location','northeast');            set(leg,'FontName','Times New Roman','FontSize',20,'FontWeight','normal');    %% 写出对比图像    frame = getframe(fig); % 获取frame    img = frame2im(frame); % 将frame变换成imwrite函数可以识别的格式    img_name = ['POI_',num2str(FID(poi)+1),'.jpg']; % 写出到dir_name文件夹中    imwrite(img,img_name); % 保存到工作目录下,名字为img_nameend%% 关闭绘图% close all;