PV_generator.m 56.4 KB
Newer Older
Angioni's avatar
Angioni committed
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 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main code to call GUI and execute sub-functions
%
% @author Marco Pau <mpau@eonerc.rwth-aachen.de>
% @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
% @license GNU General Public License (version 3)
%
% PVgenerator
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%  Automatic Code  %%%%%%%%%%%%
% Initialization code automatically generated by the GUIDE tool to build
% the Graphical User Interface

function varargout = PV_generator(varargin)
% Initialization code - DO NOT EDIT
% PV_GENERATOR MATLAB code for PV_generator.fig
%      PV_GENERATOR, by itself, creates a new PV_GENERATOR or raises the existing
%      singleton*.
%
%      H = PV_GENERATOR returns the handle to a new PV_GENERATOR or the handle to
%      the existing singleton*.
%
%      PV_GENERATOR('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PV_GENERATOR.M with the given input arguments.
%
%      PV_GENERATOR('Property','Value',...) creates a new PV_GENERATOR or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before PV_generator_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to PV_generator_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 PV_generator
% Last Modified by GUIDE v2.5 23-Sep-2017 02:05:00
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @PV_generator_OpeningFcn, ...
                   'gui_OutputFcn',  @PV_generator_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

function PV_generator_OpeningFcn(hObject, eventdata, handles, varargin)
% --- Executes just before PV_generator is made visible.
% 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 PV_generator (see VARARGIN)
% Choose default command line output for PV_generator
handles.DATA.latitude = 50.77;  % default value for Aachen
handles.DATA.longitude = 6.09;  % default value for Aachen
handles.DATA.gmt_diff = 1;      % default value for Aachen
handles.DATA.day_list = cell(31,1);
for i = 1:31
    handles.DATA.day_list{i,1} = strcat(' ',num2str(i));
end
handles.DATA.day = 1;           
handles.DATA.month = 1;
handles.DATA.num_day = 1;
handles.DATA.cloudiness_time_list = cell(96,1);
for i = 1:96
	hour = floor(i/4);
	minute = mod(i,4)*15;
	if hour < 10
		hour_str = strcat('0',num2str(hour));
	else
		hour_str = num2str(hour);
	end
	if minute < 15
		minute_str = strcat('0',num2str(minute));
	else
		minute_str = num2str(minute);
	end
	handles.DATA.cloudiness_time_list{i,1} = strcat(hour_str,':',minute_str);
end
handles.DATA.cloudiness_matrix = [0, 24, 1];
handles.DATA.number_units = 1;
handles.DATA.pv_list = '1';
handles.DATA.pvdata = [1, 30, 180, 0.2];
handles.DATA.pv_power = 1;
handles.DATA.tilt_angle = 30;
handles.DATA.azimuth_angle = 180;
handles.DATA.albedo = 0.2;
handles.DATA.pv_profiles = zeros(1,86400);
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);

function varargout = PV_generator_OutputFcn(hObject, eventdata, handles) 
% --- Outputs from this function are returned to the command line.
% 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;


%%%%%%%%%%%% End of Automatic Code %%%%%%%%%%%%%

%%%% Location inputs %%%%

function latitude_Callback(hObject, eventdata, handles)
% hObject    handle to latitude_text (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 latitude_text as text
%        str2double(get(hObject,'String')) returns contents of latitude_text as a double
val = get(handles.latitude, 'string');
val2 = str2double(val);
if isnan(val2) || ~isreal(val2)
    warndlg('Not A Number. Please insert a numeric value')
    set(handles.latitude, 'string', num2str(handles.DATA.latitude));
elseif val2 < -90 || val2 > 90
    warndlg('Not A Valid Number. Please insert a value between -90 and 90')
    set(handles.latitude, 'string', num2str(handles.DATA.latitude));
else
    handles.DATA.latitude = val2;
    set(handles.latitude, 'string', val);
end
guidata(hObject, handles);

function longitude_Callback(hObject, eventdata, handles)
% hObject    handle to longitude (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 longitude as text
%        str2double(get(hObject,'String')) returns contents of longitude as a double
val = get(handles.longitude, 'string');
val2 = str2double(val);
if isnan(val2) || ~isreal(val2)
    warndlg('Not A Number. Please insert a numeric value')
    set(handles.longitude, 'string', num2str(handles.DATA.longitude));
elseif val2 < -180 || val2 > 180
    warndlg('Not A Valid Number. Please insert a value between -180 and 180')
    set(handles.longitude, 'string', num2str(handles.DATA.longitude));
else
    handles.DATA.longitude = val2;
    set(handles.longitude, 'string', val);
end
guidata(hObject, handles);

function gmt_diff_Callback(hObject, eventdata, handles)
% hObject    handle to gmt_diff (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 gmt_diff as text
%        str2double(get(hObject,'String')) returns contents of gmt_diff as a double
val = get(handles.gmt_diff, 'string');
val2 = str2double(val);
if isnan(val2) || ~isreal(val2)
    warndlg('Not A Number. Please insert a numeric value')
    set(handles.gmt_diff, 'string', num2str(handles.DATA.gmt_diff));
elseif val2 < -12 || val2 > 14
    warndlg('Not A Valid Number. Please insert a value between -12 and 14')    
    set(handles.gmt_diff, 'string', num2str(handles.DATA.gmt_diff));
else
    handles.DATA.gmt_diff = val2;
    set(handles.gmt_diff, 'string', val);
end
guidata(hObject, handles);

%%%% Time inputs %%%%

function day_Callback(hObject, eventdata, handles)
% --- Executes on selection change in day.
% hObject    handle to day popupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns day popupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from day popupmenu
val = get(handles.day, 'value');
handles.DATA.day = val+1;
handles = num_day_calculation(handles);
guidata(hObject, handles);

function month_Callback(hObject, eventdata, handles)
% --- Executes on selection change in month.
% hObject    handle to month popupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns month popupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from month popupmenu
val = get(handles.month, 'value');
handles.DATA.month = val;
switch handles.DATA.month
    case {1, 3, 5, 7, 8, 10, 12} 
        set(handles.day, 'string', handles.DATA.day_list)
    case {4, 6, 9, 11}
        set(handles.day, 'string', handles.DATA.day_list(1:30,1))
    case 2
        set(handles.day, 'string', handles.DATA.day_list(1:29,1))
end
handles = num_day_calculation(handles);
guidata(hObject, handles);

function handles = num_day_calculation(handles)
switch handles.DATA.month
    case 1
        handles.DATA.num_day = handles.DATA.day;
    case 2
        handles.DATA.num_day = handles.DATA.day + 31;
    case 3 
        handles.DATA.num_day = handles.DATA.day + 59;
    case 4 
        handles.DATA.num_day = handles.DATA.day + 90;
    case 5 
        handles.DATA.num_day = handles.DATA.day + 120;
    case 6 
        handles.DATA.num_day = handles.DATA.day + 151;
    case 7 
        handles.DATA.num_day = handles.DATA.day + 181;
    case 8
        handles.DATA.num_day = handles.DATA.day + 212;
    case 9
        handles.DATA.num_day = handles.DATA.day + 243;
    case 10
        handles.DATA.num_day = handles.DATA.day + 273;
    case 11 
        handles.DATA.num_day = handles.DATA.day + 304;
    case 12
        handles.DATA.num_day = handles.DATA.day + 334;
end
        
%%%% Cloudiness inputs %%%%

function handles = cloudiness_fun(handles, num)
for i = num:9
	name = strcat('end_timeslot',num2str(i));
	set(handles.(genvarname(name)), 'visible', 'off');
	set(handles.(genvarname(name)), 'string', handles.DATA.cloudiness_time_list);
	set(handles.(genvarname(name)), 'value', 96);
	name = strcat('start_timeslot',num2str(i));
	set(handles.(genvarname(name)), 'visible', 'off');
	name = strcat('cloudiness_timeslot', num2str(i));
	set(handles.(genvarname(name)), 'visible', 'off');
	set(handles.(genvarname(name)), 'value', 1);
%     name = strcat('timeslot', num2str(i));
% 	set(handles.(genvarname(name)), 'visible', 'off');
end
set(handles.end_timeslot10, 'visible', 'off');
set(handles.start_timeslot10, 'visible', 'off');
set(handles.cloudiness_timeslot10, 'visible', 'off');
set(handles.cloudiness_timeslot10, 'value', 1);
% set(handles.timeslot10, 'visible', 'off');
if size(handles.DATA.cloudiness_matrix,1) >= num
    handles.DATA.cloudiness_matrix(num:end,:) = [];
end

function [handles, t] = end_timeslot_fun(handles, num)
name = strcat('end_timeslot',num2str(num));
val = get(handles.(genvarname(name)), 'value');
list = get(handles.(genvarname(name)), 'string');
str = list{val,1};
hour = str2num(str(1:2));
minute = str2num(str(4:5));
t = hour*4+minute/15;
handles.DATA.cloudiness_matrix(num,2) = t/4;
if t < 96
	name = strcat('start_timeslot',num2str(num+1));
	set(handles.(genvarname(name)), 'string', str);
	set(handles.(genvarname(name)), 'visible', 'on');
	name = strcat('end_timeslot',num2str(num+1));    
    if size(handles.DATA.cloudiness_matrix,1) == num
        set(handles.(genvarname(name)), 'string', handles.DATA.cloudiness_time_list(t+1:end,1));
        set(handles.(genvarname(name)), 'value', 96-t);
        set(handles.(genvarname(name)), 'visible', 'on'); 
    elseif size(handles.DATA.cloudiness_matrix,1) > num && num < 9
        val2 = get(handles.(genvarname(name)), 'value');
        list2 = get(handles.(genvarname(name)), 'string');
        str2 = list2{val2,1};
        hour2 = str2num(str2(1:2));
        minute2 = str2num(str2(4:5));
        t2 = hour2*4+minute2/15;
        set(handles.(genvarname(name)), 'string', handles.DATA.cloudiness_time_list(t+1:end,1));
        if t2 <= t
            set(handles.(genvarname(name)), 'value', 1);
        else
            set(handles.(genvarname(name)), 'value', t2-t);
        end
    end
	name = strcat('cloudiness_timeslot',num2str(num+1));
    set(handles.(genvarname(name)), 'visible', 'on');
% 	name = strcat('timeslot',num2str(num+1));
%     set(handles.(genvarname(name)), 'visible', 'on');
    if size(handles.DATA.cloudiness_matrix,1) == num
        handles.DATA.cloudiness_matrix = [handles.DATA.cloudiness_matrix; t/4, 24, 1];
    else
        handles.DATA.cloudiness_matrix(num+1,1) = t/4;
    end
else
	handles = cloudiness_fun(handles, num+1);
end
if num == 9
    set(handles.end_timeslot10, 'string', '24:00');
    set(handles.end_timeslot10, 'value', 1);
end

function handles = time_check(handles, num)
name = strcat('start_timeslot',num2str(num));
val_start = get(handles.(genvarname(name)), 'string');
hour_start = str2num(val_start(1:2));
min_start = str2num(val_start(4:5));
time_start = hour_start*4+min_start/15;
name = strcat('end_timeslot',num2str(num));
len = length(get(handles.(genvarname(name)), 'string'));
if len > 96 - time_start
	set(handles.(genvarname(name)), 'string', handles.DATA.cloudiness_time_list(time_start+1:end,1));
	set(handles.(genvarname(name)), 'value', 1);
end

function end_timeslot1_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot1.
% hObject    handle to end_timeslot1 popupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot1 popupmenu
[handles, end_time] = end_timeslot_fun(handles, 1);
if end_time < 96
    handles = end_timeslot2_Callback(hObject, eventdata, handles);
end
guidata(hObject, handles);

function cloudiness_timeslot1_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot1.
% hObject    handle to cloudiness_timeslot1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot1 popupmenu
val = get(handles.cloudiness_timeslot1, 'value');
handles.DATA.cloudiness_matrix(1,3) = val;
guidata(hObject, handles);

function handles = end_timeslot2_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot2.
% hObject    handle to end_timeslot2 popupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot2 popupmenu
handles = time_check(handles, 2);
[handles, end_time] = end_timeslot_fun(handles, 2);
if end_time < 96
    handles = end_timeslot3_Callback(hObject, eventdata, handles);
end
guidata(hObject, handles);

function cloudiness_timeslot2_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot2.
% hObject    handle to cloudiness_timeslot2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot2 popmenu
val = get(handles.cloudiness_timeslot2, 'value');
handles.DATA.cloudiness_matrix(2,3) = val;
guidata(hObject, handles);

function handles = end_timeslot3_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot3.
% hObject    handle to end_timeslot3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot3 popupmenu
handles = time_check(handles, 3);
[handles, end_time] = end_timeslot_fun(handles, 3);
if end_time < 96
    handles = end_timeslot4_Callback(hObject, eventdata, handles);
end
guidata(hObject, handles);

function cloudiness_timeslot3_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot3.
% hObject    handle to cloudiness_timeslot3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot3 popupmenu
val = get(handles.cloudiness_timeslot3, 'value');
handles.DATA.cloudiness_matrix(3,3) = val;
guidata(hObject, handles);

function handles = end_timeslot4_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot4.
% hObject    handle to end_timeslot4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot4 popupmenu
handles = time_check(handles, 4);
[handles, end_time] = end_timeslot_fun(handles, 4);
if end_time < 96
    handles = end_timeslot5_Callback(hObject, eventdata, handles);
end
guidata(hObject, handles);

function cloudiness_timeslot4_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot4.
% hObject    handle to cloudiness_timeslot4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot4 popupmenu
val = get(handles.cloudiness_timeslot4, 'value');
handles.DATA.cloudiness_matrix(4,3) = val;
guidata(hObject, handles);

function handles = end_timeslot5_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot5.
% hObject    handle to end_timeslot5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot5 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot5 popupmenu
handles = time_check(handles, 5);
[handles, end_time] = end_timeslot_fun(handles, 5);
if end_time < 96
    handles = end_timeslot6_Callback(hObject, eventdata, handles);
end
guidata(hObject, handles);

function cloudiness_timeslot5_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot5.
% hObject    handle to cloudiness_timeslot5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot5 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot5 popupmenu
val = get(handles.cloudiness_timeslot5, 'value');
handles.DATA.cloudiness_matrix(5,3) = val;
guidata(hObject, handles);

function handles = end_timeslot6_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot6.
% hObject    handle to end_timeslot6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot6 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot6 popupmenu
handles = time_check(handles, 6);
[handles, end_time] = end_timeslot_fun(handles, 6);
if end_time < 96
    handles = end_timeslot7_Callback(hObject, eventdata, handles);
end
guidata(hObject, handles);

function cloudiness_timeslot6_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot6.
% hObject    handle to cloudiness_timeslot6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot6 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot6 popupmenu
val = get(handles.cloudiness_timeslot6, 'value');
handles.DATA.cloudiness_matrix(6,3) = val;
guidata(hObject, handles);

function handles = end_timeslot7_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot7.
% hObject    handle to end_timeslot7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot7 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot7 popupmenu
handles = time_check(handles, 7);
[handles, end_time] = end_timeslot_fun(handles, 7);
if end_time < 96
    handles = end_timeslot8_Callback(hObject, eventdata, handles);
end
guidata(hObject, handles);

function cloudiness_timeslot7_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot7.
% hObject    handle to cloudiness_timeslot7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot7 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot7 popupmenu
val = get(handles.cloudiness_timeslot7, 'value');
handles.DATA.cloudiness_matrix(7,3) = val;
guidata(hObject, handles);

function handles = end_timeslot8_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot8.
% hObject    handle to end_timeslot8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot8 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot8 popupmenu
handles = time_check(handles, 8);
[handles, end_time] = end_timeslot_fun(handles, 8);
if end_time < 96
    handles = end_timeslot9_Callback(hObject, eventdata, handles);
end
guidata(hObject, handles);

function cloudiness_timeslot8_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot8.
% hObject    handle to cloudiness_timeslot8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot8 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot8 popupmenu
val = get(handles.cloudiness_timeslot8, 'value');
handles.DATA.cloudiness_matrix(8,3) = val;
guidata(hObject, handles);

function handles = end_timeslot9_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot9.
% hObject    handle to end_timeslot9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot9 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot9 popupmenu
handles = time_check(handles, 9);
handles = end_timeslot_fun(handles, 9);
guidata(hObject, handles);

function cloudiness_timeslot9_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot9.
% hObject    handle to cloudiness_timeslot9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot9 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot9 popupmenu
val = get(handles.cloudiness_timeslot9, 'value');
handles.DATA.cloudiness_matrix(9,3) = val;
guidata(hObject, handles);

function end_timeslot10_Callback(hObject, eventdata, handles)
% --- Executes on selection change in end_timeslot10.
% hObject    handle to end_timeslot10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns end_timeslot10 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from end_timeslot10 popupmenu
handles.DATA.cloudiness_matrix(10,2) = 24;
guidata(hObject, handles);

function cloudiness_timeslot10_Callback(hObject, eventdata, handles)
% --- Executes on selection change in cloudiness_timeslot10.
% hObject    handle to cloudiness_timeslot10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cloudiness_timeslot10 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cloudiness_timeslot10 popupmenu
val = get(handles.cloudiness_timeslot10, 'value');
handles.DATA.cloudiness_matrix(10,3) = val;
guidata(hObject, handles);

%%%% PV settings %%%%

function handles = pv_unit_Callback(hObject, eventdata, handles)
% --- Executes on selection change in pv_unit.
% hObject    handle to pv_unit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns pv_unit contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pv_unit
val = get(handles.pv_unit, 'value');
% set(handles.pv_unit, 'string', handles.DATA.pv_list(val,1));
set(handles.pv_power, 'string', num2str(handles.DATA.pvdata(val,1)));
set(handles.tilt_angle, 'string', num2str(handles.DATA.pvdata(val,2)));
set(handles.azimuth_angle, 'string', num2str(handles.DATA.pvdata(val,3)));
set(handles.albedo, 'string', num2str(handles.DATA.pvdata(val,4)));
handles = plot_unit_power(handles, val);
guidata(hObject, handles);

function number_units_Callback(hObject, eventdata, handles)
% hObject    handle to number_units (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 number_units as text
%        str2double(get(hObject,'String')) returns contents of number_units as a double
val = get(handles.number_units, 'string');
val2 = str2double(val);
if isnan(val2) || ~isreal(val2)
    warndlg('Not A Number. Please insert a numeric value')
    set(handles.number_units, 'string', handles.DATA.number_units);
elseif val2 < 1
    warndlg('Please insert a number larger than 1')
    set(handles.number_units, 'string', handles.DATA.number_units);
else
    val2 = round(val2);
    set(handles.number_units, 'string', num2str(val2));
    handles.DATA.number_units = val2;
    handles = set_unit_list(handles, val2);
end
len = size(handles.DATA.pvdata,1);
if val2 > len
    handles.DATA.pvdata = [handles.DATA.pvdata; ones(val2-len,1), 30*ones(val2-len,1), 180*ones(val2-len,1), 0.2*ones(val2-len,1)];
    handles.DATA.pv_profiles = [handles.DATA.pv_profiles; zeros(val2-len, 86400)];
elseif val2 < len
    handles.DATA.pvdata(val2+1:end,:) = [];
    handles.DATA.pv_profiles(val2+1:end,:) = [];
end
guidata(hObject, handles);

function handles = set_unit_list(handles, val)
list = cell(val,1);
for i = 1:val
    list{i,1} = num2str(i);
end
handles.DATA.pv_list = list;
set(handles.pv_unit, 'string', list);
set(handles.pv_unit, 'value', 1);

function pv_power_Callback(hObject, eventdata, handles)
% hObject    handle to pv_power (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 pv_power as text
%        str2double(get(hObject,'String')) returns contents of pv_power as a double
val = get(handles.pv_unit, 'value');
str = get(handles.pv_power, 'string');
val2 = str2double(str);
if isnan(val2) || ~isreal(val2)
    warndlg('Not A Number. Please insert a numeric value')
    set(handles.pv_power, 'string', handles.DATA.pvdata(val,1));
elseif val2 < 0
    warndlg('Please insert a number larger than 0')
    set(handles.pv_power, 'string', handles.DATA.pvdata(val,1));
else
    set(handles.pv_power, 'string', num2str(val2));
    handles.DATA.pvdata(val,1) = val2;
end
guidata(hObject, handles);

function tilt_angle_Callback(hObject, eventdata, handles)
% hObject    handle to tilt_angle (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 tilt_angle as text
%        str2double(get(hObject,'String')) returns contents of tilt_angle as a double
val = get(handles.pv_unit, 'value');
str = get(handles.tilt_angle, 'string');
val2 = str2double(str);
if isnan(val2) || ~isreal(val2)
    warndlg('Not A Number. Please insert a numeric value')
    set(handles.tilt_angle, 'string', handles.DATA.pvdata(val,2));
elseif val2 < 0 && val2 > 90
    warndlg('Please insert a value between 0 and 90')
    set(handles.tilt_angle, 'string', handles.DATA.pvdata(val,2));
else
    set(handles.tilt_angle, 'string', num2str(val2));
    handles.DATA.pvdata(val,2) = val2;
end
guidata(hObject, handles);

function azimuth_angle_Callback(hObject, eventdata, handles)
% hObject    handle to azimuth_angle (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 azimuth_angle as text
%        str2double(get(hObject,'String')) returns contents of azimuth_angle as a double
val = get(handles.pv_unit, 'value');
str = get(handles.azimuth_angle, 'string');
val2 = str2double(str);
if isnan(val2) || ~isreal(val2)
    warndlg('Not A Number. Please insert a numeric value')
    set(handles.azimuth_angle, 'string', handles.DATA.pvdata(val,3));
elseif val2 < 0 && val2 > 360
    warndlg('Please insert a value between 0 and 360')
    set(handles.azimuth_angle, 'string', handles.DATA.pvdata(val,3));
else
    set(handles.azimuth_angle, 'string', num2str(val2));
    handles.DATA.pvdata(val,3) = val2;
end
guidata(hObject, handles);

function albedo_Callback(hObject, eventdata, handles)
% hObject    handle to albedo (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 albedo as text
%        str2double(get(hObject,'String')) returns contents of albedo as a double
val = get(handles.pv_unit, 'value');
str = get(handles.albedo, 'string');
val2 = str2double(str);
if isnan(val2) || ~isreal(val2)
    warndlg('Not A Number. Please insert a numeric value')
    set(handles.albedo, 'string', handles.DATA.pvdata(val,4));
elseif val2 < 0 && val2 > 1
    warndlg('Please insert a value between 0 and 1')
    set(handles.albedo, 'string', handles.DATA.pvdata(val,4));
else
    set(handles.albedo, 'string', num2str(val2));
    handles.DATA.pvdata(val,4) = val2;
end
guidata(hObject, handles);

function generate_profiles_Callback(hObject, eventdata, handles)
% --- Executes on button press in generate_profiles.
% hObject    handle to generate_profiles (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
num_day = handles.DATA.num_day;
lat = handles.DATA.latitude;
lon = handles.DATA.longitude;
GMT_diff = handles.DATA.gmt_diff;
cloudiness = handles.DATA.cloudiness_matrix;
[theta_zenith, theta_azimuth] = sun_position(num_day, lat, lon, GMT_diff);
[GHI, DNI, DHI, extraterr_radiation] = irradiation_calc(num_day, theta_zenith, cloudiness);
tic
handles.DATA.pv_profiles = zeros(handles.DATA.number_units,86400);
for i = 1:handles.DATA.number_units
    albedo = handles.DATA.pvdata(i,4);
    tilt_pv = handles.DATA.pvdata(i,2);
    azimuth_pv = handles.DATA.pvdata(i,3);
    power = handles.DATA.pvdata(i,1);
    [PV_output] = POA_irradiance(GHI, DNI, DHI, theta_zenith, theta_azimuth, extraterr_radiation, albedo, tilt_pv, azimuth_pv);
    handles.DATA.pv_profiles(i,:) = PV_output'*power;
    uiprogressbar(i, handles.DATA.number_units, handles);
end
set(handles.pv_unit, 'value', 1);
handles = pv_unit_Callback(hObject, eventdata, handles);
S = handles.DATA.pv_profiles;
save('PV_Power_profiles', 'S');
handles = pv_unit_Callback(hObject, eventdata, handles);
guidata(hObject, handles);

function uiprogressbar(x, z, handles)
frac = x/z;
pos = get(handles.progressbar_text,'position');
pos2 = get(handles.progressstatus_text, 'position');
% bar position & length calculation
pos(3) = frac*(pos2(3));
set(handles.progressbar_text,'position',pos,'string',sprintf('%.0f%%',frac*100))
set(handles.progressbar_text,'string',sprintf('%.0f%%',frac*100))
outp = sec2timestr(fix(toc*(z-x)/x));
set(handles.progressstatus_text, 'string', [outp, ' remaining']);
drawnow

function timestr = sec2timestr(sec)
% Convert a time measurement from seconds into a human readable string.
% Convert seconds to other units
w = floor(sec/604800); % Weeks
sec = sec - w*604800;
d = floor(sec/86400); % Days
sec = sec - d*86400;
h = floor(sec/3600); % Hours
sec = sec - h*3600;
m = floor(sec/60); % Minutes
sec = sec - m*60;
s = floor(sec); % Seconds
if w > 0    % Create time string
    if w > 9
        timestr = sprintf('%d week', w);
    else
        timestr = sprintf('%d week, %d day', w, d);
    end
elseif d > 0
    if d > 9
        timestr = sprintf('%d day', d);
    else
        timestr = sprintf('%d day, %d hr', d, h);
    end
elseif h > 0
    if h > 9
        timestr = sprintf('%d hr', h);
    else
        timestr = sprintf('%d hr, %d min', h, m);
    end
elseif m > 0
    if m > 9
        timestr = sprintf('%d min', m);
    else
        timestr = sprintf('%d min, %d sec', m, s);
    end
else
    timestr = sprintf('%d sec', s);
end

function handles = plot_unit_power(handles, num_unit)
P = handles.DATA.pv_profiles(num_unit, :);
plot(handles.axes2, P);
mod_plot(handles.axes2, length(P), 'Power [kW]');

function mod_plot(hand, leng, ystr) % Function used to set the features of the graph plot;
% x-axis
set(hand,'XLim', [0 leng]);
set(hand,'XTick', [0:leng/24:leng]);
set(hand,'XTickLabel',[' 0';'  ';' 2';'  ';' 4';'  ';' 6';'  ';' 8';'  ';'10';'  ';'12';'  ';'14';'  ';'16';'  ';'18';'  ';'20';'  ';'22';'  ';'24']);
set(get(hand, 'XLabel'), 'String' ,'time[h]');
set(hand,'XGrid','on');
% y-axis
set(get(hand, 'YLabel'), 'String' ,ystr);
set(hand,'yGrid','on');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function axes1_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to input_axes2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate input_axes2
axes(hObject)
imshow('Flexmeter.png');
guidata(hObject, handles);

function day_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to day (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 month_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to month (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 latitude_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to latitude (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 longitude_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to longitude (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 gmt_diff_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to gmt_diff (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 end_timeslot1_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot1_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot2_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot2_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot3_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot3_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot4_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot4_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot5_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot5_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot6_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot6_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot7_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot7_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot8_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot8_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot9_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot9_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 end_timeslot10_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to end_timeslot10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 cloudiness_timeslot10_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to cloudiness_timeslot10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 pv_unit_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to pv_unit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 number_units_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to number_units (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 pv_power_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to pv_power (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 tilt_angle_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to tilt_angle (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 azimuth_angle_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to azimuth_angle (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 albedo_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to albedo (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 start_timeslot1_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot2_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot3_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot4_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot5_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot6_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot7_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot8_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot9_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

function start_timeslot10_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
% hObject    handle to start_timeslot10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called