├── About LandMOD ET Mapper.pdf ├── DailyREF_ET_image.m ├── FVC_fromNDVI.m ├── FindCandidate_Ag_pixels.m ├── FindHotColdPixelsImage.m ├── LandMODETMapper.fig ├── LandMODETMapper.m ├── METRIC.m ├── MakeLatLongridsFromGeotiffInfo.m ├── NetImageTimeSolarRadiation.m ├── Psih_SEBAL.m ├── Psim_SEBAL.m ├── README.md ├── SEBAL.m ├── Skin_evapAllen.m ├── allcomb.m ├── graph_img.m └── hourlyREF_ET_image.m /About LandMOD ET Mapper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishan3/LandModETmapper/39a47f8a97c4ce595cd65e9bb9f7c8f9bbdf813e/About LandMOD ET Mapper.pdf -------------------------------------------------------------------------------- /DailyREF_ET_image.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishan3/LandModETmapper/39a47f8a97c4ce595cd65e9bb9f7c8f9bbdf813e/DailyREF_ET_image.m -------------------------------------------------------------------------------- /FVC_fromNDVI.m: -------------------------------------------------------------------------------- 1 | function [FVC] = FVC_fromNDVI(landsattype,ndvi, Ag_filter, Igood,ndviupperlimit,ndvilowerlimit,ff_open) 2 | %% This function comoutes FVC based on Carlson and Ripley; 3 | % AGfilter is a binay map (1= ag, 0= non ag) 4 | % Igood = cloud binary, 1=good no cloud 5 | %ff_open = min size allowed in terms of pixels 6 | % landsattype = 5; 7 | 8 | % written by Nishan Bhattarai, nbhattar@syr.edu/nbhattar@umich.edu 9 | % Date: Nov 5, 2015 10 | %% filter edges of agricultural field by removing edges- Homogenity in NDVI pixels 11 | if isnan(nanmean(nanmean(ndvi)))==1 12 | FVC = NaN(size(ndvi)); 13 | else 14 | 15 | if landsattype ==7 16 | NHOOD = ones(3,3); 17 | h=fspecial('average', [3 3]); 18 | else 19 | NHOOD = ones(7,7); 20 | h=fspecial('average', [7 7]); 21 | end 22 | OutSDndvi= stdfilt(ndvi, NHOOD); 23 | % figure(),imagesc(OutSDndvi);colorbar; title ('SD-NDVI'); 24 | OutMnndvi= imfilter(ndvi, h); 25 | % figure(),imagesc(OutMnndvi);colorbar; title ('Mean-NDVI'); 26 | 27 | OutCVndvi = 100* OutSDndvi./OutMnndvi; 28 | % figure(); imagesc(OutCVndvi);caxis ([0 100]);colorbar; title ('CV-NDVI'); 29 | % 30 | % 31 | % figure(); imagesc(ndvi);caxis ([0 1]);colorbar; 32 | 33 | % CV > 10% is consiered mixed pixel. 34 | [m,n] = size(ndvi); 35 | ndvi_filter = zeros(m,n); 36 | % ndvi_filter (OutCVndvi <15 & lst < 305) = 1; 37 | % ndvi_filter (Ag_filter==1 & lst > 305) = 1; 38 | ndvi_filter (OutCVndvi <15) = 1; 39 | ndvi_filter (Ag_filter==1) = 1; 40 | 41 | ndvi_filter (ndvi < 0.05) = 0; % a minimum value of 0.1 is allowed. 42 | 43 | %figure(); imagesc(ndvi_filter);colorbar; 44 | 45 | %% Now work with the cloud mask data 46 | % figure();imagesc(Igood);colorbar; % Igood =1= good, Igood=0 = cloud 47 | 48 | cloudarea = zeros(m,n); 49 | cloudarea(Igood==0)=1; 50 | cloudarea = imdilate(cloudarea,strel('square', 7)); 51 | 52 | Igood1 = ones(m,n); 53 | Igood1(cloudarea==1)=0; 54 | 55 | % %[m,n] = size(Igood); 56 | % Mask = ones(7,7); 57 | % [a,b] = size (Mask); 58 | % % [x,y] = size(Igood); 59 | % 60 | % [m,n] = size(Igood); 61 | % Igood1 = ones(m,n); 62 | % % flagr 7x7 pixels around cloud as cloud 63 | % for i=1+(a-1)/2:(m-(a-1)/2); 64 | % for j= 1+(b-1)/2:(n-(b-1)/2); 65 | % if Igood(i,j) == 0; 66 | % Igood1(i-(a-1)/2:i+(a-1)/2, j-(a-1)/2:j+(a-1)/2) = 0; 67 | % else 68 | % Igood1(i,j)=1; 69 | % end 70 | % end 71 | % end 72 | % 73 | % figure();imagesc(Igood);colorbar; 74 | % figure();imagesc(Igood1);colorbar; 75 | % figure();imagesc(ndvi);colorbar; 76 | 77 | %% FInd the intersection of all crieteria 78 | % multiply CLassified binary images with conditions and agricultural land 79 | All_fil = double(Ag_filter .* (ndvi_filter .*Igood1)); 80 | 81 | % bw_1 = bwlabel(All_fil); 82 | % remove cells having pixels less than 20 83 | bw_1= bwareaopen(All_fil,ff_open,8); 84 | 85 | %% Now make histograms of NDVI and get top 1% and bottom 1% for FVC 86 | ndvi_new = ndvi .* bw_1; 87 | ndvi_new(ndvi_new ==0)= NaN; 88 | % ndvi_new(disMat > dis_allowed) = NaN; 89 | 90 | % adjust upper and lower NDVI limits according to the image 91 | ndviupperlimit = min(ndviupperlimit,max(max(ndvi_new))); %lstupperlimit is usually larger- Also ignores extreme values 92 | ndvilowerlimit = max(ndvilowerlimit,nanmin(nanmin(ndvi_new))); %lstlowerlimit is usually smaller - Also ignores extreme low values 93 | 94 | ndvi_new(ndvi_new >ndviupperlimit)= NaN; % limit the ndvi value to ndviupperlimit. 95 | 96 | % imagesc(ndvi_new);caxis([0 1]); colorbar; title('NDVI values for filtered Ag pixels'); 97 | 98 | 99 | [m,n] = size(ndvi); 100 | matrixA_n = reshape(ndvi_new,m*n,1); 101 | 102 | % list unique, non NaN ndvi values in ascending order 103 | % ndvi_list = un_sort_ndvi(1:ccn_ndvi,1); 104 | % ndviupperlimit = 0.85;ndvilowerlimit = 0.05; 105 | ndvi_bins = ndvilowerlimit:0.01:ndviupperlimit; 106 | 107 | % NDVI bins and counts 108 | % [counts_n,centers_n] = hist(un_sort_ndvi,ndvi_bins); 109 | [counts_n,centers_n] = hist(matrixA_n,ndvi_bins); 110 | cent_counts_n = horzcat(centers_n',counts_n'); 111 | 112 | [ind1,~] = find(cent_counts_n(:,2) > 50); % select bins that have atleast 50 pixels 113 | cent_counts_n1 = cent_counts_n(ind1,:); 114 | 115 | if isempty(ind1) ==1 116 | [ind1,~] = find(cent_counts_n(:,2) > 25); % select bins that have atleast 25 pixels 117 | cent_counts_n1 = cent_counts_n(ind1,:); 118 | 119 | end 120 | 121 | if isempty(ind1) ==1 122 | [ind1,~] = find(cent_counts_n(:,2) > 10); % select bins that have atleast 10 pixels 123 | cent_counts_n1 = cent_counts_n(ind1,:); 124 | 125 | end 126 | 127 | if isempty(ind1) ==1 128 | [ind1,~] = find(cent_counts_n(:,2) > 5); % select bins that have atleast 5 pixels 129 | cent_counts_n1 = cent_counts_n(ind1,:); 130 | 131 | end 132 | 133 | 134 | 135 | % 136 | % figure(); 137 | % hist(matrixA_n,ndvi_bins); 138 | % title ('NDVI from candidate pixels','FontName','Times','fontsize', 20); 139 | % xlabel('NDVI','FontName','Times','fontsize', 20); 140 | % 141 | 142 | % Get maxNDVI- top1% 143 | ind1_couN = length(cent_counts_n1); % total count 144 | ind1_topN = ceil(1/100 * ind1_couN); % 1% count 145 | 146 | if ind1_topN ==1 147 | maxndvi_list = cent_counts_n1 (end, 1); % max ndvi 148 | else 149 | maxndvi_list = cent_counts_n1 (end-ind1_topN:end, 1); % max ndvi 150 | end 151 | % Get minNDVI- bottom1% 152 | minndvi_list = cent_counts_n1 (1:ind1_topN, 1); % min ndvi 153 | 154 | max_ndvi = mean(maxndvi_list); % full cover 155 | min_ndvi = mean(minndvi_list); % soil 156 | 157 | %FVC 158 | FVC = ((ndvi-min_ndvi) ./(max_ndvi-min_ndvi)).^2; 159 | 160 | FVC(FVC>1)=1; 161 | FVC(FVC<0)=0; 162 | %FVC(Iwater==1)=0; % 0 for water 163 | 164 | %figure(); imagesc(FVC);colorbar; 165 | %figure(); imagesc(ndvi);colorbar; 166 | end 167 | 168 | end 169 | 170 | -------------------------------------------------------------------------------- /FindCandidate_Ag_pixels.m: -------------------------------------------------------------------------------- 1 | function [bw_1] = FindCandidate_Ag_pixels(lst, ndvi, albedo, Ag_filter, Igood,landsattype,lstupperlimit,lstlowerlimit,ff_open) 2 | 3 | %% This is a part of the code published in https://www.sciencedirect.com/science/article/pii/S0034425717302018 4 | % written by- Nishan Bhattarai (University of Michigan) 5 | % Contact: nbbhattar@umich.edu/nbhattar@syr.edu) 6 | % This code find candidate pixels within an image that are further filtered 7 | % to identify hot and cold pixels in SEBAL/METRIC Model. 8 | %% ### Citation ################################################################################## 9 | % Bhattarai, Nishan, Lindi J. Quackenbush, Jungho Im, and Stephen B. Shaw. 10 | % "A new optimized algorithm for automating endmember pixel selection in the SEBAL and METRIC models." 11 | % Remote Sensing of Environment 196 (2017): 178-192. 12 | % https://www.sciencedirect.com/science/article/pii/S0034425717302018 13 | %% #################################################################### 14 | %% OUTPUT 15 | %bw_1: good area for finding potential hot and cold pixels 16 | 17 | %% INPUT 18 | % landsattype: 0;5 or 7, 0 = MODIS 19 | % lst: lst in K 20 | % ndvi: ndvi (unitless) 21 | % albedo: albedo (unitless) 22 | % Ag_filter: Binary map (1= ag, 0= no ag) 23 | % lstupperlimit: upper max value of lst K), default is 330K 24 | % lstlowerlimit: min value of lst (K), default is 275 K 25 | % Igood= cloud filter, 1=good, 0 = cloud 26 | % ff_open : number of pixels for removing small areas; if the pixel 27 | % size is large, this value is smaller, default is 50 (Landsat), 10 for 28 | % MODIS 29 | %% Check number of inputs and use defaults if necessary 30 | if nargin > 9 31 | error('myfuns:somefun2:TooManyInputs', ... 32 | 'requires at most 9 (5 optional) inputs'); 33 | end 34 | 35 | % define defualts values 36 | defaults = {0,330, 275, 50}; 37 | switch nargin 38 | case 5 39 | [landsattype, lstupperlimit, lstlowerlimit, ff_open] = defaults{:}; 40 | case 6 41 | [lstupperlimit, lstlowerlimit, ff_open] = defaults{2:end}; 42 | case 7 43 | [lstlowerlimit,ff_open] = defaults{3:end}; 44 | case 8 45 | ff_open = defaults{end}; 46 | end 47 | 48 | % area to open- choose small area for MODIS 49 | if landsattype ==0 50 | ff_open = 10; 51 | 52 | end 53 | 54 | [m,n] = size(lst); 55 | % figure(); imagesc(Ag_filter);colorbar; 56 | %figure(); imagesc(lst);caxis([270 330]);colorbar; 57 | %% Homogenity in thermal pixels 58 | if landsattype ==7||landsattype ==8||landsattype ==0 59 | NHOOD = ones(3,3); 60 | % h=fspecial('average', [3 3]); 61 | else 62 | NHOOD = ones(7,7); 63 | % h=fspecial('average', [7 7]); 64 | end 65 | OutSDlst= stdfilt(lst, NHOOD); 66 | %figure(),imagesc(OutSDlst);colorbar; 67 | 68 | % OutMnlst= imfilter(lst, h); 69 | % 70 | % 71 | % OutCVlst = 100* OutSDlst./OutMnlst; 72 | % figure(); imagesc(OutCVlst);caxis ([0 100]);colorbar; title ('CV-LST'); 73 | 74 | % SD > 1K is filtered 75 | lst_filter = zeros(m,n); 76 | 77 | % lst_filter (OutSDlst <1) = 1; 78 | lst_filter (Ag_filter==1)= 1; 79 | lst_filter (OutSDlst >1.5) = 0; 80 | 81 | 82 | %figure(); imagesc(lst_filter);colorbar; 83 | 84 | % lST thresholds 85 | % lst_con = ones(m,n); 86 | lst_filter(lst > lstupperlimit)= 0; 87 | lst_filter(lst < lstlowerlimit)= 0; %probably cloud pixels 88 | 89 | 90 | 91 | %% filter edges of agricultural field by removing edges- Homogenity in NDVI pixels 92 | if landsattype ==7||landsattype ==8||landsattype ==0 93 | NHOOD = ones(3,3); 94 | h=fspecial('average', [3 3]); 95 | else 96 | NHOOD = ones(7,7); 97 | h=fspecial('average', [7 7]); 98 | end 99 | OutSDndvi= stdfilt(ndvi, NHOOD); 100 | % figure(),imagesc(OutSDndvi);colorbar; title ('SD-NDVI'); 101 | 102 | OutMnndvi= imfilter(ndvi, h); 103 | % figure(),imagesc(OutMnndvi);colorbar; title ('Mean-NDVI'); 104 | 105 | OutCVndvi = 100* OutSDndvi./OutMnndvi; 106 | % figure(); imagesc(OutCVndvi);caxis ([0 100]);colorbar; title ('CV-NDVI'); 107 | % 108 | % 109 | % figure(); imagesc(ndvi);caxis ([0 1]);colorbar; 110 | % 111 | 112 | % CV > 10% is consiered mixed pixel. 113 | ndvi_filter = zeros(m,n); 114 | ndvi_filter (Ag_filter==1) = 1; 115 | ndvi_filter (OutCVndvi >25) = 0; 116 | 117 | 118 | ndvi_filter (ndvi < 0.05) = 0; % a minimum value of 0.1 is allowed. 119 | %figure(); imagesc(ndvi_filter);colorbar; 120 | 121 | %% ALbedo threshold and homogenity 122 | alb_th1 = albedo; 123 | alb_th1 (albedo > 0.40)=0; 124 | alb_th1 (albedo < 0.05)=0; 125 | %figure(); imagesc(alb_th1);colorbar; 126 | 127 | 128 | if landsattype ==7||landsattype ==8||landsattype ==0 129 | NHOOD = ones(3,3); 130 | h=fspecial('average', [3 3]); 131 | else 132 | NHOOD = ones(7,7); 133 | h=fspecial('average', [7 7]); 134 | end 135 | OutSDalb= stdfilt(alb_th1, NHOOD); 136 | % figure(),imagesc(OutSDalb);colorbar; title ('SD-NDVI'); 137 | 138 | OutMnalb= imfilter(alb_th1, h); 139 | % figure(),imagesc(OutMnalb);colorbar; title ('Mean-NDVI'); 140 | 141 | OutCValb = 100* OutSDalb./OutMnalb; 142 | % figure(); imagesc(OutCValb);caxis ([0 100]);colorbar; title ('CV-NDVI'); 143 | 144 | 145 | % CV > 10% is consiered mixed pixel. 146 | alb_filter = zeros(m,n); 147 | % alb_filter (OutCValb <15) = 1; 148 | alb_filter (Ag_filter==1) = 1; 149 | alb_filter (OutCValb >25) = 0; 150 | %figure(); imagesc(alb_filter);colorbar; 151 | 152 | %% Now work with the cloud mask data 153 | % figure();imagesc(Igood);colorbar; % Igood =1= good, Igood=0 = cloud 154 | 155 | %[m,n] = size(Igood); 156 | % Mask = ones(7,7); 157 | % [a,b] = size (Mask); 158 | % [x,y] = size(Igood); 159 | % 160 | % [m,n] = size(Igood); 161 | % Igood1 = ones(m,n); 162 | 163 | clouds = zeros(m,n); 164 | clouds (Igood==0) = 1; 165 | 166 | 167 | % 7 by 7 neighborhood pixel around cloud = cloud 168 | [m,n] = size(clouds); 169 | 170 | cloudarea = zeros(m,n); 171 | cloudarea(Igood==0)=1; 172 | 173 | % if landsattype==7 174 | % cloudarea = imdilate(cloudarea,strel('square', 3)); 175 | % else 176 | cloudarea = imdilate(cloudarea,strel('square', 5)); 177 | % end 178 | 179 | Igood1= zeros(m,n); 180 | Igood1(cloudarea ~=1) =1; 181 | clear ('clouds','cloudarea'); 182 | 183 | 184 | % figure();imagesc(Igood);colorbar; 185 | % figure();imagesc(Igood1);colorbar; 186 | 187 | %% FInd the intersection of all crieteria 188 | % multiply CLassified binary images with conditions and agricultural land 189 | mul1 = lst_filter .*alb_filter; 190 | mul2 = double(Ag_filter .* (ndvi_filter .*Igood1)); 191 | 192 | All_fil =mul1 .* mul2; 193 | 194 | % remove small areas 195 | bw_1= bwareaopen(All_fil,ff_open,8); 196 | bw_1(isnan(lst)==1)=0; 197 | 198 | 199 | %figure();imagesc(bw_1); colorbar; title('bw_1'); 200 | %% Find a group of cold pixels 201 | % bw_1(find(lst > lstupperlimit))=NaN; 202 | % bw_1(find(lst > lstlowerlimit))=NaN; 203 | % 204 | % lst_new = lst .* bw_1; 205 | % lst_new(find(lst_new==0)) = NaN; 206 | % figure();imagesc(lst_new); colorbar; title ('lst of selected Ag pixels'); 207 | 208 | % filename = (['lst_selected_',int2str(landsattype),'_',int2str(yeardoy),'.tif']); 209 | % geotiffwrite(filename, lst_new,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 210 | 211 | 212 | 213 | end 214 | 215 | -------------------------------------------------------------------------------- /FindHotColdPixelsImage.m: -------------------------------------------------------------------------------- 1 | function [lsthotx,lsthoty,lstcoldx,lstcoldy,lstcold,lsthot,cent_counts_l1,cent_counts_n1,coldrow,coldcol,hotrow,hotcol,... 2 | per_conLcold, per_conNcold,per_conLhot, per_conNhot,count_lstcold_len,count_lsthot_len,... 3 | min_lstmean,max_ndvimean, max_lstmean,min_ndvimean] = FindHotColdPixelsImage(bw_1,subCx,subCy,pixelsize,... 4 | lst,ndvi,lstupperlimit,lstlowerlimit,ndviupperlimit,ndvilowerlimit,pixellimit_bins,pixellimit_counts,lstwindow, ndviwindow,lststep, ndvistep) 5 | 6 | %% This is a part of the code published in https://www.sciencedirect.com/science/article/pii/S0034425717302018 7 | %% This function automatically finds hot and cold pixel for use in SEBAL/METRIC procedure in an optimized way. 8 | %% This code is the 3rd version (see https://www.sciencedirect.com/science/article/pii/S0034425717302018; section 2.3.2) no nearest station needs to be defined). 9 | % written by- Nishan Bhattarai (University of Michigan) 10 | % Contact: nbbhattar@umich.edu/nbhattar@syr.edu) 11 | 12 | %% ### Citation ################################################################################## 13 | % Bhattarai, Nishan, Lindi J. Quackenbush, Jungho Im, and Stephen B. Shaw. 14 | % "A new optimized algorithm for automating endmember pixel selection in the SEBAL and METRIC models." 15 | % Remote Sensing of Environment 196 (2017): 178-192. 16 | % https://www.sciencedirect.com/science/article/pii/S0034425717302018 17 | %% #################################################################### 18 | 19 | %% INPUT 20 | % bw_1 = selected pixels for ag lands using morphogical operations and some 21 | % preprocessing (1= candidate pixel, 0 = not a candidate pixel). 22 | % disMat = distance from ET station - Not used in this version 23 | % pixellimit_bins = min number of pixels for histogram 24 | % pixellimit_counts = min number of pixels for hot and cold pixel selection 25 | % maxPer and minPer are percentiles of histogram selected for hot and cold 26 | % pixel selection 27 | % subCx and subCy are upper UTMx and UTMy of the input landsat image 28 | % lstwindow and ndviwindow are the values for windows when searching a 29 | % particular lst and ndvi values respectively. 30 | % dis_allowed = 30000; % distance from station in m - Not used in this version 31 | %lststep = bin value of lst used to create LST histograms (default is 0.5 K) 32 | %ndvistep = bin value of NDVI used to create LST histograms (default is 0.01) 33 | 34 | %% OUTPUT 35 | % per_considered, 1st row = cold pixel, 2nd row = hot pixel 36 | % col1 = % LST, col2 = NDVI%, col3 = number of pixels, col4 = lst, col5 = 37 | % NDVI 38 | % lsthotx, lsthoty, are UTMX & UTMY for hot pixel,respectively. 39 | % lstcoldx, lstcoldy, are UTMX & UTMY for cold pixel,respectively. 40 | % cent_counts_l1= LST values and number of pixels, 41 | % cent_counts_n1= NDVI values and number of pixels, 42 | % coldrow,coldcol are row and col for cold pixels, respectively 43 | % hotrow,hotcol are row and col for hot pixels, respectively 44 | % hot_min_dis and cold_min_dis are distances from ET station 45 | 46 | 47 | 48 | %% Use default values if the variables are not defined 49 | if nargin < 6 50 | error('One of six required input is missing'); 51 | end 52 | 53 | %SetDefaultValue(position, argName, defaultValue) 54 | 55 | if nargin < 7 || isempty(lstupperlimit) % lstupper limit 56 | lstupperlimit = 330; 57 | end 58 | 59 | if nargin < 8 || isempty(lstlowerlimit) %lstlowerlimit 60 | lstlowerlimit = 275; 61 | end 62 | if nargin < 9 || isempty(ndvilowerlimit) % 63 | ndvilowerlimit = 0.05; 64 | end 65 | 66 | if nargin < 10 || isempty(ndvilowerlimit) 67 | ndvilowerlimit = 0.05; 68 | end 69 | if nargin < 11 || isempty(pixellimit_bins) 70 | pixellimit_bins = 50; 71 | end 72 | if nargin < 12 || isempty(pixellimit_counts) 73 | pixellimit_counts = 10; 74 | end 75 | 76 | if nargin < 13 || isempty(lstwindow) 77 | lstwindow = 0.25; 78 | end 79 | if nargin < 14 || isempty(ndviwindow) 80 | ndviwindow = 0.01; 81 | end 82 | 83 | if nargin < 15 || isempty(lststep) 84 | lststep = 0.5; 85 | end 86 | 87 | 88 | if nargin < 16 || isempty(ndvistep) 89 | ndvistep = 0.01; 90 | end 91 | 92 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 93 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94 | % Processing Starts 95 | % Ignore the boundry pixels 96 | lst(1,:) = NaN; 97 | lst(:,1)= NaN; 98 | 99 | lst(end,:)= NaN; 100 | lst(:,end) = NaN; 101 | 102 | 103 | 104 | %% LST BINS 105 | [m,n] = size(lst); 106 | lst_new = bw_1 .*lst; 107 | 108 | 109 | lst_new(lst_new ==0) = NaN; 110 | matrixA = reshape(lst_new,m*n,1); 111 | 112 | % adjust upper and lower LST limits according to the image 113 | lstupperlimit = min(lstupperlimit,max(max(matrixA))); %lstupperlimit is usually larger- Also ignores extreme values 114 | lstlowerlimit = max(lstlowerlimit,nanmin(nanmin(matrixA))); %lstlowerlimit is usually smaller - Also ignores extreme low values 115 | 116 | % figure();imagesc(lst_new); colorbar;title('filtered LST values for Ag pixels'); 117 | % figure();imagesc(lst); colorbar;title('LST values for Ag pixels'); 118 | 119 | %LST values in ascending order 120 | sort_lst = sort(matrixA); 121 | % get unique values 122 | un_sort_lst = unique(sort_lst); % for figure 123 | lst_bins = lstlowerlimit:lststep:lstupperlimit; 124 | 125 | %lst bins and counts 126 | [counts,centers] = hist(matrixA,lst_bins); 127 | cent_counts_l = horzcat(centers',counts'); 128 | 129 | % Remove smallareas. % number of pixels limits 130 | % pixellimit_bins = 50; 131 | [ind1,~] = find(cent_counts_l(:,2) > pixellimit_bins); 132 | cent_counts_l1 = cent_counts_l(ind1,:); 133 | 134 | %% NDVI Bins 135 | %NDVI for selected ag pixels 136 | ndvi_new = ndvi .* bw_1; 137 | ndvi_new(ndvi_new ==0)= NaN; 138 | 139 | % adjust upper and lower NDVI limits according to the image 140 | ndviupperlimit = min(ndviupperlimit,max(max(ndvi_new))); %lstupperlimit is usually larger- Also ignores extreme values 141 | ndvilowerlimit = max(ndvilowerlimit,nanmin(nanmin(ndvi_new))); %lstlowerlimit is usually smaller - Also ignores extreme low values 142 | 143 | ndvi_new(ndvi_new >ndviupperlimit)= NaN; % limit the ndvi value to ndviupperlimit. 144 | 145 | % imagesc(ndvi_new);caxis([0 1]); colorbar; title('NDVI values for filtered Ag pixels'); 146 | 147 | 148 | [m,n] = size(ndvi); 149 | matrixA_n = reshape(ndvi_new,m*n,1); 150 | 151 | %ndvi values in ascending order 152 | sort_ndvi = sort(matrixA_n); 153 | % get unique values 154 | un_sort_ndvi = unique(sort_ndvi); % for figure 155 | % ccn_ndvi = length(find(isnan(un_sort_ndvi) ==0)); 156 | 157 | 158 | % list unique, non NaN ndvi values in ascending order 159 | % ndvi_list = un_sort_ndvi(1:ccn_ndvi,1); 160 | % ndviupperlimit = 0.85;ndvilowerlimit = 0.05; 161 | ndvi_bins = ndvilowerlimit:ndvistep:ndviupperlimit; 162 | 163 | % NDVI bins and counts 164 | % [counts_n,centers_n] = hist(un_sort_ndvi,ndvi_bins); 165 | [counts_n,centers_n] = hist(matrixA_n,ndvi_bins); 166 | cent_counts_n = horzcat(centers_n',counts_n'); 167 | 168 | [ind1,~] = find(cent_counts_n(:,2) > pixellimit_bins); 169 | cent_counts_n1 = cent_counts_n(ind1,:); 170 | 171 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 172 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 173 | %% PLOT 174 | % set(0,'DefaultAxesFontSize',20) 175 | % 176 | % % % aa = get(gca,'XTickLabel'); 177 | % % % set(gca,'XTickLabel',aa,'FontName','Times','fontsize',20) 178 | % % % bb = get(gca,'YTickLabel'); 179 | % % % set(gca,'YTickLabel',bb,'FontName','Times','fontsize',20) 180 | % 181 | % figure(); 182 | % mainplot(1,2,1) 183 | % set(gca, 'XTick', ndvi_bins, 'FontName','Times','fontsize', 20); 184 | % hist(matrixA_n,ndvi_bins); 185 | % title ('NDVI from candidate pixels','FontName','Times','fontsize', 20); 186 | % xlabel('NDVI','FontName','Times','fontsize', 20); 187 | % 188 | % % bar(centers_n,100*counts_n./sum(counts_n),.25,'hist'); % <- percentage cum dist 189 | % % ylabel('normalized histogram'); 190 | % 191 | % 192 | % % set(gca, 'YTick', 0:0.1:1.1, 'fontsize', 20); 193 | % 194 | % subplot (1,2,2) 195 | % set(gca, 'XTick', lst_bins,'FontName','Times', 'fontsize', 20); 196 | % hist(matrixA,lst_bins); 197 | % xlabel('\it{T}\rm_s (K)','FontName','Times','fontsize', 20); 198 | % title ('\it{T}\rm_s from candidate pixels','FontName','Times','fontsize', 20); 199 | 200 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 201 | 202 | % % of pixels considered to finding max and min LST values, 1= top 1% and 203 | % bottom 1% values. 204 | % LmaxPer = 20; 205 | % NmaxPer = 10; 206 | % per_conLs = 1:1:LmaxPer; 207 | % per_conNs = 1:1:NmaxPer; 208 | % combs = allcomb(per_conLs,per_conNs); 209 | % combs_len = length(combs); 210 | 211 | %combs = allcomb(per_conLs,per_conNs); 212 | %combs(:,[1,2]) = combs(:,[2,1]); % swap col1 (for lst) and col2(for ndvi) 213 | 214 | 215 | % tic 216 | % pixellimit_counts= 10; 217 | %% FOR COLD PIXEL 218 | % disp('Starting cold pixel selction process.....'); 219 | count_lstcold_len = 0; 220 | ii_min=1; 221 | conMore = 0; % indicates condition when additional % of NDVI or LST or both are need to be added. start with 0 222 | %pixelbin_limit_forcold = pixellimit_bins; 223 | % follwing combination lengths will be modified in the loop 224 | %conMore1 =0; 225 | %conMore2 =0; 226 | coldpixel_countlimit = pixellimit_counts; 227 | sel_per = 10:5:25; % Per in Bins 228 | runcold = 1; 229 | 230 | NmaxPer = sel_per(1,runcold); %start with 10% 231 | LmaxPer = sel_per(1,runcold); %start with 10% 232 | per_conLs = 1:1:LmaxPer; 233 | per_conNs = 1:1:NmaxPer; 234 | combs = allcomb(per_conLs,per_conNs); 235 | combs_len = length(combs); 236 | 237 | inc1 =5; % increment 238 | while count_lstcold_len < coldpixel_countlimit 239 | 240 | % The loop below is for condition when no good cold pixels were found 241 | if ii_min > combs_len && runcold <= 4% the max NDVI can vary by a lot., starting with ii_min <1, i.e. less than combs_len 242 | conMore = 1; 243 | %msgbox('Increase the max % for LST bins (LmaxPer) to cover more LST values'); 244 | %error('myApp:argChk', 'Increase the max percentage value for LST bins (LmaxPer) to cover more LST values') 245 | % pixellimit_counts = 5; 246 | NmaxPer1 = sel_per(1,runcold); % by 5% 247 | LmaxPer1 = sel_per(1,runcold);% by 5% 248 | % disp(['Cold pixels (10) not found within top ',int2str(10), '% NDVI and bottom ', int2str(NmaxPer), '% LST; Hence, increasing search area to ', int2str(NmaxPer1),'% with 1% increment......']); 249 | %modify combs 250 | per_conLs1 = 1:1:LmaxPer1;% [5, 10, 15, 20]; % take top 5% 10% 15% 20% to save some time 251 | per_conNs1 = 1:1:NmaxPer1; 252 | % combs = allcomb(per_conLs1,per_conNs1); 253 | combs = allcomb(per_conLs1,per_conNs1); 254 | % combs(:,[1,2]) = combs(:,[2,1]); 255 | combs_len = length(combs); 256 | %combs_len1 = combs_len; 257 | ii_min = 1; % start again with the new set of max NDVI %ages 258 | % disp(LmaxPer1) 259 | end 260 | 261 | if ii_min >= combs_len && conMore>=1 && runcold >=5 262 | 263 | %Increase LST to 15% (bottom) and NDVI to top 20% (top 20%) 264 | %pixels are found 265 | conMore =2; 266 | %count_lstcold_len = 0; 267 | ii_min=1; % reset 268 | NmaxPer2 = NmaxPer1+inc1; 269 | LmaxPer2 = LmaxPer1+inc1; 270 | %modify combs 271 | per_conLs2 = sel_per(end-1)+inc1:1:LmaxPer2;%sel_per(end-1)+inc1= 25 and then keeps increasing 272 | per_conNs2 = sel_per(end-1)+inc1:1:NmaxPer2; %upto 20% NDVI % 25:1:NmaxPers 273 | % disp(['No sutiable cold pixels: increasing search area to', int2str(NmaxPer2),'% with 1% increment......']); 274 | combs = allcomb(per_conLs2,per_conNs2); 275 | combs_len = length(combs); 276 | %combs_len2 = length(combs); 277 | inc1 = inc1 + 5; % keep adding 5% 278 | end 279 | 280 | if ii_min == combs_len && conMore==2 281 | % msgbox(['No good Cold pixels (10) found within bottom ', int2str(LmaxPer2), 'LST of histogram, decrease pixellimits, check input images and cloud cover']); 282 | break 283 | 284 | end 285 | 286 | per_conLcold = combs(ii_min,1); 287 | per_conNcold = combs(ii_min,2); 288 | 289 | % Now get the top per_con% max and bottom per_con (i.e. min) LST values 290 | ind1_couL = length(cent_counts_l1); 291 | ind1_topL = ceil((per_conLcold * ind1_couL)/100); 292 | 293 | ind1_couN = length(cent_counts_n1); 294 | ind1_topN = ceil(per_conNcold/100 * ind1_couN); 295 | 296 | 297 | % Top per_ndvi% max ndvi value 298 | minlst_list = cent_counts_l1(1:ind1_topL, 1); % min n% LST 299 | 300 | if ind1_topN ==1 301 | maxndvi_list = cent_counts_n1 (end, 1); % max ndvi 302 | else 303 | % ind1_topN_adj = max(size(cent_counts_n1,1)-ind1_topN_adj,1); % avoid 0 indexing 304 | % maxndvi_list = cent_counts_n1 (end-ind1_topN_adj:end, 1); % max ndvi 305 | 306 | maxndvi_list = cent_counts_n1 (end-ind1_topN:end, 1); % max ndvi 307 | end 308 | 309 | % get the mean value 310 | min_lstmean = mean(minlst_list); % get max value out of the minimum list 311 | max_ndvimean = mean(maxndvi_list); 312 | 313 | [uu_c,~] = size(maxndvi_list); 314 | [pp_c, ~] = size(minlst_list); 315 | 316 | % if conMore == 1; 317 | % std_minlst = std(minlst_list); 318 | % min_lstmean = max(minlst_list);%-std_minlst; % get max value out of the minimum list 319 | % end 320 | 321 | if conMore==1 %&& isempty(minlst_list)==0 322 | ind_lstmin = find (bw_1 == 1 & lst < minlst_list(pp_c)+lstwindow & lst > minlst_list(1)-lstwindow..... 323 | & ndvi < maxndvi_list (uu_c)+ ndviwindow & ndvi > maxndvi_list (1)-ndviwindow); 324 | count_lstcold_len = length(ind_lstmin); 325 | 326 | else 327 | ind_lstmin = find (bw_1 == 1 & lst < min_lstmean+ lstwindow & lst > min_lstmean-lstwindow..... 328 | & ndvi < max_ndvimean+ ndviwindow & ndvi > max_ndvimean-ndviwindow); 329 | count_lstcold_len = length(ind_lstmin); 330 | 331 | end 332 | 333 | % if length (ind_lstmin)==1 334 | ii_min = ii_min+1; 335 | % end 336 | % end 337 | 338 | if count_lstcold_len >= coldpixel_countlimit 339 | % disp(['Cold pixels found within bottom ', int2str(per_conLcold), '% LST and top ', int2str(per_conNcold),... 340 | % '% NDVI with LST ~', num2str(min_lstmean),'K and NDVI ~', num2str(max_ndvimean,3)]) 341 | end 342 | 343 | if count_lstcold_len >= coldpixel_countlimit && per_conLcold > 25 344 | % disp('LST from Cold pixels are not within botton 25%, consider modifications to pixel limits, check input images......'); 345 | end 346 | 347 | if count_lstcold_len >= coldpixel_countlimit && per_conNcold > 25 348 | % disp('NDVI from Cold pixels are not within top 25%, consider modifications to pixel limits, check input images......'); 349 | end 350 | 351 | if ii_min == length(combs) % whole combination of %s values tried 352 | runcold = runcold+1; % add 1 353 | end 354 | 355 | end 356 | % disp('.....Selection of cold pixels selction done.'); 357 | % 358 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 359 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 360 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 361 | % disp('starting hot pixel selction process.....'); 362 | %% For hot PIXEL 363 | %Back to original combination- start with 10% (Top) LST 10% NDVI (bottom) 364 | conMore = 0; % indicates condition when additional % of NDVI or LST or both are need to be added. start with 0 365 | %pixelbin_limit_forcold = pixellimit_bins; 366 | %conMore1 =0; 367 | %conMore2 =0; 368 | hotpixel_countlimit = pixellimit_counts; 369 | sel_per = 10:5:25; %Per in Bins 370 | runhot = 1; 371 | 372 | NmaxPer = sel_per(1,runhot); %start with 10% 373 | LmaxPer = sel_per(1,runhot); %start with 10% 374 | per_conLs = 1:1:LmaxPer; 375 | per_conNs = 1:1:NmaxPer; 376 | combs = allcomb(per_conLs,per_conNs); 377 | combs_len = length(combs); 378 | 379 | 380 | count_lsthot_len = 0; 381 | ii_max=1; 382 | inc1 =5; % increment 383 | % tic 384 | while count_lsthot_len < hotpixel_countlimit 385 | % for ii =1:combs_len-1 386 | %ii=ii+1; 387 | if ii_max > combs_len && runhot <= 4% the max NDVI can vary by a lot., starting with ii_min <1, i.e. less than combs_len 388 | conMore = 1; 389 | %msgbox('Increase the max % for LST bins (LmaxPer) to cover more LST values'); 390 | %error('myApp:argChk', 'Increase the max percentage value for LST bins (LmaxPer) to cover more LST values') 391 | % pixellimit_counts = 5; 392 | NmaxPer1 = sel_per(1,runhot); % by 5% 393 | LmaxPer1 = sel_per(1,runhot);% by 5% 394 | % disp(['Hot pixels (10) not found within bottom ',int2str(10), '% NDVI and Top ', int2str(NmaxPer), '% LST; Hence, increasing search area to ', int2str(NmaxPer1),'% with 1% increment......']); 395 | %modify combs 396 | per_conLs1 = 1:1:LmaxPer1;% [5, 10, 15, 20]; % take top 5% 10% 15% 20% to save some time 397 | per_conNs1 = 1:1:NmaxPer1; 398 | % combs = allcomb(per_conLs1,per_conNs1); 399 | combs = allcomb(per_conLs1,per_conNs1); 400 | % combs(:,[1,2]) = combs(:,[2,1]); 401 | combs_len = length(combs); 402 | %combs_len1 = combs_len; 403 | ii_max = 1; % start again with the new set of max NDVI %ages 404 | % disp(LmaxPer1) 405 | end 406 | 407 | if ii_max >= combs_len && conMore >=1 && runhot >=5 408 | %Increase LST to 15% (bottom) and NDVI to top 20% (top 20%) 409 | %pixels are found 410 | conMore =2; 411 | ii_max=1; 412 | NmaxPer2 = NmaxPer1+inc1; 413 | LmaxPer2 = LmaxPer1+inc1; 414 | %modify combs 415 | per_conLs2 = sel_per(end-1)+inc1:1:LmaxPer2;%sel_per(end-1)+inc1= 25 and then keeps increasing 416 | per_conNs2 = sel_per(end-1)+inc1:1:NmaxPer2; %upto 20% NDVI % 25:1:NmaxPers 417 | % disp(['No sutiable Hot pixels: increasing search area to', int2str(NmaxPer2),'% with 1% increment......']); 418 | combs = allcomb(per_conLs2,per_conNs2); 419 | %combs_len2 = length(combs); 420 | combs_len = length(combs); 421 | 422 | inc1 = inc1 + 5; % keep adding by 5% 423 | 424 | end 425 | 426 | % if ii_max == combs_len && conMore==2 427 | % % msgbox(['No good Hot pixels (10) found within top ', int2str(LmaxPer2), 'LST of histogram, decrease pixellimits, check input images and cloud cover']); 428 | % % break 429 | % 430 | % end 431 | % 432 | 433 | per_conLhot = combs(ii_max,1); 434 | per_conNhot = combs(ii_max,2); 435 | 436 | % Now get the top per_con% max and bottom per_con (i.e. min) LST values 437 | ind1_couL = length(cent_counts_l1); 438 | ind1_topL = ceil((per_conLhot * ind1_couL)/100); 439 | 440 | ind1_couN = length(cent_counts_n1); 441 | ind1_topN = ceil(per_conNhot/100 * ind1_couN); 442 | 443 | % Top per_ndvi% max ndvi value 444 | maxlst_list = cent_counts_l1 (end-ind1_topL:end, 1); % min n% LST 445 | minndvi_list = cent_counts_n1 (1:ind1_topN, 1); % min ndvi 446 | 447 | 448 | % get the mean values. 449 | %min_ndvimean = mean(minndvi_list); 450 | min_ndvimean = mean(minndvi_list); 451 | max_lstmean = mean(maxlst_list); 452 | [uu,~] = size(minndvi_list); 453 | [pp, ~] = size(maxlst_list); 454 | 455 | 456 | if conMore == 1 %&& isempty(maxlst_list)==0 457 | ind_lstmax = find (bw_1 == 1 & lst < maxlst_list (pp)+lstwindow & lst > maxlst_list(1)-lstwindow..... 458 | & ndvi < minndvi_list(uu)+ndviwindow & ndvi > minndvi_list(1)-ndviwindow); 459 | count_lsthot_len = length(ind_lstmax); 460 | 461 | else 462 | ind_lstmax = find (bw_1 == 1 & lst < max_lstmean+lstwindow & lst > max_lstmean-lstwindow..... 463 | & ndvi < min_ndvimean+ndviwindow & ndvi > min_ndvimean-ndviwindow); 464 | count_lsthot_len = length(ind_lstmax); 465 | end 466 | 467 | 468 | % move next 469 | ii_max = ii_max+1; 470 | 471 | 472 | if count_lsthot_len >= hotpixel_countlimit 473 | % disp(['Hot pixels found within Top ', int2str(per_conLhot), '% LST and bottom ', int2str(per_conNhot),... 474 | % '% NDVI with LST ~', num2str(max_lstmean),' K and NDVI ~', num2str(min_ndvimean,3)]) 475 | end 476 | 477 | if count_lsthot_len >= hotpixel_countlimit && per_conLhot> 25 478 | % disp('LST from Hot pixels are not within top 25%, consider modifications to pixel limits, check input images......'); 479 | end 480 | 481 | if count_lsthot_len >= hotpixel_countlimit && per_conNhot > 25 482 | % disp('NDVI from Hot pixels are not within bottom 25%, consider modifications to pixel limits, check input images......'); 483 | end 484 | 485 | if ii_max == length(combs) % whole combination of %s value stried 486 | runhot = runhot+1; % add 1 487 | end 488 | 489 | % if runhot > 500 % take 490 | % hotpixel_countlimit =hotpixel_countlimit-1; 491 | % hotpixel_countlimit = max(hotpixel_countlimit,1); % take atleast 1 492 | % end 493 | % ii_max 494 | end 495 | 496 | % disp('.....Selection of hot pixels selction done.'); 497 | 498 | 499 | 500 | 501 | % toc; 502 | % percentages of pixel values for NDVI and LST considered 503 | %per_considered = [per_conLcold, per_conNcold,per_conLhot, per_conNhot,count_lstcold_len,count_lsthot_len 504 | 505 | %% Select pixels which satisfies crieteria for max LST and min NDVI; 506 | hotcoldpixels = zeros(m,n); 507 | hotcoldpixels(ind_lstmin) = 1; % 1 = cold pixel 508 | hotcoldpixels(ind_lstmax) = 2; % 2 = hot pixel 509 | 510 | % figure(); imagesc(hotcoldpixels); colorbar; 511 | % 512 | % lsthottest= lst; lsthottest(find(hotcoldpixels ~=1))=NaN; 513 | % lstcoldtest = lst;lstcoldtest(find(hotcoldpixels ~=2))=NaN; 514 | % 515 | % meanhotlst = nanmean(nanmean(lsthottest)); 516 | % meancoldlst = nanmean(nanmean(lstcoldtest)); 517 | % 518 | % figure(); imagesc(lsthottest); colorbar; title (num2str (meanhotlst)); 519 | % figure(); imagesc(lstcoldtest); colorbar; title (num2str (meancoldlst)); 520 | 521 | 522 | %% Write Files 523 | % %bounding box = ([left bottom; right top]) from ArcGIS 524 | % info_sub.BoundingBox= [379515.741468408 2973615.67295261;502845.741468408 3045765.67295261]; 525 | % 526 | % filename = (['lsthottest_',int2str(landsattype),'_',int2str(yeardoy),'.tif']); 527 | % geotiffwrite(filename, lsthottest,Rsub, ... 528 | % 'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 529 | % 530 | % filename = (['lstcoldtest_',int2str(landsattype),'_',int2str(yeardoy),'.tif']); 531 | % geotiffwrite(filename, lstcoldtest,Rsub, ... 532 | % 'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 533 | % 534 | % filename = (['lst_Selected_AG_',int2str(landsattype),'_',int2str(yeardoy),'.tif']); 535 | % geotiffwrite(filename, lst_new,Rsub, ... 536 | % 'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 537 | 538 | 539 | % testing 540 | % Agfil_lst= Ag_filter .* lst; 541 | % Agfil_lst (find(Agfil_lst==0)) = NaN; 542 | % figure(),imagesc(Agfil_lst);colorbar; 543 | % 544 | % filename = (['Ag_filter',int2str(landsattype),'_',int2str(yeardoy),'.tif']); 545 | % geotiffwrite(filename, Ag_filter,Rsub, ... 546 | % 'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 547 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 548 | 549 | 550 | %% Use minimum distance from the weather station to get a single location of hot and cold pixel 551 | 552 | %find the final hot and cold pixel location in col and row 553 | % Get/ verify LST values for hot and cold pixel 554 | % in_cold = find(hotcoldpixels ==1 & disMat 1 592 | ind = ceil(rand * size(ind_rank,1)); 593 | ind_rank =ind_rank(ind); 594 | end 595 | 596 | coldind = in_cold(ind_rank); 597 | [coldrow, coldcol] = ind2sub([m,n],coldind); 598 | 599 | 600 | %% SELCTION OF ONE COLD PIXEL 601 | data = lst(in_hot); 602 | data_sorted = sort(data); 603 | [~, rank_lst] = ismember(data,data_sorted); 604 | 605 | % inverse ranking of NDVI 606 | data = 1- ndvi(in_hot); 607 | data_sorted = sort(data); 608 | [~, rank_ndvi] = ismember(data,data_sorted); 609 | 610 | ranksum = rank_lst+rank_ndvi; 611 | 612 | ind_rank = find(ranksum==max(ranksum)); % take the maximum rank- min NDVI and max LST 613 | 614 | % if there's more than one pixel, select one random 615 | if length(ind_rank) > 1 616 | ind = ceil(rand * size(ind_rank,1)); 617 | ind_rank =ind_rank(ind); 618 | end 619 | 620 | hotind = in_hot(ind_rank); 621 | [hotrow, hotcol] = ind2sub([m,n],hotind); 622 | 623 | 624 | % ignore the boundary pixels(5x5 pixels); 625 | 626 | 627 | 628 | lsthot = lst(hotrow,hotcol); 629 | lstcold = lst(coldrow,coldcol); 630 | 631 | %% Now store information of hot and cold pixels 632 | lsthotx= subCx + (hotcol-1) * pixelsize; 633 | lsthoty= subCy - (hotrow-1) * pixelsize; 634 | 635 | % in case more than one pixel is selected take one 636 | lstcoldx=subCx + coldcol * pixelsize +1; 637 | lstcoldy=subCy - coldrow * pixelsize +1; 638 | 639 | % display the message box 640 | %msgbox('Hot and cold pixels are automatically selected'); 641 | 642 | if lstcold > lsthot 643 | %msgbox('Increase the max % for LST bins (LmaxPer) to cover more LST values'); 644 | error('myApp:argChk', 'cold pixel LST is greater than Hot pixel LST- Check your input image for clouds') 645 | 646 | end 647 | 648 | if isempty (lstcoldx) ==1||isempty (lstcoldy) ==1 649 | %msgbox('Increase the max % for LST bins (LmaxPer) to cover more LST values'); 650 | error('myApp:argChk', 'No Cold pixel within distance allowed; Check distance allowed') 651 | 652 | end 653 | 654 | if isempty (lsthotx) ==1||isempty (lsthoty) ==1 655 | %msgbox('Increase the max % for LST bins (LmaxPer) to cover more LST values'); 656 | error('myApp:argChk', 'No Hot pixel within distance allowed; Check distance allowed') 657 | 658 | end 659 | 660 | %% Special Condition:when diff between hot and cold pixel temp. are very small 661 | % if lsthot-lstcold < 10 662 | % disp('Difference between LSTs from hot and cold pixels are less than 663 | % 10 C'); 664 | % end 665 | 666 | 667 | end 668 | 669 | -------------------------------------------------------------------------------- /LandMODETMapper.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishan3/LandModETmapper/39a47f8a97c4ce595cd65e9bb9f7c8f9bbdf813e/LandMODETMapper.fig -------------------------------------------------------------------------------- /LandMODETMapper.m: -------------------------------------------------------------------------------- 1 | function varargout = LandMODETMapper(varargin) 2 | % LANDMODETMAPPER MATLAB code for LandMODETMapper.fig 3 | % LANDMODETMAPPER, by itself, creates a new LANDMODETMAPPER or raises the existing 4 | % singleton*. 5 | % 6 | % H = LANDMODETMAPPER returns the handle to a new LANDMODETMAPPER or the handle to 7 | % the existing singleton*. 8 | % 9 | % LANDMODETMAPPER('CALLBACK',hObject,eventData,handles,...) calls the local 10 | % function named CALLBACK in LANDMODETMAPPER.M with the given input arguments. 11 | % 12 | % LANDMODETMAPPER('Property','Value',...) creates a new LANDMODETMAPPER or raises the 13 | % existing singleton*. Starting from the left, property value pairs are 14 | % applied to the GUI before LandMODETMapper_OpeningFcn gets called. An 15 | % unrecognized property name or invalid value makes property application 16 | % stop. All inputs are passed to LandMODETMapper_OpeningFcn via varargin. 17 | % 18 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 19 | % instance to run (singleton)". 20 | % 21 | % See also: GUIDE, GUIDATA, GUIHANDLES 22 | 23 | % Edit the above text to modify the response to help LandMODETMapper 24 | 25 | % Last Modified by GUIDE v2.5 01-Feb-2019 17:15:14 26 | 27 | % Begin initialization code - DO NOT EDIT 28 | gui_Singleton = 1; 29 | gui_State = struct('gui_Name', mfilename, ... 30 | 'gui_Singleton', gui_Singleton, ... 31 | 'gui_OpeningFcn', @LandMODETMapper_OpeningFcn, ... 32 | 'gui_OutputFcn', @LandMODETMapper_OutputFcn, ... 33 | 'gui_LayoutFcn', [] , ... 34 | 'gui_Callback', []); 35 | if nargin && ischar(varargin{1}) 36 | gui_State.gui_Callback = str2func(varargin{1}); 37 | end 38 | 39 | if nargout 40 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 41 | else 42 | gui_mainfcn(gui_State, varargin{:}); 43 | end 44 | % End initialization code - DO NOT EDIT 45 | 46 | 47 | % --- Executes just before LandMODETMapper is made visible. 48 | function LandMODETMapper_OpeningFcn(hObject, eventdata, handles, varargin) 49 | % This function has no output args, see OutputFcn. 50 | % hObject handle to figure 51 | % eventdata reserved - to be defined in a future version of MATLAB 52 | % handles structure with handles and user data (see GUIDATA) 53 | % varargin command line arguments to LandMODETMapper (see VARARGIN) 54 | 55 | % Choose default command line output for LandMODETMapper 56 | handles.output = hObject; 57 | 58 | % Update handles structure 59 | guidata(hObject, handles); 60 | mainPath = pwd; 61 | inputPath = fullfile(mainPath,'Inputs'); 62 | outPath = fullfile(mainPath,'Outputs','Landsat'); 63 | if ~exist(outPath) 64 | mkdir(fullfile(mainPath,'Outputs','Landsat')) 65 | end 66 | cd(mainPath); 67 | set(handles.edit_outputpath,'String',outPath) 68 | 69 | %defaultfile=fullfile(pwd,'Inputs','lst_l5_2011277.tif'); 70 | set(handles.popupmenu_satallite_type,'Value',1) 71 | set(handles.edit_yeardoy,'String',num2str(2006215)) 72 | set(handles.edit_landsattype,'String', num2str(5)) 73 | set(handles.edit_b,'String', num2str(90-61.66628785)) 74 | set(handles.edit_imghr,'String', num2str(10)) 75 | set(handles.edit_imgmm,'String', num2str(55)) 76 | 77 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 78 | defaultfile=fullfile(inputPath,'RS',strcat('lst_',int2str(yeardoy),'_Landsat.tif')); 79 | set(handles.edit_lst,'String',defaultfile) 80 | defaultfile=fullfile(inputPath,'RS',strcat('albedo_', int2str(yeardoy),'_Landsat.tif')); 81 | set(handles.edit_albedo,'String',defaultfile) 82 | defaultfile=fullfile(inputPath,'RS',strcat('emiss_', int2str(yeardoy),'_Landsat.tif')); 83 | set(handles.edit_emiss,'String',defaultfile) 84 | defaultfile=fullfile(inputPath,'RS',strcat('ndvi_', int2str(yeardoy),'_Landsat.tif')); 85 | set(handles.edit_ndvi,'String',defaultfile) 86 | 87 | defaultfile=fullfile(inputPath,'Derived',strcat('z0m_', int2str(yeardoy),'_Landsat.tif')); 88 | set(handles.edit_z0m,'String',defaultfile) 89 | defaultfile=fullfile(inputPath,'Derived',strcat('Igood_', int2str(yeardoy),'_Landsat.tif')); 90 | set(handles.edit_Igood,'String',defaultfile) 91 | defaultfile=fullfile(inputPath,'Derived',strcat('Iwater_', int2str(yeardoy),'_Landsat.tif')); 92 | set(handles.edit_Iwater,'String',defaultfile) 93 | defaultfile=fullfile(mainPath,'Agbinary_landsat.tif'); 94 | set(handles.edit_Ag_filter,'String',defaultfile) 95 | 96 | defaultfile=fullfile(inputPath,'Weather',strcat('rhinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 97 | set(handles.edit_rh_inst,'String',defaultfile) 98 | defaultfile=fullfile(inputPath,'Weather',strcat('TinstK_awdn_', int2str(yeardoy),'_Landsat.tif')); 99 | set(handles.edit_TinstK,'String',defaultfile) 100 | defaultfile=fullfile(inputPath,'Weather',strcat('uinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 101 | set(handles.edit_u_inst,'String',defaultfile) 102 | defaultfile=fullfile(inputPath,'Weather',strcat('solarinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 103 | set(handles.edit_solar_i,'String',defaultfile) 104 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmaxd_awdn_', int2str(yeardoy),'_Landsat.tif')); 105 | set(handles.edit_TmaxdailyK,'String',defaultfile) 106 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmeand_awdn_', int2str(yeardoy),'_Landsat.tif')); 107 | set(handles.edit_TmeandailyK,'String',defaultfile) 108 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmind_awdn_', int2str(yeardoy),'_Landsat.tif')); 109 | set(handles.edit_TmindailyK,'String',defaultfile) 110 | defaultfile=fullfile(inputPath,'Weather',strcat('s24d_awdn_', int2str(yeardoy),'_Landsat.tif')); 111 | set(handles.edit_solar24,'String',defaultfile) 112 | defaultfile=fullfile(inputPath,'Weather',strcat('rhd_awdn_', int2str(yeardoy),'_Landsat.tif')); 113 | set(handles.edit_rh_daily,'String',defaultfile) 114 | defaultfile=fullfile(inputPath,'Weather',strcat('ud_awdn_', int2str(yeardoy),'_Landsat.tif')); 115 | set(handles.edit_u_daily,'String',defaultfile) 116 | 117 | set(handles.popupmenu_computeK,'Value',2) 118 | set(handles.edit_p_year,'String','Null') 119 | set(handles.edit_et0_year,'String','Null') 120 | set(handles.edit_soil,'String','Null') 121 | 122 | yeardoy_str = num2str(yeardoy); 123 | year = str2num(yeardoy_str(1:4)); 124 | defaultfile=fullfile(inputPath,'Weather',strcat('Pstacked_',int2str(year),'.tif')); 125 | %set(handles.edit_p_year,'String',defaultfile) 126 | 127 | fullname_et0_year=fullfile(inputPath,'Weather',strcat('ETostacked_',int2str(year),'.tif')); 128 | %set(handles.edit_et0_year,'String',fullname_et0_year) 129 | fullname_soil=fullfile(mainPath,'soil_ras_landsat.tif'); 130 | %set(handles.edit_soil,'String',fullname_soil) 131 | set(handles.edit_kr,'String','0') 132 | set(handles.edit_kr_max,'String','0.15') 133 | set(handles.edit_z_st_veg,'String','0.15') 134 | set(handles.edit_zref,'String','2') 135 | set(handles.edit_t_interval,'String','1') 136 | set(handles.edit_lapse,'String','0.0065') 137 | set(handles.edit_zb,'String','200') 138 | 139 | set(handles.edit_dem,'String',fullfile(mainPath,'dem_landsat.tif')) 140 | 141 | load defaults_hotcold_param_landsat; 142 | 143 | set(handles.edit_ff_open,'String',num2str(ff_open)) 144 | set(handles.edit_lstlowerlimit,'String',num2str(lstlowerlimit)) 145 | set(handles.edit_lststep,'String',num2str(lststep)) 146 | set(handles.edit_lstupperlimit,'String',num2str(lstupperlimit)) 147 | set(handles.edit_lstwindow,'String',num2str(lstwindow)) 148 | set(handles.edit_ndvilowerlimit,'String',num2str(ndvilowerlimit)) 149 | set(handles.edit_ndvistep,'String',num2str(ndvistep)) 150 | set(handles.edit_ndviupperlimit,'String',num2str(ndviupperlimit)) 151 | set(handles.edit_ndviwindow,'String',num2str(ndviwindow)) 152 | set(handles.edit_pixellimit_bins,'String',num2str(pixellimit_bins)) 153 | set(handles.edit_pixellimit_counts,'String',num2str(pixellimit_counts)) 154 | set(handles.edit_Kadj,'String',num2str(1.05)) 155 | set(handles.edit_k,'String',num2str(0.41)) 156 | set(handles.checkbox_saveGeoTIFFS,'value',1); 157 | set(handles.checkbox_saveMATS,'value',1); 158 | set(handles.checkbox_saveRn_MATS,'value',1); 159 | set(handles.checkbox_saveG_MATS,'value',1); 160 | set(handles.checkbox_saveRn_GeoTIFFS,'value',1); 161 | set(handles.checkbox_saveG_GeoTIFFS,'value',1); 162 | set(handles.checkbox_makeFig_LE,'value',0); 163 | set(handles.checkbox_makeFig_DailyETs,'value',0); 164 | set(handles.checkbox_runMETRIC,'value',1); 165 | set(handles.checkbox_runSEBAL,'value',1); 166 | 167 | % --- Outputs from this function are returned to the command line. 168 | function varargout = LandMODETMapper_OutputFcn(hObject, eventdata, handles) 169 | % varargout cell array for returning output args (see VARARGOUT); 170 | % hObject handle to figure 171 | % eventdata reserved - to be defined in a future version of MATLAB 172 | % handles structure with handles and user data (see GUIDATA) 173 | 174 | % Get default command line output from handles structure 175 | varargout{1} = handles.output; 176 | 177 | 178 | function edit_yeardoy_Callback(hObject, eventdata, handles) 179 | % hObject handle to edit_yeardoy (see GCBO) 180 | % eventdata reserved - to be defined in a future version of MATLAB 181 | % handles structure with handles and user data (see GUIDATA) 182 | 183 | % Hints: get(hObject,'String') returns contents of edit_yeardoy as text 184 | % str2double(get(hObject,'String')) returns contents of edit_yeardoy as a double 185 | 186 | 187 | % --- Executes during object creation, after setting all properties. 188 | function edit_yeardoy_CreateFcn(hObject, eventdata, handles) 189 | % hObject handle to edit_yeardoy (see GCBO) 190 | % eventdata reserved - to be defined in a future version of MATLAB 191 | % handles empty - handles not created until after all CreateFcns called 192 | 193 | % Hint: edit controls usually have a white background on Windows. 194 | % See ISPC and COMPUTER. 195 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 196 | set(hObject,'BackgroundColor','white'); 197 | end 198 | 199 | 200 | 201 | function edit_landsattype_Callback(hObject, eventdata, handles) 202 | % hObject handle to edit_landsattype (see GCBO) 203 | % eventdata reserved - to be defined in a future version of MATLAB 204 | % handles structure with handles and user data (see GUIDATA) 205 | 206 | % Hints: get(hObject,'String') returns contents of edit_landsattype as text 207 | % str2double(get(hObject,'String')) returns contents of edit_landsattype as a double 208 | 209 | 210 | % --- Executes during object creation, after setting all properties. 211 | function edit_landsattype_CreateFcn(hObject, eventdata, handles) 212 | % hObject handle to edit_landsattype (see GCBO) 213 | % eventdata reserved - to be defined in a future version of MATLAB 214 | % handles empty - handles not created until after all CreateFcns called 215 | 216 | % Hint: edit controls usually have a white background on Windows. 217 | % See ISPC and COMPUTER. 218 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 219 | set(hObject,'BackgroundColor','white'); 220 | end 221 | 222 | 223 | 224 | function edit_b_Callback(hObject, eventdata, handles) 225 | % hObject handle to edit_b (see GCBO) 226 | % eventdata reserved - to be defined in a future version of MATLAB 227 | % handles structure with handles and user data (see GUIDATA) 228 | 229 | % Hints: get(hObject,'String') returns contents of edit_b as text 230 | % str2double(get(hObject,'String')) returns contents of edit_b as a double 231 | 232 | 233 | % --- Executes during object creation, after setting all properties. 234 | function edit_b_CreateFcn(hObject, eventdata, handles) 235 | % hObject handle to edit_b (see GCBO) 236 | % eventdata reserved - to be defined in a future version of MATLAB 237 | % handles empty - handles not created until after all CreateFcns called 238 | 239 | % Hint: edit controls usually have a white background on Windows. 240 | % See ISPC and COMPUTER. 241 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 242 | set(hObject,'BackgroundColor','white'); 243 | end 244 | 245 | 246 | 247 | function edit_imghr_Callback(hObject, eventdata, handles) 248 | % hObject handle to edit_imghr (see GCBO) 249 | % eventdata reserved - to be defined in a future version of MATLAB 250 | % handles structure with handles and user data (see GUIDATA) 251 | 252 | % Hints: get(hObject,'String') returns contents of edit_imghr as text 253 | % str2double(get(hObject,'String')) returns contents of edit_imghr as a double 254 | 255 | 256 | % --- Executes during object creation, after setting all properties. 257 | function edit_imghr_CreateFcn(hObject, eventdata, handles) 258 | % hObject handle to edit_imghr (see GCBO) 259 | % eventdata reserved - to be defined in a future version of MATLAB 260 | % handles empty - handles not created until after all CreateFcns called 261 | 262 | % Hint: edit controls usually have a white background on Windows. 263 | % See ISPC and COMPUTER. 264 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 265 | set(hObject,'BackgroundColor','white'); 266 | end 267 | 268 | 269 | 270 | function edit_imgmm_Callback(hObject, eventdata, handles) 271 | % hObject handle to edit_imgmm (see GCBO) 272 | % eventdata reserved - to be defined in a future version of MATLAB 273 | % handles structure with handles and user data (see GUIDATA) 274 | 275 | % Hints: get(hObject,'String') returns contents of edit_imgmm as text 276 | % str2double(get(hObject,'String')) returns contents of edit_imgmm as a double 277 | 278 | 279 | % --- Executes during object creation, after setting all properties. 280 | function edit_imgmm_CreateFcn(hObject, eventdata, handles) 281 | % hObject handle to edit_imgmm (see GCBO) 282 | % eventdata reserved - to be defined in a future version of MATLAB 283 | % handles empty - handles not created until after all CreateFcns called 284 | 285 | % Hint: edit controls usually have a white background on Windows. 286 | % See ISPC and COMPUTER. 287 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 288 | set(hObject,'BackgroundColor','white'); 289 | end 290 | 291 | 292 | 293 | function edit_lst_Callback(hObject, eventdata, handles) 294 | % hObject handle to edit_lst (see GCBO) 295 | % eventdata reserved - to be defined in a future version of MATLAB 296 | % handles structure with handles and user data (see GUIDATA) 297 | 298 | % Hints: get(hObject,'String') returns contents of edit_lst as text 299 | % str2double(get(hObject,'String')) returns contents of edit_lst as a double 300 | 301 | 302 | % --- Executes during object creation, after setting all properties. 303 | function edit_lst_CreateFcn(hObject, eventdata, handles) 304 | % hObject handle to edit_lst (see GCBO) 305 | % eventdata reserved - to be defined in a future version of MATLAB 306 | % handles empty - handles not created until after all CreateFcns called 307 | 308 | % Hint: edit controls usually have a white background on Windows. 309 | % See ISPC and COMPUTER. 310 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 311 | set(hObject,'BackgroundColor','white'); 312 | end 313 | 314 | 315 | 316 | function edit_albedo_Callback(hObject, eventdata, handles) 317 | % hObject handle to edit_albedo (see GCBO) 318 | % eventdata reserved - to be defined in a future version of MATLAB 319 | % handles structure with handles and user data (see GUIDATA) 320 | 321 | % Hints: get(hObject,'String') returns contents of edit_albedo as text 322 | % str2double(get(hObject,'String')) returns contents of edit_albedo as a double 323 | 324 | 325 | % --- Executes during object creation, after setting all properties. 326 | function edit_albedo_CreateFcn(hObject, eventdata, handles) 327 | % hObject handle to edit_albedo (see GCBO) 328 | % eventdata reserved - to be defined in a future version of MATLAB 329 | % handles empty - handles not created until after all CreateFcns called 330 | 331 | % Hint: edit controls usually have a white background on Windows. 332 | % See ISPC and COMPUTER. 333 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 334 | set(hObject,'BackgroundColor','white'); 335 | end 336 | 337 | 338 | 339 | function edit_ndvi_Callback(hObject, eventdata, handles) 340 | % hObject handle to edit_ndvi (see GCBO) 341 | % eventdata reserved - to be defined in a future version of MATLAB 342 | % handles structure with handles and user data (see GUIDATA) 343 | 344 | % Hints: get(hObject,'String') returns contents of edit_ndvi as text 345 | % str2double(get(hObject,'String')) returns contents of edit_ndvi as a double 346 | 347 | 348 | % --- Executes during object creation, after setting all properties. 349 | function edit_ndvi_CreateFcn(hObject, eventdata, handles) 350 | % hObject handle to edit_ndvi (see GCBO) 351 | % eventdata reserved - to be defined in a future version of MATLAB 352 | % handles empty - handles not created until after all CreateFcns called 353 | 354 | % Hint: edit controls usually have a white background on Windows. 355 | % See ISPC and COMPUTER. 356 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 357 | set(hObject,'BackgroundColor','white'); 358 | end 359 | 360 | 361 | 362 | function edit_emiss_Callback(hObject, eventdata, handles) 363 | % hObject handle to edit_emiss (see GCBO) 364 | % eventdata reserved - to be defined in a future version of MATLAB 365 | % handles structure with handles and user data (see GUIDATA) 366 | 367 | % Hints: get(hObject,'String') returns contents of edit_emiss as text 368 | % str2double(get(hObject,'String')) returns contents of edit_emiss as a double 369 | 370 | 371 | % --- Executes during object creation, after setting all properties. 372 | function edit_emiss_CreateFcn(hObject, eventdata, handles) 373 | % hObject handle to edit_emiss (see GCBO) 374 | % eventdata reserved - to be defined in a future version of MATLAB 375 | % handles empty - handles not created until after all CreateFcns called 376 | 377 | % Hint: edit controls usually have a white background on Windows. 378 | % See ISPC and COMPUTER. 379 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 380 | set(hObject,'BackgroundColor','white'); 381 | end 382 | 383 | 384 | 385 | function edit_z0m_Callback(hObject, eventdata, handles) 386 | % hObject handle to edit_z0m (see GCBO) 387 | % eventdata reserved - to be defined in a future version of MATLAB 388 | % handles structure with handles and user data (see GUIDATA) 389 | 390 | % Hints: get(hObject,'String') returns contents of edit_z0m as text 391 | % str2double(get(hObject,'String')) returns contents of edit_z0m as a double 392 | 393 | 394 | % --- Executes during object creation, after setting all properties. 395 | function edit_z0m_CreateFcn(hObject, eventdata, handles) 396 | % hObject handle to edit_z0m (see GCBO) 397 | % eventdata reserved - to be defined in a future version of MATLAB 398 | % handles empty - handles not created until after all CreateFcns called 399 | 400 | % Hint: edit controls usually have a white background on Windows. 401 | % See ISPC and COMPUTER. 402 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 403 | set(hObject,'BackgroundColor','white'); 404 | end 405 | 406 | 407 | 408 | function edit_Igood_Callback(hObject, eventdata, handles) 409 | % hObject handle to edit_Igood (see GCBO) 410 | % eventdata reserved - to be defined in a future version of MATLAB 411 | % handles structure with handles and user data (see GUIDATA) 412 | 413 | % Hints: get(hObject,'String') returns contents of edit_Igood as text 414 | % str2double(get(hObject,'String')) returns contents of edit_Igood as a double 415 | 416 | 417 | % --- Executes during object creation, after setting all properties. 418 | function edit_Igood_CreateFcn(hObject, eventdata, handles) 419 | % hObject handle to edit_Igood (see GCBO) 420 | % eventdata reserved - to be defined in a future version of MATLAB 421 | % handles empty - handles not created until after all CreateFcns called 422 | 423 | % Hint: edit controls usually have a white background on Windows. 424 | % See ISPC and COMPUTER. 425 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 426 | set(hObject,'BackgroundColor','white'); 427 | end 428 | 429 | 430 | 431 | function edit_Iwater_Callback(hObject, eventdata, handles) 432 | % hObject handle to edit_Iwater (see GCBO) 433 | % eventdata reserved - to be defined in a future version of MATLAB 434 | % handles structure with handles and user data (see GUIDATA) 435 | 436 | % Hints: get(hObject,'String') returns contents of edit_Iwater as text 437 | % str2double(get(hObject,'String')) returns contents of edit_Iwater as a double 438 | 439 | 440 | % --- Executes during object creation, after setting all properties. 441 | function edit_Iwater_CreateFcn(hObject, eventdata, handles) 442 | % hObject handle to edit_Iwater (see GCBO) 443 | % eventdata reserved - to be defined in a future version of MATLAB 444 | % handles empty - handles not created until after all CreateFcns called 445 | 446 | % Hint: edit controls usually have a white background on Windows. 447 | % See ISPC and COMPUTER. 448 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 449 | set(hObject,'BackgroundColor','white'); 450 | end 451 | 452 | 453 | 454 | function edit_Ag_filter_Callback(hObject, eventdata, handles) 455 | % hObject handle to edit_Ag_filter (see GCBO) 456 | % eventdata reserved - to be defined in a future version of MATLAB 457 | % handles structure with handles and user data (see GUIDATA) 458 | 459 | % Hints: get(hObject,'String') returns contents of edit_Ag_filter as text 460 | % str2double(get(hObject,'String')) returns contents of edit_Ag_filter as a double 461 | 462 | 463 | % --- Executes during object creation, after setting all properties. 464 | function edit_Ag_filter_CreateFcn(hObject, eventdata, handles) 465 | % hObject handle to edit_Ag_filter (see GCBO) 466 | % eventdata reserved - to be defined in a future version of MATLAB 467 | % handles empty - handles not created until after all CreateFcns called 468 | 469 | % Hint: edit controls usually have a white background on Windows. 470 | % See ISPC and COMPUTER. 471 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 472 | set(hObject,'BackgroundColor','white'); 473 | end 474 | 475 | 476 | 477 | function edit_rh_inst_Callback(hObject, eventdata, handles) 478 | % hObject handle to edit_rh_inst (see GCBO) 479 | % eventdata reserved - to be defined in a future version of MATLAB 480 | % handles structure with handles and user data (see GUIDATA) 481 | 482 | % Hints: get(hObject,'String') returns contents of edit_rh_inst as text 483 | % str2double(get(hObject,'String')) returns contents of edit_rh_inst as a double 484 | 485 | 486 | % --- Executes during object creation, after setting all properties. 487 | function edit_rh_inst_CreateFcn(hObject, eventdata, handles) 488 | % hObject handle to edit_rh_inst (see GCBO) 489 | % eventdata reserved - to be defined in a future version of MATLAB 490 | % handles empty - handles not created until after all CreateFcns called 491 | 492 | % Hint: edit controls usually have a white background on Windows. 493 | % See ISPC and COMPUTER. 494 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 495 | set(hObject,'BackgroundColor','white'); 496 | end 497 | 498 | 499 | 500 | function edit_TinstK_Callback(hObject, eventdata, handles) 501 | % hObject handle to edit_TinstK (see GCBO) 502 | % eventdata reserved - to be defined in a future version of MATLAB 503 | % handles structure with handles and user data (see GUIDATA) 504 | 505 | % Hints: get(hObject,'String') returns contents of edit_TinstK as text 506 | % str2double(get(hObject,'String')) returns contents of edit_TinstK as a double 507 | 508 | 509 | % --- Executes during object creation, after setting all properties. 510 | function edit_TinstK_CreateFcn(hObject, eventdata, handles) 511 | % hObject handle to edit_TinstK (see GCBO) 512 | % eventdata reserved - to be defined in a future version of MATLAB 513 | % handles empty - handles not created until after all CreateFcns called 514 | 515 | % Hint: edit controls usually have a white background on Windows. 516 | % See ISPC and COMPUTER. 517 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 518 | set(hObject,'BackgroundColor','white'); 519 | end 520 | 521 | 522 | 523 | function edit_u_inst_Callback(hObject, eventdata, handles) 524 | % hObject handle to edit_u_inst (see GCBO) 525 | % eventdata reserved - to be defined in a future version of MATLAB 526 | % handles structure with handles and user data (see GUIDATA) 527 | 528 | % Hints: get(hObject,'String') returns contents of edit_u_inst as text 529 | % str2double(get(hObject,'String')) returns contents of edit_u_inst as a double 530 | 531 | 532 | % --- Executes during object creation, after setting all properties. 533 | function edit_u_inst_CreateFcn(hObject, eventdata, handles) 534 | % hObject handle to edit_u_inst (see GCBO) 535 | % eventdata reserved - to be defined in a future version of MATLAB 536 | % handles empty - handles not created until after all CreateFcns called 537 | 538 | % Hint: edit controls usually have a white background on Windows. 539 | % See ISPC and COMPUTER. 540 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 541 | set(hObject,'BackgroundColor','white'); 542 | end 543 | 544 | 545 | 546 | function edit_solar_i_Callback(hObject, eventdata, handles) 547 | % hObject handle to edit_solar_i (see GCBO) 548 | % eventdata reserved - to be defined in a future version of MATLAB 549 | % handles structure with handles and user data (see GUIDATA) 550 | 551 | % Hints: get(hObject,'String') returns contents of edit_solar_i as text 552 | % str2double(get(hObject,'String')) returns contents of edit_solar_i as a double 553 | 554 | 555 | % --- Executes during object creation, after setting all properties. 556 | function edit_solar_i_CreateFcn(hObject, eventdata, handles) 557 | % hObject handle to edit_solar_i (see GCBO) 558 | % eventdata reserved - to be defined in a future version of MATLAB 559 | % handles empty - handles not created until after all CreateFcns called 560 | 561 | % Hint: edit controls usually have a white background on Windows. 562 | % See ISPC and COMPUTER. 563 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 564 | set(hObject,'BackgroundColor','white'); 565 | end 566 | 567 | 568 | 569 | function edit_TmaxdailyK_Callback(hObject, eventdata, handles) 570 | % hObject handle to edit_TmaxdailyK (see GCBO) 571 | % eventdata reserved - to be defined in a future version of MATLAB 572 | % handles structure with handles and user data (see GUIDATA) 573 | 574 | % Hints: get(hObject,'String') returns contents of edit_TmaxdailyK as text 575 | % str2double(get(hObject,'String')) returns contents of edit_TmaxdailyK as a double 576 | 577 | 578 | % --- Executes during object creation, after setting all properties. 579 | function edit_TmaxdailyK_CreateFcn(hObject, eventdata, handles) 580 | % hObject handle to edit_TmaxdailyK (see GCBO) 581 | % eventdata reserved - to be defined in a future version of MATLAB 582 | % handles empty - handles not created until after all CreateFcns called 583 | 584 | % Hint: edit controls usually have a white background on Windows. 585 | % See ISPC and COMPUTER. 586 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 587 | set(hObject,'BackgroundColor','white'); 588 | end 589 | 590 | 591 | 592 | function edit_TmeandailyK_Callback(hObject, eventdata, handles) 593 | % hObject handle to edit_TmeandailyK (see GCBO) 594 | % eventdata reserved - to be defined in a future version of MATLAB 595 | % handles structure with handles and user data (see GUIDATA) 596 | 597 | % Hints: get(hObject,'String') returns contents of edit_TmeandailyK as text 598 | % str2double(get(hObject,'String')) returns contents of edit_TmeandailyK as a double 599 | 600 | 601 | % --- Executes during object creation, after setting all properties. 602 | function edit_TmeandailyK_CreateFcn(hObject, eventdata, handles) 603 | % hObject handle to edit_TmeandailyK (see GCBO) 604 | % eventdata reserved - to be defined in a future version of MATLAB 605 | % handles empty - handles not created until after all CreateFcns called 606 | 607 | % Hint: edit controls usually have a white background on Windows. 608 | % See ISPC and COMPUTER. 609 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 610 | set(hObject,'BackgroundColor','white'); 611 | end 612 | 613 | 614 | 615 | function edit_TmindailyK_Callback(hObject, eventdata, handles) 616 | % hObject handle to edit_TmindailyK (see GCBO) 617 | % eventdata reserved - to be defined in a future version of MATLAB 618 | % handles structure with handles and user data (see GUIDATA) 619 | 620 | % Hints: get(hObject,'String') returns contents of edit_TmindailyK as text 621 | % str2double(get(hObject,'String')) returns contents of edit_TmindailyK as a double 622 | 623 | 624 | % --- Executes during object creation, after setting all properties. 625 | function edit_TmindailyK_CreateFcn(hObject, eventdata, handles) 626 | % hObject handle to edit_TmindailyK (see GCBO) 627 | % eventdata reserved - to be defined in a future version of MATLAB 628 | % handles empty - handles not created until after all CreateFcns called 629 | 630 | % Hint: edit controls usually have a white background on Windows. 631 | % See ISPC and COMPUTER. 632 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 633 | set(hObject,'BackgroundColor','white'); 634 | end 635 | 636 | 637 | 638 | function edit_solar24_Callback(hObject, eventdata, handles) 639 | % hObject handle to edit_solar24 (see GCBO) 640 | % eventdata reserved - to be defined in a future version of MATLAB 641 | % handles structure with handles and user data (see GUIDATA) 642 | 643 | % Hints: get(hObject,'String') returns contents of edit_solar24 as text 644 | % str2double(get(hObject,'String')) returns contents of edit_solar24 as a double 645 | 646 | 647 | % --- Executes during object creation, after setting all properties. 648 | function edit_solar24_CreateFcn(hObject, eventdata, handles) 649 | % hObject handle to edit_solar24 (see GCBO) 650 | % eventdata reserved - to be defined in a future version of MATLAB 651 | % handles empty - handles not created until after all CreateFcns called 652 | 653 | % Hint: edit controls usually have a white background on Windows. 654 | % See ISPC and COMPUTER. 655 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 656 | set(hObject,'BackgroundColor','white'); 657 | end 658 | 659 | 660 | 661 | function edit_rh_daily_Callback(hObject, eventdata, handles) 662 | % hObject handle to edit_rh_daily (see GCBO) 663 | % eventdata reserved - to be defined in a future version of MATLAB 664 | % handles structure with handles and user data (see GUIDATA) 665 | 666 | % Hints: get(hObject,'String') returns contents of edit_rh_daily as text 667 | % str2double(get(hObject,'String')) returns contents of edit_rh_daily as a double 668 | 669 | 670 | % --- Executes during object creation, after setting all properties. 671 | function edit_rh_daily_CreateFcn(hObject, eventdata, handles) 672 | % hObject handle to edit_rh_daily (see GCBO) 673 | % eventdata reserved - to be defined in a future version of MATLAB 674 | % handles empty - handles not created until after all CreateFcns called 675 | 676 | % Hint: edit controls usually have a white background on Windows. 677 | % See ISPC and COMPUTER. 678 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 679 | set(hObject,'BackgroundColor','white'); 680 | end 681 | 682 | 683 | 684 | function edit_u_daily_Callback(hObject, eventdata, handles) 685 | % hObject handle to edit_u_daily (see GCBO) 686 | % eventdata reserved - to be defined in a future version of MATLAB 687 | % handles structure with handles and user data (see GUIDATA) 688 | 689 | % Hints: get(hObject,'String') returns contents of edit_u_daily as text 690 | % str2double(get(hObject,'String')) returns contents of edit_u_daily as a double 691 | 692 | 693 | % --- Executes during object creation, after setting all properties. 694 | function edit_u_daily_CreateFcn(hObject, eventdata, handles) 695 | % hObject handle to edit_u_daily (see GCBO) 696 | % eventdata reserved - to be defined in a future version of MATLAB 697 | % handles empty - handles not created until after all CreateFcns called 698 | 699 | % Hint: edit controls usually have a white background on Windows. 700 | % See ISPC and COMPUTER. 701 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 702 | set(hObject,'BackgroundColor','white'); 703 | end 704 | 705 | 706 | % --- Executes on button press in pushbutton_rh_inst. 707 | function pushbutton_rh_inst_Callback(hObject, eventdata, handles) 708 | % hObject handle to pushbutton_rh_inst (see GCBO) 709 | % eventdata reserved - to be defined in a future version of MATLAB 710 | % handles structure with handles and user data (see GUIDATA) 711 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 712 | 713 | mainPath = pwd; 714 | inputPath = fullfile(mainPath,'Inputs'); 715 | defaultfile=fullfile(inputPath,'Weather',strcat('rhinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 716 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select rh_inst file'); 717 | fullname_rh_inst=fullfile(PathName,FileName); 718 | set(handles.edit_rh_inst,'String',fullname_rh_inst) 719 | 720 | 721 | % --- Executes on button press in pushbutton_TinstK. 722 | function pushbutton_TinstK_Callback(hObject, eventdata, handles) 723 | % hObject handle to pushbutton_TinstK (see GCBO) 724 | % eventdata reserved - to be defined in a future version of MATLAB 725 | % handles structure with handles and user data (see GUIDATA) 726 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 727 | 728 | mainPath = pwd; 729 | inputPath = fullfile(mainPath,'Inputs'); 730 | defaultfile=fullfile(inputPath,'Weather',strcat('TinstK_awdn_', int2str(yeardoy),'_Landsat.tif')); 731 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select rh_inst file'); 732 | fullname_TinstK=fullfile(PathName,FileName); 733 | set(handles.edit_TinstK,'String',fullname_TinstK) 734 | 735 | 736 | % --- Executes on button press in pushbutton_u_inst. 737 | function pushbutton_u_inst_Callback(hObject, eventdata, handles) 738 | % hObject handle to pushbutton_u_inst (see GCBO) 739 | % eventdata reserved - to be defined in a future version of MATLAB 740 | % handles structure with handles and user data (see GUIDATA) 741 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 742 | 743 | mainPath = pwd; 744 | inputPath = fullfile(mainPath,'Inputs'); 745 | defaultfile=fullfile(inputPath,'Weather',strcat('uinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 746 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select u_inst file'); 747 | fullname_u_inst=fullfile(PathName,FileName); 748 | set(handles.edit_u_inst,'String',fullname_u_inst) 749 | 750 | 751 | % --- Executes on button press in pushbutton4. 752 | function pushbutton4_Callback(hObject, eventdata, handles) 753 | % hObject handle to pushbutton4 (see GCBO) 754 | % eventdata reserved - to be defined in a future version of MATLAB 755 | % handles structure with handles and user data (see GUIDATA) 756 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 757 | 758 | mainPath = pwd; 759 | inputPath = fullfile(mainPath,'Inputs'); 760 | defaultfile=fullfile(inputPath,'Weather',strcat('solarinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 761 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select u_inst file'); 762 | fullname_solar_i=fullfile(PathName,FileName); 763 | set(handles.edit_solar_i,'String',fullname_solar_i) 764 | 765 | 766 | % --- Executes on button press in pushbutton_TmaxdailyK. 767 | function pushbutton_TmaxdailyK_Callback(hObject, eventdata, handles) 768 | % hObject handle to pushbutton_TmaxdailyK (see GCBO) 769 | % eventdata reserved - to be defined in a future version of MATLAB 770 | % handles structure with handles and user data (see GUIDATA) 771 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 772 | mainPath = pwd; 773 | inputPath = fullfile(mainPath,'Inputs'); 774 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmaxd_awdn_', int2str(yeardoy),'_Landsat.tif')); 775 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select TmaxdailyK file'); 776 | fullname_TmaxdailyK=fullfile(PathName,FileName); 777 | set(handles.edit_TmaxdailyK,'String',fullname_TmaxdailyK) 778 | 779 | 780 | % --- Executes on button press in pushbutton_TmeandailyK. 781 | function pushbutton_TmeandailyK_Callback(hObject, eventdata, handles) 782 | % hObject handle to pushbutton_TmeandailyK (see GCBO) 783 | % eventdata reserved - to be defined in a future version of MATLAB 784 | % handles structure with handles and user data (see GUIDATA) 785 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 786 | mainPath = pwd; 787 | inputPath = fullfile(mainPath,'Inputs'); 788 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmeand_awdn_', int2str(yeardoy),'_Landsat.tif')); 789 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select TmeandailyK file'); 790 | fullname_TmeandailyK=fullfile(PathName,FileName); 791 | set(handles.edit_TmeandailyK,'String',fullname_TmeandailyK) 792 | 793 | 794 | % --- Executes on button press in pushbutton7. 795 | function pushbutton7_Callback(hObject, eventdata, handles) 796 | % hObject handle to pushbutton7 (see GCBO) 797 | % eventdata reserved - to be defined in a future version of MATLAB 798 | % handles structure with handles and user data (see GUIDATA) 799 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 800 | mainPath = pwd; 801 | inputPath = fullfile(mainPath,'Inputs'); 802 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmind_awdn_', int2str(yeardoy),'_Landsat.tif')); 803 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select TmindailyK file'); 804 | fullname_TmindailyKK=fullfile(PathName,FileName); 805 | set(handles.edit_TmindailyK,'String',fullname_TmindailyKK) 806 | 807 | 808 | % --- Executes on button press in pushbutton_solar24. 809 | function pushbutton_solar24_Callback(hObject, eventdata, handles) 810 | % hObject handle to pushbutton_solar24 (see GCBO) 811 | % eventdata reserved - to be defined in a future version of MATLAB 812 | % handles structure with handles and user data (see GUIDATA) 813 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 814 | mainPath = pwd; 815 | inputPath = fullfile(mainPath,'Inputs'); 816 | defaultfile=fullfile(inputPath,'Weather',strcat('s24d_awdn_', int2str(yeardoy),'_Landsat.tif')); 817 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select TmindailyK file'); 818 | fullname_solar24=fullfile(PathName,FileName); 819 | set(handles.edit_TmindailyK,'String',fullname_solar24) 820 | 821 | 822 | % --- Executes on button press in pushbutton_rh_daily. 823 | function pushbutton_rh_daily_Callback(hObject, eventdata, handles) 824 | % hObject handle to pushbutton_rh_daily (see GCBO) 825 | % eventdata reserved - to be defined in a future version of MATLAB 826 | % handles structure with handles and user data (see GUIDATA) 827 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 828 | mainPath = pwd; 829 | inputPath = fullfile(mainPath,'Inputs'); 830 | defaultfile=fullfile(inputPath,'Weather',strcat('rhd_awdn_', int2str(yeardoy),'_Landsat.tif')); 831 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select TmindailyK file'); 832 | fullname_rh_daily=fullfile(PathName,FileName); 833 | set(handles.edit_rh_daily,'String',fullname_rh_daily) 834 | 835 | 836 | % --- Executes on button press in pushbutton_u_daily. 837 | function pushbutton_u_daily_Callback(hObject, eventdata, handles) 838 | % hObject handle to pushbutton_u_daily (see GCBO) 839 | % eventdata reserved - to be defined in a future version of MATLAB 840 | % handles structure with handles and user data (see GUIDATA) 841 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 842 | mainPath = pwd; 843 | inputPath = fullfile(mainPath,'Inputs'); 844 | defaultfile=fullfile(inputPath,'Weather',strcat('ud_awdn_', int2str(yeardoy),'_Landsat.tif')); 845 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select TmindailyK file'); 846 | fullname_u_daily=fullfile(PathName,FileName); 847 | set(handles.edit_u_daily,'String',fullname_u_daily) 848 | 849 | 850 | % --- Executes on button press in pushbutton_lst. 851 | function pushbutton_lst_Callback(hObject, eventdata, handles) 852 | % hObject handle to pushbutton_lst (see GCBO) 853 | % eventdata reserved - to be defined in a future version of MATLAB 854 | % handles structure with handles and user data (see GUIDATA) 855 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 856 | mainPath = pwd; 857 | inputPath = fullfile(mainPath,'Inputs'); 858 | defaultfile=fullfile(inputPath,'RS',strcat('lst_',int2str(yeardoy),'_Landsat.tif')); 859 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select LST file'); 860 | fullname_lst=fullfile(PathName,FileName); 861 | set(handles.edit_lst,'String',fullname_lst) 862 | 863 | 864 | % --- Executes on button press in pushbutton_albedo. 865 | function pushbutton_albedo_Callback(hObject, eventdata, handles) 866 | % hObject handle to pushbutton_albedo (see GCBO) 867 | % eventdata reserved - to be defined in a future version of MATLAB 868 | % handles structure with handles and user data (see GUIDATA) 869 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 870 | mainPath = pwd; 871 | inputPath = fullfile(mainPath,'Inputs'); 872 | defaultfile=fullfile(inputPath,'RS',strcat('albedo_', int2str(yeardoy),'_Landsat.tif')); 873 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select LST file'); 874 | fullname_albedo=fullfile(PathName,FileName); 875 | set(handles.edit_albedo,'String',fullname_albedo) 876 | 877 | 878 | % --- Executes on button press in pushbutton_ndvi. 879 | function pushbutton_ndvi_Callback(hObject, eventdata, handles) 880 | % hObject handle to pushbutton_ndvi (see GCBO) 881 | % eventdata reserved - to be defined in a future version of MATLAB 882 | % handles structure with handles and user data (see GUIDATA) 883 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 884 | mainPath = pwd; 885 | inputPath = fullfile(mainPath,'Inputs'); 886 | defaultfile=fullfile(inputPath,'RS',strcat('ndvi_', int2str(yeardoy),'_Landsat.tif')); 887 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select LST file'); 888 | fullname_ndvi=fullfile(PathName,FileName); 889 | set(handles.edit_ndvi,'String',fullname_ndvi) 890 | 891 | 892 | % --- Executes on button press in pushbutton_emiss. 893 | function pushbutton_emiss_Callback(hObject, eventdata, handles) 894 | % hObject handle to pushbutton_emiss (see GCBO) 895 | % eventdata reserved - to be defined in a future version of MATLAB 896 | % handles structure with handles and user data (see GUIDATA) 897 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 898 | mainPath = pwd; 899 | inputPath = fullfile(mainPath,'Inputs'); 900 | defaultfile=fullfile(inputPath,'RS',strcat('emiss_', int2str(yeardoy),'_Landsat.tif')); 901 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select emiss file'); 902 | fullname_emiss=fullfile(PathName,FileName); 903 | set(handles.edit_emiss,'String',fullname_emiss) 904 | 905 | 906 | % --- Executes on button press in pushbutton_imghr. 907 | function pushbutton_imghr_Callback(hObject, eventdata, handles) 908 | % hObject handle to pushbutton_imghr (see GCBO) 909 | % eventdata reserved - to be defined in a future version of MATLAB 910 | % handles structure with handles and user data (see GUIDATA) 911 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 912 | mainPath = pwd; 913 | inputPath = fullfile(mainPath,'Inputs'); 914 | defaultfile=fullfile(inputPath,'RS',strcat('imghr_', int2str(yeardoy),'_Modis.tif')); 915 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select emiss file'); 916 | fullname_imghr=fullfile(PathName,FileName); 917 | set(handles.edit_imghr,'String',fullname_imghr) 918 | 919 | 920 | % --- Executes on button press in pushbutton_imgmm. 921 | function pushbutton_imgmm_Callback(hObject, eventdata, handles) 922 | % hObject handle to pushbutton_imgmm (see GCBO) 923 | % eventdata reserved - to be defined in a future version of MATLAB 924 | % handles structure with handles and user data (see GUIDATA) 925 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 926 | mainPath = pwd; 927 | inputPath = fullfile(mainPath,'Inputs'); 928 | defaultfile=fullfile(inputPath,'RS',strcat('imgmm_', int2str(yeardoy),'_Modis.tif')); 929 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select imgmm file'); 930 | fullname_imgmm=fullfile(PathName,FileName); 931 | set(handles.edit_imgmm,'String',fullname_imgmm) 932 | 933 | 934 | % --- Executes on button press in pushbutton_b. 935 | function pushbutton_b_Callback(hObject, eventdata, handles) 936 | % hObject handle to pushbutton_b (see GCBO) 937 | % eventdata reserved - to be defined in a future version of MATLAB 938 | % handles structure with handles and user data (see GUIDATA) 939 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 940 | mainPath = pwd; 941 | inputPath = fullfile(mainPath,'Inputs'); 942 | defaultfile=fullfile(inputPath,'RS',strcat('b_', int2str(yeardoy),'_Modis.tif')); 943 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select imgmm file'); 944 | fullname_b=fullfile(PathName,FileName); 945 | set(handles.edit_b,'String',fullname_b) 946 | 947 | 948 | % --- Executes on button press in pushbutton_z0m. 949 | function pushbutton_z0m_Callback(hObject, eventdata, handles) 950 | % hObject handle to pushbutton_z0m (see GCBO) 951 | % eventdata reserved - to be defined in a future version of MATLAB 952 | % handles structure with handles and user data (see GUIDATA) 953 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 954 | mainPath = pwd; 955 | inputPath = fullfile(mainPath,'Inputs'); 956 | defaultfile=fullfile(inputPath,'Derived',strcat('z0m_', int2str(yeardoy),'_Landsat.tif')); 957 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select imgmm file'); 958 | fullname_z0m=fullfile(PathName,FileName); 959 | set(handles.edit_z0m,'String',fullname_z0m) 960 | 961 | 962 | % --- Executes on button press in pushbutton_Igood. 963 | function pushbutton_Igood_Callback(hObject, eventdata, handles) 964 | % hObject handle to pushbutton_Igood (see GCBO) 965 | % eventdata reserved - to be defined in a future version of MATLAB 966 | % handles structure with handles and user data (see GUIDATA) 967 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 968 | mainPath = pwd; 969 | inputPath = fullfile(mainPath,'Inputs'); 970 | defaultfile=fullfile(inputPath,'Derived',strcat('Igood_', int2str(yeardoy),'_Landsat.tif')); 971 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select imgmm file'); 972 | fullname_Igood=fullfile(PathName,FileName); 973 | set(handles.edit_Igood,'String',fullname_Igood) 974 | 975 | 976 | % --- Executes on button press in pushbutton_Iwater. 977 | function pushbutton_Iwater_Callback(hObject, eventdata, handles) 978 | % hObject handle to pushbutton_Iwater (see GCBO) 979 | % eventdata reserved - to be defined in a future version of MATLAB 980 | % handles structure with handles and user data (see GUIDATA) 981 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 982 | mainPath = pwd; 983 | inputPath = fullfile(mainPath,'Inputs'); 984 | defaultfile=fullfile(inputPath,'Derived',strcat('Iwater_', int2str(yeardoy),'_Landsat.tif')); 985 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select imgmm file'); 986 | fullname_Iwater=fullfile(PathName,FileName); 987 | set(handles.edit_Iwater,'String',fullname_Iwater) 988 | 989 | 990 | % --- Executes on button press in pushbutton_Ag_filter. 991 | function pushbutton_Ag_filter_Callback(hObject, eventdata, handles) 992 | % hObject handle to pushbutton_Ag_filter (see GCBO) 993 | % eventdata reserved - to be defined in a future version of MATLAB 994 | % handles structure with handles and user data (see GUIDATA) 995 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 996 | mainPath = pwd; 997 | defaultfile=fullfile(mainPath,'Agbinary_landsat.tif'); 998 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select imgmm file'); 999 | fullname_Ag_filter=fullfile(PathName,FileName); 1000 | set(handles.edit_Ag_filter,'String',fullname_Ag_filter) 1001 | 1002 | 1003 | 1004 | function edit_computeKr_Callback(hObject, eventdata, handles) 1005 | % hObject handle to edit_computeKr (see GCBO) 1006 | % eventdata reserved - to be defined in a future version of MATLAB 1007 | % handles structure with handles and user data (see GUIDATA) 1008 | 1009 | % Hints: get(hObject,'String') returns contents of edit_computeKr as text 1010 | % str2double(get(hObject,'String')) returns contents of edit_computeKr as a double 1011 | 1012 | 1013 | % --- Executes during object creation, after setting all properties. 1014 | function edit_computeKr_CreateFcn(hObject, eventdata, handles) 1015 | % hObject handle to edit_computeKr (see GCBO) 1016 | % eventdata reserved - to be defined in a future version of MATLAB 1017 | % handles empty - handles not created until after all CreateFcns called 1018 | 1019 | % Hint: edit controls usually have a white background on Windows. 1020 | % See ISPC and COMPUTER. 1021 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1022 | set(hObject,'BackgroundColor','white'); 1023 | end 1024 | 1025 | 1026 | % --- Executes on button press in pushbutton_p_year. 1027 | function pushbutton_p_year_Callback(hObject, eventdata, handles) 1028 | % hObject handle to pushbutton_p_year (see GCBO) 1029 | % eventdata reserved - to be defined in a future version of MATLAB 1030 | % handles structure with handles and user data (see GUIDATA) 1031 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 1032 | mainPath = pwd; 1033 | inputPath = fullfile(mainPath,'Inputs'); 1034 | yeardoy_str = num2str(yeardoy); 1035 | year = str2num(yeardoy_str(1:4)); 1036 | defaultfile=fullfile(inputPath,'Weather',strcat('Pstacked_',int2str(year),'.tif')); 1037 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select p_year file'); 1038 | fullname_p_year=fullfile(PathName,FileName); 1039 | set(handles.edit_p_year,'String',fullname_p_year) 1040 | 1041 | 1042 | function edit_p_year_Callback(hObject, eventdata, handles) 1043 | % hObject handle to edit_p_year (see GCBO) 1044 | % eventdata reserved - to be defined in a future version of MATLAB 1045 | % handles structure with handles and user data (see GUIDATA) 1046 | 1047 | % Hints: get(hObject,'String') returns contents of edit_p_year as text 1048 | % str2double(get(hObject,'String')) returns contents of edit_p_year as a double 1049 | 1050 | 1051 | % --- Executes during object creation, after setting all properties. 1052 | function edit_p_year_CreateFcn(hObject, eventdata, handles) 1053 | % hObject handle to edit_p_year (see GCBO) 1054 | % eventdata reserved - to be defined in a future version of MATLAB 1055 | % handles empty - handles not created until after all CreateFcns called 1056 | 1057 | % Hint: edit controls usually have a white background on Windows. 1058 | % See ISPC and COMPUTER. 1059 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1060 | set(hObject,'BackgroundColor','white'); 1061 | end 1062 | 1063 | 1064 | % --- Executes on button press in pushbutton_et0_year. 1065 | function pushbutton_et0_year_Callback(hObject, eventdata, handles) 1066 | % hObject handle to pushbutton_et0_year (see GCBO) 1067 | % eventdata reserved - to be defined in a future version of MATLAB 1068 | % handles structure with handles and user data (see GUIDATA) 1069 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 1070 | mainPath = pwd; 1071 | inputPath = fullfile(mainPath,'Inputs'); 1072 | yeardoy_str = num2str(yeardoy); 1073 | year = str2num(yeardoy_str(1:4)); 1074 | defaultfile=fullfile(inputPath,'Weather',strcat('ETostacked_',int2str(year),'.tif')); 1075 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select p_year file'); 1076 | fullname_et0_year=fullfile(PathName,FileName); 1077 | set(handles.edit_et0_year,'String',fullname_et0_year) 1078 | 1079 | 1080 | function edit_et0_year_Callback(hObject, eventdata, handles) 1081 | % hObject handle to edit_et0_year (see GCBO) 1082 | % eventdata reserved - to be defined in a future version of MATLAB 1083 | % handles structure with handles and user data (see GUIDATA) 1084 | 1085 | % Hints: get(hObject,'String') returns contents of edit_et0_year as text 1086 | % str2double(get(hObject,'String')) returns contents of edit_et0_year as a double 1087 | 1088 | 1089 | % --- Executes during object creation, after setting all properties. 1090 | function edit_et0_year_CreateFcn(hObject, eventdata, handles) 1091 | % hObject handle to edit_et0_year (see GCBO) 1092 | % eventdata reserved - to be defined in a future version of MATLAB 1093 | % handles empty - handles not created until after all CreateFcns called 1094 | 1095 | % Hint: edit controls usually have a white background on Windows. 1096 | % See ISPC and COMPUTER. 1097 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1098 | set(hObject,'BackgroundColor','white'); 1099 | end 1100 | 1101 | 1102 | % --- Executes on selection change in popupmenu_computeK. 1103 | function popupmenu_computeK_Callback(hObject, eventdata, handles) 1104 | % hObject handle to popupmenu_computeK (see GCBO) 1105 | % eventdata reserved - to be defined in a future version of MATLAB 1106 | % handles structure with handles and user data (see GUIDATA) 1107 | 1108 | % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_computeK contents as cell array 1109 | % contents{get(hObject,'Value')} returns selected item from popupmenu_computeK 1110 | popupmenu_computeK=get(handles.popupmenu_computeK,'Value'); 1111 | if popupmenu_computeK==1 1112 | mainPath = pwd; 1113 | inputPath = fullfile(mainPath,'Inputs'); 1114 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 1115 | yeardoy_str = num2str(yeardoy); 1116 | year = str2num(yeardoy_str(1:4)); 1117 | defaultfile=fullfile(inputPath,'Weather',strcat('Pstacked_',int2str(year),'.tif')); 1118 | set(handles.edit_p_year,'String',defaultfile) 1119 | 1120 | fullname_et0_year=fullfile(inputPath,'Weather',strcat('ETostacked_',int2str(year),'.tif')); 1121 | set(handles.edit_et0_year,'String',fullname_et0_year) 1122 | fullname_soil=fullfile(mainPath,'soil_ras_landsat.tif'); 1123 | set(handles.edit_soil,'String',fullname_soil) 1124 | else 1125 | set(handles.edit_p_year,'String','Null') 1126 | set(handles.edit_et0_year,'String','Null') 1127 | set(handles.edit_soil,'String','Null') 1128 | 1129 | end 1130 | 1131 | % --- Executes during object creation, after setting all properties. 1132 | function popupmenu_computeK_CreateFcn(hObject, eventdata, handles) 1133 | % hObject handle to popupmenu_computeK (see GCBO) 1134 | % eventdata reserved - to be defined in a future version of MATLAB 1135 | % handles empty - handles not created until after all CreateFcns called 1136 | 1137 | % Hint: popupmenu controls usually have a white background on Windows. 1138 | % See ISPC and COMPUTER. 1139 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1140 | set(hObject,'BackgroundColor','white'); 1141 | end 1142 | 1143 | 1144 | % --- Executes on button press in pushbutton_soil. 1145 | function pushbutton_soil_Callback(hObject, eventdata, handles) 1146 | % hObject handle to pushbutton_soil (see GCBO) 1147 | % eventdata reserved - to be defined in a future version of MATLAB 1148 | % handles structure with handles and user data (see GUIDATA) 1149 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 1150 | mainPath = pwd; 1151 | inputPath = fullfile(mainPath,'Inputs'); 1152 | yeardoy_str = num2str(yeardoy); 1153 | year = str2num(yeardoy_str(1:4)); 1154 | defaultfile=fullfile(mainPath,'soil_ras_landsat.tif'); 1155 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select soil file'); 1156 | fullname_soil=fullfile(PathName,FileName); 1157 | set(handles.edit_soil,'String',fullname_soil) 1158 | 1159 | 1160 | function edit_soil_Callback(hObject, eventdata, handles) 1161 | % hObject handle to edit_soil (see GCBO) 1162 | % eventdata reserved - to be defined in a future version of MATLAB 1163 | % handles structure with handles and user data (see GUIDATA) 1164 | 1165 | % Hints: get(hObject,'String') returns contents of edit_soil as text 1166 | % str2double(get(hObject,'String')) returns contents of edit_soil as a double 1167 | 1168 | 1169 | % --- Executes during object creation, after setting all properties. 1170 | function edit_soil_CreateFcn(hObject, eventdata, handles) 1171 | % hObject handle to edit_soil (see GCBO) 1172 | % eventdata reserved - to be defined in a future version of MATLAB 1173 | % handles empty - handles not created until after all CreateFcns called 1174 | 1175 | % Hint: edit controls usually have a white background on Windows. 1176 | % See ISPC and COMPUTER. 1177 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1178 | set(hObject,'BackgroundColor','white'); 1179 | end 1180 | 1181 | 1182 | 1183 | function edit_kr_Callback(hObject, eventdata, handles) 1184 | % hObject handle to edit_kr (see GCBO) 1185 | % eventdata reserved - to be defined in a future version of MATLAB 1186 | % handles structure with handles and user data (see GUIDATA) 1187 | 1188 | % Hints: get(hObject,'String') returns contents of edit_kr as text 1189 | % str2double(get(hObject,'String')) returns contents of edit_kr as a double 1190 | 1191 | 1192 | % --- Executes during object creation, after setting all properties. 1193 | function edit_kr_CreateFcn(hObject, eventdata, handles) 1194 | % hObject handle to edit_kr (see GCBO) 1195 | % eventdata reserved - to be defined in a future version of MATLAB 1196 | % handles empty - handles not created until after all CreateFcns called 1197 | 1198 | % Hint: edit controls usually have a white background on Windows. 1199 | % See ISPC and COMPUTER. 1200 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1201 | set(hObject,'BackgroundColor','white'); 1202 | end 1203 | 1204 | 1205 | 1206 | function edit_kr_max_Callback(hObject, eventdata, handles) 1207 | % hObject handle to edit_kr_max (see GCBO) 1208 | % eventdata reserved - to be defined in a future version of MATLAB 1209 | % handles structure with handles and user data (see GUIDATA) 1210 | 1211 | % Hints: get(hObject,'String') returns contents of edit_kr_max as text 1212 | % str2double(get(hObject,'String')) returns contents of edit_kr_max as a double 1213 | 1214 | 1215 | % --- Executes during object creation, after setting all properties. 1216 | function edit_kr_max_CreateFcn(hObject, eventdata, handles) 1217 | % hObject handle to edit_kr_max (see GCBO) 1218 | % eventdata reserved - to be defined in a future version of MATLAB 1219 | % handles empty - handles not created until after all CreateFcns called 1220 | 1221 | % Hint: edit controls usually have a white background on Windows. 1222 | % See ISPC and COMPUTER. 1223 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1224 | set(hObject,'BackgroundColor','white'); 1225 | end 1226 | 1227 | 1228 | 1229 | function edit_z_st_veg_Callback(hObject, eventdata, handles) 1230 | % hObject handle to edit_z_st_veg (see GCBO) 1231 | % eventdata reserved - to be defined in a future version of MATLAB 1232 | % handles structure with handles and user data (see GUIDATA) 1233 | 1234 | % Hints: get(hObject,'String') returns contents of edit_z_st_veg as text 1235 | % str2double(get(hObject,'String')) returns contents of edit_z_st_veg as a double 1236 | 1237 | 1238 | % --- Executes during object creation, after setting all properties. 1239 | function edit_z_st_veg_CreateFcn(hObject, eventdata, handles) 1240 | % hObject handle to edit_z_st_veg (see GCBO) 1241 | % eventdata reserved - to be defined in a future version of MATLAB 1242 | % handles empty - handles not created until after all CreateFcns called 1243 | 1244 | % Hint: edit controls usually have a white background on Windows. 1245 | % See ISPC and COMPUTER. 1246 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1247 | set(hObject,'BackgroundColor','white'); 1248 | end 1249 | 1250 | 1251 | 1252 | function edit_zref_Callback(hObject, eventdata, handles) 1253 | % hObject handle to edit_zref (see GCBO) 1254 | % eventdata reserved - to be defined in a future version of MATLAB 1255 | % handles structure with handles and user data (see GUIDATA) 1256 | 1257 | % Hints: get(hObject,'String') returns contents of edit_zref as text 1258 | % str2double(get(hObject,'String')) returns contents of edit_zref as a double 1259 | 1260 | 1261 | % --- Executes during object creation, after setting all properties. 1262 | function edit_zref_CreateFcn(hObject, eventdata, handles) 1263 | % hObject handle to edit_zref (see GCBO) 1264 | % eventdata reserved - to be defined in a future version of MATLAB 1265 | % handles empty - handles not created until after all CreateFcns called 1266 | 1267 | % Hint: edit controls usually have a white background on Windows. 1268 | % See ISPC and COMPUTER. 1269 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1270 | set(hObject,'BackgroundColor','white'); 1271 | end 1272 | 1273 | 1274 | 1275 | function edit_t_interval_Callback(hObject, eventdata, handles) 1276 | % hObject handle to edit_t_interval (see GCBO) 1277 | % eventdata reserved - to be defined in a future version of MATLAB 1278 | % handles structure with handles and user data (see GUIDATA) 1279 | 1280 | % Hints: get(hObject,'String') returns contents of edit_t_interval as text 1281 | % str2double(get(hObject,'String')) returns contents of edit_t_interval as a double 1282 | 1283 | 1284 | % --- Executes during object creation, after setting all properties. 1285 | function edit_t_interval_CreateFcn(hObject, eventdata, handles) 1286 | % hObject handle to edit_t_interval (see GCBO) 1287 | % eventdata reserved - to be defined in a future version of MATLAB 1288 | % handles empty - handles not created until after all CreateFcns called 1289 | 1290 | % Hint: edit controls usually have a white background on Windows. 1291 | % See ISPC and COMPUTER. 1292 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1293 | set(hObject,'BackgroundColor','white'); 1294 | end 1295 | 1296 | 1297 | 1298 | function edit_lapse_Callback(hObject, eventdata, handles) 1299 | % hObject handle to edit_lapse (see GCBO) 1300 | % eventdata reserved - to be defined in a future version of MATLAB 1301 | % handles structure with handles and user data (see GUIDATA) 1302 | 1303 | % Hints: get(hObject,'String') returns contents of edit_lapse as text 1304 | % str2double(get(hObject,'String')) returns contents of edit_lapse as a double 1305 | 1306 | 1307 | % --- Executes during object creation, after setting all properties. 1308 | function edit_lapse_CreateFcn(hObject, eventdata, handles) 1309 | % hObject handle to edit_lapse (see GCBO) 1310 | % eventdata reserved - to be defined in a future version of MATLAB 1311 | % handles empty - handles not created until after all CreateFcns called 1312 | 1313 | % Hint: edit controls usually have a white background on Windows. 1314 | % See ISPC and COMPUTER. 1315 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1316 | set(hObject,'BackgroundColor','white'); 1317 | end 1318 | 1319 | 1320 | 1321 | function edit_zb_Callback(hObject, eventdata, handles) 1322 | % hObject handle to edit_zb (see GCBO) 1323 | % eventdata reserved - to be defined in a future version of MATLAB 1324 | % handles structure with handles and user data (see GUIDATA) 1325 | 1326 | % Hints: get(hObject,'String') returns contents of edit_zb as text 1327 | % str2double(get(hObject,'String')) returns contents of edit_zb as a double 1328 | 1329 | 1330 | % --- Executes during object creation, after setting all properties. 1331 | function edit_zb_CreateFcn(hObject, eventdata, handles) 1332 | % hObject handle to edit_zb (see GCBO) 1333 | % eventdata reserved - to be defined in a future version of MATLAB 1334 | % handles empty - handles not created until after all CreateFcns called 1335 | 1336 | % Hint: edit controls usually have a white background on Windows. 1337 | % See ISPC and COMPUTER. 1338 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1339 | set(hObject,'BackgroundColor','white'); 1340 | end 1341 | 1342 | 1343 | % --- Executes on button press in pushbutton27. 1344 | function pushbutton27_Callback(hObject, eventdata, handles) 1345 | % hObject handle to pushbutton27 (see GCBO) 1346 | % eventdata reserved - to be defined in a future version of MATLAB 1347 | % handles structure with handles and user data (see GUIDATA) 1348 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 1349 | mainPath = pwd; 1350 | inputPath = fullfile(mainPath,'Inputs'); 1351 | yeardoy_str = num2str(yeardoy); 1352 | year = str2num(yeardoy_str(1:4)); 1353 | defaultfile=fullfile(mainPath,'dem_landsat.tif'); 1354 | [FileName,PathName,FilterIndex] = uigetfile(defaultfile,'Select dem file'); 1355 | fullname_dem=fullfile(PathName,FileName); 1356 | set(handles.edit_dem,'String',fullname_dem) 1357 | 1358 | 1359 | 1360 | function edit_dem_Callback(hObject, eventdata, handles) 1361 | % hObject handle to edit_dem (see GCBO) 1362 | % eventdata reserved - to be defined in a future version of MATLAB 1363 | % handles structure with handles and user data (see GUIDATA) 1364 | 1365 | % Hints: get(hObject,'String') returns contents of edit_dem as text 1366 | % str2double(get(hObject,'String')) returns contents of edit_dem as a double 1367 | 1368 | 1369 | % --- Executes during object creation, after setting all properties. 1370 | function edit_dem_CreateFcn(hObject, eventdata, handles) 1371 | % hObject handle to edit_dem (see GCBO) 1372 | % eventdata reserved - to be defined in a future version of MATLAB 1373 | % handles empty - handles not created until after all CreateFcns called 1374 | 1375 | % Hint: edit controls usually have a white background on Windows. 1376 | % See ISPC and COMPUTER. 1377 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1378 | set(hObject,'BackgroundColor','white'); 1379 | end 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | function edit_ff_open_Callback(hObject, eventdata, handles) 1386 | % hObject handle to edit_ff_open (see GCBO) 1387 | % eventdata reserved - to be defined in a future version of MATLAB 1388 | % handles structure with handles and user data (see GUIDATA) 1389 | 1390 | % Hints: get(hObject,'String') returns contents of edit_ff_open as text 1391 | % str2double(get(hObject,'String')) returns contents of edit_ff_open as a double 1392 | 1393 | 1394 | % --- Executes during object creation, after setting all properties. 1395 | function edit_ff_open_CreateFcn(hObject, eventdata, handles) 1396 | % hObject handle to edit_ff_open (see GCBO) 1397 | % eventdata reserved - to be defined in a future version of MATLAB 1398 | % handles empty - handles not created until after all CreateFcns called 1399 | 1400 | % Hint: edit controls usually have a white background on Windows. 1401 | % See ISPC and COMPUTER. 1402 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1403 | set(hObject,'BackgroundColor','white'); 1404 | end 1405 | 1406 | 1407 | 1408 | 1409 | % Hint: edit controls usually have a white background on Windows. 1410 | % See ISPC and COMPUTER. 1411 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1412 | set(hObject,'BackgroundColor','white'); 1413 | end 1414 | 1415 | 1416 | 1417 | function edit_lstlowerlimit_Callback(hObject, eventdata, handles) 1418 | % hObject handle to edit_lstlowerlimit (see GCBO) 1419 | % eventdata reserved - to be defined in a future version of MATLAB 1420 | % handles structure with handles and user data (see GUIDATA) 1421 | 1422 | % Hints: get(hObject,'String') returns contents of edit_lstlowerlimit as text 1423 | % str2double(get(hObject,'String')) returns contents of edit_lstlowerlimit as a double 1424 | 1425 | 1426 | % --- Executes during object creation, after setting all properties. 1427 | function edit_lstlowerlimit_CreateFcn(hObject, eventdata, handles) 1428 | % hObject handle to edit_lstlowerlimit (see GCBO) 1429 | % eventdata reserved - to be defined in a future version of MATLAB 1430 | % handles empty - handles not created until after all CreateFcns called 1431 | 1432 | % Hint: edit controls usually have a white background on Windows. 1433 | % See ISPC and COMPUTER. 1434 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1435 | set(hObject,'BackgroundColor','white'); 1436 | end 1437 | 1438 | 1439 | 1440 | function edit_lststep_Callback(hObject, eventdata, handles) 1441 | % hObject handle to edit_lststep (see GCBO) 1442 | % eventdata reserved - to be defined in a future version of MATLAB 1443 | % handles structure with handles and user data (see GUIDATA) 1444 | 1445 | % Hints: get(hObject,'String') returns contents of edit_lststep as text 1446 | % str2double(get(hObject,'String')) returns contents of edit_lststep as a double 1447 | 1448 | 1449 | % --- Executes during object creation, after setting all properties. 1450 | function edit_lststep_CreateFcn(hObject, eventdata, handles) 1451 | % hObject handle to edit_lststep (see GCBO) 1452 | % eventdata reserved - to be defined in a future version of MATLAB 1453 | % handles empty - handles not created until after all CreateFcns called 1454 | 1455 | % Hint: edit controls usually have a white background on Windows. 1456 | % See ISPC and COMPUTER. 1457 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1458 | set(hObject,'BackgroundColor','white'); 1459 | end 1460 | 1461 | 1462 | 1463 | function edit_lstupperlimit_Callback(hObject, eventdata, handles) 1464 | % hObject handle to edit_lstupperlimit (see GCBO) 1465 | % eventdata reserved - to be defined in a future version of MATLAB 1466 | % handles structure with handles and user data (see GUIDATA) 1467 | 1468 | % Hints: get(hObject,'String') returns contents of edit_lstupperlimit as text 1469 | % str2double(get(hObject,'String')) returns contents of edit_lstupperlimit as a double 1470 | 1471 | 1472 | % --- Executes during object creation, after setting all properties. 1473 | function edit_lstupperlimit_CreateFcn(hObject, eventdata, handles) 1474 | % hObject handle to edit_lstupperlimit (see GCBO) 1475 | % eventdata reserved - to be defined in a future version of MATLAB 1476 | % handles empty - handles not created until after all CreateFcns called 1477 | 1478 | % Hint: edit controls usually have a white background on Windows. 1479 | % See ISPC and COMPUTER. 1480 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1481 | set(hObject,'BackgroundColor','white'); 1482 | end 1483 | 1484 | 1485 | 1486 | function edit_lstwindow_Callback(hObject, eventdata, handles) 1487 | % hObject handle to edit_lstwindow (see GCBO) 1488 | % eventdata reserved - to be defined in a future version of MATLAB 1489 | % handles structure with handles and user data (see GUIDATA) 1490 | 1491 | % Hints: get(hObject,'String') returns contents of edit_lstwindow as text 1492 | % str2double(get(hObject,'String')) returns contents of edit_lstwindow as a double 1493 | 1494 | 1495 | % --- Executes during object creation, after setting all properties. 1496 | function edit_lstwindow_CreateFcn(hObject, eventdata, handles) 1497 | % hObject handle to edit_lstwindow (see GCBO) 1498 | % eventdata reserved - to be defined in a future version of MATLAB 1499 | % handles empty - handles not created until after all CreateFcns called 1500 | 1501 | % Hint: edit controls usually have a white background on Windows. 1502 | % See ISPC and COMPUTER. 1503 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1504 | set(hObject,'BackgroundColor','white'); 1505 | end 1506 | 1507 | 1508 | 1509 | function edit_ndvilowerlimit_Callback(hObject, eventdata, handles) 1510 | % hObject handle to edit_ndvilowerlimit (see GCBO) 1511 | % eventdata reserved - to be defined in a future version of MATLAB 1512 | % handles structure with handles and user data (see GUIDATA) 1513 | 1514 | % Hints: get(hObject,'String') returns contents of edit_ndvilowerlimit as text 1515 | % str2double(get(hObject,'String')) returns contents of edit_ndvilowerlimit as a double 1516 | 1517 | 1518 | % --- Executes during object creation, after setting all properties. 1519 | function edit_ndvilowerlimit_CreateFcn(hObject, eventdata, handles) 1520 | % hObject handle to edit_ndvilowerlimit (see GCBO) 1521 | % eventdata reserved - to be defined in a future version of MATLAB 1522 | % handles empty - handles not created until after all CreateFcns called 1523 | 1524 | % Hint: edit controls usually have a white background on Windows. 1525 | % See ISPC and COMPUTER. 1526 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1527 | set(hObject,'BackgroundColor','white'); 1528 | end 1529 | 1530 | 1531 | 1532 | function edit_ndvistep_Callback(hObject, eventdata, handles) 1533 | % hObject handle to edit_ndvistep (see GCBO) 1534 | % eventdata reserved - to be defined in a future version of MATLAB 1535 | % handles structure with handles and user data (see GUIDATA) 1536 | 1537 | % Hints: get(hObject,'String') returns contents of edit_ndvistep as text 1538 | % str2double(get(hObject,'String')) returns contents of edit_ndvistep as a double 1539 | 1540 | 1541 | % --- Executes during object creation, after setting all properties. 1542 | function edit_ndvistep_CreateFcn(hObject, eventdata, handles) 1543 | % hObject handle to edit_ndvistep (see GCBO) 1544 | % eventdata reserved - to be defined in a future version of MATLAB 1545 | % handles empty - handles not created until after all CreateFcns called 1546 | 1547 | % Hint: edit controls usually have a white background on Windows. 1548 | % See ISPC and COMPUTER. 1549 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1550 | set(hObject,'BackgroundColor','white'); 1551 | end 1552 | 1553 | 1554 | 1555 | function edit_ndviupperlimit_Callback(hObject, eventdata, handles) 1556 | % hObject handle to edit_ndviupperlimit (see GCBO) 1557 | % eventdata reserved - to be defined in a future version of MATLAB 1558 | % handles structure with handles and user data (see GUIDATA) 1559 | 1560 | % Hints: get(hObject,'String') returns contents of edit_ndviupperlimit as text 1561 | % str2double(get(hObject,'String')) returns contents of edit_ndviupperlimit as a double 1562 | 1563 | 1564 | % --- Executes during object creation, after setting all properties. 1565 | function edit_ndviupperlimit_CreateFcn(hObject, eventdata, handles) 1566 | % hObject handle to edit_ndviupperlimit (see GCBO) 1567 | % eventdata reserved - to be defined in a future version of MATLAB 1568 | % handles empty - handles not created until after all CreateFcns called 1569 | 1570 | % Hint: edit controls usually have a white background on Windows. 1571 | % See ISPC and COMPUTER. 1572 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1573 | set(hObject,'BackgroundColor','white'); 1574 | end 1575 | 1576 | 1577 | 1578 | function edit_ndviwindow_Callback(hObject, eventdata, handles) 1579 | % hObject handle to edit_ndviwindow (see GCBO) 1580 | % eventdata reserved - to be defined in a future version of MATLAB 1581 | % handles structure with handles and user data (see GUIDATA) 1582 | 1583 | % Hints: get(hObject,'String') returns contents of edit_ndviwindow as text 1584 | % str2double(get(hObject,'String')) returns contents of edit_ndviwindow as a double 1585 | 1586 | 1587 | % --- Executes during object creation, after setting all properties. 1588 | function edit_ndviwindow_CreateFcn(hObject, eventdata, handles) 1589 | % hObject handle to edit_ndviwindow (see GCBO) 1590 | % eventdata reserved - to be defined in a future version of MATLAB 1591 | % handles empty - handles not created until after all CreateFcns called 1592 | 1593 | % Hint: edit controls usually have a white background on Windows. 1594 | % See ISPC and COMPUTER. 1595 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1596 | set(hObject,'BackgroundColor','white'); 1597 | end 1598 | 1599 | 1600 | % Hint: edit controls usually have a white background on Windows. 1601 | % See ISPC and COMPUTER. 1602 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1603 | set(hObject,'BackgroundColor','white'); 1604 | end 1605 | 1606 | 1607 | 1608 | function edit_pixellimit_bins_Callback(hObject, eventdata, handles) 1609 | % hObject handle to edit_pixellimit_bins (see GCBO) 1610 | % eventdata reserved - to be defined in a future version of MATLAB 1611 | % handles structure with handles and user data (see GUIDATA) 1612 | 1613 | % Hints: get(hObject,'String') returns contents of edit_pixellimit_bins as text 1614 | % str2double(get(hObject,'String')) returns contents of edit_pixellimit_bins as a double 1615 | 1616 | 1617 | % --- Executes during object creation, after setting all properties. 1618 | function edit_pixellimit_bins_CreateFcn(hObject, eventdata, handles) 1619 | % hObject handle to edit_pixellimit_bins (see GCBO) 1620 | % eventdata reserved - to be defined in a future version of MATLAB 1621 | % handles empty - handles not created until after all CreateFcns called 1622 | 1623 | % Hint: edit controls usually have a white background on Windows. 1624 | % See ISPC and COMPUTER. 1625 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1626 | set(hObject,'BackgroundColor','white'); 1627 | end 1628 | 1629 | 1630 | 1631 | function edit_pixellimit_counts_Callback(hObject, eventdata, handles) 1632 | % hObject handle to edit_pixellimit_counts (see GCBO) 1633 | % eventdata reserved - to be defined in a future version of MATLAB 1634 | % handles structure with handles and user data (see GUIDATA) 1635 | 1636 | % Hints: get(hObject,'String') returns contents of edit_pixellimit_counts as text 1637 | % str2double(get(hObject,'String')) returns contents of edit_pixellimit_counts as a double 1638 | 1639 | 1640 | % --- Executes during object creation, after setting all properties. 1641 | function edit_pixellimit_counts_CreateFcn(hObject, eventdata, handles) 1642 | % hObject handle to edit_pixellimit_counts (see GCBO) 1643 | % eventdata reserved - to be defined in a future version of MATLAB 1644 | % handles empty - handles not created until after all CreateFcns called 1645 | 1646 | % Hint: edit controls usually have a white background on Windows. 1647 | % See ISPC and COMPUTER. 1648 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1649 | set(hObject,'BackgroundColor','white'); 1650 | end 1651 | 1652 | 1653 | 1654 | function edit_Kadj_Callback(hObject, eventdata, handles) 1655 | % hObject handle to edit_Kadj (see GCBO) 1656 | % eventdata reserved - to be defined in a future version of MATLAB 1657 | % handles structure with handles and user data (see GUIDATA) 1658 | 1659 | % Hints: get(hObject,'String') returns contents of edit_Kadj as text 1660 | % str2double(get(hObject,'String')) returns contents of edit_Kadj as a double 1661 | 1662 | 1663 | % --- Executes during object creation, after setting all properties. 1664 | function edit_Kadj_CreateFcn(hObject, eventdata, handles) 1665 | % hObject handle to edit_Kadj (see GCBO) 1666 | % eventdata reserved - to be defined in a future version of MATLAB 1667 | % handles empty - handles not created until after all CreateFcns called 1668 | 1669 | % Hint: edit controls usually have a white background on Windows. 1670 | % See ISPC and COMPUTER. 1671 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1672 | set(hObject,'BackgroundColor','white'); 1673 | end 1674 | 1675 | 1676 | 1677 | function edit_k_Callback(hObject, eventdata, handles) 1678 | % hObject handle to edit_k (see GCBO) 1679 | % eventdata reserved - to be defined in a future version of MATLAB 1680 | % handles structure with handles and user data (see GUIDATA) 1681 | 1682 | % Hints: get(hObject,'String') returns contents of edit_k as text 1683 | % str2double(get(hObject,'String')) returns contents of edit_k as a double 1684 | 1685 | 1686 | % --- Executes during object creation, after setting all properties. 1687 | function edit_k_CreateFcn(hObject, eventdata, handles) 1688 | % hObject handle to edit_k (see GCBO) 1689 | % eventdata reserved - to be defined in a future version of MATLAB 1690 | % handles empty - handles not created until after all CreateFcns called 1691 | 1692 | % Hint: edit controls usually have a white background on Windows. 1693 | % See ISPC and COMPUTER. 1694 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1695 | set(hObject,'BackgroundColor','white'); 1696 | end 1697 | 1698 | 1699 | 1700 | function edit_outputpath_Callback(hObject, eventdata, handles) 1701 | % hObject handle to edit_outputpath (see GCBO) 1702 | % eventdata reserved - to be defined in a future version of MATLAB 1703 | % handles structure with handles and user data (see GUIDATA) 1704 | 1705 | % Hints: get(hObject,'String') returns contents of edit_outputpath as text 1706 | % str2double(get(hObject,'String')) returns contents of edit_outputpath as a double 1707 | 1708 | 1709 | % --- Executes during object creation, after setting all properties. 1710 | function edit_outputpath_CreateFcn(hObject, eventdata, handles) 1711 | % hObject handle to edit_outputpath (see GCBO) 1712 | % eventdata reserved - to be defined in a future version of MATLAB 1713 | % handles empty - handles not created until after all CreateFcns called 1714 | 1715 | % Hint: edit controls usually have a white background on Windows. 1716 | % See ISPC and COMPUTER. 1717 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1718 | set(hObject,'BackgroundColor','white'); 1719 | end 1720 | 1721 | 1722 | % --- Executes on button press in pushbutton28. 1723 | function pushbutton28_Callback(hObject, eventdata, handles) 1724 | % hObject handle to pushbutton28 (see GCBO) 1725 | % eventdata reserved - to be defined in a future version of MATLAB 1726 | % handles structure with handles and user data (see GUIDATA) 1727 | mainPath = pwd; 1728 | outPath = fullfile(mainPath,'Outputs','Landsat'); 1729 | 1730 | defaultfile=outPath; 1731 | PathName= uigetdir(defaultfile,'Select output path'); 1732 | fullname_outpath=PathName; 1733 | set(handles.edit_outputpath,'String',fullname_outpath) 1734 | 1735 | 1736 | % --- Executes on button press in pushbutton29. 1737 | function pushbutton29_Callback(hObject, eventdata, handles) 1738 | % hObject handle to pushbutton29 (see GCBO) 1739 | % eventdata reserved - to be defined in a future version of MATLAB 1740 | % handles structure with handles and user data (see GUIDATA) 1741 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 1742 | 1743 | lst_path=get(handles.edit_lst,'string'); 1744 | [lst, Rsub] = geotiffread(lst_path); % Jiménez?Muñoz et al., 2003; Sobrino et al. 2004, (http://onlinelibrary.wiley.com/doi/10.1029/2003JD003480/full) 1745 | info_sub = geotiffinfo(lst_path); 1746 | albedo_path=get(handles.edit_albedo,'string'); 1747 | albedo = geotiffread(albedo_path); 1748 | ndvi_path=get(handles.edit_ndvi,'string'); 1749 | ndvi = geotiffread(ndvi_path); 1750 | emiss_path=get(handles.edit_emiss,'string'); 1751 | emiss=geotiffread(emiss_path); 1752 | 1753 | z0m_path=get(handles.edit_z0m,'string'); 1754 | z0m=geotiffread(z0m_path); 1755 | 1756 | Igood_path=get(handles.edit_Igood,'string'); 1757 | Igood=geotiffread(Igood_path); 1758 | Iwater_path=get(handles.edit_Iwater,'string'); 1759 | Iwater=geotiffread(Iwater_path); 1760 | Ag_filter_path=get(handles.edit_Ag_filter,'string'); 1761 | Ag_filter=geotiffread(Ag_filter_path); 1762 | Ag_filter = double(Ag_filter); 1763 | 1764 | rh_inst_path=get(handles.edit_rh_inst,'string'); 1765 | rh_inst=geotiffread(rh_inst_path); 1766 | 1767 | TinstK_path=get(handles.edit_TinstK,'string'); 1768 | TinstK=geotiffread(TinstK_path); 1769 | 1770 | u_inst_path=get(handles.edit_u_inst,'string'); 1771 | u_inst=geotiffread(u_inst_path); 1772 | 1773 | solar_i_path=get(handles.edit_solar_i,'string'); 1774 | solar_i=geotiffread(solar_i_path); 1775 | 1776 | TmaxdailyK_path=get(handles.edit_TmaxdailyK,'string'); 1777 | TmaxdailyK=geotiffread(TmaxdailyK_path); 1778 | 1779 | TmeandailyK_path=get(handles.edit_TmeandailyK,'string'); 1780 | TmeandailyK=geotiffread(TmeandailyK_path); 1781 | 1782 | TmindailyK_path=get(handles.edit_TmindailyK,'string'); 1783 | TmindailyK=geotiffread(TmindailyK_path); 1784 | 1785 | solar24_path=get(handles.edit_solar24,'string'); 1786 | solar24=geotiffread(solar24_path); 1787 | 1788 | rh_daily_path=get(handles.edit_rh_daily,'string'); 1789 | rh_daily=geotiffread(rh_daily_path); 1790 | 1791 | u_daily_path=get(handles.edit_u_daily,'string'); 1792 | u_daily=geotiffread(u_daily_path); 1793 | 1794 | computeKr=get(handles.popupmenu_computeK,'Value'); 1795 | 1796 | if computeKr ==1 1797 | yeardoy_str = num2str(yeardoy); 1798 | year = str2num(yeardoy_str(1:4)); 1799 | 1800 | % vector- one column 1801 | % load ([inputPath,'Weather\P_',int2str(year),'.mat']); 1802 | % load ([inputPath,'Weather\et0_',int2str(year),'.mat']); 1803 | 1804 | % % 365/366 days of stacked daily P and et0 1805 | p_year_path=get(handles.edit_p_year,'string'); 1806 | p_year=geotiffread(p_year_path); 1807 | et0_year_path=get(handles.edit_et0_year,'string'); 1808 | et0_year=geotiffread(et0_year_path); 1809 | soil_path=get(handles.edit_soil,'string'); 1810 | soil=geotiffread(soil_path); 1811 | % also load soil type map. 1812 | 1813 | end 1814 | 1815 | kr=str2num(get(handles.edit_kr,'string')); 1816 | kr_max=str2num(get(handles.edit_kr_max,'string')); 1817 | z_st_veg=str2num(get(handles.edit_z_st_veg,'string')); 1818 | zref=str2num(get(handles.edit_zref,'string')); 1819 | t_interval=str2num(get(handles.edit_t_interval,'string')); 1820 | lapse=str2num(get(handles.edit_lapse,'string')); 1821 | zb=str2num(get(handles.edit_zb,'string')); 1822 | dem_path=get(handles.edit_dem,'string'); 1823 | dem=geotiffread(dem_path); 1824 | dem= double(dem); 1825 | 1826 | 1827 | ff_open=str2num(get(handles.edit_ff_open,'string')); 1828 | lstlowerlimit=str2num(get(handles.edit_lstlowerlimit,'string')); 1829 | lststep=str2num(get(handles.edit_lststep,'string')); 1830 | lstupperlimit=str2num(get(handles.edit_lstupperlimit,'string')); 1831 | lstwindow=str2num(get(handles.edit_lstwindow,'string')); 1832 | ndvilowerlimit=str2num(get(handles.edit_ndvilowerlimit,'string')); 1833 | ndvistep=str2num(get(handles.edit_ndvistep,'string')); 1834 | ndviupperlimit=str2num(get(handles.edit_ndviupperlimit,'string')); 1835 | ndviwindow=str2num(get(handles.edit_ndviwindow,'string')); 1836 | pixellimit_bins=str2num(get(handles.edit_pixellimit_bins,'string')); 1837 | pixellimit_counts=str2num(get(handles.edit_pixellimit_counts,'string')); 1838 | 1839 | landsattype=str2num(get(handles.edit_landsattype,'string')); 1840 | 1841 | satellite_type=get(handles.popupmenu_satallite_type,'Value'); 1842 | if satellite_type==1 1843 | b=str2num(get(handles.edit_b,'string')); 1844 | imghr=str2num(get(handles.edit_imghr,'string')); 1845 | imgmm=str2num(get(handles.edit_imgmm,'string')); 1846 | 1847 | else 1848 | b_path=get(handles.edit_b,'string'); 1849 | b=geotiffread(b_path); 1850 | imghr_path=get(handles.edit_imghr,'string'); 1851 | imghr=geotiffread(imghr_path); 1852 | imgmm_path=get(handles.edit_imgmm,'string'); 1853 | imgmm=geotiffread(imgmm_path); 1854 | end 1855 | 1856 | tic; 1857 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 1858 | yeardoy_str = num2str(yeardoy); 1859 | doy = str2num(yeardoy_str(5:7)); 1860 | Kadj=str2num(get(handles.edit_Kadj,'string')); 1861 | k=str2num(get(handles.edit_k,'string')); 1862 | bbmain= info_sub.BoundingBox; 1863 | pixelsize = info_sub.PixelScale(1); 1864 | % %main image cornerx and cornery and subimage cornerx and corney y; 1865 | mainCx = bbmain(1,1); mainCy = bbmain(2,2); 1866 | 1867 | m = info_sub.Height; 1868 | n = info_sub.Width; 1869 | [imglon,imglat] = MakeLatLongridsFromGeotiffInfo(info_sub,m,n); 1870 | 1871 | 1872 | % computing reference weather info 1873 | 1874 | % for reference ET and atm tswimage 1875 | lon_vec = imglon(:,1); 1876 | lz = zeros(size(lon_vec)); 1877 | lm = zeros(size(lon_vec)); 1878 | for loni =1:size(lon_vec,1) 1879 | lon = lon_vec(loni,1); 1880 | if lon >0 1881 | lz(loni,1) = 360-round(lon,0); 1882 | lm(loni,1) = 360-round(lon,0); 1883 | 1884 | else 1885 | lz(loni,1) = round(lon,0); 1886 | lm(loni,1) = round(lon,0); 1887 | end 1888 | 1889 | while rem(lz(loni,1),15)~=0 1890 | lz(loni,1)=lz(loni,1)+1; 1891 | end 1892 | 1893 | end 1894 | 1895 | lz = repmat(lz,1,n); 1896 | lm = repmat(lm,1,n); 1897 | 1898 | imgtime = imghr + imgmm/60; 1899 | 1900 | f = waitbar(0,'Data processing started...'); 1901 | pause(1) 1902 | 1903 | % reference imagetime ETr 1904 | [etr_inst,~] = hourlyREF_ET_image(doy,TinstK-273.15,TinstK-273.15,dem,solar_i,rh_inst,u_inst,zref,imgtime,lz,imglat,lm,t_interval); 1905 | % Daily ETr and 24hr net radiation 1906 | [etr_d, ~, Q24] = DailyREF_ET_image(doy, TmindailyK-273.15, TmaxdailyK-273.15,dem,solar24,rh_daily,u_daily,zref,imglat); 1907 | %DEM correct LST 1908 | lst_dem = lst + lapse .*dem; 1909 | %% HOT AND COLD PIXEL SELECTION 1910 | %1.1 binary image of ag and non ag 1911 | [bw_1] = FindCandidate_Ag_pixels(lst_dem, ndvi, albedo, Ag_filter, Igood,landsattype,lstupperlimit,lstlowerlimit,ff_open); 1912 | % figure,imagesc(bw_1); 1913 | %2.2. Select hot and cold pixel 1914 | 1915 | 1916 | [lsthotx,lsthoty,lstcoldx,lstcoldy,lstcold,lsthot,cent_counts_l1,cent_counts_n1,coldrow,coldcol,hotrow,hotcol,... 1917 | per_conLcold, per_conNcold,per_conLhot, per_conNhot,count_lstcold_len,count_lsthot_len,... 1918 | min_lstmean,max_ndvimean, max_lstmean,min_ndvimean] = FindHotColdPixelsImage(bw_1,mainCx,mainCy,pixelsize,... 1919 | lst_dem,ndvi,lstupperlimit,lstlowerlimit,ndviupperlimit,ndvilowerlimit,pixellimit_bins,pixellimit_counts,lstwindow, ndviwindow,lststep, ndvistep); 1920 | 1921 | waitbar(.25,f,'Hot and Cold pixel selected Completed.'); 1922 | pause(1) 1923 | 1924 | %% 2. NOW RUN THE SEBAL and METRIC MODELS 1925 | % [m,n] = size(lst); 1926 | % tinstC in degree C 1927 | TinstC = TinstK - 273.15; 1928 | 1929 | %computeKr=get(handles.popupmenu_computeK,'Value'); 1930 | 1931 | if computeKr ==1 1932 | if length(size(soil)) >1 % if 3 diemensional 1933 | soil_t_hot = soil(hotrow,hotcol); 1934 | 1935 | end 1936 | 1937 | end 1938 | hot_lon = imglon(hotrow,hotcol); 1939 | hot_lat = imglat(hotrow,hotcol); 1940 | 1941 | if computeKr ==1 1942 | if length(size(p_year)) >2 % if 3 diemensional 1943 | if size(p_year,3) < 365 1944 | error('missing P for all doys in the year, check this input') 1945 | elseif size(p_year,3) >= 365 1946 | p_year_path=get(handles.edit_et0_year,'string'); 1947 | 1948 | info_p = geotiffinfo(p_year_path); 1949 | [imglon_p,imglat_p] = MakeLatLongridsFromGeotiffInfo(info_p,info_p.Height, info_p.Width); 1950 | bbmain_p= info_p.BoundingBox; 1951 | pixelsize_p = info_p.PixelScale(1); 1952 | mainCx_p = bbmain_p(1,1); mainCy_p = bbmain_p(2,2); 1953 | %find location of hot pixel 1954 | hotcol_p = ceil((abs(mainCx_p-hot_lon))/pixelsize_p)+1; 1955 | hotrow_p= ceil((abs(mainCy_p-hot_lat))/pixelsize_p)+1; 1956 | p_year_vec = p_year(hotrow_p,hotcol_p,1:end); 1957 | p_year = p_year_vec(:); 1958 | 1959 | end 1960 | end 1961 | 1962 | if length(size(et0_year)) >2 % if 3 diemensional 1963 | if size(et0_year,3) < 365 1964 | error('missing ET0 for all doys in the year, check this input') 1965 | elseif size(et0_year,3) >= 365 1966 | et0_year_path=get(handles.edit_et0_year,'string'); 1967 | % et0_year=geotiffread(et0_year_path); 1968 | info_p = geotiffinfo(et0_year_path); 1969 | [imglon_p,imglat_p] = MakeLatLongridsFromGeotiffInfo(info_p,info_p.Height, info_p.Width); 1970 | bbmain_p= info_p.BoundingBox; 1971 | pixelsize_p = info_p.PixelScale(1); 1972 | mainCx_p = bbmain_p(1,1); mainCy_p = bbmain_p(2,2); 1973 | %find location of hot pixel 1974 | hotcol_p = ceil((abs(mainCx_p-hot_lon))/pixelsize_p)+1; 1975 | hotrow_p= ceil((abs(mainCy_p-hot_lat))/pixelsize_p)+1; 1976 | 1977 | et0_year_vec = et0_year(hotrow_p,hotcol_p,1:end); 1978 | et0_year = et0_year_vec(:); 1979 | 1980 | end 1981 | end 1982 | 1983 | kr = Skin_evapAllen(p_year,et0_year,soil_t_hot,doy); 1984 | kr = min(kr,kr_max); 1985 | 1986 | end 1987 | 1988 | %% Compute Net radiation and soil heat flux durin gimage hour 1989 | % cd(codePath); 1990 | % Use same method to compute Rn and G in all models 1991 | [m,n] = size(lst); 1992 | Isnow = zeros(m,n); 1993 | Isnow(ndvi < 0 & albedo > 0.47) = 1; 1994 | ind = find(Iwater ==1|Isnow ==1); 1995 | Rn = NetImageTimeSolarRadiation(solar_i,TinstK,rh_inst, albedo, emiss, lst); 1996 | GbyRn = ((lst-273.16) ./ albedo .* (0.0038 * albedo + 0.0074 * albedo .^2)) .* (1 - 0.98 * ndvi .^4); 1997 | G = round(Rn .*GbyRn); 1998 | clear ('GbyRn'); 1999 | G(Iwater ==1|Isnow ==1) = 0.5 * Rn(Iwater ==1|Isnow ==1); % G of water and snow 2000 | 2001 | Igood(isnan(G)==1)=0; 2002 | Igood(isnan(Rn)==1)=0; 2003 | 2004 | 2005 | 2006 | runSEBAL=get(handles.checkbox_runSEBAL,'value'); 2007 | runMETRIC=get(handles.checkbox_runMETRIC,'value'); 2008 | if runSEBAL ==1 && runMETRIC~=1 2009 | %% 2.1 SEBAL MODEL 2010 | % tic; 2011 | waitbar(.50,f,'Running Automated SEBAL model.....'); 2012 | pause(1) 2013 | % disp('Running Automated SEBAL.........'); 2014 | [~, ~, ~, ~,~,~, ~,~,~, ~,efcold,efhot, ~,... 2015 | h_sebal,lamdaet_sebal,inset_sebal, ef_sebal, det_sebal, ~, lamda24et_sebal,Lamda24] = SEBAL(Rn, G,zref,zb,Q24,... 2016 | lst,TinstK,TmeandailyK,coldrow,coldcol,hotrow,hotcol,z0m,dem,z_st_veg,u_inst, lapse); 2017 | % toc; 2018 | end 2019 | 2020 | if runMETRIC ==1 && runSEBAL~=1 2021 | %% 2.1 METRIC MODEL 2022 | % tic; 2023 | waitbar(.50,f,'Running Automated METRIC model.....'); 2024 | pause(1) 2025 | [lstcold, lsthot, countiter, ~,~,~, ~,~,~, ~,~,~, ~,... 2026 | h_metric,lamdaet_metric,inset_metric, etrf_metric,det_metric, ~, lamda24et_metric] = METRIC(Rn, G,... 2027 | lst,coldrow,coldcol,hotrow,hotcol,kr, z0m, zref,dem,z_st_veg,u_inst,zb,TinstK,etr_inst,etr_d, Q24,Kadj, lapse); 2028 | % toc; 2029 | % figure, imagesc(lamdaet_metric);caxis([0 400]);colorbar;title('lamdaet_metric'); 2030 | % figure, imagesc(det_metric);caxis([0 8]);colorbar;title('Daily ET metric'); 2031 | end 2032 | 2033 | 2034 | if runSEBAL ==1 && runMETRIC==1 2035 | waitbar(.50,f,'Running Automated SEBAL and METRIC models.....'); 2036 | pause(1) 2037 | % tic; 2038 | [~, ~, ~, ~,~,~, ~,~,~, ~,efcold,efhot, ~,... 2039 | h_sebal,lamdaet_sebal,inset_sebal, ef_sebal, det_sebal, ~, lamda24et_sebal,Lamda24] = SEBAL(Rn, G,zref,zb,Q24,... 2040 | lst,TinstK,TmeandailyK,coldrow,coldcol,hotrow,hotcol,z0m,dem,z_st_veg,u_inst, lapse); 2041 | 2042 | [lstcold, lsthot, countiter, ~,~,~, ~,~,~, ~,~,~, ~,... 2043 | h_metric,lamdaet_metric,inset_metric, etrf_metric,det_metric, ~, lamda24et_metric] = METRIC(Rn, G,... 2044 | lst,coldrow,coldcol,hotrow,hotcol,kr, z0m, zref,dem,z_st_veg,u_inst,zb,TinstK,etr_inst,etr_d, Q24,Kadj, lapse); 2045 | % toc; 2046 | 2047 | end 2048 | 2049 | 2050 | if runMETRIC ~=1 && runSEBAL~=1 2051 | %% 2.1 METRIC MODEL 2052 | % tic; 2053 | waitbar(.50,f,'Please select a Model to run.....'); 2054 | pause(1) 2055 | 2056 | % toc; 2057 | % figure, imagesc(lamdaet_metric);caxis([0 400]);colorbar;title('lamdaet_metric'); 2058 | % figure, imagesc(det_metric);caxis([0 8]);colorbar;title('Daily ET metric'); 2059 | end 2060 | 2061 | 2062 | 2063 | makeFig_LE=get(handles.checkbox_makeFig_LE,'value'); 2064 | makeFig_DailyETs=get(handles.checkbox_makeFig_DailyETs,'value'); 2065 | saveMATS=get(handles.checkbox_saveMATS,'value'); 2066 | saveGeoTIFFS=get(handles.checkbox_saveGeoTIFFS,'value'); 2067 | %% Give Options to save output as geotiff or mats 2068 | outPath=get(handles.edit_outputpath,'String'); 2069 | %% Make Figure 2070 | % [imglon,imglat] = MakeLatLongridsFromGeotiffInfo(info_sub,m,n); 2071 | %% Click to visualize location of hot and cold pixel 2072 | % figure,imagesc(lst .*bw_1);caxis([lstcold-5 lsthot+5]);colorbar;title('LST from candidate pixels'); 2073 | % text(hotcol,hotrow,'* Hot pixel','Color','r','FontWeight','Bold','FontSize',16) 2074 | % text(coldcol,coldrow,'* Cold pixel','Color','r','FontWeight','Bold','FontSize',16) 2075 | 2076 | % [FigHandle] = graph_img(lst .*bw_1,imglat,imglon, 'Tentative location of hot and cold pixels in the image', lstcold-5, lsthot+5,1,'LST from candidate pixels (K)'); 2077 | % text(imglon(hotrow,hotcol),imglat(hotrow,hotcol),'* Hot pixel','Color','r','FontWeight','Bold','FontSize',16) 2078 | % text(imglon(coldrow,coldcol),imglat(coldrow,coldcol),'* Cold pixel','Color','r','FontWeight','Bold','FontSize',16) 2079 | % 2080 | % % figure, imagesc(det_sebal); caxis([0 8]);colorbar; 2081 | % 2082 | % %% Click to visualize Latent heat flux from SEBAL and METRIC 2083 | 2084 | 2085 | %% SEBAL MODEL 2086 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2087 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2088 | if runSEBAL ==1 && runMETRIC~=1 2089 | 2090 | if makeFig_LE==1 2091 | figure, 2092 | % subplot(1,2,1) 2093 | [FigHandle] = graph_img(lamdaet_sebal,imglat,imglon, 'LE from SEBAL', 0, min(nanmax(nanmax(lamdaet_sebal)),500),1,'Instantaneous LE (W m ^{-2})'); 2094 | % subplot(1,2,2) 2095 | % [FigHandle1] = graph_img(lamdaet_metric,imglat,imglon, 'LE from METRIC', 0, min(nanmax(nanmax(lamdaet_metric)),500),1,'Instantaneous LE (W m ^{-2})'); 2096 | end 2097 | % 2098 | % 2099 | %% Click to visualize daily ET from SEBAL and METRIC 2100 | if makeFig_DailyETs==1 2101 | figure, 2102 | % subplot(1,2,1) 2103 | [FigHandle] = graph_img(det_sebal,imglat,imglon, 'Daily from SEBAL', 0, min(nanmax(nanmax(det_sebal)),8),1,'Daily ET (mm day^{-1})'); 2104 | % subplot(1,2,2) 2105 | % [FigHandle1] = graph_img(det_metric,imglat,imglon, 'Daily ET from METRIC', 0, min(nanmax(nanmax(det_metric)),8),1,'Daily ET (mm day^{-1})'); 2106 | end 2107 | 2108 | %% Give Options to save output as geotiff or mats 2109 | %saveGeoTIFFS=1; % USE YES or NO button (Save model outputs as GeoTIFFS) 2110 | %saveMATS=1;%(Save model outputs as MATS) 2111 | 2112 | if saveMATS ==1 2113 | 2114 | % SEBAL 2115 | save (fullfile(outPath,strcat('le_sebal_',int2str(yeardoy),'.mat')),'lamdaet_sebal'); 2116 | save (fullfile(outPath,strcat('h_sebal_',int2str(yeardoy),'.mat')),'h_sebal'); 2117 | save (fullfile(outPath,strcat('ef_sebal_',int2str(yeardoy),'.mat')),'ef_sebal'); 2118 | save (fullfile(outPath,strcat('inset_sebal_',int2str(yeardoy),'.mat')),'inset_sebal'); 2119 | save (fullfile(outPath,strcat('det_sebal_',int2str(yeardoy),'.mat')),'det_sebal'); 2120 | end 2121 | 2122 | if saveGeoTIFFS==1 2123 | %SEBAL 2124 | geotiffwrite(fullfile(outPath,strcat('le_sebal_',int2str(yeardoy),'.tif')), lamdaet_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2125 | geotiffwrite(fullfile(outPath,strcat('h_sebal_',int2str(yeardoy),'.tif')), h_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2126 | geotiffwrite(fullfile(outPath,strcat('ef_sebal_',int2str(yeardoy),'.tif')), ef_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2127 | geotiffwrite(fullfile(outPath,strcat('inset_sebal_',int2str(yeardoy),'.tif')), inset_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2128 | geotiffwrite(fullfile(outPath,strcat('det_sebal_',int2str(yeardoy),'.tif')), det_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2129 | end 2130 | 2131 | 2132 | 2133 | 2134 | end 2135 | 2136 | 2137 | %% METRIC MODEL 2138 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2139 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2140 | if runMETRIC ==1 && runSEBAL~=1 2141 | 2142 | 2143 | if makeFig_LE==1 2144 | figure, 2145 | 2146 | [FigHandle1] = graph_img(lamdaet_metric,imglat,imglon, 'LE from METRIC', 0, min(nanmax(nanmax(lamdaet_metric)),500),1,'Instantaneous LE (W m ^{-2})'); 2147 | end 2148 | % 2149 | % 2150 | %% Click to visualize daily ET from SEBAL and METRIC 2151 | if makeFig_DailyETs==1 2152 | figure, 2153 | [FigHandle1] = graph_img(det_metric,imglat,imglon, 'Daily ET from METRIC', 0, min(nanmax(nanmax(det_metric)),8),1,'Daily ET (mm day^{-1})'); 2154 | end 2155 | 2156 | %% Give Options to save output as geotiff or mats 2157 | %saveGeoTIFFS=1; % USE YES or NO button (Save model outputs as GeoTIFFS) 2158 | %saveMATS=1;%(Save model outputs as MATS) 2159 | 2160 | if saveMATS ==1 2161 | 2162 | % METRIC 2163 | save (fullfile(outPath,strcat('le_metric_',int2str(yeardoy),'.mat')),'lamdaet_metric'); 2164 | save (fullfile(outPath,strcat('h_metric_',int2str(yeardoy),'.mat')),'h_metric'); 2165 | save (fullfile(outPath,strcat('etrf_metric_',int2str(yeardoy),'.mat')),'etrf_metric'); 2166 | save (fullfile(outPath,strcat('inset_metric_',int2str(yeardoy),'.mat')),'inset_metric'); 2167 | save (fullfile(outPath,strcat('det_metric_',int2str(yeardoy),'.mat')),'det_metric'); 2168 | end 2169 | 2170 | if saveGeoTIFFS==1 2171 | % METRIC 2172 | geotiffwrite(fullfile(outPath,strcat('le_metric_',int2str(yeardoy),'.tif')), lamdaet_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2173 | geotiffwrite(fullfile(outPath,strcat('h_metric_',int2str(yeardoy),'.tif')), h_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2174 | geotiffwrite(fullfile(outPath,strcat('etrf_metric_',int2str(yeardoy),'.tif')), etrf_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2175 | geotiffwrite(fullfile(outPath,strcat('inset_metric_',int2str(yeardoy),'.tif')), inset_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2176 | geotiffwrite(fullfile(outPath,strcat('det_metric_',int2str(yeardoy),'.tif')), det_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2177 | end 2178 | 2179 | 2180 | 2181 | 2182 | end 2183 | 2184 | 2185 | %% BOTH MODELS 2186 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2187 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2188 | if runSEBAL ==1 && runMETRIC==1 2189 | 2190 | 2191 | if makeFig_LE==1 2192 | figure, 2193 | subplot(1,2,1) 2194 | [FigHandle] = graph_img(lamdaet_sebal,imglat,imglon, 'LE from SEBAL', 0, min(nanmax(nanmax(lamdaet_sebal)),500),1,'Instantaneous LE (W m ^{-2})'); 2195 | subplot(1,2,2) 2196 | [FigHandle1] = graph_img(lamdaet_metric,imglat,imglon, 'LE from METRIC', 0, min(nanmax(nanmax(lamdaet_metric)),500),1,'Instantaneous LE (W m ^{-2})'); 2197 | end 2198 | % 2199 | % 2200 | %% Click to visualize daily ET from SEBAL and METRIC 2201 | if makeFig_DailyETs==1 2202 | figure, 2203 | subplot(1,2,1) 2204 | [FigHandle] = graph_img(det_sebal,imglat,imglon, 'Daily from SEBAL', 0, min(nanmax(nanmax(det_sebal)),8),1,'Daily ET (mm day^{-1})'); 2205 | subplot(1,2,2) 2206 | [FigHandle1] = graph_img(det_metric,imglat,imglon, 'Daily ET from METRIC', 0, min(nanmax(nanmax(det_metric)),8),1,'Daily ET (mm day^{-1})'); 2207 | end 2208 | 2209 | %% Give Options to save output as geotiff or mats 2210 | %saveGeoTIFFS=1; % USE YES or NO button (Save model outputs as GeoTIFFS) 2211 | %saveMATS=1;%(Save model outputs as MATS) 2212 | 2213 | if saveMATS ==1 2214 | % METRIC 2215 | save (fullfile(outPath,strcat('le_metric_',int2str(yeardoy),'.mat')),'lamdaet_metric'); 2216 | save (fullfile(outPath,strcat('h_metric_',int2str(yeardoy),'.mat')),'h_metric'); 2217 | save (fullfile(outPath,strcat('etrf_metric_',int2str(yeardoy),'.mat')),'etrf_metric'); 2218 | save (fullfile(outPath,strcat('inset_metric_',int2str(yeardoy),'.mat')),'inset_metric'); 2219 | save (fullfile(outPath,strcat('det_metric_',int2str(yeardoy),'.mat')),'det_metric'); 2220 | 2221 | % SEBAL 2222 | save (fullfile(outPath,strcat('le_sebal_',int2str(yeardoy),'.mat')),'lamdaet_sebal'); 2223 | save (fullfile(outPath,strcat('h_sebal_',int2str(yeardoy),'.mat')),'h_sebal'); 2224 | save (fullfile(outPath,strcat('ef_sebal_',int2str(yeardoy),'.mat')),'ef_sebal'); 2225 | save (fullfile(outPath,strcat('inset_sebal_',int2str(yeardoy),'.mat')),'inset_sebal'); 2226 | save (fullfile(outPath,strcat('det_sebal_',int2str(yeardoy),'.mat')),'det_sebal'); 2227 | end 2228 | 2229 | if saveGeoTIFFS==1 2230 | % METRIC 2231 | geotiffwrite(fullfile(outPath,strcat('le_metric_',int2str(yeardoy),'.tif')), lamdaet_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2232 | geotiffwrite(fullfile(outPath,strcat('h_metric_',int2str(yeardoy),'.tif')), h_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2233 | geotiffwrite(fullfile(outPath,strcat('etrf_metric_',int2str(yeardoy),'.tif')), etrf_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2234 | geotiffwrite(fullfile(outPath,strcat('inset_metric_',int2str(yeardoy),'.tif')), inset_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2235 | geotiffwrite(fullfile(outPath,strcat('det_metric_',int2str(yeardoy),'.tif')), det_metric,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2236 | 2237 | %SEBAL 2238 | geotiffwrite(fullfile(outPath,strcat('le_sebal_',int2str(yeardoy),'.tif')), lamdaet_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2239 | geotiffwrite(fullfile(outPath,strcat('h_sebal_',int2str(yeardoy),'.tif')), h_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2240 | geotiffwrite(fullfile(outPath,strcat('ef_sebal_',int2str(yeardoy),'.tif')), ef_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2241 | geotiffwrite(fullfile(outPath,strcat('inset_sebal_',int2str(yeardoy),'.tif')), inset_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2242 | geotiffwrite(fullfile(outPath,strcat('det_sebal_',int2str(yeardoy),'.tif')), det_sebal,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2243 | end 2244 | 2245 | 2246 | end 2247 | 2248 | 2249 | 2250 | 2251 | % Options to save Rn and G 2252 | saveRn_MATS=get(handles.checkbox_saveRn_MATS,'value'); 2253 | saveG_MATS =get(handles.checkbox_saveG_MATS,'value'); 2254 | saveRn_GeoTIFFS =get(handles.checkbox_saveRn_GeoTIFFS,'value'); 2255 | saveG_GeoTIFFS =get(handles.checkbox_saveG_GeoTIFFS,'value'); 2256 | if saveRn_MATS ==1 2257 | 2258 | save(fullfile(outPath,strcat('Rn_',int2str(yeardoy),'.mat')), 'Rn'); 2259 | end 2260 | 2261 | if saveG_MATS ==1 2262 | save(fullfile(outPath,strcat('G_',int2str(yeardoy),'.mat')), 'G'); 2263 | end 2264 | 2265 | 2266 | if saveRn_GeoTIFFS ==1 2267 | geotiffwrite(fullfile(outPath,strcat('Rn_',int2str(yeardoy),'.tif')), Rn,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2268 | end 2269 | 2270 | if saveG_GeoTIFFS ==1 2271 | geotiffwrite(fullfile(outPath,strcat('G_',int2str(yeardoy),'.tif')), G,Rsub,'GeoKeyDirectoryTag', info_sub.GeoTIFFTags.GeoKeyDirectoryTag); 2272 | end 2273 | 2274 | 2275 | if (saveRn_GeoTIFFS==1|| saveRn_GeoTIFFS) ==1 && (runSEBAL ==1||runMETRIC==1) 2276 | waitbar(1,f,'Finished. Outputs are saved. Please close this message box'); 2277 | 2278 | elseif runSEBAL ~=1 && runMETRIC~=1 2279 | waitbar(1,f,'Please close this message box. No model selected'); 2280 | 2281 | else 2282 | waitbar(1,f,'Finished. Please close this message box'); 2283 | end 2284 | 2285 | pause(1) 2286 | 2287 | toc; 2288 | 2289 | % --- Executes on button press in checkbox_saveGeoTIFFS. 2290 | function checkbox_saveGeoTIFFS_Callback(hObject, eventdata, handles) 2291 | % hObject handle to checkbox_saveGeoTIFFS (see GCBO) 2292 | % eventdata reserved - to be defined in a future version of MATLAB 2293 | % handles structure with handles and user data (see GUIDATA) 2294 | 2295 | % Hint: get(hObject,'Value') returns toggle state of checkbox_saveGeoTIFFS 2296 | 2297 | 2298 | % --- Executes on button press in checkbox_saveSEBAL_GeoTIFFS. 2299 | function checkbox_saveSEBAL_GeoTIFFS_Callback(hObject, eventdata, handles) 2300 | % hObject handle to checkbox_saveSEBAL_GeoTIFFS (see GCBO) 2301 | % eventdata reserved - to be defined in a future version of MATLAB 2302 | % handles structure with handles and user data (see GUIDATA) 2303 | 2304 | % Hint: get(hObject,'Value') returns toggle state of checkbox_saveSEBAL_GeoTIFFS 2305 | 2306 | 2307 | % --- Executes on button press in checkbox_saveMETRIC_MATS. 2308 | function checkbox_saveMETRIC_MATS_Callback(hObject, eventdata, handles) 2309 | % hObject handle to checkbox_saveMETRIC_MATS (see GCBO) 2310 | % eventdata reserved - to be defined in a future version of MATLAB 2311 | % handles structure with handles and user data (see GUIDATA) 2312 | 2313 | % Hint: get(hObject,'Value') returns toggle state of checkbox_saveMETRIC_MATS 2314 | 2315 | 2316 | % --- Executes on button press in checkbox_saveMATS. 2317 | function checkbox_saveMATS_Callback(hObject, eventdata, handles) 2318 | % hObject handle to checkbox_saveMATS (see GCBO) 2319 | % eventdata reserved - to be defined in a future version of MATLAB 2320 | % handles structure with handles and user data (see GUIDATA) 2321 | 2322 | % Hint: get(hObject,'Value') returns toggle state of checkbox_saveMATS 2323 | 2324 | 2325 | % --- Executes on button press in checkbox_saveRn_MATS. 2326 | function checkbox_saveRn_MATS_Callback(hObject, eventdata, handles) 2327 | % hObject handle to checkbox_saveRn_MATS (see GCBO) 2328 | % eventdata reserved - to be defined in a future version of MATLAB 2329 | % handles structure with handles and user data (see GUIDATA) 2330 | 2331 | % Hint: get(hObject,'Value') returns toggle state of checkbox_saveRn_MATS 2332 | 2333 | 2334 | % --- Executes on button press in checkbox_saveG_MATS. 2335 | function checkbox_saveG_MATS_Callback(hObject, eventdata, handles) 2336 | % hObject handle to checkbox_saveG_MATS (see GCBO) 2337 | % eventdata reserved - to be defined in a future version of MATLAB 2338 | % handles structure with handles and user data (see GUIDATA) 2339 | 2340 | % Hint: get(hObject,'Value') returns toggle state of checkbox_saveG_MATS 2341 | 2342 | 2343 | % --- Executes on button press in checkbox_saveRn_GeoTIFFS. 2344 | function checkbox_saveRn_GeoTIFFS_Callback(hObject, eventdata, handles) 2345 | % hObject handle to checkbox_saveRn_GeoTIFFS (see GCBO) 2346 | % eventdata reserved - to be defined in a future version of MATLAB 2347 | % handles structure with handles and user data (see GUIDATA) 2348 | 2349 | % Hint: get(hObject,'Value') returns toggle state of checkbox_saveRn_GeoTIFFS 2350 | 2351 | 2352 | % --- Executes on button press in checkbox_saveG_GeoTIFFS. 2353 | function checkbox_saveG_GeoTIFFS_Callback(hObject, eventdata, handles) 2354 | % hObject handle to checkbox_saveG_GeoTIFFS (see GCBO) 2355 | % eventdata reserved - to be defined in a future version of MATLAB 2356 | % handles structure with handles and user data (see GUIDATA) 2357 | 2358 | % Hint: get(hObject,'Value') returns toggle state of checkbox_saveG_GeoTIFFS 2359 | 2360 | 2361 | % --- Executes on button press in radiobutton1. 2362 | 2363 | 2364 | %--- Executes on selection change in popupmenu_satallite_type. 2365 | function popupmenu_satallite_type_Callback(hObject, eventdata, handles) 2366 | % hObject handle to popupmenu_satallite_type (see GCBO) 2367 | % eventdata reserved - to be defined in a future version of MATLAB 2368 | % handles structure with handles and user data (see GUIDATA) 2369 | 2370 | % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_satallite_type contents as cell array 2371 | % contents{get(hObject,'Value')} returns selected item from popupmenu_satallite_type 2372 | satellite_type=get(handles.popupmenu_satallite_type,'Value'); 2373 | if satellite_type==1 2374 | mainPath = pwd; 2375 | inputPath = fullfile(mainPath,'Inputs'); 2376 | outPath = fullfile(mainPath,'Outputs','Landsat'); 2377 | if ~exist(outPath) 2378 | mkdir(fullfile(mainPath,'Outputs','Landsat')) 2379 | end 2380 | cd(mainPath); 2381 | 2382 | %defaultfile=fullfile(pwd,'Inputs','lst_l5_2011277.tif'); 2383 | set(handles.popupmenu_satallite_type,'Value',1) 2384 | set(handles.edit_yeardoy,'String',num2str(2006215)) 2385 | set(handles.edit_landsattype,'String', num2str(5)) 2386 | set(handles.edit_b,'String', num2str(90-61.66628785)) 2387 | set(handles.edit_imghr,'String', num2str(10)) 2388 | set(handles.edit_imgmm,'String', num2str(55)) 2389 | 2390 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 2391 | defaultfile=fullfile(inputPath,'RS',strcat('lst_',int2str(yeardoy),'_Landsat.tif')); 2392 | set(handles.edit_lst,'String',defaultfile) 2393 | defaultfile=fullfile(inputPath,'RS',strcat('albedo_', int2str(yeardoy),'_Landsat.tif')); 2394 | set(handles.edit_albedo,'String',defaultfile) 2395 | defaultfile=fullfile(inputPath,'RS',strcat('emiss_', int2str(yeardoy),'_Landsat.tif')); 2396 | set(handles.edit_emiss,'String',defaultfile) 2397 | defaultfile=fullfile(inputPath,'RS',strcat('ndvi_', int2str(yeardoy),'_Landsat.tif')); 2398 | set(handles.edit_ndvi,'String',defaultfile) 2399 | 2400 | defaultfile=fullfile(inputPath,'Derived',strcat('z0m_', int2str(yeardoy),'_Landsat.tif')); 2401 | set(handles.edit_z0m,'String',defaultfile) 2402 | defaultfile=fullfile(inputPath,'Derived',strcat('Igood_', int2str(yeardoy),'_Landsat.tif')); 2403 | set(handles.edit_Igood,'String',defaultfile) 2404 | defaultfile=fullfile(inputPath,'Derived',strcat('Iwater_', int2str(yeardoy),'_Landsat.tif')); 2405 | set(handles.edit_Iwater,'String',defaultfile) 2406 | defaultfile=fullfile(mainPath,'Agbinary_landsat.tif'); 2407 | set(handles.edit_Ag_filter,'String',defaultfile) 2408 | 2409 | 2410 | defaultfile=fullfile(inputPath,'Weather',strcat('rhinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 2411 | set(handles.edit_rh_inst,'String',defaultfile) 2412 | defaultfile=fullfile(inputPath,'Weather',strcat('TinstK_awdn_', int2str(yeardoy),'_Landsat.tif')); 2413 | set(handles.edit_TinstK,'String',defaultfile) 2414 | defaultfile=fullfile(inputPath,'Weather',strcat('uinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 2415 | set(handles.edit_u_inst,'String',defaultfile) 2416 | defaultfile=fullfile(inputPath,'Weather',strcat('solarinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 2417 | set(handles.edit_solar_i,'String',defaultfile) 2418 | defaultfile=fullfile(inputPath,'Weather',strcat('solarinst_awdn_', int2str(yeardoy),'_Landsat.tif')); 2419 | set(handles.edit_solar_i,'String',defaultfile) 2420 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmaxd_awdn_', int2str(yeardoy),'_Landsat.tif')); 2421 | set(handles.edit_TmaxdailyK,'String',defaultfile) 2422 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmeand_awdn_', int2str(yeardoy),'_Landsat.tif')); 2423 | set(handles.edit_TmeandailyK,'String',defaultfile) 2424 | defaultfile=fullfile(inputPath,'Weather',strcat('Tmind_awdn_', int2str(yeardoy),'_Landsat.tif')); 2425 | set(handles.edit_TmindailyK,'String',defaultfile) 2426 | defaultfile=fullfile(inputPath,'Weather',strcat('s24d_awdn_', int2str(yeardoy),'_Landsat.tif')); 2427 | set(handles.edit_solar24,'String',defaultfile) 2428 | defaultfile=fullfile(inputPath,'Weather',strcat('rhd_awdn_', int2str(yeardoy),'_Landsat.tif')); 2429 | set(handles.edit_rh_daily,'String',defaultfile) 2430 | defaultfile=fullfile(inputPath,'Weather',strcat('ud_awdn_', int2str(yeardoy),'_Landsat.tif')); 2431 | set(handles.edit_u_daily,'String',defaultfile) 2432 | set(handles.popupmenu_computeK,'Value',2) 2433 | set(handles.edit_p_year,'String','Null') 2434 | set(handles.edit_et0_year,'String','Null') 2435 | set(handles.edit_soil,'String','Null') 2436 | yeardoy_str = num2str(yeardoy); 2437 | year = str2num(yeardoy_str(1:4)); 2438 | defaultfile=fullfile(inputPath,'Weather',strcat('Pstacked_',int2str(year),'.tif')); 2439 | %set(handles.edit_p_year,'String',defaultfile) 2440 | 2441 | fullname_et0_year=fullfile(inputPath,'Weather',strcat('ETostacked_',int2str(year),'.tif')); 2442 | %set(handles.edit_et0_year,'String',fullname_et0_year) 2443 | fullname_soil=fullfile(mainPath,'soil_ras_landsat.tif'); 2444 | %set(handles.edit_soil,'String',fullname_soil) 2445 | set(handles.edit_kr,'String','0') 2446 | set(handles.edit_kr_max,'String','0.15') 2447 | set(handles.edit_z_st_veg,'String','0.15') 2448 | set(handles.edit_zref,'String','10') 2449 | set(handles.edit_t_interval,'String','1') 2450 | set(handles.edit_lapse,'String','0.0065') 2451 | set(handles.edit_zb,'String','200') 2452 | 2453 | set(handles.edit_dem,'String',fullfile(mainPath,'dem_landsat.tif')) 2454 | 2455 | load defaults_hotcold_param_landsat; 2456 | 2457 | set(handles.edit_ff_open,'String',num2str(ff_open)) 2458 | set(handles.edit_lstlowerlimit,'String',num2str(lstlowerlimit)) 2459 | set(handles.edit_lststep,'String',num2str(lststep)) 2460 | set(handles.edit_lstupperlimit,'String',num2str(lstupperlimit)) 2461 | set(handles.edit_lstwindow,'String',num2str(lstwindow)) 2462 | set(handles.edit_ndvilowerlimit,'String',num2str(ndvilowerlimit)) 2463 | set(handles.edit_ndvistep,'String',num2str(ndvistep)) 2464 | set(handles.edit_ndviupperlimit,'String',num2str(ndviupperlimit)) 2465 | set(handles.edit_ndviwindow,'String',num2str(ndviwindow)) 2466 | set(handles.edit_pixellimit_bins,'String',num2str(pixellimit_bins)) 2467 | set(handles.edit_pixellimit_counts,'String',num2str(pixellimit_counts)) 2468 | 2469 | set(handles.edit_Kadj,'String',num2str(1.05)) 2470 | set(handles.edit_k,'String',num2str(0.41)) 2471 | 2472 | set(handles.checkbox_saveGeoTIFFS,'value',1); 2473 | set(handles.checkbox_saveMATS,'value',1); 2474 | 2475 | set(handles.checkbox_saveRn_MATS,'value',1); 2476 | set(handles.checkbox_saveG_MATS,'value',1); 2477 | set(handles.checkbox_saveRn_GeoTIFFS,'value',1); 2478 | set(handles.checkbox_saveG_GeoTIFFS,'value',1); 2479 | 2480 | set(handles.checkbox_makeFig_LE,'value',0); 2481 | set(handles.checkbox_makeFig_DailyETs,'value',0); 2482 | set(handles.checkbox_runMETRIC,'value',1); 2483 | set(handles.checkbox_runSEBAL,'value',1); 2484 | elseif satellite_type==2 2485 | mainPath=pwd; 2486 | inputPath = fullfile(mainPath,'Inputs'); 2487 | % outPath = fullfile(mainPath,'Outputs','Landsat'); 2488 | % if ~exist(outPath) 2489 | % mkdir(fullfile(mainPath,'Outputs','Landsat')) 2490 | % end 2491 | % cd(mainPath); 2492 | % 2493 | % %defaultfile=fullfile(pwd,'Inputs','lst_l5_2011277.tif'); 2494 | % set(handles.popupmenu_satallite_type,'Value',1) 2495 | % set(handles.edit_yeardoy,'String',num2str(2006215)) 2496 | yeardoy=str2num(get(handles.edit_yeardoy,'string')); 2497 | % set(handles.edit_landsattype,'String', num2str(0)) 2498 | set(handles.edit_b,'String', fullfile(inputPath,'RS',strcat('b_', int2str(yeardoy),'_Modis.tif'))) 2499 | set(handles.edit_imghr,'String', fullfile(inputPath,'RS',strcat('imghr_', int2str(yeardoy),'_Modis.tif'))) 2500 | set(handles.edit_imgmm,'String', fullfile(inputPath,'RS',strcat('imgmm_', int2str(yeardoy),'_Modis.tif'))) 2501 | % 2502 | defaultfile=fullfile(inputPath,'RS',strcat('lst_', int2str(yeardoy),'_Modis.tif')); 2503 | set(handles.edit_lst,'String',defaultfile) 2504 | defaultfile=fullfile(inputPath,'RS',strcat('albedo_', int2str(yeardoy),'_Modis.tif')); 2505 | set(handles.edit_albedo,'String',defaultfile) 2506 | defaultfile=fullfile(inputPath,'RS',strcat('emiss_', int2str(yeardoy),'_Modis.tif')); 2507 | set(handles.edit_emiss,'String',defaultfile) 2508 | defaultfile=fullfile(inputPath,'RS',strcat('ndvi_', int2str(yeardoy),'_Modis.tif')); 2509 | set(handles.edit_ndvi,'String',defaultfile) 2510 | % 2511 | defaultfile=fullfile(inputPath,'Derived',strcat('z0m_', int2str(yeardoy),'_Modis.tif')); 2512 | set(handles.edit_z0m,'String',defaultfile) 2513 | defaultfile=fullfile(inputPath,'Derived',strcat('Igood_', int2str(yeardoy),'_Modis.tif')); 2514 | set(handles.edit_Igood,'String',defaultfile) 2515 | defaultfile=fullfile(inputPath,'Derived',strcat('Iwater_', int2str(yeardoy),'_Modis.tif')); 2516 | set(handles.edit_Iwater,'String',defaultfile) 2517 | defaultfile=fullfile(mainPath,'Agbinary_Modis.tif'); 2518 | set(handles.edit_Ag_filter,'String',defaultfile) 2519 | % 2520 | % 2521 | defaultfile=fullfile(inputPath,'Weather',strcat('rhinst_awdn_', int2str(yeardoy),'_Modis.tif')); 2522 | set(handles.edit_rh_inst,'String',defaultfile) 2523 | defaultfile=fullfile(inputPath,'Weather',strcat('TinstK_awdn_', int2str(yeardoy),'_Modis.tif')); 2524 | set(handles.edit_TinstK,'String',defaultfile) 2525 | defaultfile=fullfile(inputPath,'Weather',strcat('uinst_awdn_', int2str(yeardoy),'_Modis.tif')); 2526 | set(handles.edit_u_inst,'String',defaultfile) 2527 | defaultfile=fullfile(inputPath,'Weather',strcat('solarinst_awdn_', int2str(yeardoy),'_Modis.tif')); 2528 | set(handles.edit_solar_i,'String',defaultfile) 2529 | defaultfile=fullfile(inputPath,'Weather',strcat('TmaxdK_awdn_', int2str(yeardoy),'_Modis.tif')); 2530 | set(handles.edit_TmaxdailyK,'String',defaultfile) 2531 | defaultfile=fullfile(inputPath,'Weather',strcat('TmeandK_awdn_', int2str(yeardoy),'_Modis.tif')); 2532 | set(handles.edit_TmeandailyK,'String',defaultfile) 2533 | defaultfile=fullfile(inputPath,'Weather',strcat('TmindK_awdn_', int2str(yeardoy),'_Modis.tif')); 2534 | set(handles.edit_TmindailyK,'String',defaultfile) 2535 | defaultfile=fullfile(inputPath,'Weather',strcat('s24d_awdn_', int2str(yeardoy),'_Modis.tif')); 2536 | set(handles.edit_solar24,'String',defaultfile) 2537 | defaultfile=fullfile(inputPath,'Weather',strcat('rhd_awdn_', int2str(yeardoy),'_Modis.tif')); 2538 | set(handles.edit_rh_daily,'String',defaultfile) 2539 | defaultfile=fullfile(inputPath,'Weather',strcat('ud_awdn_', int2str(yeardoy),'_Modis.tif')); 2540 | set(handles.edit_u_daily,'String',defaultfile) 2541 | 2542 | set(handles.popupmenu_computeK,'Value',2) 2543 | set(handles.edit_p_year,'String','Null') 2544 | set(handles.edit_et0_year,'String','Null') 2545 | set(handles.edit_soil,'String','Null') 2546 | 2547 | yeardoy_str = num2str(yeardoy); 2548 | year = str2num(yeardoy_str(1:4)); 2549 | defaultfile=fullfile(inputPath,'Weather',strcat('Pstacked_',int2str(year),'.tif')); 2550 | %set(handles.edit_p_year,'String',defaultfile) 2551 | 2552 | fullname_et0_year=fullfile(inputPath,'Weather',strcat('ETostacked_',int2str(year),'.tif')); 2553 | %set(handles.edit_et0_year,'String',fullname_et0_year) 2554 | fullname_soil=fullfile(mainPath,'soil_ras_modis.tif'); 2555 | %set(handles.edit_soil,'String',fullname_soil) 2556 | set(handles.edit_kr,'String','0') 2557 | set(handles.edit_kr_max,'String','0.15') 2558 | set(handles.edit_z_st_veg,'String','0.15') 2559 | set(handles.edit_zref,'String','10') 2560 | set(handles.edit_t_interval,'String','1') 2561 | set(handles.edit_lapse,'String','0.0065') 2562 | set(handles.edit_zb,'String','200') 2563 | % 2564 | set(handles.edit_dem,'String',fullfile(mainPath,'dem4Modis.tif')) 2565 | % 2566 | load defaults_hotcold_param_modis; 2567 | 2568 | set(handles.edit_ff_open,'String',num2str(ff_open)) 2569 | set(handles.edit_lstlowerlimit,'String',num2str(lstlowerlimit)) 2570 | set(handles.edit_lststep,'String',num2str(lststep)) 2571 | set(handles.edit_lstupperlimit,'String',num2str(lstupperlimit)) 2572 | set(handles.edit_lstwindow,'String',num2str(lstwindow)) 2573 | set(handles.edit_ndvilowerlimit,'String',num2str(ndvilowerlimit)) 2574 | set(handles.edit_ndvistep,'String',num2str(ndvistep)) 2575 | set(handles.edit_ndviupperlimit,'String',num2str(ndviupperlimit)) 2576 | set(handles.edit_ndviwindow,'String',num2str(ndviwindow)) 2577 | set(handles.edit_pixellimit_bins,'String',num2str(pixellimit_bins)) 2578 | set(handles.edit_pixellimit_counts,'String',num2str(pixellimit_counts)) 2579 | set(handles.edit_Kadj,'String',num2str(1.05)) 2580 | set(handles.edit_k,'String',num2str(0.41)) 2581 | set(handles.checkbox_saveGeoTIFFS,'value',1); 2582 | set(handles.checkbox_saveMATS,'value',1); 2583 | set(handles.checkbox_saveRn_MATS,'value',1); 2584 | set(handles.checkbox_saveG_MATS,'value',1); 2585 | set(handles.checkbox_saveRn_GeoTIFFS,'value',1); 2586 | set(handles.checkbox_saveG_GeoTIFFS,'value',1); 2587 | set(handles.checkbox_makeFig_LE,'value',0); 2588 | set(handles.checkbox_makeFig_DailyETs,'value',0); 2589 | set(handles.checkbox_runMETRIC,'value',1); 2590 | set(handles.checkbox_runSEBAL,'value',1); 2591 | end 2592 | 2593 | % --- Executes during object creation, after setting all properties. 2594 | function popupmenu_satallite_type_CreateFcn(hObject, eventdata, handles) 2595 | % hObject handle to popupmenu_satallite_type (see GCBO) 2596 | % eventdata reserved - to be defined in a future version of MATLAB 2597 | % handles empty - handles not created until after all CreateFcns called 2598 | 2599 | % Hint: popupmenu controls usually have a white background on Windows. 2600 | % See ISPC and COMPUTER. 2601 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 2602 | set(hObject,'BackgroundColor','white'); 2603 | end 2604 | 2605 | 2606 | % --- Executes on button press in checkbox_makeFig_LE. 2607 | function checkbox_makeFig_LE_Callback(hObject, eventdata, handles) 2608 | % hObject handle to checkbox_makeFig_LE (see GCBO) 2609 | % eventdata reserved - to be defined in a future version of MATLAB 2610 | % handles structure with handles and user data (see GUIDATA) 2611 | 2612 | % Hint: get(hObject,'Value') returns toggle state of checkbox_makeFig_LE 2613 | 2614 | 2615 | % --- Executes on button press in checkbox_makeFig_DailyETs. 2616 | function checkbox_makeFig_DailyETs_Callback(hObject, eventdata, handles) 2617 | % hObject handle to checkbox_makeFig_DailyETs (see GCBO) 2618 | % eventdata reserved - to be defined in a future version of MATLAB 2619 | % handles structure with handles and user data (see GUIDATA) 2620 | 2621 | % Hint: get(hObject,'Value') returns toggle state of checkbox_makeFig_DailyETs 2622 | 2623 | 2624 | % --- Executes on selection change in popupmenu6. 2625 | function popupmenu6_Callback(hObject, eventdata, handles) 2626 | % hObject handle to popupmenu6 (see GCBO) 2627 | % eventdata reserved - to be defined in a future version of MATLAB 2628 | % handles structure with handles and user data (see GUIDATA) 2629 | 2630 | % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu6 contents as cell array 2631 | % contents{get(hObject,'Value')} returns selected item from popupmenu6 2632 | 2633 | 2634 | % --- Executes during object creation, after setting all properties. 2635 | function popupmenu6_CreateFcn(hObject, eventdata, handles) 2636 | % hObject handle to popupmenu6 (see GCBO) 2637 | % eventdata reserved - to be defined in a future version of MATLAB 2638 | % handles empty - handles not created until after all CreateFcns called 2639 | 2640 | % Hint: popupmenu controls usually have a white background on Windows. 2641 | % See ISPC and COMPUTER. 2642 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 2643 | set(hObject,'BackgroundColor','white'); 2644 | end 2645 | 2646 | 2647 | % --- Executes on button press in checkbox_runSEBAL. 2648 | function checkbox_runSEBAL_Callback(hObject, eventdata, handles) 2649 | % hObject handle to checkbox_runSEBAL (see GCBO) 2650 | % eventdata reserved - to be defined in a future version of MATLAB 2651 | % handles structure with handles and user data (see GUIDATA) 2652 | 2653 | % Hint: get(hObject,'Value') returns toggle state of checkbox_runSEBAL 2654 | 2655 | 2656 | % --- Executes on button press in checkbox_runMETRIC. 2657 | function checkbox_runMETRIC_Callback(hObject, eventdata, handles) 2658 | % hObject handle to checkbox_runMETRIC (see GCBO) 2659 | % eventdata reserved - to be defined in a future version of MATLAB 2660 | % handles structure with handles and user data (see GUIDATA) 2661 | 2662 | % Hint: get(hObject,'Value') returns toggle state of checkbox_runMETRIC 2663 | -------------------------------------------------------------------------------- /METRIC.m: -------------------------------------------------------------------------------- 1 | function [lstcold, lsthot, countiter, ustar,rah,rahhot, rahcold,dttemp,dtcold, dthot,etrfcold,etrfhot, L,... 2 | sensheat,lamdaet,inset, etrf,dailyet, sens24, lam24] = METRIC(Rn, G,... 3 | lst,coldrow,coldcol,hotrow,hotcol,kr, z0m, zref,dem,z_st_veg,u_inst,zb,TinstK,etr_inst,etr_d, Q24,Kadj,lapse) 4 | % written by- Nishan Bhattarai (University of Michigan) 5 | % Contact: nbbhattar@umich.edu/nbhattar@syr.edu) 6 | % clear all; close all; clc; 7 | %% NOTE: In this model, Rn and G are provided as input. 8 | %% INPUT DATA 9 | % Rn = net radiation (Wm-2) 10 | % G = soil heat flux (W m-2) 11 | % lst = lst in K 12 | % coldrow = row of cold pixel 13 | % hotrow = row of hot pixel 14 | % hotcol = column number of hot pixel 15 | % kr = ERrF in hot pixel using FAO method 16 | % z0m = surface roughness (m) 17 | % zref = reference height of wind measurment 18 | % dem = elevation (m) 19 | % u_inst = wind speed at ref height 20 | % z_st_veg = height of grass in the weather station(m) 21 | % zb = blending height (m) 22 | % TinstK = air temp (K) at image time 23 | % TmeandailyK= mean daily air temp (K) 24 | % ETrinst = Instantaneous ETr from ASCE-PM method(mm/hr) 25 | % ETrdaily = Daily ETr from ASCE-PM method (mm/day) 26 | % Q24 = 24 hr net radiation (W m-2) 27 | % Kadj = adjustment factor used for cold pixel ET (1.05) 28 | % lapse = lapse rate (0.0065 C per m); 29 | 30 | 31 | %% OUTPUT 32 | %lstcold = LST (K) at the cold pixel 33 | % lsthot = LST (K) at the hot pixel 34 | % countiter = total number of iteations used in rah stabilization 35 | % ustar = frictional velocity (m/s) 36 | % rah = aerodynamic resistance 37 | % rahhot = rah at hot pixel 38 | % rahcold = rah at cold pixel 39 | % L = monin-Okuluv length (m) 40 | % dttemp = near surface temp difference (Ts-Ta) 41 | % dtcold = dttemp at cold pixel 42 | % dthot = dttemp at hot pixel 43 | % efcold = reference ET fraction at the cold pixel 44 | % efhot= reference ET fraction at the hot pixel 45 | % sensheat = sensible heat flux (H) - W m-2 46 | % lamdaet = latent heat flux (LE) - W m-2 47 | % inset = instantaneous ET (mm/hr) 48 | % etrf = reference ET fraction 49 | % dailyet = Daily ET (mm/day) 50 | % sens24 = 24 hr net sensible heat flux (W m-2) 51 | % lam24 = 24 hr net latent heat flux (W m-2) 52 | 53 | z2= 2; 54 | z1 = 0.1; 55 | 56 | lst_dem = lst + lapse*dem; 57 | 58 | % wind speed at blending height 59 | k = 0.41; 60 | zomst = 0.12*z_st_veg; %momentum roughness length (m), h = height of the vegetation in the weather station 61 | ux = k*u_inst/(log(zref/zomst)); 62 | u200 = ux * log(zb/zomst)/k; % wind speed at 200m during imagetime 63 | 64 | 65 | % LST at the hot and cold pixel -using 3x3 mean 66 | lstcold = nanmin(nanmin(lst_dem(coldrow-1:coldrow+1,coldcol-1:coldcol+1))); %%% get the minimum value 67 | lsthot = nanmean(nanmean(lst_dem(hotrow-1:hotrow+1,hotcol-1:hotcol+1))); 68 | 69 | 70 | %%Fluxes at hot and cold pixels 71 | %%%% using 3x3 mean 72 | Rcold = nanmean(nanmean(Rn(coldrow-1:coldrow+1,coldcol-1:coldcol+1))); 73 | Rhotpixels = Rn(hotrow-1:hotrow+1,hotcol-1:hotcol+1); 74 | % Rhot = nanmean(nanmean(Rhotpixels(Rhotpixels >0))); 75 | Rhot = nanmean(nanmean(Rhotpixels)); 76 | 77 | Gcold = nanmean(nanmean(G(coldrow-1:coldrow+1,coldcol-1:coldcol+1))); 78 | Ghotpixels = G(hotrow-1:hotrow+1,hotcol-1:hotcol+1); 79 | % Ghot = nanmean(nanmean(Ghotpixels(Ghotpixels >0))); 80 | Ghot = nanmean(nanmean(Ghotpixels)); 81 | 82 | 83 | % Ref et for the cold pixel- if ref ET is provided as an image get 84 | % the value for the cold pixel 85 | if length(etr_inst) >1 86 | ret_cold = mean(mean(etr_inst(coldrow-1:coldrow+1,coldcol-1:coldcol+1))); 87 | ret_hot = mean(mean(etr_inst(hotrow-1:hotrow+1,hotcol-1:hotcol+1))); 88 | % lecold = 1.05*ret_cold*681.6; 89 | lecold = Kadj*ret_cold*681.6; 90 | lehot = kr*ret_hot*681.6; 91 | else 92 | % lecold = 1.05*etr_inst*681.6;% 681.6 is a factor to change it to W/m2 1.2 if ET0 is used from grass 93 | % adj K 94 | lecold = Kadj*etr_inst*681.6; 95 | 96 | lehot = kr*etr_inst*681.6; 97 | end 98 | 99 | 100 | h1cold = Rcold-lecold-Gcold; 101 | % if h1cold < 0 102 | % h1cold = 0; 103 | % end 104 | h1hot = Rhot-lehot-Ghot; 105 | 106 | % friction velocity and rah 107 | ustar = k*u200./log((zb)./z0m); 108 | rah = real(log(z2/z1)./(ustar*k)); 109 | 110 | rahcold =mean(mean(rah(coldrow-1:coldrow+1,coldcol-1:coldcol+1))); 111 | rahhot =mean(mean(rah(hotrow-1:hotrow+1,hotcol-1:hotcol+1))); 112 | 113 | demcold = mean(mean(dem(coldrow-1:coldrow+1,coldcol-1:coldcol+1))); 114 | demhot = mean(mean(dem(hotrow-1:hotrow+1,hotcol-1:hotcol+1))); 115 | 116 | 117 | % clear dem; 118 | pcold = (1 -demcold* 0.0000225577)^ 5.2599 * 101325 /(287.05 * lstcold); % air density at cold pixel 119 | phot = (1 -demhot* 0.0000225577)^ 5.2599 * 101325 /(287.05 * lsthot); % air density at hot pixel 120 | 121 | 122 | % estimated canopy height 123 | hc = real(z0m/0.13); 124 | d0 = 2/3 * hc; 125 | 126 | %%Iteration starts 127 | zb=200; % blending height 128 | %[m,n] = size (lst); 129 | countiter = 1; % to record the number of iterations. published papers indicate 2-8 interations is common 130 | diff = 100; % arbitary. just to run the loop 131 | % dtcold =0; 132 | % dthot =0; 133 | 134 | 135 | while diff > 5 %% run it till difference in rah(hot pixel) is < 5%...can do same with DT(hot) 136 | % typically 3-8 iterations will stabilize rah at the hot pixel 137 | dtcold =rahcold * h1cold/(pcold*1004); % sensible heat equation,..1004 is the water density 138 | dthot=rahhot* h1hot/(phot*1004); 139 | 140 | dtplot= [lsthot dthot; lstcold dtcold]; 141 | p = polyfit(dtplot(:,1), dtplot(:,2),1); 142 | a1 = p(1); b1 = p(2); 143 | dttemp = double(a1*lst_dem +b1); 144 | tair = lst_dem-dttemp; 145 | den = (287.05 * tair); 146 | num = (101325 * (1 - 0.0000225577 .*dem).^ 5.2599); % elve in m/ can use a DEM too 147 | pair = num./den; clear num; clear den; 148 | 149 | %sensible heatflux 150 | sensheat = 1004* (pair.*dttemp)./rah; 151 | % clear tair; clear dttemp; 152 | 153 | num = -(1004*pair.*(ustar.^3)).*lst; 154 | den = (0.41*9.81*sensheat); 155 | L = num./den; clear num; clear den; 156 | 157 | 158 | psim_zb = Psim_SEBAL((zb)./L,L); 159 | psih_z2 = Psih_SEBAL((z2)./L, L); 160 | psih_z1 = Psih_SEBAL(z1./L,L); 161 | newu = real(u200*k./(log((zb)./z0m)-psim_zb)); %Bastiaanssen et al. (1998, 2005) 162 | rah_new = real((log((z2)./z1)- psih_z2+psih_z1 )./(k* newu)); 163 | 164 | 165 | 166 | % the following codes can be used to test model under different zref 167 | % 168 | % if zref <=2 169 | % psim_zb = Psim_SEBAL((zb)./L,L); 170 | % psih_z2 = Psih_SEBAL((z2)./L, L); 171 | % psih_z1 = Psih_SEBAL(z1./L,L); 172 | % newu = real(u200*k./(log((zb)./z0m)-psim_zb)); %Bastiaanssen et al. (1998, 2005) 173 | % rah_new = real((log((z2)./z1)- psih_z2+psih_z1 )./(k* newu)); 174 | % 175 | % 176 | % elseif zref >2 177 | % 178 | % psim_zb = Psim_SEBAL((zb-d0)./L,L); 179 | % psih_zref = Psih_SEBAL((zref-d0)./L, L); 180 | % psih_z1 = Psih_SEBAL(z1./L,L); 181 | % newu = real(u200*k./(log((zb-d0)./z0m)-psim_zb)); %Bastiaanssen et al. (1998, 2005) 182 | % rah_new = real((log((zref-d0)./z1)- psih_zref+psih_z1 )./(k* newu)); 183 | % 184 | % end 185 | 186 | % rahcold_new =nanmean(nanmean(rah_new(coldrow-1:coldrow+1,coldcol-1:coldcol+1))); 187 | rahhot_new =nanmean(nanmean(rah_new(hotrow-1:hotrow+1,hotcol-1:hotcol+1))); 188 | diff = abs(100* (rahhot-rahhot_new)/rahhot_new); %% differnce in Rah for hot pixel 189 | 190 | % rahcold = rahcold_new; 191 | rahhot =rahhot_new; 192 | % set new rah and ustar 193 | rah= rah_new; ustar = newu; 194 | countiter = countiter+1; 195 | 196 | if countiter == 50 % stop after 10 iterations- in some cases 197 | diff = 4; % < 5 to close the loop 198 | end 199 | 200 | end 201 | 202 | 203 | sensheat (sensheat <0) = 0; 204 | % figure,imagesc(sensheat);colorbar; 205 | lamdaet = Rn-G-sensheat; 206 | % instantaneous ET (ET at the image time) mm/day 207 | inset = 3600* lamdaet./ ((2.501-(0.002361 * (TinstK-273.15))) * 1000000); % instant et in mm/hr 208 | etrf = inset./etr_inst; % reference evaporative fraction 209 | 210 | etrf(etrf <0)= 0; 211 | etrf(etrf > 1.2) =1.2; 212 | 213 | etrf = real(etrf); 214 | 215 | dailyet = etrf .*etr_d; % daily ET 216 | % figure,imagesc(dailyet);colorbar; 217 | % figure,imagesc(etrf);colorbar; 218 | 219 | lamda = (2.501-(0.002361 * (TinstK-273.15))) * 1000000; 220 | 221 | % 24 hr latent heat flux 222 | lam24 = (dailyet/ 86400) .* lamda; 223 | 224 | % 24 hr sensible hear flux 225 | sens24 = Q24-lam24; 226 | 227 | etrfcold = etrf(coldrow,coldcol); 228 | etrfhot =etrf(hotrow,hotcol); 229 | 230 | 231 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 232 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 233 | %% 234 | % figure(); 235 | % subplot(2,1,1) 236 | % imagesc(etrf);colorbar; 237 | % subplot (2,1,2) 238 | % imagesc(dailyet); caxis([ 0 10]); colorbar; 239 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 240 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 241 | end 242 | 243 | 244 | 245 | 246 | 247 | 248 | -------------------------------------------------------------------------------- /MakeLatLongridsFromGeotiffInfo.m: -------------------------------------------------------------------------------- 1 | function [longrids,latgrids] = MakeLatLongridsFromGeotiffInfo(info_sub,m,n) 2 | % Make Lat and Lon grids 3 | % Get the Corner coordinates 4 | % Info_sub= geotiffinfo 5 | % Nishan Bhattarai- nishan.bhattarai@tufts.edu 6 | %m= number of rows 7 | %n = number of cols 8 | 9 | LatUL =info_sub.CornerCoords.Lat(1,1); 10 | LonUL=info_sub.CornerCoords.Lon(1,1); 11 | 12 | % LatUR =info_sub.CornerCoords.Lat(1,2); 13 | LonUR=info_sub.CornerCoords.Lon(1,2); 14 | LatLR = info_sub.CornerCoords.Lat(1,4); 15 | 16 | Lonrange = LonUL-LonUR;%Lon changes along columns- X axis (i.e. same for each column-Y) 17 | Latrange = LatUL-LatLR;%Lat changes along rows- Y axis (i.e. same for each column-X 18 | % Pixel size based on degrees 19 | Lonc = Lonrange/n; 20 | Latc = Latrange/m; 21 | LonR = zeros(1,n); 22 | LatR = zeros(m,1); 23 | 24 | % Note that this is for Northern Hemisphere 25 | for i =1:n 26 | LonR(1,i)=LonUL-i*Lonc; 27 | 28 | end 29 | for i =1:m 30 | LatR(i,1) = LatUL - i*Latc; 31 | end 32 | 33 | longrids = repmat(LonR,m, 1); 34 | latgrids = repmat(LatR,[1,n]); 35 | 36 | end 37 | 38 | -------------------------------------------------------------------------------- /NetImageTimeSolarRadiation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishan3/LandModETmapper/39a47f8a97c4ce595cd65e9bb9f7c8f9bbdf813e/NetImageTimeSolarRadiation.m -------------------------------------------------------------------------------- /Psih_SEBAL.m: -------------------------------------------------------------------------------- 1 | function [psih] = Psih_SEBAL(zeta,L) 2 | %% SEBAL and METRIC stability correction for momentum transport 3 | %zeta = z/L, z = height (or z-zero displacement height), L = Monin-Obukhov length 4 | % change z to get stability correction for heat transfer at different 5 | % heights 6 | % written by- Nishan Bhattarai (University of Michigan) 7 | % Contact: nbbhattar@umich.edu/nbhattar@syr.edu) 8 | 9 | [mm,nn]= size(zeta); 10 | 11 | %Unstable condition 12 | xh = (1.0-16* zeta) .^ 0.25; 13 | 14 | psih=zeros(mm,nn); % netural condition 15 | 16 | ind0less =find(L <0); 17 | ind0more=find(L>0); 18 | 19 | psih(ind0less) = 2*log((1+ xh(ind0less).^2)/2); 20 | psih(ind0more) = -5 * zeta(ind0more); 21 | 22 | % 23 | % for i=1:mm 24 | % for j = 1:nn 25 | % if zeta(i,j) < 0; %unstable condition 26 | % psih(i,j) = 2*log((1+ xh(i,j).^2)/2); 27 | % 28 | % elseif zeta(i,j) > 0 %stable condition 29 | % psih(i,j) = -5 * zeta(i,j); 30 | % end 31 | % end 32 | % end 33 | 34 | psih= real(psih); 35 | 36 | end 37 | 38 | -------------------------------------------------------------------------------- /Psim_SEBAL.m: -------------------------------------------------------------------------------- 1 | function [psim] = Psim_SEBAL(zeta,L) 2 | %% SEBAL and METRIC stability correction for momentum transport 3 | %zeta = z/L, z = height (or z-zero displacement height), L = Monin-Obukhov length 4 | % change z to get stability correction for momentum transfer at different 5 | % heights 6 | 7 | % written by- Nishan Bhattarai (University of Michigan) 8 | % Contact: nbbhattar@umich.edu/nbhattar@syr.edu) 9 | [mm,nn]= size(zeta); 10 | 11 | %Unstable condition 12 | xm = (1-16* zeta) .^ 0.25; 13 | 14 | psim=zeros(mm,nn); % neutral condition. 15 | 16 | ind0less =find(L <0); 17 | ind0more=find(L>0); 18 | 19 | 20 | psim(ind0less) = real(2*log((1+ xm(ind0less))/2)+log((1+ xm(ind0less).^2)/2) -2 * atan(xm(ind0less)) + 0.5 *pi); 21 | psim(ind0more) = -5 * zeta(ind0more); 22 | 23 | % for i=1:mm 24 | % for j = 1:nn 25 | % if zeta(i,j) < 0; %unstable condition 26 | % psim(i,j) = real(2*log((1+ xm(i,j))/2)+log((1+ xm(i,j).^2)/2) -2 * atan(xm(i,j)) + 0.5 *pi); 27 | % 28 | % elseif zeta(i,j) > 0 %stable condition 29 | % psim(i,j) = -5 * zeta(i,j); 30 | % end 31 | % end 32 | % end 33 | 34 | psim = real(psim); 35 | 36 | end 37 | 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LandModETmapper 2 | The LandMODETmapper is a Matlab based GUI for implementation of SEBAL and METRIC models on Landsat and MODIS. 3 | Input data (and all the codes for running the models) for one sample image (one Landsat and MODIS each) for running the LandModET Mapper are available in this google drive folder https://drive.google.com/file/d/1MS5Dx5A9zmilduYKf7ugqXO7E6t2P0Am/view?usp=sharing. 4 | Read "About LandMOD ET Mapper.pdf" for more details. 5 | Sources: https://www.sciencedirect.com/science/article/pii/S1364815219301203 and https://www.sciencedirect.com/science/article/pii/S0034425717302018 6 | Contact: Nishan Bhattarai. nishan@ou.edu 7 | -------------------------------------------------------------------------------- /SEBAL.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishan3/LandModETmapper/39a47f8a97c4ce595cd65e9bb9f7c8f9bbdf813e/SEBAL.m -------------------------------------------------------------------------------- /Skin_evapAllen.m: -------------------------------------------------------------------------------- 1 | function [kr] = Skin_evapAllen(pptyear,etoyear,soil_t_hot,doy) 2 | %% computes kr for hot pixel based on FAO based skin evaporation (allen et 3 | % al. 1998, Allen et al., 2011) 4 | 5 | 6 | % INPUTS 7 | % pptyear = column vector of ppt in inches 8 | % etoyear = column vector of eto in mm/day 9 | % soil_t_hot, soil text code 10 | % doy of the given year 11 | 12 | % pptyear =Ref_ET_daily.RAIN(Ref_ET_daily.YEAR==year); 13 | % pptyear(pptyear <0)= 0; %0 14 | % etoyear= Ref_ET_daily.ET0(Ref_ET_daily.YEAR==year); 15 | % etoyear(etoyear<0)=nanmean(etoyear >0); % replace by mean value 16 | % 17 | % % soil_t_hot = soil_text(hotrow,hotcol); 18 | % soil_t_hot = 2; 19 | 20 | yr1 = length(pptyear); 21 | y_fao = zeros(yr1,6); 22 | y_fao(:,1) = pptyear; 23 | y_fao(:,2) = etoyear; 24 | 25 | 26 | 27 | soil_t_hot = max(0,soil_t_hot); % no water will be selected. 0 -water 28 | 29 | % Typical soil water characteristics for different soil types (after Allen et al., 1998) 30 | rew = 8; tew = 25; % 31 | 32 | if soil_t_hot == 1 33 | rew = 2; tew = 12; 34 | elseif soil_t_hot == 2 35 | rew = 4; tew = 14; 36 | 37 | elseif soil_t_hot == 3 38 | rew = 6; tew = 20; 39 | 40 | elseif soil_t_hot == 4 41 | rew = 8; tew = 22; 42 | 43 | elseif soil_t_hot == 5 44 | rew = 8; tew = 25; 45 | 46 | elseif soil_t_hot == 6 47 | rew = 8; tew = 26; 48 | elseif soil_t_hot == 7 49 | rew = 8; tew = 27; 50 | 51 | elseif soil_t_hot == 8 52 | rew = 8; tew = 28; 53 | 54 | elseif soil_t_hot == 9 55 | rew = 8; tew = 29; 56 | 57 | end 58 | 59 | 60 | 61 | tew_rew = tew-rew; 62 | % cumulative depth of evaporation for day i, De,i (mm) 63 | % dei = tew_rew; % start from Jan 1st..assume it's tew-rew 64 | y_fao(1,4) = 1; % kr,..start with 1 65 | y_fao(1,5) = y_fao(1,4)*y_fao(1,2); % et % use 1.2 when ETo is used 66 | 67 | y_fao(1,3) = tew_rew; 68 | y_fao(1,6) = y_fao(1,3) - y_fao(1,4)+ y_fao(1,5); 69 | y_fao(1,6) = min(tew,y_fao(1,6)); % limit max value to tew 70 | y_fao(1,6) = max(0,y_fao(1,6)); % limit min value to 0 71 | 72 | % 73 | % % now dei for i=2 day 74 | % y_fao(2,3) = max(y_fao(1,6) - y_fao(2,1)*25.4,0); 75 | % y_fao(2,3) = min(tew,y_fao(2,3)); 76 | % %y_fao(2,3) = max(0,y_fao(2,3)); 77 | % 78 | % % kr for i day; 79 | % y_fao(2,4) = (tew - y_fao(2,3))/tew_rew; 80 | % y_fao(2,4) = min(1,y_fao(2,4)); 81 | % y_fao(2,4) = max(0,y_fao(2,4)); 82 | % y_fao(2,5) = y_fao(2,4)*y_fao(2,2); 83 | % y_fao(2,6) = y_fao(2,3) - y_fao(2,4)+ y_fao(2,5); 84 | % y_fao(2,6) = min(tew,y_fao(2,6)); % limit max value to tew 85 | % y_fao(2,6) = max(0,y_fao(2,6)); % limit min value to 0 86 | 87 | 88 | for i = 1:yr1-1 89 | %cumulative depth of evaporation for day i start 90 | y_fao(i+1,3) = max(y_fao(i,6) - y_fao(i+1,1)*25.4,0); % 91 | y_fao(i+1,3) = min(tew,y_fao(i+1,3)); 92 | % kr 93 | y_fao(i+1,4) = (tew - y_fao(i+1,3))/tew_rew; %kr 94 | y_fao(i+1,4) = min(1,y_fao(i+1,4)); 95 | y_fao(i+1,4) = max(0,y_fao(i+1,4)); 96 | y_fao(i+1,5) = y_fao(i+1,4)*y_fao(i+1,2); % ET 97 | %cumulative depth of evaporation for day i end 98 | y_fao(i+1,6) = y_fao(i+1,3) - y_fao(i+1,4)+ y_fao(i+1,5); 99 | y_fao(i+1,6) = min(tew,y_fao(i+1,6)); % limit max value to tew 100 | y_fao(i+1,6) = max(0,y_fao(i+1,6)); % limit min value to 0 101 | end 102 | 103 | 104 | % Now get kr for the hot pixel for image doy; 105 | kr = y_fao(doy,4); 106 | %kr = min(0.5,kr); % limit value of kr to 0.5. Higher value may result into inconsistant results 107 | 108 | if doy > 5 109 | ppt_doy = y_fao(doy,1)* 25.4; 110 | ppt_doy1 = y_fao(doy-1,1)* 25.4; 111 | ppt_doy2 = y_fao(doy-2,1)* 25.4; 112 | ppt_doy3 = y_fao(doy-3,1)* 25.4; 113 | ppt_doy4 = y_fao(doy-4,1)* 25.4; 114 | 115 | ppt_4days = (y_fao(doy-4,1)+y_fao(doy-3,1)+y_fao(doy-2,1)+y_fao(doy-1,1)) * 25.4; % in mm 116 | 117 | % if there was no ppt in ast 4-5 days. 118 | if ppt_4days ==0 119 | kr =0; 120 | end 121 | end 122 | 123 | end 124 | 125 | -------------------------------------------------------------------------------- /allcomb.m: -------------------------------------------------------------------------------- 1 | function A = allcomb(varargin) 2 | % ALLCOMB - All combinations 3 | % B = ALLCOMB(A1,A2,A3,...,AN) returns all combinations of the elements 4 | % in A1, A2, ..., and AN. B is P-by-N matrix is which P is the product 5 | % of the number of elements of the N inputs. 6 | % Empty inputs yields an empty matrix B of size 0-by-N. Note that 7 | % previous versions (1.x) simply ignored empty inputs. 8 | % 9 | % Example: 10 | % allcomb([1 3 5],[-3 8],[0 1]) 11 | % 1 -3 0 12 | % 1 -3 1 13 | % 1 8 0 14 | % ... 15 | % 5 -3 1 16 | % 5 8 1 17 | % 18 | % % Inputs can be character arrays as well: 19 | % allcomb('abc','XY') 20 | % aX 21 | % aY 22 | % bX 23 | % bY 24 | % cX 25 | % cY 26 | % 27 | % % or combined (output will be a character array) 28 | % allcomb('ab',[65 66]) 29 | % aA 30 | % aB 31 | % bA 32 | % bB 33 | % 34 | % ALLCOMB(A1,..AN,'matlab') causes the first column to change fastest. 35 | % This is more consistent with matlab indexing. Example: 36 | % allcomb(1:2,3:4,5:6,'matlab') %-> 37 | % 1 3 5 38 | % 2 3 5 39 | % 1 4 5 40 | % ... 41 | % 2 4 6 42 | % 43 | % This functionality is also known as the cartesian product. 44 | % 45 | % See also NCHOOSEK, PERMS, NDGRID 46 | % and COMBN, KTHCOMBN (Matlab Central FEX) 47 | 48 | % for Matlab R13+ 49 | % version 2.2 (jan 2012) 50 | % (c) Jos van der Geest 51 | % email: jos@jasen.nl 52 | 53 | % History 54 | % 1.1 (feb 2006), removed minor bug when entering empty cell arrays; 55 | % added option to let the first input run fastest (suggestion by JD) 56 | % 1.2 (jan 2010), using ii as an index on the left-hand for the multiple 57 | % output by NDGRID. Thanks to Jan Simon, for showing this little trick 58 | % 2.0 (dec 2010). Bruno Luong convinced me that an empty input should 59 | % return an empty output. 60 | % 2.1 (feb 2011). A cell as input argument caused the check on the last 61 | % argument (specifying the order) to crash. 62 | % 2.2 (jan 2012). removed a superfluous line of code (ischar(..)) 63 | % 3.0 (may 2012) removed check for doubles so character arrays are accepted 64 | 65 | error(nargchk(1,Inf,nargin)) ; 66 | 67 | % check for empty inputs 68 | q = ~cellfun('isempty',varargin) ; 69 | if any(~q) 70 | warning('ALLCOMB:EmptyInput','Empty inputs result in an empty output.') ; 71 | A = zeros(0,nargin) ; 72 | else 73 | 74 | ni = sum(q) ; 75 | 76 | argn = varargin{end} ; 77 | 78 | if ischar(argn) && (strcmpi(argn,'matlab') || strcmpi(argn,'john')) 79 | % based on a suggestion by JD on the FEX 80 | ni = ni-1 ; 81 | ii = 1:ni ; 82 | q(end) = 0 ; 83 | else 84 | % enter arguments backwards, so last one (AN) is changing fastest 85 | ii = ni:-1:1 ; 86 | end 87 | 88 | if ni==0 89 | A = [] ; 90 | else 91 | args = varargin(q) ; 92 | if ni==1 93 | A = args{1}(:) ; 94 | else 95 | % flip using ii if last column is changing fastest 96 | [A{ii}] = ndgrid(args{ii}) ; 97 | % concatenate 98 | A = reshape(cat(ni+1,A{:}),[],ni) ; 99 | end 100 | end 101 | end 102 | -------------------------------------------------------------------------------- /graph_img.m: -------------------------------------------------------------------------------- 1 | function [FigHandle] = graph_img(data,lat_trmm,lon_trmm, GraphTitle, caxismin, caxismax,colorbarcode,colortitle) 2 | % GraphTitle ='MOD Day Available Days'; 3 | FigHandle=surface(lon_trmm,lat_trmm,data,'EdgeColor','none'); 4 | shading flat; 5 | xlim([min(min(lon_trmm)) max(max(lon_trmm))]); 6 | ylim([min(min(lat_trmm)) max(max(lat_trmm))]); 7 | xlabel('Longitude'); 8 | ylabel('Latitude'); 9 | caxis([caxismin caxismax]); 10 | title(GraphTitle); 11 | 12 | if colorbarcode==1 13 | % c = colorbar('southoutside'); 14 | c = colorbar; 15 | c.Label.String = colortitle; 16 | end 17 | end 18 | 19 | -------------------------------------------------------------------------------- /hourlyREF_ET_image.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishan3/LandModETmapper/39a47f8a97c4ce595cd65e9bb9f7c8f9bbdf813e/hourlyREF_ET_image.m --------------------------------------------------------------------------------