-
Notifications
You must be signed in to change notification settings - Fork 7
/
PDSI_Tool_Launcher.m
634 lines (528 loc) · 26.4 KB
/
PDSI_Tool_Launcher.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
%% © 2012 Vanderbilt University %%
function varargout = PDSI_Tool_Launcher(varargin)
% PDSI_Tool_Launcher MATLAB code for PDSI_Tool_Launcher.fig
% PDSI_Tool_Launcher, by itself, creates a new PDSI_Tool_Launcher or raises the existing
% singleton*.
%
% H = PDSI_Tool_Launcher returns the handle to a new PDSI_Tool_Launcher or the handle to
% the existing singleton*.
%
% PDSI_Tool_Launcher('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PDSI_Tool_Launcher.M with the given input
% arguments.
%
% PDSI_Tool_Launcher('Property','Value',...) creates a new PDSI_Tool_Launcher or raises
% the existing singleton*. Starting from the left, property value
% pairs are applied to the GUI before PDSI_Tool_Launcher_OpeningFcn gets called.
% An unrecognized property name or invalid value makes property
% application stop. All inputs are passed to PDSI_Tool_Launcher_OpeningFcn via
% varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help PDSI_Tool_Launcher
% Last Modified by GUIDE 13-Jun-2014
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PDSI_Tool_Launcher_OpeningFcn, ...
'gui_OutputFcn', @PDSI_Tool_Launcher_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before PDSI_Tool_Launcher is made visible.
function PDSI_Tool_Launcher_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to PDSI_Tool_Launcher (see VARARGIN)
% Choose default command line output for PDSI_Tool_Launcher
handles.output = hObject;
set(handles.pet_buttongroup,'SelectionChangeFcn', ...
@pet_buttongroup_SelectionChangeFcn);
set(handles.calyrs_buttongroup, 'SelectionChangeFcn', ...
@calyrs_buttongroup_SelectionChangeFcn);
set(handles.radiobutton_thorn,'Value',1)
set(handles.radiobutton_noaa,'Value',1)
set(handles.help_text,'Visible','off')
set(handles.edit_const_alb,'string','0.23')
set(handles.edit_alb_file,'string','')
set(handles.edit_alb_file,'Enable','off')
set(handles.radiobutton1_const_Alb,'Value',1)
set(handles.pushbutton_browse,'Enable','off')
set(handles.radiobutton_alb_file,'Value',0)
set(handles.uipanel_albedo,'SelectionChangeFcn',@uipanel_albedo_SelectionChangeFcn);
set(handles.pushbutton_Elevation,'Enable','off')
set(handles.pushbutton_OK,'Enable','off')
set(handles.radiobutton1_const_Alb,'Enable','off')
set(handles.radiobutton_alb_file,'Enable','off')
set(handles.edit_const_alb,'Enable','off')
W1 = {'Welcome to the MATLAB Palmer Drought Indices Calculator.'};
W2 = {'Please load your data, select your desired PET calculation method'};
W3 = {'and calibration period, and run the program.'};
W4 = {'Click the "Help" button for directions and answers to any questions.'};
dash = {'--------'};
space = {''};
set(handles.welcome_text,'String',[space;W1;dash;W2;W3;dash;W4;]);
H4 = {'------- Climate Inputs -------'};
H5 = {'- The US Historical Climate Network (USHCN) has historical temperature and precipitation data available for US stations at http://cdiac.ornl.gov/epubs/ndp/ushcn/access.html.'};
H6 = {'- Data must be consecutive (i.e., no gaps) and combined into one .txt file. Do not include column headers.'};
H7 = {'- Data should be chronologically organized into eight columns: Column 1 is the latitude in degrees, Column 2 is the year, Columns 3 and 4 are min/max temperature (Farenheit),'};
H8 = {' Column 5 is precipitation (inches), Column 6 is the average daily downward shortwave radiation at surface (W m-2), Column 7 is wind speed (m/s), and Column 8 is specific humdity (kg/kg).'};
H9 = {'- Note: Column 8 can be relative humidity (See the comments in the penman.m code).'};
H10 = {'- Note: Hamon and Thornswaite methods can be used if Columns 6 to 8 are note available.'};
H11 = {'- Note: The code can be used if mean temperature is available instead of min/max temperature.'};
H12 = {'- Note that all observations must have a latitude and a year associated with it.'};
H13 = {'- If there are data for multiple locations, make sure that the data are arranged in the same order.'};
H14 = {'-------- Available Water Capacity (AWC) Input --------'};
H15 = {'- Different locations have different field capacities. An AWC value for each location must be loaded into the program in inches.'};
H16 = {'- AWC data should be organized in a column in one .txt file. The AWCs should be organized in the same location order as the temperature and precipitation data.'};
H17 = {'- Note that only one AWC value is needed per location (i.e. the number of AWC values must equal the number of stations).'};
H18 = {'-------- Albedo --------'};
H19 = {'- Different locations have different Albedo (%). Albedo is used in Penman method to calculate net radiation. If Albedo is not available, user can input a constant Albedo.'};
H20 = {'- Note that if Albedo file is loaded only one Albedo value is needed per location (i.e. the number of Albedo values must equal the number of stations).'};
H21 = {'-------- Elevation --------'};
H22 = {'- Different locations have different Elevation (m). If Elevation is not available, then sea level is used.'};
H23 = {'- Note that if Elevation file is loaded only one Elevation value is needed per location (i.e. the number of Elevation values must equal the number of stations).'};
H24 = {'------- Calibration Period -------'};
H25 = {'- The calibration period is used to calculate the "Climatologically Appropriate for Existing Conditions" (CAFEC) precipitation for a location.'};
H26 = {'- The CAFEC is used to calculate weighting factors used in the Z-Index calculation (see Palmer, 1965).'};
H27 = {'- NOAA uses the period January 1931 to December 1990 as its calibration period (see Karl, 1986), and this option is provided.'};
H28 = {'- In the absence of long data records or to use a more comprehensive timespan, the option is also provided to use the full record as the calibration period.'};
H29 = {'------- Operation -------'};
H30 = {'- To operate the GUI, load your input data using the "Load Data" buttons, select your desired PET calculation method and calibration period, and click "Run."'};
H31 = {'------- Output Details -------'};
H32 = {'- Units for the output of the PET calculations are in inches. Main drought index outputs are PET, Z-Index, PDSI, and PHDI (see Palmer, 1965).'};
H33 = {'- Results are output into a text file (Palmer.txt) that is saved in the working folder of the current directory. The text file should be opened in Notepad or imported into Excel.'};
H34 = {''};
H35 = {'* For additional help please refer to README_Penman.txt.'};
H36 = {'TO EXIT THIS HELP MENU, PRESS THE "HELP" BUTTON IN THE LOWER RIGHT CORNER'};
set(handles.help_text,'String',[H4;H5;H6;H7;H8;H9;H10;H11; ...
H12;H13;H14;H15;H16;H17;H18;H19;H20;H21;H22; ...
H23;H24;H25;H26;H27;H28;H29;H30;H31;H32;H33;H34;H35;H36]);
global RB_Cal RB_PET alb file_load Elevation_file_load
% Set button values to defaults in case user doesn't press them.
RB_PET = 2;
RB_Cal = 1;
alb=1;
file_load=0;
Elevation_file_load=0;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes PDSI_Tool_Launcher wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = PDSI_Tool_Launcher_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton_data.
function pushbutton_data_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_data (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global DATA lat_col yr_col T_F T_F_minmax P rsds u_2 Spec_Hum mean_temp
D = uiimport('-file');
fprintf('%s\n%s %s.\n','Climate data successfully loaded.');
E = fieldnames(D);
DATA = getfield(D,char(E));
% Extract latitude, temperature, and precipitation data from large data
% file.
lat_col = DATA(1:end,1);
yr_col = DATA(1:end,2);
if (isempty(mean_temp)==1) | (mean_temp==1)
T_F = DATA(1:end,3);
T_F_minmax=[];
P = DATA(1:end,4);
if size(DATA,2)==7
set(handles.radiobutton_penman,'Enable','on')
rsds= DATA(1:end,5);
u_2= DATA(1:end,6);
Spec_Hum= DATA(1:end,7);%%%note: The Specific humidity unit is kg/kg here, not g/kg
else
disp('Note: Not enough input data to run Penman! You can only run Thornthwaite or Hamon.')
set(handles.radiobutton_penman,'Enable','off')
rsds=[];
u_2=[];
Spec_Hum=[];
end
else
T_F_minmax = DATA(1:end,3:4);
T_F=(T_F_minmax(:,1)+T_F_minmax(:,2))/2;
P = DATA(1:end,5);
if size(DATA,2)==8
set(handles.radiobutton_penman,'Enable','on')
rsds= DATA(1:end,6);
u_2= DATA(1:end,7);
Spec_Hum= DATA(1:end,8);%%%note: The Specific humidity unit is kg/kg, not g/kg
else
disp('Note: Not enough input data to run Penman! You can only run Thornthwaite or Hamon!')
set(handles.radiobutton_penman,'Enable','off')
rsds=[];
u_2=[];
Spec_Hum=[];
end
end
% --- Executes on button press in pushbutton_awc.
function pushbutton_awc_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_awc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global AWC
A = uiimport('-file');
fprintf('%s\n%s %s.\n','AWC data successfully loaded.');
W = fieldnames(A);
AWC_DATA = getfield(A,char(W));
% Extract AWC data from larger data file.
AWC = AWC_DATA(1:end,1);
% --- Executes on button press in togglebutton_help.
function togglebutton_help_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton_help (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton_help
button_state = get(hObject,'Value');
if button_state == get(hObject,'Max')
set(handles.help_text,'Visible','on')
elseif button_state == get(hObject,'Min')
set(handles.help_text,'Visible','off')
end
function pet_buttongroup_SelectionChangeFcn(hObject, eventdata)
global RB_PET alb
%retrieve GUI data, i.e. the handles structure
handles = guidata(hObject);
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object
case 'radiobutton_hamon'
%execute this code when hamon_radiobutton is selected
RB_PET = 1;
set(handles.radiobutton1_const_Alb,'Enable','off')
set(handles.radiobutton_alb_file,'Enable','off')
set(handles.edit_const_alb,'Enable','off')
set(handles.pushbutton_browse,'Enable','off')
set(handles. pushbutton_Elevation,'Enable','off')
set(handles.pushbutton_OK,'Enable','off')
set(handles.pushbutton_run,'Enable','on')
case 'radiobutton_thorn'
%execute this code when thorn_radiobutton is selected
RB_PET = 2;
set(handles.radiobutton1_const_Alb,'Enable','off')
set(handles.radiobutton_alb_file,'Enable','off')
set(handles.edit_const_alb,'Enable','off')
set(handles.pushbutton_browse,'Enable','off')
set(handles. pushbutton_Elevation,'Enable','off')
set(handles.pushbutton_OK,'Enable','off')
set(handles.pushbutton_run,'Enable','on')
case 'radiobutton_penman'
%execute this code when penman_radiobutton is selected
RB_PET = 3;
% set(handles.pushbutton_penman,'Enable','on')
set(handles.radiobutton1_const_Alb,'Enable','on')
set(handles.radiobutton_alb_file,'Enable','on')
set(handles.edit_const_alb,'Enable','on')
set(handles.pushbutton_OK,'Enable','on')
set(handles.pushbutton_Elevation,'Enable','on')
if alb==1
set(handles.pushbutton_browse,'Enable','off')
else
set(handles.pushbutton_browse,'Enable','on')
set(handles.edit_const_alb,'Enable','off')
end
set(handles.pushbutton_run,'Enable','off')
otherwise
% Code for when there is no match.
end
%updates the handles structure
guidata(hObject, handles);
function calyrs_buttongroup_SelectionChangeFcn(hObject, eventdata)
global RB_Cal
%retrieve GUI data, i.e. the handles structure
handles = guidata(hObject);
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object
case 'radiobutton_noaa'
%execute this code when hamon_radiobutton is selected
RB_Cal = 1;
case 'radiobutton_full'
%execute this code when thorn_radiobutton is selected
RB_Cal = 2;
otherwise
% Code for when there is no match.
end
%updates the handles structure
guidata(hObject, handles);
% --- Executes on button press in pushbutton_run.
function pushbutton_run_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_run (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global RB_Cal RB_PET AWC lat_col yr_col T_F T_F_minmax P rsds u_2 Spec_Hum Alb_Data Elevation_file_load Elevation_Data
[beg_row_col,end_row_col,beg_row_mat,end_row_mat,count_loc, ...
lat_list,lat_mat] = Count_Loc(lat_col);
if RB_Cal == 1
% Use the calibration period that the NCDC and CPC use - January 1931
% through December 1990 (cf. Karl, 1986; Journal of Climate and Applied
% Meteorology, Vol. 25, No. 1, January 1986).
% NOTE:
% THE ORDERING OF LOCATIONS MUST BE CONSISTENT ACROSS INPUTS!
% yr_col is the record of years for all locations, arranged in a column
% vector, where a year is associated with each observation (i.e.,
% month) of the record for all locations.
% beg_row_col is a vector of the row numbers where the temperature data
% for each of the different locations begins.
% beg_row_mat is a vector of the row numbers where the temperature data
% for each of the different locations begins when the data is listed in
% a matrix such that years represent rows and columns represent months.
% count_loc is the number of different locations in the total data
% record.
% yr_mat_rec is the record of years for all locations, arranged in a
% matrix, where a year is associated with each MONTH of the record for
% all locations.
yr_mat_rec = (reshape(yr_col,12,length(yr_col)/12))';
% yr is the record of years for all locations, arranged in a column
% vector, where each year of the record is listed only once (i.e., one
% year for each year of observations) for all locations.
yr = yr_mat_rec(:,1);
% count1931 is a counter that tracks the rows in the total data record
% (i.e. column vector) that holds the January 1931 temperature and
% precipitation data for each of the different locations.
count1931 = 1;
% count1990 is a counter that tracks the rows in the total data record
% (i.e., column vector) that holds the December 1990 temperature and
% precipitation data for each of the different locations.
count1990 = 1;
% beg_yr_col is a vector of the row numbers that hold the January 1931
% temperature and precipitation data for each of the different
% locations.
beg_yr_col = [];
% end_yr_col is a vector of the row numbers that the December 1990
% temperature and precipitation data for each of the different
% locations.
end_yr_col = [];
for j = 1:count_loc
for m = 1:(end_row_col(j) - beg_row_col(j) + 1)
if m == 1
v(m) = beg_row_col(j);
if yr_col(v(m)) == 1950
count1931(m) = count1931(m);
count1990(m) = count1990(m);
beg_yr_col = [beg_yr_col; count1931(m)];
elseif yr_col(v(m)) == 1999
count1931(m) = count1931(m);
count1990(m) = count1990(m);
end_yr_col = [end_yr_col; count1990(m)];
else
count1931(m) = count1931(m);
count1990(m) = count1990(m);
end
continue
elseif m == (end_row_col(j) - beg_row_col(j) + 1)
v(m) = end_row_col(j);
else
v(m) = v(m-1) + 1;
end
if yr_col(v(m)) == 1950
count1931(m) = count1931(m - 1) + 1;
count1990(m) = count1990(m - 1) + 1;
beg_yr_col = [beg_yr_col; count1931(m)];
elseif yr_col(v(m)) == 1999
count1931(m) = count1931(m - 1) + 1;
count1990(m) = count1990(m - 1) + 1;
end_yr_col = [end_yr_col; count1990(m)];
else
count1931(m) = count1931(m - 1) + 1;
count1990(m) = count1990(m - 1) + 1;
end
end
beg_calyr_col(j) = min(beg_yr_col);
beg_yr_col = [];
beg_calyr_mat(j) = (beg_calyr_col(j) - 1)/12 + 1;
end_calyr_col(j) = max(end_yr_col);
end_yr_col = [];
end_calyr_mat(j) = end_calyr_col(j)/12;
end
else
% Use the entire period of record as the calibration period (cf. Karl,
% 1986; Journal of Climate and Applied Meteorology, Vol. 25, No. 1,
% January 1986).
for j = 1:count_loc
beg_calyr_col(j) = 1;
end_calyr_col(j) = (end_row_col(j) - beg_row_col(j) + 1);
beg_calyr_mat(j) = (beg_calyr_col(j) - 1)/12 + 1;
end_calyr_mat(j) = end_calyr_col(j)/12;
end
end
if RB_PET == 1
PET = Hamon_PET(T_F,lat_list,count_loc,beg_row_mat,lat_mat);
elseif RB_PET == 2
PET = Thornthwaite_PET(T_F,lat_list,count_loc,beg_row_col, ...
lat_col);
else
yr_uniqu=unique(yr_col);
[ Days_in_month ] = Days_each_month( yr_uniqu );%%%Number of days in each month.
if Elevation_file_load==1
Elevation=Elevation_Data;
else
Elevation=0;
end
PET = Penman_PET(T_F,T_F_minmax,rsds,u_2,Spec_Hum,Alb_Data,Elevation,lat_list,count_loc,beg_row_col,Days_in_month);
%%% Note: If T_F_minmax is not available, then use [].
end
[ET,PR,R,RO,PRO,L,PL] = WaterBalance(AWC,PET,P,beg_row_col, ...
end_row_col,count_loc);
[Z_all] = Z_Index(P,PET,ET,PR,R,RO,PRO,L,PL,beg_row_mat,end_row_mat, ...
count_loc,beg_calyr_mat,end_calyr_mat,beg_row_col,end_row_col);
[table] = PDSI_Central(Z_all,count_loc,beg_row_col,end_row_col, ...
lat_col,yr_col,PET);
% Open the text file to which the table of values is to be written with
% write permission.
fid = fopen('Palmer.txt','w');
fprintf(fid, '%10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s\r\n','Latitude','Year','PET','Z-Index','PPe','PX1','PX2','PX3','X','PDSI','PHDI');
fprintf(fid, '%10.6f %10.0f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f\r\n',(table'));
fclose(fid);
% If the tool successfully executes the Palmer calculations, then print
% text, including the directory and folder to which the output text file
% was written, to the command window.
currentFolder = pwd;
screen_text_l1 = 'Success! The output file - "Palmer.txt" -';
screen_text_l2 = 'is located in';
fprintf('%s\n%s %s.\n',screen_text_l1,screen_text_l2,currentFolder)
function edit_const_alb_Callback(hObject, eventdata, handles)
% hObject handle to edit_const_alb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_const_alb as text
% str2double(get(hObject,'String')) returns contents of edit_const_alb as a double
% --- Executes during object creation, after setting all properties.
function edit_const_alb_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_const_alb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_alb_file_Callback(hObject, eventdata, handles)
% hObject handle to edit_alb_file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_alb_file as text
% str2double(get(hObject,'String')) returns contents of edit_alb_file as a double
% --- Executes during object creation, after setting all properties.
function edit_alb_file_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_alb_file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton_browse.
function pushbutton_browse_Callback(hObject, eventdata, handles)
global Data file_load
% hObject handle to pushbutton_browse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName,PathName] = uigetfile('*.txt' , 'Select Albedo Text File');
Current_Dir{ 1 } = [ PathName FileName ];
set(handles.edit_alb_file,'string',Current_Dir{ 1 })
Data=load(Current_Dir{ 1 });
file_load=1;
% --- Executes on button press in pushbutton_OK.
function pushbutton_OK_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_OK (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global alb Data Alb_Data file_load
if alb==1
Alb_Data=str2double(get(handles.edit_const_alb,'string'));
h = msgbox(['Albedo Constant Value: ',num2str(Alb_Data)]);
set(handles.pushbutton_run,'Enable','on')
elseif (alb==2) && (file_load==1)
Alb_Data=Data;
h = msgbox('Albedo File Successfully Loaded!');
set(handles.pushbutton_run,'Enable','on')
else
h = msgbox('Please Upload the Albedo File!');
set(handles.pushbutton_run,'Enable','off')
end
% --- Executes when selected object is changed in uipanel_albedo.
function uipanel_albedo_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel_albedo
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
global alb
handles = guidata(hObject);
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object
case 'radiobutton1_const_Alb'
%execute this code when hamon_radiobutton is selected
alb = 1;
set(handles.edit_const_alb,'Enable','on')
set(handles.pushbutton_browse,'Enable','off')
set(handles.pushbutton_run,'Enable','off')
case 'radiobutton_alb_file'
%execute this code when thorn_radiobutton is selected
alb = 2;
set(handles.pushbutton_browse,'Enable','on')
set(handles.edit_const_alb,'Enable','off')
set(handles.pushbutton_run,'Enable','off')
otherwise
% Code for when there is no match.
end
% --- Executes during object creation, after setting all properties.
function uipanel_albedo_CreateFcn(hObject, eventdata, handles)
% hObject handle to uipanel_albedo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes when selected object is changed in uipanel7.
function uipanel7_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel7
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
global mean_temp
handles = guidata(hObject);
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object
case 'radiobutton_Mean_tmp'
%execute this code when hamon_radiobutton is selected
mean_temp = 1;
case 'radiobutton_minmax_tmp'
%execute this code when thorn_radiobutton is selected
mean_temp = 0;
otherwise
% Code for when there is no match.
end
% --- Executes on button press in pushbutton_Elevation.
function pushbutton_Elevation_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_Elevation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global Elevation_Data Elevation_file_load
% hObject handle to pushbutton_browse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName,PathName] = uigetfile('*.txt' , 'Select Elevation Text File');
Current_Dir{ 1 } = [ PathName FileName ];
Elevation_Data=load(Current_Dir{ 1 });
Elevation_file_load=1;
h = msgbox('Elevation File Successfully Loaded!');