├── _config.yml ├── sample_data.mat ├── Example_output.PNG ├── models ├── Polo2009CSD.m ├── Garcia2014CSD.m ├── Ineichen2006CSD.m ├── Ineichen2009CSD.m ├── Ineichen2016CSD.m ├── Lefevre2013CSD.m ├── RuizArias2018CSD.m ├── AliaMartinez2016CSD.m ├── LongAckerman2000CSD.m ├── Quesadaruiz2015CSD.m ├── BrightSun2020CSDs.m ├── BrightSun2020CSDc.m └── Zhang2018CSD.m ├── Example.m ├── README.md └── LICENSE /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /sample_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/sample_data.mat -------------------------------------------------------------------------------- /Example_output.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/Example_output.PNG -------------------------------------------------------------------------------- /models/Polo2009CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/Polo2009CSD.m -------------------------------------------------------------------------------- /models/Garcia2014CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/Garcia2014CSD.m -------------------------------------------------------------------------------- /models/Ineichen2006CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/Ineichen2006CSD.m -------------------------------------------------------------------------------- /models/Ineichen2009CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/Ineichen2009CSD.m -------------------------------------------------------------------------------- /models/Ineichen2016CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/Ineichen2016CSD.m -------------------------------------------------------------------------------- /models/Lefevre2013CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/Lefevre2013CSD.m -------------------------------------------------------------------------------- /models/RuizArias2018CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/RuizArias2018CSD.m -------------------------------------------------------------------------------- /models/AliaMartinez2016CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/AliaMartinez2016CSD.m -------------------------------------------------------------------------------- /models/LongAckerman2000CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/LongAckerman2000CSD.m -------------------------------------------------------------------------------- /models/Quesadaruiz2015CSD.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamieMBright/csd-library/HEAD/models/Quesadaruiz2015CSD.m -------------------------------------------------------------------------------- /Example.m: -------------------------------------------------------------------------------- 1 | % Example of all CSD methodologies 2 | % ------------------------------------------------------------------------ 3 | % INPUT PARAMETERS 4 | % ------------------------------------------------------------------------ 5 | % ASSUMPTION: all data is in 1-min resolution and all vectors perfectly 6 | % match each other in terms of time stamps. 7 | % 8 | % ghi = Global horizontal irradiance, column vector. Not necessary 9 | % to be continuous so long as the ghics perfectly corresponds. 10 | % 11 | % ghics = Clear-sky global horizontal irradiance, column vector. 12 | % 13 | % dni = Direct normal irradiance, column vector. Not necessary 14 | % to be continuous so long as the dnics perfectly corresponds. 15 | % 16 | % dnics = Clear-sky direct normal irradiance, column vector. 17 | % 18 | % dif = Diffuse horizontal irradiance, column vector. Not necessary 19 | % to be continuous so long as the difcs perfectly corresponds. 20 | % 21 | % difcs = Clear-sky diffuse horizontal irradiance, column vector. 22 | % 23 | % zen = Zenith angle in degrees. Corresponding to all inputs 24 | % 25 | % exth = Horizontal projection of extraterrestrial irradiance. 26 | % 27 | % aod = Total aerosol extinction at 550nm. 28 | % 29 | % plot_figure = if this variable is defined by any class, then a figure is 30 | % plotted illustrating the outcome of the CSD method, e.g. 1; 31 | % ------------------------------------------------------------------------ 32 | % OUTPUTS 33 | % ------------------------------------------------------------------------ 34 | % csd = clear-sky detection. a flag of 1 means that clouds were detected 35 | % whereas a flag of 0 means that the hour is clear. 36 | %% Pre-amble 37 | clearvars 38 | close all 39 | addpath('models\') 40 | %% Data 41 | % all sample data is taken from BSRN 2013 at Adelaide Airport. 42 | data = load('sample_data.mat');data=data.data; 43 | % sample ghi data from Adelaide Airport, sz = [3000,1] 44 | ghi = data(:,1); 45 | % sample corresponding REST2 clear-sky ghi 46 | ghics = data(:,2); 47 | % sample dni data from Adelaide Airport, 48 | dni = data(:,3); 49 | % sample corresponding REST2 clear-sky dni 50 | dnics = data(:,4); 51 | % sample dif data from Adelaide Airport 52 | dif = data(:,5); 53 | % sample corresponding REST2 clear-sky dif 54 | difcs = data(:,6); 55 | % sample Eexth calculated at Adelaide Airport 56 | exth = data(:,7); 57 | % sample Zenith angle for Adelaide Airport 58 | zen = data(:,8); 59 | % sample MERRA2 aerosol extinction at 550nm 60 | aod = data(:,9); 61 | % sample LST for Adelaide Airport 62 | LST = datevec(data(:,10)); 63 | 64 | %% CSD methods 65 | % produce clear-sky detection from each model available. 66 | perez = Perez1990CSD(dif,dni,zen); 67 | batlles = Batlles1999CSD(ghi,dif,exth,zen); 68 | brightsuncsdc= BrightSun2020CSDc(zen,ghi,ghics,dif,difcs,LST); 69 | brightsuncsds= BrightSun2020CSDs(zen,ghi,ghics,dif,difcs,LST); 70 | longackerman = LongAckerman2000CSD(ghi,dif,zen,LST); 71 | ineichen06 = Ineichen2006CSD(exth,dni,zen); 72 | ineichen09 = Ineichen2009CSD(ghi,exth,zen); 73 | polo = Polo2009CSD(ghi,ghics,zen,LST); 74 | xie = Xie2013CSD(ghi,ghics,dni,dnics,zen,exth); 75 | gueymard = Gueymard2013CSD(dni,dnics,zen); 76 | lefevre = Lefevre2013CSD(ghi,dif,exth,zen); 77 | garcia = Garcia2014CSD(ghi,dif,zen,aod,LST); 78 | quesadaruiz = Quesadaruiz2015CSD(ghi,ghics); 79 | reno = Reno2016CSD(ghi,ghics); 80 | inman = Inman2015CSD(ghi,ghics,dni,dnics); 81 | ineichen16 = Ineichen2016CSD(ghi,dni,dif,zen,exth,aod); 82 | aliamartinez = AliaMartinez2016CSD(ghi,ghics,zen,LST); 83 | larraneta = Larraneta2017CSD(dni,dnics,zen,LST); 84 | shen = Shen2018CSD(dni,dnics,aod); 85 | ellis = Ellis2018CSD(ghi,ghics); 86 | zhang = Zhang2018CSD(ghi,ghics); 87 | zhao = Zhao2018CSD(dni,dnics); 88 | ruizarias = RuizArias2018CSD(ghi,dif,zen,LST); 89 | 90 | %% Figures 91 | close all 92 | % produce a large figure showing the data from all models 93 | methods = {'Perez','Batlles','BrightSunCSDc','BrightSunCSDs','LongAckerman'... 94 | ,'Ineichen06','Ineichen09','Polo','Garcia','Xie','Gueymard','Lefevre',... 95 | 'QuesadaRuiz','Reno','Inman','Ineichen16','AliaMartinez','Larraneta',... 96 | 'Shen','Ellis','Zhang','RuizArias','Zhao'}; 97 | csds_methods = {'BrightSunCSDs','Gueymard','Larraneta','RuizArias','Shen','Zhao'}; 98 | ymax = 1300; 99 | 100 | cols = 2; 101 | rows = ceil(length(methods)/2); 102 | topgap = 0.03; 103 | botgap = 0.03; 104 | leftgap = 0.02; 105 | rightgap = 0.01; 106 | midgap = 0.03; 107 | subfigheight = (1-topgap-botgap-midgap*(rows-1))/rows; 108 | subfigwidth = (1-rightgap-leftgap-midgap*(cols-1))/cols; 109 | 110 | f=figure('name','CSD methods','color','w'); 111 | f.Position = [50,50,1200,1000]; 112 | for i =1:length(methods) 113 | r = ceil(i/cols); 114 | c = cols - mod(i,cols); 115 | x = leftgap+midgap*(c-1)+subfigwidth*(c-1); 116 | y = botgap+midgap*(rows-r)+subfigheight*(rows-r); 117 | subplot('Position',[x,y,subfigwidth,subfigheight]) 118 | 119 | hold on 120 | 121 | if ismember(methods{i},csds_methods) 122 | plot(dni,'r') 123 | plot(dnics,'k:') 124 | CSD = dni; 125 | else 126 | plot(ghi) 127 | plot(ghics,'k:') 128 | CSD = ghi; 129 | end 130 | csd = eval(lower(methods{i})); 131 | CSD(csd==1)=NaN; 132 | plot(CSD,'linewidth',2,'color','k') 133 | hold off 134 | 135 | set(gca,'xtick',[]); 136 | set(gca,'ytick',[]); 137 | ylim([0 ymax]) 138 | ylabel('GHI','FontSize',8,'FontName','Times') 139 | xlim([1,length(ghi)]) 140 | text(length(ghi)*0.05,ymax*1.05,['\textbf{',methods{i},'}\quad'],'HorizontalAlignment','left','Interpreter','latex') 141 | if i>length(methods)-2 142 | xlabel('Time','FontSize',8,'FontName','Times') 143 | end 144 | set(gca,'FontName','Times') 145 | end 146 | 147 | print('Example_output.PNG','-dpng','-r300') 148 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CLEAR-SKY DETECTION METHODOLOGY LIBRARY 2 | 3 | ## What is a clear-sky detection methodology? 4 | A clear-sky detection (CSD) methodology is one that analysies time-series of irradiance data and determines one of two things, (1) whether or not the sky at the time of measurement was free of clouds [CSDc], or (2) whether or not there was a clear line of sight to the sun at the time of measurement [CSDs]. 5 | 6 | ## Our recommendations 7 | After reviewing all available methodologies from the library and published the findings (Gueymard et al, 2019 [3], see bottom of README.md) we have a good grasp of which models perform best. 8 | We found that, despite some models performing excellently in certain climtaes, no model in [3] could perform reliably everywhere. 9 | Becasue of this, we designed our own model drawing influence from all involved here: the **Bright-Sun** CSDc and CSDs models (though primarily a CSDc). 10 | This work has been published (Bright et al. 2020 [4]) alongside a thorough investigation into the other methodologies detailed herein. 11 | Naturally, we find this methodology the most reliable, and it is quite insensitive to choice of clear-sky irradiance model (of which I have also provided substantial amounts of code in my other repository at https://github.com/JamieMBright/clear-sky-models). 12 | 13 | ## Introduction 14 | Welcome to the CSD methodology library. 15 | This is a collection of as many CSD methodologies as was found in literature and subsequently coded into Matlab. 16 | Note that many of the models required some form of interpretation or conversion. 17 | Each model (found in the 'models' directory) state the citation of the literature article or conference proceedings from where the model was interpreted. 18 | In the case when the methodology was provided in code, the disclaimer reads "Coded and Converted by..." as opposed to just "Coded by..." 19 | 20 | Whilst the CSD methodologies from literature do state their express intentions between type (1) and type (2) methodologies, our investigation determines that they are often not adept at their intended use case. 21 | As such, it is recommended to consider the different methodologies (start by using the Example.m script) in order to get a feel for their strengths and weaknesses. 22 | 23 | The below image shows an example of all the methodologies within the library (produced using Example.m). The black line shows the detected clear-sky periods. Those with a blue line are CSDc methods an plotted on GHI; those in red are CSDs methods and plotted on DNI. All methods can be used as CSDs or CSDc, though some are clearly better than others. 24 | 25 | ![Time series of clear-sky detection from every CSD model, the same graphic as produced by Example.m](https://github.com/JamieMBright/csd-library/raw/master/Example_output.PNG "Example_output.PNG") 26 | 27 | ## Download 28 | To download or clone this repository, click the above link or [click here to visit the csd-library Github Repository](https://github.com/JamieMBright/csd-library). 29 | Or simply [download the whole master repository](https://github.com/JamieMBright/csd-library/archive/master.zip) as a `.zip` file. 30 | 31 | ## Input Data 32 | The different types of input into each methodology are defined with the assumption that all data is at 1-minute resolution, and that all data is a single column vector, and also that each of the same index across different variables corresponds to the same time-step. 33 | Note that no methodology needs all of these, however, all are needed should one wish to run all methods. The fewest inputs is two, the most is six. Some need clear-sky irradiance, others do not, some it doesn't matter even it if is a poor clear-sky estimate due to optimisation. 34 | 35 | `ghi` = Global horizontal irradiance (Wm-2), column vector. 36 | 37 | `ghics` = Clear-sky global horizontal irradiance (Wm-2), column vector. 38 | 39 | `dni` = Direct normal irradiance (Wm-2), column vector. 40 | 41 | `dnics` = Clear-sky direct normal irradiance (Wm-2), column vector. 42 | 43 | `dif` = Diffuse horizontal irradiance (Wm-2), column vector. 44 | 45 | `zen` = Solar zenith angle (degrees), column vector. 46 | 47 | `exth` = Horizontal projection of extraterrestrial irradiance (Wm-2), column vector. 48 | 49 | `aod` = Total aerosol extinction at 550nm (dimensionless), column vector. 50 | 51 | `LST` = the local solar time, datevector. 52 | 53 | `plot_figure` = if this variable is defined, a figure is plotted illustrating the outcome of the select CSD method, e.g. 1; 54 | 55 | 56 | A summary of the different model's inputs are detailed in the below table. Note that the top 17 models are cloudless-sky CSDc (type 1) methodologies, and the bottom 5 are line of sight CSDs detection methodologies (type 2). 57 | 58 | | Author | Abbreviation | `zen` | `exth` | `ghi` | `dni` | `dif` | `ghics` | `dnics` | `difcs` | `aod` | `LST` 59 | | ---------------------| ------ |:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| 60 | |Alia-Martinez et al. (2016) | AliaMartinez | • | | • | | | • | | | | • 61 | |Batlles | Batlles | • | • | • | | • | | | | | 62 | |Bright et al. (2020) | BrightSunCSDc | • | • | • | | • | • | | • | | • 63 | |Ellis et al. (2018) | Ellis | | | • | | | • | | | | 64 | |Garcia et al. (2014) | Garcia | • | | • | | • | | | | •| • 65 | |Ineichen (2006) | Ineichen06 | • | • | | • | | | | | | 66 | |Ineichen et al. (2009) | Ineichen09 | • | • | • | | | | | | | 67 | |Ineichen (2016) | Ineichen16 | • | • | • | • | • | | | | •| 68 | |Inman et al. (2015) | Inman | | | • | • | | • | • | | | 69 | |Lefevre (2013) | Lefevre | • | • | • | | • | | | | | 70 | |Long and Ackerman (2000) | Long | • | | • | | • | | | | | • 71 | |Perez et al. (1990) | Perez | • | | | • | • | | | | | 72 | |Polo et al. (2009) | Polo | • | | • | | | • | | | | • 73 | |Quesada-Ruiz et al. (2015) | Quesada | | | • | | | • | | | | 74 | |Reno and Hansen (2016) | Reno | | | • | | | • | | | | 75 | |Xie and Liu (2013) | Xie | • | • | • | • | | • | • | | | 76 | |Zhang et al. (2018) | Zhang | | | • | | | • | | | | 77 | ||||||||| 78 | |Bright et al. (2020) | BrightSunCSDs | • | • | • | | • | • | | • | | • 79 | |Gueymard (2013)| Gueymard |•| | |• | | |• | | | 80 | |Larraneta et al. (2017)|Larraneta|•| | |• | | |• | | | 81 | |Ruiz-Arias et al. (2018)|RuizArias|•||• | |• | | | | | • 82 | |Shen et al. (2018) |Shen | | |• |• | | |• | |• | 83 | |Zhao et al. (2018) |Zhao || | |• | | |• | | | 84 | 85 | ## Output Data 86 | Each CSD model offers a single output which is of identical dimensions to the input data. Pay particular attention to the fact that 1 indicates cloud/not-clear and 0 indicates clear. This can of course be swapped or converted to a Boolean etc. However, this is the convention we adopt. 87 | 88 | csd = clear-sky detection. A value of 1 means that clouds were present whereas a flag of 0 means that the hour is clear. 89 | 90 | **1 = cloud** 91 | 92 | **0 = clear** 93 | 94 | ## Example 95 | An example of all the methodologies in action is provided in `Example.m`. 96 | This script should work first time with no inputs and produce a nice figure to see every model's outputs. 97 | In the "Example.m" script, sample data is provided from Adelaide Airport irradiance station operated by the Bureau of Meteorology, Australia. 98 | It is situated at -34.9524 degrees of latitude and 138.5196 degrees of longitude (East of prime meridian) and at an elevation of 2m above sea level. 99 | The time stamps are not provided to anonymise the data. 100 | You can use this to decide which is the most suitable method for your needs, as some have better applications than others. 101 | For eaxmple, the Zhang model is by far the best at isolating only entirely clear days, something not offered by other models, however, it is hyper-conservative in that it rejects the vast majority of days where clear-sky conditions are also observed. 102 | Contrastingly, the Ellis/Reno/Inman are the most adept in identifying any possible period where it could be considered clear-sky, though one could argue that they are better type 2 methodologies than those advertised as so. 103 | 104 | To run all the models: 105 | 1. Download and unzip the csd-library 106 | 2. Open `Example.m` with Matlab 107 | 3. Click `Run` or hit `F5` 108 | 109 | You should be able to see the convention for all the input data, and how each model is called in turn. 110 | Once you have decided which model you wish to use, for example if you were to choose the _RuizArias_ methodology, one must only call `csd =RuizArias2018CSD(ghi,dif,zen)` in order to obtain clear-sky detection flags by replacing `ghi`, `dif` and `zen` with your own data. 111 | 112 | ## Contributors 113 | The literature review in order to identify all the different methodologies of CSD was carried out by Christian A. Gueymard. 114 | The model interpretation and coding was carried out by Jamie M. Bright with support, proofing and testing by David Lingfors. 115 | We pay particular thanks to Gueymard, Jose Ruiz-Arias, Yu Xie, Javier Antonanzas, Ben Ellis and Wenqi 'Flora' Zhang for providing coded versions or support for their models. 116 | 117 | ## Future 118 | This repository will be managed by Jamie M. Bright. Do not hesitate to get in touch should you have new models or corrections to existing ones that you wish to be amended. 119 | 120 | ## Usage rights 121 | All models within this library have been interpreted from literature, converted to Matlab from publically available code, or done so with permission of the author. 122 | These methods are freely available to be downloaded and adopted, though check the license before use! A **strict requirement** for using any of the models that may result in publication is appropriate recognition through citation of the original source as stated in each model [1], this repository as the location for obtaining the models [2] and furthermore reference the following work [3] which was the purpose for the conception of this library: 123 | 124 | [1] Found at the top of the script of each model script. 125 | 126 | [2] Bright, Jamie M. 2018. Clear-sky Detection Library. Github repository, url . 127 | 128 | [3] Gueymard, Christian. A., Bright, Jamie M. and Lingfors, David. 2018. posteriori clear-sky identification methods in solar irradiance time series: Review and preliminary validation using sky imagers. Renewable and Sustainable Energy Reviews, Volume 109, July 2019, Pages 412-427, https://doi.org/10.1016/j.rser.2019.04.027 129 | 130 | [4] Bright, Jamie A., Sun, Xixi, Gueymard, Christian A., Acord, Brendan, Wang, Peng and Engerer, Nicholas A. 2020. Bright-Sun: a globally applicable 1-min clear-sky detection model. Renewable and Sustainable Energy Reviews, Volume xxx, xx 2020, Pages xxx-xxx, https://doixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. IN PRESS. 131 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | AMMENDED WITH CONDITION 10 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | 10. All models within this library have been interpretted from literature, 178 | converted to Matlab from publically available code, or done so with 179 | permission of the author. These methods are freely available to be 180 | downloaded and adopted, though check the licenses. A strict requirement 181 | for doing so is that any publications that utilise any model in this 182 | libaray must cite the original source as stated in each model [1], 183 | cite this repository as the location for obtaining the models [2] and 184 | furthermore reference the following work [3] which was the purpose 185 | for the conception of this library: 186 | 187 | [1] Found at the top of the script of each model 188 | [2] Bright, Jamie M. 2018. Clear-sky Detection Library. Github 189 | repository, url https://github.com/JamieMBright/csd-library. 190 | [3] Gueymard, Christian. A., Bright, Jamie M. and Lingfors, David. 2018. 191 | A posterori clear-sky idenfication methods in solar irradiance time 192 | series: Review and validation. TO BE UPDATED ONCE PUBLISHED 193 | 194 | END OF TERMS AND CONDITIONS 195 | 196 | Copyright 2018 Jamie M. Bright 197 | 198 | Licensed under the Apache License, Version 2.0 (the "License"); 199 | you may not use this file except in compliance with the License. 200 | You may obtain a copy of the License at 201 | 202 | http://www.apache.org/licenses/LICENSE-2.0 203 | 204 | Unless required by applicable law or agreed to in writing, software 205 | distributed under the License is distributed on an "AS IS" BASIS, 206 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 207 | See the License for the specific language governing permissions and 208 | limitations under the License. 209 | -------------------------------------------------------------------------------- /models/BrightSun2020CSDs.m: -------------------------------------------------------------------------------- 1 | function [csd, csd_tricomponent, ghics_optimised,dnics_optimised,difcs_optimised] = BrightSun2020CSDs(zen,ghi,ghics,dif,difcs,LST,plot_figure) 2 | % The Bright-Sun clear-sky detection methodology, 2020. 3 | % Cloudless sky CSDc 4 | % 5 | % ## References ## 6 | % 7 | % M. Alia-Martinez, J. Antonanzas, R. Urraca, F. J. Martinez-De-Pison, and 8 | % F. Antonanzas-Torres, ‘Benchmark of algorithms for solar clear- sky 9 | % detection’, J. Renew. Sustain. Energy, vol. 8, no. 3, 2016. 10 | % 11 | % Ellis, 2018, PVLIB detect_ghics at commit 12 | % f4e4ad3bbe335fa49bf300ce53784d69d719ca98 13 | % https://github.com/pvlib/pvlib-python/pull/596/commits 14 | % 15 | % Reno, M. J. and Hansen, C. W. 2016. Identification of periods of clear 16 | % sky irradiance in time series of GHI measurements. Renewable Energy. 90, 17 | % 520-531. 18 | % 19 | % Shen, Yu; Wei, Haikun; Zhu, Tingting; Zhao, Xin; Zhang, Kanjian. 2018. A 20 | % Data-driven Clear Sky Model for Direct Normal Irradiance. IOP Conf. 21 | % Series: Journal of Physics: Conf. Series. 1072. 22 | % 23 | % Inman, Rich H; Edson, James G and Coimbra, Carlos F M. 2015. Impact of 24 | % local broadband turbidity estimation on forecasting of clear sky direct 25 | % normal irradiance Solar Energy. 117, 125-138 26 | % 27 | % Gueymard, C.A; Bright, J.M.; Lingfors, D.; Habte, A. and Sengupta, M. 28 | % 2019. A posteriori clear-sky identification methods in solar irradiance 29 | % time series: Review and preliminary validation using sky imagers. 30 | % Renewable and Sustainable Energy Reviews. In review. 31 | % 32 | % Larraneta, M; Reno, M J; Lillo-bravo, I; Silva-p, M A. 2017. Identifying 33 | % periods of clear sky direct normal irradiance. Renewable Energy. 113, 34 | % 756-763. 35 | % 36 | % Quesada-Ruiz, Samuel Linares-Rodriguez, Alvaro Ruiz-arias, José A 37 | % Pozo-Vázquez, David. 2015. ScienceDirect An advanced ANN-based method to 38 | % estimate hourly solar radiation from multi-spectral MSG imagery. Solar 39 | % Energy. 115, 494-504. 40 | % 41 | % Zhang, Wenqi; Florita, Anthony R; Hodge, Bri-mathias; Mather, Barry. 42 | % 2018. Modeling and Simulation of High Frequency Solar Irradiance. 43 | % Preprint to Journal of Photovoltaics. 44 | % 45 | % Zhang, Wenqi Kleiber, William Florita, Anthony R Hodge, Bri-mathias 46 | % Mather, Barry. 2018. A stochastic downscaling approach for generating 47 | % high-frequency solar irradiance scenarios. Solar Energy. 176, 370-379. 48 | % 49 | % 50 | % ------------------------------------------------------------------------ 51 | % INPUTS 52 | % ------------------------------------------------------------------------ 53 | % ASSUMPTION: all data is in 1-min resolution. 54 | % zen = Zenith angle in degrees. Corresponding to all inputs 55 | % 56 | % ghi = Global horizontal irradiance, column vector. Not necessary 57 | % to be continuous so long as the ghics perfectly corresponds. 58 | % 59 | % ghics = Clear-sky global horizontal irradiance, column vector. 60 | % 61 | % dif = Diffuse horizontal irradiance, column vector. Not necessary 62 | % to be continuous so long as the ghics perfectly corresponds. 63 | % 64 | % difcs = Clear-sky diffuse horizontal irradiance, column vector. 65 | % 66 | % 67 | % LST = the local solar time, datevector. This can be calculated as 68 | % LST = datevec(datenum(UTC) + (lon*15)/24); 69 | % 70 | % plot_figure = if this variable is defined by any class, then a figure is 71 | % plotted illustrating the outcome of the CSD method, e.g. 1; 72 | % ------------------------------------------------------------------------ 73 | % OUTPUTS 74 | % ------------------------------------------------------------------------ 75 | % csd = clear-sky detection for cloudless sky. a flag of 1 means that 76 | % clouds were suspected whereas a flag of 0 means that the hour is clear. 77 | % 78 | % csd_tricomponent = clear-sky detection from the reno tri component 79 | % optimisation, this returns many many more suspected clear-sky periods 80 | % without the durational filters etc. 81 | % 82 | % dnics/difcs_optimised - the resulting optimised clear-sky curves. Note 83 | % that closure is not maintained or guaranteed with this approach, GHIcs 84 | % should be recalculated to maintian closure. 85 | 86 | %% safety checks 87 | if ~iscolumn(zen) 88 | zen = zen'; 89 | if ~iscolumn(zen) 90 | error('var zen must be a column vector') 91 | end 92 | end 93 | if ~iscolumn(ghi) 94 | ghi = ghi'; 95 | if ~iscolumn(ghi) 96 | error('var ghi must be a column vector') 97 | end 98 | end 99 | if ~iscolumn(ghics) 100 | ghics = ghics'; 101 | if ~iscolumn(ghics) 102 | error('var ghi must be a column vector') 103 | end 104 | end 105 | if ~iscolumn(dif) 106 | dif = dif'; 107 | if ~iscolumn(dif) 108 | error('var dif must be a column vector') 109 | end 110 | end 111 | if ~iscolumn(difcs) 112 | difcs = difcs'; 113 | if ~iscolumn(difcs) 114 | error('var difcscs must be a column vector') 115 | end 116 | end 117 | if length(unique([length(ghi),length(ghics),length(zen),length(dif),length(difcs),length(datenum(LST))]))~=1 118 | error('vars must be equal in length') 119 | end 120 | 121 | % turn off hankel diagonal conflict warning. This happens if the last 122 | % element in ghi/dni/dif is NaN. 123 | warning('off','MATLAB:hankel:AntiDiagonalConflict') 124 | 125 | %% calculate DNI 126 | % we could also request DNI as an input. 127 | 128 | % make sure dif is not greater than ghi 129 | dif(dif>ghi)=ghi(dif>ghi); 130 | difcs(difcs>ghics)=ghics(difcs>ghics); 131 | 132 | % calculate dni and dnics from closure 133 | dnics = (ghics-difcs)./cosd(zen); 134 | dni = (ghi-dif)./cosd(zen); 135 | 136 | %% Clean the data for NaN values 137 | % find all the indices where there are missing data of ghi, dni or dif. 138 | idxs_nan = (isnan(ghi) | isnan(dni) | isnan(dif)); 139 | % find the corresponding index of where the data is not nan. 140 | not_nan_indxs = (~isnan(ghi) & ~isnan(dni) & ~isnan(dif)); 141 | % find the length of the required ouput for sanity. 142 | n_output = length(ghi); 143 | 144 | % Now delete all cases of missing data. We cannot perform on this. 145 | ghi(idxs_nan)=[]; 146 | dni(idxs_nan)=[]; 147 | dif(idxs_nan)=[]; 148 | ghics(idxs_nan)=[]; 149 | dnics(idxs_nan)=[]; 150 | difcs(idxs_nan)=[]; 151 | zen(idxs_nan)=[]; 152 | LST(idxs_nan,:)=[]; 153 | % what remains is perfectly continuous time series of all the variables. 154 | % The tests do not matter should time skip because all tests are 155 | % comparative to the clear-sky irradiance and they too also skip. 156 | 157 | %% Parameterisation 158 | % The methodology applies the Reno 2016 methodology to each sub-component 159 | % of irradiance. There have been many proposed parametrisations in 160 | % literature---all contained here and commented out if not used. 161 | % This methodology mixes and matches the different parametrisations and 162 | % also proposes new limits to certain tests. 163 | 164 | % Reno 2016 Parameterisations for Optimisation 165 | reno_ghi_mean_diff=75; 166 | reno_ghi_max_diff=75; 167 | reno_ghi_lower_line_length=-5; 168 | reno_ghi_upper_line_length=10; 169 | reno_ghi_var_diff=0.1;% old reno 0.005; 170 | reno_ghi_slope_dev=8; 171 | 172 | % optimisation lower irradiance limit threshold (Wm-2) 173 | opt_thres = 30; 174 | 175 | % Bright 2019 parametrisations for modified-Reno 176 | % GHI 177 | BrightSunCriteria.ghi_c1_big_zenith = 0.5; 178 | BrightSunCriteria.ghi_c1_mean_diff=0.125; 179 | BrightSunCriteria.ghi_c1_small_zenith = 0.25; 180 | 181 | BrightSunCriteria.ghi_c2_big_zenith = 0.5; 182 | BrightSunCriteria.ghi_c2_max_diff=0.125; 183 | BrightSunCriteria.ghi_c2_small_zenith = 0.25; 184 | 185 | BrightSunCriteria.ghi_c3_lower_line_length=-0.5; 186 | BrightSunCriteria.ghi_c3_small_zenith = -7; 187 | 188 | BrightSunCriteria.ghi_c4_var_diff=0.4; 189 | 190 | BrightSunCriteria.ghi_c5_slope_dev=15; 191 | BrightSunCriteria.ghi_c5_small_zenith = BrightSunCriteria.ghi_c5_slope_dev*3; 192 | 193 | %DIF 194 | BrightSunCriteria.dif_c1_big_zenith = 0.5; 195 | BrightSunCriteria.dif_c1_mean_diff=0.5; 196 | BrightSunCriteria.dif_c1_small_zenith = 0.25; 197 | 198 | BrightSunCriteria.dif_c2_big_zenith = 0.5; 199 | BrightSunCriteria.dif_c2_max_diff=0.5; 200 | BrightSunCriteria.dif_c2_small_zenith = 0.25; 201 | 202 | BrightSunCriteria.dif_c3_lower_line_length=-1.7; 203 | BrightSunCriteria.dif_c3_small_zenith = -6; 204 | 205 | BrightSunCriteria.dif_c4_var_diff=0.2; 206 | 207 | BrightSunCriteria.dif_c5_slope_dev=8; 208 | BrightSunCriteria.dif_c5_small_zenith = BrightSunCriteria.dif_c5_slope_dev*3; 209 | 210 | 211 | % set parametrisation for the turnaround in the zenith tuned parameters 212 | % At this zenith parameter, the criteria 1,2,4,5 for Bright-Sun will be 213 | % exactly as set. 214 | zenith_turn_around = 30; 215 | 216 | % the window length is as standard across all the Reno variants at 10 mins 217 | window_length = 10; 218 | % the max iterations comes from Ellis 2018 whereby optimisations are 219 | % acheived up until 20 attempts or convergence is reached. 220 | max_iterations=20; 221 | 222 | % assert a minimum and maximum allowable modification to the clear-sky 223 | % irradiance curve, where 1 = no change. 224 | upper_alpha_limit = 1.5; 225 | lower_alpha_limit = 0.7; 226 | lower_alpha_limit_DIF = 0.4; 227 | 228 | 229 | % Duration filter strictness 230 | % First durational window. Higher time but lower strictness. 231 | % The window is the duration size of the window in mins. 232 | window_1st_filter = 1; 233 | % Tolerance is the permissible number of CSD periods within the window. 234 | tolerance_1st_filter = 1; 235 | 236 | % Second durational window. Lower time but higher strictness. 237 | window_2nd_filter = 1; 238 | tolerance_2nd_filter = 1; 239 | 240 | %% Initial CSD guess using Reno for Optimisation Only. 241 | %%% 242 | %%% GHI 243 | %%% 244 | 245 | % produce Hankel matrices for GHI and GHIcs as defined by window_length. a 246 | % Hankel matrix is essentially a staggered set of time series where each 247 | % column is the same data offset by 1 time step, this means that each row 248 | % has a "window" length time series, and each column has the entire time 249 | % series offset by the column number. 250 | ghi_window = hankel(ghi,[ghi(end),NaN(1,window_length-1)]); 251 | ghics_window = hankel(ghics,[ghics(end),NaN(1,window_length-1)]); 252 | 253 | % Calculate the statistics for use in the criteria. This approach is lifted 254 | % from Ellis 2018, Inman 2015 and Reno 2012/2016. 255 | % calculate measurement statistics for ghi. 256 | meas_mean = nanmean(ghi_window,2); % DIM=2, so the mean is taken on a row-wise basis 257 | % [M,NDX] = NANMAX(A,[],DIM) operates along the dimension DIM. 258 | meas_max = nanmax(ghi_window,[],2); % the [] is just matlab specific operations. 259 | % diff reduces the matrix size by 1 due to delta between. The resultant is 260 | % increaasaed by a row of NaNs representing that there is no t+1 for the 261 | % final time step. 262 | meas_diff = [diff(ghi_window);NaN(1,window_length)]; 263 | meas_slope = [diff(ghi_window);NaN(1,window_length)]; 264 | % Y = STD(X,W,DIM), we want DIM=2. 265 | % Pass in 0 for W to use the default normalization by N-1, or 1 to use N. 266 | % use the omitnan option to ignore NaN values, this automatically updates N 267 | meas_slope_nstd = std(meas_slope,0,2,'omitnan') ./ meas_mean; 268 | meas_line_length = nansum(sqrt(meas_diff .* meas_diff + 1^2),2); 269 | 270 | % Repeat the above for GHIcs statistics 271 | clear_mean = nanmean(ghics_window,2); 272 | clear_max = nanmax(ghics_window,[],2); 273 | clear_diff = [diff(ghics_window);NaN(1,window_length)]; 274 | clear_slope = [diff(ghics_window);NaN(1,window_length)]; 275 | clear_line_length = nansum(sqrt(1^2 + clear_diff.^2),2); 276 | 277 | % the final statistic is the line difference that requires both GHIcs and 278 | % GHI statistics combined. 279 | line_diff = meas_line_length - clear_line_length; 280 | 281 | % initialise the criteria matrices where 1 = cloud. The default assumption 282 | % is that cloud is present, satisfaction of all criteria results in an 283 | % assertion of 0 for that time step. 284 | c1 = ones(size(ghi)); 285 | c2 = ones(size(ghi)); 286 | c3 = ones(size(ghi)); 287 | c4 = ones(size(ghi)); 288 | c5 = ones(size(ghi)); 289 | c6 = ones(size(ghi)); 290 | 291 | % perform criteria. We use the Ellis parameterisation for GHI. 292 | % these criteria are very well documented in all Reno, Ellis and Inman 293 | % papers. Particularly in the figure 5 of Inman 2015! 294 | 295 | % if clear>meas, this is ok 296 | c1(abs(meas_mean - clear_mean) < reno_ghi_mean_diff)=0; 297 | c2(abs(meas_max - clear_max) < reno_ghi_max_diff)=0; 298 | c3((line_diff > reno_ghi_lower_line_length) & (line_diff < reno_ghi_upper_line_length))=0; 299 | c4(meas_slope_nstd < reno_ghi_var_diff)=0; 300 | c5(nanmax(abs(meas_slope - clear_slope),[],2) < reno_ghi_slope_dev)=0; 301 | % this 6th criteria only exists in the Ellis 2018 coded version in PVlib. 302 | % It is a sensibility check for NaN results, though probably redundant due 303 | % to the prior screening. 304 | c6((clear_mean ~= 0) & ~isnan(clear_mean))=0; 305 | 306 | % should any criteria be 1(cloud), then the time-step is deemed cloudy 307 | csd_initial = c1 + c2 + c3 + c4 + c5 + c6; 308 | % csd is now the sum of failed tests and so should all 6 criteria have 309 | % failed, csd_1=6. A value of 0 is the only case where clear sky is 310 | % detected. We are unconcerned with how many tests failed, so long as 1 did 311 | % fail, it can then be represented as a binary and so we set all failures 312 | % to be 1. 313 | csd_ghiz = zeros(size(ghi)); 314 | csd_ghiz(csd_initial>0)=1; 315 | % initialise the first CSD guess. 316 | % zeros indicate that the period is clear. 1s indicate cloud 317 | % if all three components do not corroborate, then we assume the period was 318 | % cloudy 319 | csd_initial = csd_ghiz; 320 | 321 | if exist('plot_figure','var') 322 | % % plot an example of the first guess CSD. 323 | lst_plot = datetime(LST); 324 | figure('name','Initial CSD from Reno 2016 example','color','w'); 325 | hold on 326 | plot(lst_plot,ghi) 327 | plot(lst_plot,dni) 328 | plot(lst_plot,dif) 329 | ghiCSD = ghi; ghiCSD(csd_initial==1)=NaN; 330 | plot(lst_plot,ghiCSD,'linewidth',2,'color','k') 331 | plot(lst_plot,ghics,'k:') 332 | dniCSD = dni; dniCSD(csd_initial==1)=NaN; 333 | difCSD = dif; difCSD(csd_initial==1)=NaN; 334 | plot(lst_plot,dniCSD,'linewidth',2,'color','k') 335 | plot(lst_plot,difCSD,'linewidth',2,'color','k') 336 | plot(lst_plot,dnics,'k:') 337 | plot(lst_plot,difcs,'k:') 338 | ylim([1,1300]) 339 | hold off 340 | legend({'GHI','DNI','DIF','CSD','Clear-sky irradiance'},'fontname','times') 341 | ylabel(gca,'Irradiance [Wm$^{-2}$]','Interpreter','latex') 342 | % set(gca,'xtick',[]); 343 | xlabel('Time','Interpreter','latex') 344 | set(gca,'FontName','times') 345 | end 346 | 347 | %% Find all the unique days 348 | % find the unique days so that optimisation can be done on a daily basis. 349 | dtn = floor(datenum(LST)); 350 | unique_days = unique(dtn); 351 | 352 | % initial clear-sky optimisation is that the clear-sky irradiance that is 353 | % input is already perfect (e.g. alpha=1), with each iteration and 354 | % optimisation, we will adjust 1 based on those periods identified as clear 355 | % by the modified Zhang. 356 | alpha_ghi = ones(size(unique_days)); 357 | alpha_dif = ones(size(unique_days)); 358 | alpha_dni = ones(size(unique_days)); 359 | 360 | %% Optimisation of clear-sky irradiance 361 | % This is a similar principal as employed by Alia-Martinez 2016 and Ellis 362 | % 2018. 363 | 364 | if exist('plot_figure','var') 365 | old_ghics = ghics; 366 | old_dnics = dnics; 367 | old_difcs = difcs; 368 | end 369 | 370 | % First, we look through every single day identified in the input data 371 | for d = 1:length(unique_days) 372 | % find the indices within the data that correspond to this day 373 | idxs = find(dtn == unique_days(d)); 374 | 375 | % isolate the variables to only this day 376 | ghid = ghi(idxs); 377 | ghicsd = ghics(idxs); 378 | difd = dif(idxs); 379 | difcsd = difcs(idxs); 380 | dnid = dni(idxs); 381 | dnicsd = dnics(idxs); 382 | csdd = csd_initial(idxs); 383 | 384 | % apply the optimisation lower limit threshold 385 | csdd(difd60 405 | % Begining of optimisation 406 | 407 | % initialise the "current_alpha", which is always 1. 408 | current_alpha = alpha_ghi(d); 409 | % set the previous_alpha as NaN so that it cannot pass the "if" 410 | % statement featured in the following "while" loop. 411 | previous_alpha = NaN; 412 | % initialise the iteration count 413 | iter = 0; 414 | 415 | % enter the while loop. This means that the process will continue 416 | % until the condition is satisfied. The condition is satisfied if 417 | % the optimisation has converged within 0.00001 or if 20 iterations 418 | % has occured. 419 | while (iterupper_alpha_limit) = upper_alpha_limit; 460 | temp(tempupper_alpha_limit) = upper_alpha_limit; 465 | temp(tempupper_alpha_limit) = upper_alpha_limit; 470 | temp(tempmeas, this is ok 601 | c1(abs(meas_mean - clear_mean)./clear_mean < c1_lim)=0; 602 | c2(abs(meas_max - clear_max)./clear_max < c2_lim)=0; 603 | c3((line_diff > c3_lim_lower) & (line_diff < c3_lim_upper))=0; 604 | c4(meas_slope_nstd < BrightSunCriteria.ghi_c4_var_diff)=0; 605 | c5(nanmax(abs(meas_slope - clear_slope),[],2) < c5_lim_lower)=0; 606 | % this 6th criteria only exists in the Ellis 2018 coded version in PVlib. 607 | % It is a sensibility check for NaN results, though probably redundant due 608 | % to the prior screening. 609 | c6((clear_mean ~= 0) & ~isnan(clear_mean))=0; 610 | 611 | % should any criteria be 1(cloud), then the time-step is deemed cloudy 612 | csd_1 = c1 + c2 + c3 + c4 + c5 + c6; 613 | % csd is now the sum of failed tests and so should all 6 criteria have 614 | % failed, csd_1=6. A value of 0 is the only case where clear sky is 615 | % detected. We are unconcerned with how many tests failed, so long as 1 did 616 | % fail, it can then be represented as a binary and so we set all failures 617 | % to be 1. 618 | csd_ghi = zeros(size(ghi)); 619 | csd_ghi(csd_1>0)=1; 620 | 621 | % Keep diagnostics for demonstration plots 622 | criteria_ghi = [c1,c2,c3,c4,c5,c6]; 623 | 624 | % The same process is repeated for DIF 625 | %%% 626 | %%% DIF 627 | %%% 628 | dif_window = hankel(dif,[dif(end),NaN(1,window_length-1)]); 629 | difcs_window = hankel(difcs,[difcs(end),NaN(1,window_length-1)]); 630 | meas_mean = nanmean(dif_window,2); % DIM=2. 631 | meas_max = nanmax(dif_window,[],2); 632 | meas_diff = [diff(dif_window);NaN(1,window_length)]; 633 | meas_slope = [diff(dif_window);NaN(1,window_length)]; 634 | meas_slope_nstd = std(meas_slope,0,2,'omitnan') ./ meas_mean; 635 | meas_line_length = nansum(sqrt(meas_diff .* meas_diff + 1),2); 636 | 637 | clear_mean = nanmean(difcs_window,2); 638 | clear_max = nanmax(difcs_window,[],2); 639 | clear_diff = [diff(difcs_window);NaN(1,window_length)]; 640 | clear_slope = [diff(difcs_window);NaN(1,window_length)]; 641 | clear_line_length = nansum(sqrt(1^2 + clear_diff.^2),2); 642 | 643 | line_diff = (meas_line_length - clear_line_length)./clear_line_length; 644 | 645 | c1 = ones(size(dif)); 646 | c2 = ones(size(dif)); 647 | c3 = ones(size(dif)); 648 | c4 = ones(size(dif)); 649 | c5 = ones(size(dif)); 650 | c6 = ones(size(dif)); 651 | 652 | z = (20:0.01:90)'; 653 | c1_lim = flip([linspace(BrightSunCriteria.dif_c1_big_zenith,BrightSunCriteria.dif_c1_mean_diff,find(z==zenith_turn_around))';... 654 | linspace(BrightSunCriteria.dif_c1_mean_diff,BrightSunCriteria.dif_c1_small_zenith,length(z)-find(z==zenith_turn_around))']); 655 | inds = knnsearch(z,zen); 656 | c1_lim = c1_lim(inds); 657 | c2_lim = flip([linspace(BrightSunCriteria.dif_c2_big_zenith,BrightSunCriteria.dif_c2_max_diff,find(z==zenith_turn_around))';... 658 | linspace(BrightSunCriteria.dif_c2_max_diff,BrightSunCriteria.dif_c2_small_zenith,length(z)-find(z==zenith_turn_around))']); 659 | c2_lim = c2_lim(inds); 660 | c3_lim_lower = flip([linspace(BrightSunCriteria.dif_c3_lower_line_length,BrightSunCriteria.dif_c3_lower_line_length,find(z==zenith_turn_around))';... 661 | linspace(BrightSunCriteria.dif_c3_lower_line_length,BrightSunCriteria.dif_c3_small_zenith,length(z)-find(z==zenith_turn_around))']); 662 | c3_lim_lower = c3_lim_lower(inds); 663 | c3_lim_upper = abs(c3_lim_lower); 664 | c5_lim_lower = flip([linspace(BrightSunCriteria.dif_c5_slope_dev,BrightSunCriteria.dif_c5_slope_dev,find(z==zenith_turn_around))';... 665 | linspace(BrightSunCriteria.dif_c5_slope_dev,BrightSunCriteria.dif_c5_small_zenith,length(z)-find(z==zenith_turn_around))']); 666 | c5_lim_lower = c5_lim_lower(inds); 667 | 668 | 669 | % note that the BrightSunCriteria.dif parameters are now used. 670 | c1(abs(meas_mean - clear_mean)./clear_mean < c1_lim)=0; 671 | c2(abs(meas_max - clear_max)./clear_max < c2_lim)=0; 672 | c3((line_diff > c3_lim_lower) & (line_diff < c3_lim_upper))=0; 673 | c4(meas_slope_nstd < BrightSunCriteria.dif_c4_var_diff)=0; 674 | c5(nanmax(abs(meas_slope - clear_slope),[],2) < c5_lim_lower)=0; 675 | c6((clear_mean ~= 0) & ~isnan(clear_mean))=0; 676 | 677 | csd_2 = c1 + c2 + c3 + c4 + c5 + c6; 678 | csd_dif = zeros(size(ghi)); 679 | csd_dif(csd_2>0)=1; 680 | 681 | % Keep diagnostics for demonstration plots 682 | criteria_dif = [c1,c2,c3,c4,c5,c6]; 683 | 684 | %%% 685 | %%% DNI 686 | %%% 687 | % Apply the Quesada-Ruiz 2015 methodology, though due to optimisation of 688 | % the clear-sky curves, we can afford to be more conservative and apply 689 | % 0.95 instead. 690 | % We also introduce the zenith flexibility introduced by Larraneta 2017. 691 | % create zenith bins from 30:85 at a 0.01 interval size 692 | z = (30:0.01:90)'; 693 | % produce a linearly spaced correction factor as proposed by Larraneta 694 | % 2017. Note that they used three fixed bins, we smooth this through 695 | % interpolation 696 | kc_lims = flip(linspace(0.5,0.9,length(z)))'; 697 | % find the indices where the zenith angles correspond. 698 | inds = knnsearch(z,zen); 699 | % find the kc_limimts for those associated time steps 700 | kc_lim = kc_lims(inds); 701 | 702 | % find the clear sky index for DNI/beam (kcb) 703 | kcb = dni./dnics; 704 | % pre allocate the DNI CSD time series with assumption of cloudy=1 as 705 | % initial guess. 706 | csd_dni=ones(size(dni)); 707 | % should the clear-sky beam index be below the limt, we assert that this 708 | % DNI period is clear---with a 0. 709 | csd_dni(kcb>kc_lim)=0; 710 | 711 | % keep diagnostics for dni 712 | criteria_dni = csd_dni; 713 | 714 | %% Overall criteria 715 | % pre allocate assuming all cloudy 716 | csd_overall = ones(size(ghi)); 717 | % if all componentats are clear, then clear. 718 | csd_overall(csd_ghi+csd_dif+csd_dni==0)=0; 719 | 720 | if exist('plot_figure','var') 721 | % % Exploration plot of the tri-component analysis. Zoom in to have a look. 722 | f = figure('name','Demonstrate that the tri-componenet is working','color','w'); 723 | f.Position(3:4) = [1000,250]; 724 | hold on 725 | plot(ghi) 726 | plot(dni) 727 | plot(dif) 728 | ghiCSD = ghi; ghiCSD(csd_ghi==1)=NaN; 729 | dniCSD = dni; dniCSD(csd_dni==1)=NaN; 730 | difCSD = dif; difCSD(csd_dif==1)=NaN; 731 | allCSD = ghi; allCSD(csd_overall==1)=NaN; 732 | plot(ghiCSD,'linewidth',4,'color','k') 733 | plot(ghics,'k:') 734 | plot(allCSD,'LineWidth',2,'Color','g') 735 | plot(dnics,'k:') 736 | plot(difcs,'k:') 737 | plot(dniCSD,'linewidth',2,'color','k') 738 | plot(difCSD,'linewidth',2,'color','k') 739 | hold off 740 | leg = legend('GHI','DNI','DIF','CSD','CS','combined CSD'); 741 | ylabel(gca,'Irradiance [Wm$^{-2}$]','FontName','Times','Interpreter','latex') 742 | set(gca,'xtick',[]); 743 | ylim([0,1300]) 744 | set(gca,'FontName','Times') 745 | xlabel('Time','FontName','Times') 746 | set(gca,'Position',[0.0564000000000000,0.0944000000000000,0.922800000000000,0.873800000000002]) 747 | end 748 | 749 | %% Make a plot of the reno & DNI diagnostics. 750 | if exist('plot_figure','var') 751 | major_line_width = 20; 752 | line_sep = (major_line_width - 3)/5; 753 | cols = [199,233,180;... 754 | 127,205,187;... 755 | 65,182,196;... 756 | 44,127,184;... 757 | 37,52,148]./255; 758 | % % Exploration plot of the tri-component analysis. Zoom in to have a look. 759 | f = figure('name','explore the nature of Reno criteria','color','w'); 760 | f.Position(3:4) = [1000,250]; 761 | hold on 762 | plot(ghi) 763 | plot(dni) 764 | plot(dif) 765 | plot(ghics,'k:') 766 | plot(dnics,'k:') 767 | plot(difcs,'k:') 768 | for c = 1:5 769 | eval(['c',num2str(c),'=ghi;']); 770 | crit = criteria_ghi(:,c); 771 | eval(['c',num2str(c),'(crit==1)=NaN;']); 772 | eval(['plot(c',num2str(c),',''linewidth'',major_line_width-line_sep*',num2str(c),',''color'',cols(',num2str(c),',:));']); 773 | end 774 | csdghi=ghi;csdghi(csd_ghi==1)=NaN;plot(csdghi,'m'); 775 | csdghi=ghi;csdghi(csd_overall==1)=NaN;plot(csdghi,'r','linewidth',2); 776 | 777 | csddni=dni;csddni(csd_dni==1)=NaN;plot(csddni,'m'); 778 | csddni=dni;csddni(csd_overall==1)=NaN;plot(csddni,'r','linewidth',2); 779 | 780 | for c = 1:5 781 | eval(['c',num2str(c),'=dif;']); 782 | crit = criteria_dif(:,c); 783 | eval(['c',num2str(c),'(crit==1)=NaN;']); 784 | eval(['plot(c',num2str(c),',''linewidth'',major_line_width-line_sep*',num2str(c),',''color'',cols(',num2str(c),',:));']); 785 | end 786 | csddif=dif;csddif(csd_dif==1)=NaN;plot(csddif,'m'); 787 | csddif=dif;csddif(csd_overall==1)=NaN;plot(csddif,'r','linewidth',2); 788 | hold off 789 | leg = legend('GHI','DNI','DIF','GHIcs','DNIcs','DIFcs','c1','c2','c3','c4','c5','CSD_{g/b/d}','tri-CSD'); 790 | ylabel(gca,'Irradiance [Wm$^{-2}$]','FontName','Times','Interpreter','latex') 791 | set(gca,'xtick',[]); 792 | ylim([0,1300]) 793 | set(gca,'FontName','Times') 794 | xlabel('Time','FontName','Times') 795 | set(gca,'Position',[0.0564000000000000,0.0944000000000000,0.922800000000000,0.873800000000002]) 796 | end 797 | 798 | 799 | %% Duration criteria 800 | % we build an hour durational filter looking ahead and behind for 45 801 | % minutes. should there not have been a continuous CSD for an hour, then we 802 | % reject all those instances. 803 | 804 | % safety check on windows 805 | if window_1st_filter<=1 806 | if tolerance_1st_filter==window_1st_filter 807 | tolerance_1st_filter = 2; 808 | end 809 | window_1st_filter=2; 810 | end 811 | if window_2nd_filter<=1 812 | if tolerance_2nd_filter==window_2nd_filter 813 | tolerance_2nd_filter = 2; 814 | end 815 | window_2nd_filter=2; 816 | end 817 | 818 | % First Duration Filter 819 | csdh_1st_duration = nansum(hankel(csd_overall,[csd_overall(end),NaN(1,window_1st_filter-1)]),2); 820 | csdh_1st_duration = [NaN(window_1st_filter/2,1);csdh_1st_duration(1:end-window_1st_filter/2)]; 821 | csd_1st_duration=zeros(size(ghi)); 822 | csd_1st_duration(csdh_1st_duration>tolerance_1st_filter)=1; 823 | % this test makes morning and evening during sunlight hours impossible, 824 | % therefore we relax the CSD at low zenith. However, in polar climates, 825 | % some whole weeks can be >80. 826 | A = (1:length(zen))'; 827 | B = find(round(zen)==85); 828 | [~, distance_to_nearest_sunrise_set] = knnsearch(B,A); 829 | csd_1st_duration(distance_to_nearest_sunrise_settolerance_2nd_filter)=1; 836 | 837 | % As sun-down is considered cloudy (which it should not be), the second 838 | % filter unfavourably elimiates these periods. For that reason, the scond 839 | % filter during sun down proximity (defined by the 840 | % distance_to_nearest_sunset principle) is overridden by a less strict 841 | % duration filter. 842 | % Proximity to Sundown Duration Filter 843 | window_3rd_duration = 10; 844 | tolerance_3rd_duration = 2; 845 | csdh_3rd_duration= nansum(hankel(csd_overall,[csd_overall(end),NaN(1,window_3rd_duration-1)]),2); 846 | csdh_3rd_duration = [NaN(window_3rd_duration/2,1);csdh_3rd_duration(1:end-window_3rd_duration/2)]; 847 | csd_3rd_duration=zeros(size(ghi)); 848 | csd_3rd_duration(csdh_3rd_duration>tolerance_3rd_duration)=1; 849 | 850 | % override the 2nd duration filter at peak proximity to sunrise defined as 851 | % within the first filter window mins of sunrise and where the 10min filter 852 | % found it permissable. 853 | csd_2nd_duration(csd_3rd_duration==0 & distance_to_nearest_sunrise_set20000 936 | xlim([1,20000]) 937 | end 938 | legend({'GHI','DNI','DIF','Clear-sky irrad.','Tri-component CSD','Corroborating CSD','90min window','30min window CSD','Final CSD'},'fontname','times') 939 | ylabel(gca,'Irradiance [Wm$^{-2}$]','Interpreter','latex') 940 | set(gca,'xtick',[]); 941 | xlabel('Time','Interpreter','latex') 942 | set(gca,'fontname','times') 943 | 944 | colours = [215,48,39;254,224,139;145,207,96]./255; 945 | figure('name','Bright-Sun CSD 2019 example','color','w'); 946 | hold on 947 | plot(ghi) 948 | plot(ghics,'k:') 949 | ghiCSD = ghi; ghiCSD(csd(not_nan_indxs)==1)=NaN; 950 | plot(ghiCSD,'LineWidth',4,'color',colours(3,:)) 951 | hold off 952 | legend('GHI','GHIcs','CSD') 953 | ylabel(gca,'Irradiance [Wm$^{-2}$]','Interpreter','latex') 954 | set(gca,'xtick',[]); 955 | xlabel('Time') 956 | 957 | end 958 | end 959 | -------------------------------------------------------------------------------- /models/BrightSun2020CSDc.m: -------------------------------------------------------------------------------- 1 | function [csd, csd_tricomponent, ghics_optimised,dnics_optimised,difcs_optimised] = BrightSun2020CSDc(zen,ghi,ghics,dif,difcs,LST,plot_figure) 2 | % The Bright-Sun clear-sky detection methodology, 2020. 3 | % Cloudless sky CSDc 4 | % 5 | % ## References ## 6 | % 7 | % M. Alia-Martinez, J. Antonanzas, R. Urraca, F. J. Martinez-De-Pison, and 8 | % F. Antonanzas-Torres, ‘Benchmark of algorithms for solar clear- sky 9 | % detection’, J. Renew. Sustain. Energy, vol. 8, no. 3, 2016. 10 | % 11 | % Ellis, 2018, PVLIB detect_ghics at commit 12 | % f4e4ad3bbe335fa49bf300ce53784d69d719ca98 13 | % https://github.com/pvlib/pvlib-python/pull/596/commits 14 | % 15 | % Reno, M. J. and Hansen, C. W. 2016. Identification of periods of clear 16 | % sky irradiance in time series of GHI measurements. Renewable Energy. 90, 17 | % 520-531. 18 | % 19 | % Shen, Yu; Wei, Haikun; Zhu, Tingting; Zhao, Xin; Zhang, Kanjian. 2018. A 20 | % Data-driven Clear Sky Model for Direct Normal Irradiance. IOP Conf. 21 | % Series: Journal of Physics: Conf. Series. 1072. 22 | % 23 | % Inman, Rich H; Edson, James G and Coimbra, Carlos F M. 2015. Impact of 24 | % local broadband turbidity estimation on forecasting of clear sky direct 25 | % normal irradiance Solar Energy. 117, 125-138 26 | % 27 | % Gueymard, C.A; Bright, J.M.; Lingfors, D.; Habte, A. and Sengupta, M. 28 | % 2019. A posteriori clear-sky identification methods in solar irradiance 29 | % time series: Review and preliminary validation using sky imagers. 30 | % Renewable and Sustainable Energy Reviews. In review. 31 | % 32 | % Larraneta, M; Reno, M J; Lillo-bravo, I; Silva-p, M A. 2017. Identifying 33 | % periods of clear sky direct normal irradiance. Renewable Energy. 113, 34 | % 756-763. 35 | % 36 | % Quesada-Ruiz, Samuel Linares-Rodriguez, Alvaro Ruiz-arias, José A 37 | % Pozo-Vázquez, David. 2015. ScienceDirect An advanced ANN-based method to 38 | % estimate hourly solar radiation from multi-spectral MSG imagery. Solar 39 | % Energy. 115, 494-504. 40 | % 41 | % Zhang, Wenqi; Florita, Anthony R; Hodge, Bri-mathias; Mather, Barry. 42 | % 2018. Modeling and Simulation of High Frequency Solar Irradiance. 43 | % Preprint to Journal of Photovoltaics. 44 | % 45 | % Zhang, Wenqi Kleiber, William Florita, Anthony R Hodge, Bri-mathias 46 | % Mather, Barry. 2018. A stochastic downscaling approach for generating 47 | % high-frequency solar irradiance scenarios. Solar Energy. 176, 370-379. 48 | % 49 | % 50 | % ------------------------------------------------------------------------ 51 | % INPUTS 52 | % ------------------------------------------------------------------------ 53 | % ASSUMPTION: all data is in 1-min resolution. 54 | % zen = Zenith angle in degrees. Corresponding to all inputs 55 | % 56 | % ghi = Global horizontal irradiance, column vector. Not necessary 57 | % to be continuous so long as the ghics perfectly corresponds. 58 | % 59 | % ghics = Clear-sky global horizontal irradiance, column vector. 60 | % 61 | % dif = Diffuse horizontal irradiance, column vector. Not necessary 62 | % to be continuous so long as the ghics perfectly corresponds. 63 | % 64 | % difcs = Clear-sky diffuse horizontal irradiance, column vector. 65 | % 66 | % 67 | % LST = the local solar time, datevector. This can be calculated as 68 | % LST = datevec(datenum(UTC) + (lon*15)/24); 69 | % 70 | % plot_figure = if this variable is defined by any class, then a figure is 71 | % plotted illustrating the outcome of the CSD method, e.g. 1; 72 | % ------------------------------------------------------------------------ 73 | % OUTPUTS 74 | % ------------------------------------------------------------------------ 75 | % csd = clear-sky detection for cloudless sky. a flag of 1 means that 76 | % clouds were suspected whereas a flag of 0 means that the hour is clear. 77 | % 78 | % csd_tricomponent = clear-sky detection from the reno tri component 79 | % optimisation, this returns many many more suspected clear-sky periods 80 | % without the durational filters etc. 81 | % 82 | % dnics/difcs_optimised - the resulting optimised clear-sky curves. Note 83 | % that closure is not maintained or guaranteed with this approach, GHIcs 84 | % should be recalculated to maintian closure. 85 | 86 | %% safety checks 87 | if ~iscolumn(zen) 88 | zen = zen'; 89 | if ~iscolumn(zen) 90 | error('var zen must be a column vector') 91 | end 92 | end 93 | if ~iscolumn(ghi) 94 | ghi = ghi'; 95 | if ~iscolumn(ghi) 96 | error('var ghi must be a column vector') 97 | end 98 | end 99 | if ~iscolumn(ghics) 100 | ghics = ghics'; 101 | if ~iscolumn(ghics) 102 | error('var ghi must be a column vector') 103 | end 104 | end 105 | if ~iscolumn(dif) 106 | dif = dif'; 107 | if ~iscolumn(dif) 108 | error('var dif must be a column vector') 109 | end 110 | end 111 | if ~iscolumn(difcs) 112 | difcs = difcs'; 113 | if ~iscolumn(difcs) 114 | error('var difcscs must be a column vector') 115 | end 116 | end 117 | if length(unique([length(ghi),length(ghics),length(zen),length(dif),length(difcs),length(datenum(LST))]))~=1 118 | error('vars must be equal in length') 119 | end 120 | 121 | % turn off hankel diagonal conflict warning. This happens if the last 122 | % element in ghi/dni/dif is NaN. 123 | warning('off','MATLAB:hankel:AntiDiagonalConflict') 124 | 125 | %% calculate DNI 126 | % we could also request DNI as an input. 127 | 128 | % make sure dif is not greater than ghi 129 | dif(dif>ghi)=ghi(dif>ghi); 130 | difcs(difcs>ghics)=ghics(difcs>ghics); 131 | 132 | % calculate dni and dnics from closure 133 | dnics = (ghics-difcs)./cosd(zen); 134 | dni = (ghi-dif)./cosd(zen); 135 | 136 | %% Clean the data for NaN values 137 | % find all the indices where there are missing data of ghi, dni or dif. 138 | idxs_nan = (isnan(ghi) | isnan(dni) | isnan(dif)); 139 | % find the corresponding index of where the data is not nan. 140 | not_nan_indxs = (~isnan(ghi) & ~isnan(dni) & ~isnan(dif)); 141 | % find the length of the required ouput for sanity. 142 | n_output = length(ghi); 143 | 144 | % Now delete all cases of missing data. We cannot perform on this. 145 | ghi(idxs_nan)=[]; 146 | dni(idxs_nan)=[]; 147 | dif(idxs_nan)=[]; 148 | ghics(idxs_nan)=[]; 149 | dnics(idxs_nan)=[]; 150 | difcs(idxs_nan)=[]; 151 | zen(idxs_nan)=[]; 152 | LST(idxs_nan,:)=[]; 153 | % what remains is perfectly continuous time series of all the variables. 154 | % The tests do not matter should time skip because all tests are 155 | % comparative to the clear-sky irradiance and they too also skip. 156 | 157 | %% Parameterisation 158 | % The methodology applies the Reno 2016 methodology to each sub-component 159 | % of irradiance. There have been many proposed parametrisations in 160 | % literature---all contained here and commented out if not used. 161 | % This methodology mixes and matches the different parametrisations and 162 | % also proposes new limits to certain tests. 163 | 164 | % Reno 2016 Parameterisations for Optimisation 165 | reno_ghi_mean_diff=75; 166 | reno_ghi_max_diff=75; 167 | reno_ghi_lower_line_length=-5; 168 | reno_ghi_upper_line_length=10; 169 | reno_ghi_var_diff=0.1;% old reno 0.005; 170 | reno_ghi_slope_dev=8; 171 | 172 | % optimisation lower irradiance limit threshold (Wm-2) 173 | opt_thres = 30; 174 | 175 | % Bright 2019 parametrisations for modified-Reno 176 | % GHI 177 | BrightSunCriteria.ghi_c1_big_zenith = 0.5; 178 | BrightSunCriteria.ghi_c1_mean_diff=0.125; 179 | BrightSunCriteria.ghi_c1_small_zenith = 0.25; 180 | 181 | BrightSunCriteria.ghi_c2_big_zenith = 0.5; 182 | BrightSunCriteria.ghi_c2_max_diff=0.125; 183 | BrightSunCriteria.ghi_c2_small_zenith = 0.25; 184 | 185 | BrightSunCriteria.ghi_c3_lower_line_length=-0.5; 186 | BrightSunCriteria.ghi_c3_small_zenith = -7; 187 | 188 | BrightSunCriteria.ghi_c4_var_diff=0.4; 189 | 190 | BrightSunCriteria.ghi_c5_slope_dev=15; 191 | BrightSunCriteria.ghi_c5_small_zenith = BrightSunCriteria.ghi_c5_slope_dev*3; 192 | 193 | %DIF 194 | BrightSunCriteria.dif_c1_big_zenith = 0.5; 195 | BrightSunCriteria.dif_c1_mean_diff=0.5; 196 | BrightSunCriteria.dif_c1_small_zenith = 0.25; 197 | 198 | BrightSunCriteria.dif_c2_big_zenith = 0.5; 199 | BrightSunCriteria.dif_c2_max_diff=0.5; 200 | BrightSunCriteria.dif_c2_small_zenith = 0.25; 201 | 202 | BrightSunCriteria.dif_c3_lower_line_length=-1.7; 203 | BrightSunCriteria.dif_c3_small_zenith = -6; 204 | 205 | BrightSunCriteria.dif_c4_var_diff=0.2; 206 | 207 | BrightSunCriteria.dif_c5_slope_dev=8; 208 | BrightSunCriteria.dif_c5_small_zenith = BrightSunCriteria.dif_c5_slope_dev*3; 209 | 210 | 211 | % set parametrisation for the turnaround in the zenith tuned parameters 212 | % At this zenith parameter, the criteria 1,2,4,5 for Bright-Sun will be 213 | % exactly as set. 214 | zenith_turn_around = 30; 215 | 216 | % the window length is as standard across all the Reno variants at 10 mins 217 | window_length = 10; 218 | % the max iterations comes from Ellis 2018 whereby optimisations are 219 | % acheived up until 20 attempts or convergence is reached. 220 | max_iterations=20; 221 | 222 | % assert a minimum and maximum allowable modification to the clear-sky 223 | % irradiance curve, where 1 = no change. 224 | upper_alpha_limit = 1.5; 225 | lower_alpha_limit = 0.7; 226 | lower_alpha_limit_DIF = 0.3; 227 | 228 | 229 | % Duration filter strictness 230 | % First durational window. Higher time but lower strictness. 231 | % The window is the duration size of the window in mins. 232 | window_1st_filter = 90; 233 | % Tolerance is the permissible number of CSD periods within the window. 234 | tolerance_1st_filter = 10; 235 | 236 | % Second durational window. Lower time but higher strictness. 237 | window_2nd_filter = 30; 238 | tolerance_2nd_filter = 0; 239 | 240 | %% Initial CSD guess using Reno for Optimisation Only. 241 | %%% 242 | %%% GHI 243 | %%% 244 | 245 | % produce Hankel matrices for GHI and GHIcs as defined by window_length. a 246 | % Hankel matrix is essentially a staggered set of time series where each 247 | % column is the same data offset by 1 time step, this means that each row 248 | % has a "window" length time series, and each column has the entire time 249 | % series offset by the column number. 250 | ghi_window = hankel(ghi,[ghi(end),NaN(1,window_length-1)]); 251 | ghics_window = hankel(ghics,[ghics(end),NaN(1,window_length-1)]); 252 | 253 | % Calculate the statistics for use in the criteria. This approach is lifted 254 | % from Ellis 2018, Inman 2015 and Reno 2012/2016. 255 | % calculate measurement statistics for ghi. 256 | meas_mean = nanmean(ghi_window,2); % DIM=2, so the mean is taken on a row-wise basis 257 | % [M,NDX] = NANMAX(A,[],DIM) operates along the dimension DIM. 258 | meas_max = nanmax(ghi_window,[],2); % the [] is just matlab specific operations. 259 | % diff reduces the matrix size by 1 due to delta between. The resultant is 260 | % increaasaed by a row of NaNs representing that there is no t+1 for the 261 | % final time step. 262 | meas_diff = [diff(ghi_window);NaN(1,window_length)]; 263 | meas_slope = [diff(ghi_window);NaN(1,window_length)]; 264 | % Y = STD(X,W,DIM), we want DIM=2. 265 | % Pass in 0 for W to use the default normalization by N-1, or 1 to use N. 266 | % use the omitnan option to ignore NaN values, this automatically updates N 267 | meas_slope_nstd = std(meas_slope,0,2,'omitnan') ./ meas_mean; 268 | meas_line_length = nansum(sqrt(meas_diff .* meas_diff + 1^2),2); 269 | 270 | % Repeat the above for GHIcs statistics 271 | clear_mean = nanmean(ghics_window,2); 272 | clear_max = nanmax(ghics_window,[],2); 273 | clear_diff = [diff(ghics_window);NaN(1,window_length)]; 274 | clear_slope = [diff(ghics_window);NaN(1,window_length)]; 275 | clear_line_length = nansum(sqrt(1^2 + clear_diff.^2),2); 276 | 277 | % the final statistic is the line difference that requires both GHIcs and 278 | % GHI statistics combined. 279 | line_diff = meas_line_length - clear_line_length; 280 | 281 | % initialise the criteria matrices where 1 = cloud. The default assumption 282 | % is that cloud is present, satisfaction of all criteria results in an 283 | % assertion of 0 for that time step. 284 | c1 = ones(size(ghi)); 285 | c2 = ones(size(ghi)); 286 | c3 = ones(size(ghi)); 287 | c4 = ones(size(ghi)); 288 | c5 = ones(size(ghi)); 289 | c6 = ones(size(ghi)); 290 | 291 | % perform criteria. We use the Ellis parameterisation for GHI. 292 | % these criteria are very well documented in all Reno, Ellis and Inman 293 | % papers. Particularly in the figure 5 of Inman 2015! 294 | 295 | % if clear>meas, this is ok 296 | c1(abs(meas_mean - clear_mean) < reno_ghi_mean_diff)=0; 297 | c2(abs(meas_max - clear_max) < reno_ghi_max_diff)=0; 298 | c3((line_diff > reno_ghi_lower_line_length) & (line_diff < reno_ghi_upper_line_length))=0; 299 | c4(meas_slope_nstd < reno_ghi_var_diff)=0; 300 | c5(nanmax(abs(meas_slope - clear_slope),[],2) < reno_ghi_slope_dev)=0; 301 | % this 6th criteria only exists in the Ellis 2018 coded version in PVlib. 302 | % It is a sensibility check for NaN results, though probably redundant due 303 | % to the prior screening. 304 | c6((clear_mean ~= 0) & ~isnan(clear_mean))=0; 305 | 306 | % should any criteria be 1(cloud), then the time-step is deemed cloudy 307 | csd_initial = c1 + c2 + c3 + c4 + c5 + c6; 308 | % csd is now the sum of failed tests and so should all 6 criteria have 309 | % failed, csd_1=6. A value of 0 is the only case where clear sky is 310 | % detected. We are unconcerned with how many tests failed, so long as 1 did 311 | % fail, it can then be represented as a binary and so we set all failures 312 | % to be 1. 313 | csd_ghiz = zeros(size(ghi)); 314 | csd_ghiz(csd_initial>0)=1; 315 | % initialise the first CSD guess. 316 | % zeros indicate that the period is clear. 1s indicate cloud 317 | % if all three components do not corroborate, then we assume the period was 318 | % cloudy 319 | csd_initial = csd_ghiz; 320 | 321 | if exist('plot_figure','var') 322 | % % plot an example of the first guess CSD. 323 | lst_plot = datetime(LST); 324 | figure('name','Initial CSD from Reno 2016 example','color','w'); 325 | hold on 326 | plot(lst_plot,ghi) 327 | plot(lst_plot,dni) 328 | plot(lst_plot,dif) 329 | ghiCSD = ghi; ghiCSD(csd_initial==1)=NaN; 330 | plot(lst_plot,ghiCSD,'linewidth',2,'color','k') 331 | plot(lst_plot,ghics,'k:') 332 | dniCSD = dni; dniCSD(csd_initial==1)=NaN; 333 | difCSD = dif; difCSD(csd_initial==1)=NaN; 334 | plot(lst_plot,dniCSD,'linewidth',2,'color','k') 335 | plot(lst_plot,difCSD,'linewidth',2,'color','k') 336 | plot(lst_plot,dnics,'k:') 337 | plot(lst_plot,difcs,'k:') 338 | ylim([1,1300]) 339 | hold off 340 | legend({'GHI','DNI','DIF','CSD','Clear-sky irradiance'},'fontname','times') 341 | ylabel(gca,'Irradiance [Wm$^{-2}$]','Interpreter','latex') 342 | % set(gca,'xtick',[]); 343 | xlabel('Time','Interpreter','latex') 344 | set(gca,'FontName','times') 345 | end 346 | 347 | %% Find all the unique days 348 | % find the unique days so that optimisation can be done on a daily basis. 349 | dtn = floor(datenum(LST)); 350 | unique_days = unique(dtn); 351 | 352 | % initial clear-sky optimisation is that the clear-sky irradiance that is 353 | % input is already perfect (e.g. alpha=1), with each iteration and 354 | % optimisation, we will adjust 1 based on those periods identified as clear 355 | % by the modified Zhang. 356 | alpha_ghi = ones(size(unique_days)); 357 | alpha_dif = ones(size(unique_days)); 358 | alpha_dni = ones(size(unique_days)); 359 | 360 | %% Optimisation of clear-sky irradiance 361 | % This is a similar principal as employed by Alia-Martinez 2016 and Ellis 362 | % 2018. 363 | 364 | if exist('plot_figure','var') 365 | old_ghics = ghics; 366 | old_dnics = dnics; 367 | old_difcs = difcs; 368 | end 369 | 370 | % First, we look through every single day identified in the input data 371 | for d = 1:length(unique_days) 372 | % find the indices within the data that correspond to this day 373 | idxs = find(dtn == unique_days(d)); 374 | 375 | % isolate the variables to only this day 376 | ghid = ghi(idxs); 377 | ghicsd = ghics(idxs); 378 | difd = dif(idxs); 379 | difcsd = difcs(idxs); 380 | dnid = dni(idxs); 381 | dnicsd = dnics(idxs); 382 | csdd = csd_initial(idxs); 383 | 384 | % apply the optimisation lower limit threshold 385 | csdd(difd60 405 | % Begining of optimisation 406 | 407 | % initialise the "current_alpha", which is always 1. 408 | current_alpha = alpha_ghi(d); 409 | % set the previous_alpha as NaN so that it cannot pass the "if" 410 | % statement featured in the following "while" loop. 411 | previous_alpha = NaN; 412 | % initialise the iteration count 413 | iter = 0; 414 | 415 | % enter the while loop. This means that the process will continue 416 | % until the condition is satisfied. The condition is satisfied if 417 | % the optimisation has converged within 0.00001 or if 20 iterations 418 | % has occured. 419 | while (iterupper_alpha_limit) = upper_alpha_limit; 460 | temp(tempupper_alpha_limit) = upper_alpha_limit; 465 | temp(tempupper_alpha_limit) = upper_alpha_limit; 470 | temp(tempmeas, this is ok 601 | c1(abs(meas_mean - clear_mean)./clear_mean < c1_lim)=0; 602 | c2(abs(meas_max - clear_max)./clear_max < c2_lim)=0; 603 | c3((line_diff > c3_lim_lower) & (line_diff < c3_lim_upper))=0; 604 | c4(meas_slope_nstd < BrightSunCriteria.ghi_c4_var_diff)=0; 605 | c5(nanmax(abs(meas_slope - clear_slope),[],2) < c5_lim_lower)=0; 606 | % this 6th criteria only exists in the Ellis 2018 coded version in PVlib. 607 | % It is a sensibility check for NaN results, though probably redundant due 608 | % to the prior screening. 609 | c6((clear_mean ~= 0) & ~isnan(clear_mean))=0; 610 | 611 | % should any criteria be 1(cloud), then the time-step is deemed cloudy 612 | csd_1 = c1 + c2 + c3 + c4 + c5 + c6; 613 | % csd is now the sum of failed tests and so should all 6 criteria have 614 | % failed, csd_1=6. A value of 0 is the only case where clear sky is 615 | % detected. We are unconcerned with how many tests failed, so long as 1 did 616 | % fail, it can then be represented as a binary and so we set all failures 617 | % to be 1. 618 | csd_ghi = zeros(size(ghi)); 619 | csd_ghi(csd_1>0)=1; 620 | 621 | % Keep diagnostics for demonstration plots 622 | criteria_ghi = [c1,c2,c3,c4,c5,c6]; 623 | 624 | % The same process is repeated for DIF 625 | %%% 626 | %%% DIF 627 | %%% 628 | dif_window = hankel(dif,[dif(end),NaN(1,window_length-1)]); 629 | difcs_window = hankel(difcs,[difcs(end),NaN(1,window_length-1)]); 630 | meas_mean = nanmean(dif_window,2); % DIM=2. 631 | meas_max = nanmax(dif_window,[],2); 632 | meas_diff = [diff(dif_window);NaN(1,window_length)]; 633 | meas_slope = [diff(dif_window);NaN(1,window_length)]; 634 | meas_slope_nstd = std(meas_slope,0,2,'omitnan') ./ meas_mean; 635 | meas_line_length = nansum(sqrt(meas_diff .* meas_diff + 1),2); 636 | 637 | clear_mean = nanmean(difcs_window,2); 638 | clear_max = nanmax(difcs_window,[],2); 639 | clear_diff = [diff(difcs_window);NaN(1,window_length)]; 640 | clear_slope = [diff(difcs_window);NaN(1,window_length)]; 641 | clear_line_length = nansum(sqrt(1^2 + clear_diff.^2),2); 642 | 643 | line_diff = (meas_line_length - clear_line_length)./clear_line_length; 644 | 645 | c1 = ones(size(dif)); 646 | c2 = ones(size(dif)); 647 | c3 = ones(size(dif)); 648 | c4 = ones(size(dif)); 649 | c5 = ones(size(dif)); 650 | c6 = ones(size(dif)); 651 | 652 | z = (20:0.01:90)'; 653 | c1_lim = flip([linspace(BrightSunCriteria.dif_c1_big_zenith,BrightSunCriteria.dif_c1_mean_diff,find(z==zenith_turn_around))';... 654 | linspace(BrightSunCriteria.dif_c1_mean_diff,BrightSunCriteria.dif_c1_small_zenith,length(z)-find(z==zenith_turn_around))']); 655 | inds = knnsearch(z,zen); 656 | c1_lim = c1_lim(inds); 657 | c2_lim = flip([linspace(BrightSunCriteria.dif_c2_big_zenith,BrightSunCriteria.dif_c2_max_diff,find(z==zenith_turn_around))';... 658 | linspace(BrightSunCriteria.dif_c2_max_diff,BrightSunCriteria.dif_c2_small_zenith,length(z)-find(z==zenith_turn_around))']); 659 | c2_lim = c2_lim(inds); 660 | c3_lim_lower = flip([linspace(BrightSunCriteria.dif_c3_lower_line_length,BrightSunCriteria.dif_c3_lower_line_length,find(z==zenith_turn_around))';... 661 | linspace(BrightSunCriteria.dif_c3_lower_line_length,BrightSunCriteria.dif_c3_small_zenith,length(z)-find(z==zenith_turn_around))']); 662 | c3_lim_lower = c3_lim_lower(inds); 663 | c3_lim_upper = abs(c3_lim_lower); 664 | c5_lim_lower = flip([linspace(BrightSunCriteria.dif_c5_slope_dev,BrightSunCriteria.dif_c5_slope_dev,find(z==zenith_turn_around))';... 665 | linspace(BrightSunCriteria.dif_c5_slope_dev,BrightSunCriteria.dif_c5_small_zenith,length(z)-find(z==zenith_turn_around))']); 666 | c5_lim_lower = c5_lim_lower(inds); 667 | 668 | 669 | % note that the BrightSunCriteria.dif parameters are now used. 670 | c1(abs(meas_mean - clear_mean)./clear_mean < c1_lim)=0; 671 | c2(abs(meas_max - clear_max)./clear_max < c2_lim)=0; 672 | c3((line_diff > c3_lim_lower) & (line_diff < c3_lim_upper))=0; 673 | c4(meas_slope_nstd < BrightSunCriteria.dif_c4_var_diff)=0; 674 | c5(nanmax(abs(meas_slope - clear_slope),[],2) < c5_lim_lower)=0; 675 | c6((clear_mean ~= 0) & ~isnan(clear_mean))=0; 676 | 677 | csd_2 = c1 + c2 + c3 + c4 + c5 + c6; 678 | csd_dif = zeros(size(ghi)); 679 | csd_dif(csd_2>0)=1; 680 | 681 | % Keep diagnostics for demonstration plots 682 | criteria_dif = [c1,c2,c3,c4,c5,c6]; 683 | 684 | %%% 685 | %%% DNI 686 | %%% 687 | % Apply the Quesada-Ruiz 2015 methodology, though due to optimisation of 688 | % the clear-sky curves, we can afford to be more conservative and apply 689 | % 0.95 instead. 690 | % We also introduce the zenith flexibility introduced by Larraneta 2017. 691 | % create zenith bins from 30:85 at a 0.01 interval size 692 | z = (30:0.01:90)'; 693 | % produce a linearly spaced correction factor as proposed by Larraneta 694 | % 2017. Note that they used three fixed bins, we smooth this through 695 | % interpolation 696 | kc_lims = flip(linspace(0.5,0.9,length(z)))'; 697 | % find the indices where the zenith angles correspond. 698 | inds = knnsearch(z,zen); 699 | % find the kc_limimts for those associated time steps 700 | kc_lim = kc_lims(inds); 701 | 702 | % find the clear sky index for DNI/beam (kcb) 703 | kcb = dni./dnics; 704 | % pre allocate the DNI CSD time series with assumption of cloudy=1 as 705 | % initial guess. 706 | csd_dni=ones(size(dni)); 707 | % should the clear-sky beam index be below the limt, we assert that this 708 | % DNI period is clear---with a 0. 709 | csd_dni(kcb>kc_lim)=0; 710 | 711 | % keep diagnostics for dni 712 | criteria_dni = csd_dni; 713 | 714 | %% Overall criteria 715 | % pre allocate assuming all cloudy 716 | csd_overall = ones(size(ghi)); 717 | % if all componentats are clear, then clear. 718 | csd_overall(csd_ghi+csd_dif+csd_dni==0)=0; 719 | 720 | if exist('plot_figure','var') 721 | % % Exploration plot of the tri-component analysis. Zoom in to have a look. 722 | f = figure('name','Demonstrate that the tri-componenet is working','color','w'); 723 | f.Position(3:4) = [1000,250]; 724 | hold on 725 | plot(ghi) 726 | plot(dni) 727 | plot(dif) 728 | ghiCSD = ghi; ghiCSD(csd_ghi==1)=NaN; 729 | dniCSD = dni; dniCSD(csd_dni==1)=NaN; 730 | difCSD = dif; difCSD(csd_dif==1)=NaN; 731 | allCSD = ghi; allCSD(csd_overall==1)=NaN; 732 | plot(ghiCSD,'linewidth',4,'color','k') 733 | plot(ghics,'k:') 734 | plot(allCSD,'LineWidth',2,'Color','g') 735 | plot(dnics,'k:') 736 | plot(difcs,'k:') 737 | plot(dniCSD,'linewidth',2,'color','k') 738 | plot(difCSD,'linewidth',2,'color','k') 739 | hold off 740 | leg = legend('GHI','DNI','DIF','CSD','CS','combined CSD'); 741 | ylabel(gca,'Irradiance [Wm$^{-2}$]','FontName','Times','Interpreter','latex') 742 | set(gca,'xtick',[]); 743 | ylim([0,1300]) 744 | set(gca,'FontName','Times') 745 | xlabel('Time','FontName','Times') 746 | set(gca,'Position',[0.0564000000000000,0.0944000000000000,0.922800000000000,0.873800000000002]) 747 | end 748 | 749 | %% Make a plot of the reno & DNI diagnostics. 750 | if exist('plot_figure','var') 751 | major_line_width = 20; 752 | line_sep = (major_line_width - 3)/5; 753 | cols = [199,233,180;... 754 | 127,205,187;... 755 | 65,182,196;... 756 | 44,127,184;... 757 | 37,52,148]./255; 758 | % % Exploration plot of the tri-component analysis. Zoom in to have a look. 759 | f = figure('name','explore the nature of Reno criteria','color','w'); 760 | f.Position(3:4) = [1000,250]; 761 | hold on 762 | plot(ghi) 763 | plot(dni) 764 | plot(dif) 765 | plot(ghics,'k:') 766 | plot(dnics,'k:') 767 | plot(difcs,'k:') 768 | for c = 1:5 769 | eval(['c',num2str(c),'=ghi;']); 770 | crit = criteria_ghi(:,c); 771 | eval(['c',num2str(c),'(crit==1)=NaN;']); 772 | eval(['plot(c',num2str(c),',''linewidth'',major_line_width-line_sep*',num2str(c),',''color'',cols(',num2str(c),',:));']); 773 | end 774 | csdghi=ghi;csdghi(csd_ghi==1)=NaN;plot(csdghi,'m'); 775 | csdghi=ghi;csdghi(csd_overall==1)=NaN;plot(csdghi,'r','linewidth',2); 776 | 777 | csddni=dni;csddni(csd_dni==1)=NaN;plot(csddni,'m'); 778 | csddni=dni;csddni(csd_overall==1)=NaN;plot(csddni,'r','linewidth',2); 779 | 780 | for c = 1:5 781 | eval(['c',num2str(c),'=dif;']); 782 | crit = criteria_dif(:,c); 783 | eval(['c',num2str(c),'(crit==1)=NaN;']); 784 | eval(['plot(c',num2str(c),',''linewidth'',major_line_width-line_sep*',num2str(c),',''color'',cols(',num2str(c),',:));']); 785 | end 786 | csddif=dif;csddif(csd_dif==1)=NaN;plot(csddif,'m'); 787 | csddif=dif;csddif(csd_overall==1)=NaN;plot(csddif,'r','linewidth',2); 788 | hold off 789 | leg = legend('GHI','DNI','DIF','GHIcs','DNIcs','DIFcs','c1','c2','c3','c4','c5','CSD_{g/b/d}','tri-CSD'); 790 | ylabel(gca,'Irradiance [Wm$^{-2}$]','FontName','Times','Interpreter','latex') 791 | set(gca,'xtick',[]); 792 | ylim([0,1300]) 793 | set(gca,'FontName','Times') 794 | xlabel('Time','FontName','Times') 795 | set(gca,'Position',[0.0564000000000000,0.0944000000000000,0.922800000000000,0.873800000000002]) 796 | end 797 | 798 | 799 | %% Duration criteria 800 | % we build an hour durational filter looking ahead and behind for 45 801 | % minutes. should there not have been a continuous CSD for an hour, then we 802 | % reject all those instances. 803 | 804 | % safety check on windows 805 | if window_1st_filter<=1 806 | if tolerance_1st_filter==window_1st_filter 807 | tolerance_1st_filter = 2; 808 | end 809 | window_1st_filter=2; 810 | end 811 | if window_2nd_filter<=1 812 | if tolerance_2nd_filter==window_2nd_filter 813 | tolerance_2nd_filter = 2; 814 | end 815 | window_2nd_filter=2; 816 | end 817 | 818 | % First Duration Filter 819 | csdh_1st_duration = nansum(hankel(csd_overall,[csd_overall(end),NaN(1,window_1st_filter-1)]),2); 820 | csdh_1st_duration = [NaN(window_1st_filter/2,1);csdh_1st_duration(1:end-window_1st_filter/2)]; 821 | csd_1st_duration=zeros(size(ghi)); 822 | csd_1st_duration(csdh_1st_duration>tolerance_1st_filter)=1; 823 | % this test makes morning and evening during sunlight hours impossible, 824 | % therefore we relax the CSD at low zenith. However, in polar climates, 825 | % some whole weeks can be >80. 826 | A = (1:length(zen))'; 827 | B = find(round(zen)==85); 828 | [~, distance_to_nearest_sunrise_set] = knnsearch(B,A); 829 | csd_1st_duration(distance_to_nearest_sunrise_settolerance_2nd_filter)=1; 836 | 837 | % As sun-down is considered cloudy (which it should not be), the second 838 | % filter unfavourably elimiates these periods. For that reason, the scond 839 | % filter during sun down proximity (defined by the 840 | % distance_to_nearest_sunset principle) is overridden by a less strict 841 | % duration filter. 842 | % Proximity to Sundown Duration Filter 843 | window_3rd_duration = 10; 844 | tolerance_3rd_duration = 2; 845 | csdh_3rd_duration= nansum(hankel(csd_overall,[csd_overall(end),NaN(1,window_3rd_duration-1)]),2); 846 | csdh_3rd_duration = [NaN(window_3rd_duration/2,1);csdh_3rd_duration(1:end-window_3rd_duration/2)]; 847 | csd_3rd_duration=zeros(size(ghi)); 848 | csd_3rd_duration(csdh_3rd_duration>tolerance_3rd_duration)=1; 849 | 850 | % override the 2nd duration filter at peak proximity to sunrise defined as 851 | % within the first filter window mins of sunrise and where the 10min filter 852 | % found it permissable. 853 | csd_2nd_duration(csd_3rd_duration==0 & distance_to_nearest_sunrise_set20000 936 | xlim([1,20000]) 937 | end 938 | legend({'GHI','DNI','DIF','Clear-sky irrad.','Tri-component CSD','Corroborating CSD','90min window','30min window CSD','Final CSD'},'fontname','times') 939 | ylabel(gca,'Irradiance [Wm$^{-2}$]','Interpreter','latex') 940 | set(gca,'xtick',[]); 941 | xlabel('Time','Interpreter','latex') 942 | set(gca,'fontname','times') 943 | 944 | colours = [215,48,39;254,224,139;145,207,96]./255; 945 | figure('name','Bright-Sun CSD 2019 example','color','w'); 946 | hold on 947 | plot(ghi) 948 | plot(ghics,'k:') 949 | ghiCSD = ghi; ghiCSD(csd(not_nan_indxs)==1)=NaN; 950 | plot(ghiCSD,'LineWidth',4,'color',colours(3,:)) 951 | hold off 952 | legend('GHI','GHIcs','CSD') 953 | ylabel(gca,'Irradiance [Wm$^{-2}$]','Interpreter','latex') 954 | set(gca,'xtick',[]); 955 | xlabel('Time') 956 | 957 | end 958 | end 959 | -------------------------------------------------------------------------------- /models/Zhang2018CSD.m: -------------------------------------------------------------------------------- 1 | % Zhang 2018 Clear-sky detection method [1] 2 | % 3 | % ## References ## 4 | % [1] Zhang, Wenqi; Florita, Anthony R; Hodge, Bri-mathias; Mather, Barry. 5 | % 2018. Modeling and Simulation of High Frequency Solar Irradiance. 6 | % Preprint to Journal of Photovoltaics. 7 | % [2] Zhang, Wenqi Kleiber, William Florita, Anthony R Hodge, Bri-mathias 8 | % Mather, Barry. 2018. A stochastic downscaling approach for generating 9 | % high-frequency solar irradiance scenarios. Solar Energy. 176, 370-379. 10 | % 11 | 12 | % Coded by Jamie M. Bright 11/2018. 13 | % ------------------------------------------------------------------------ 14 | % INPUTS 15 | % ------------------------------------------------------------------------ 16 | % ASSUMPTION: all data is in 1-min resolution and all vectors perfectly 17 | % match each other in terms of time stamps. 18 | % 19 | % ghi = Global horizontal irradiance, column vector. Not necessary 20 | % to be continuous so long as the ghics perfectly corresponds. 21 | % 22 | % ghics = Clear-sky global horizontal irradiance, column vector. 23 | % 24 | % plot_figure = if this variable is defined by any class, then a figure is 25 | % plotted illustrating the outcome of the CSD method, e.g. 1; 26 | % ------------------------------------------------------------------------ 27 | % OUTPUTS 28 | % ------------------------------------------------------------------------ 29 | % csd = clear-sky detection. a flag of 1 means that clouds were detected 30 | % whereas a flag of 0 means that the hour is clear. 31 | % 32 | % ------------------------------------------------------------------------ 33 | % EXAMPLE 34 | % ------------------------------------------------------------------------ 35 | % % sample ghi data from Adelaide Airport, sz = [3000,1] 36 | % ghi = [8.19160000000000;8.79400000000000;9.49820000000000;10.4160000000000;11.2860000000000;12.1570000000000;14.7830000000000;16.4240000000000;18.2430000000000;22.9120000000000;27.4670000000000;30.0280000000000;32.2490000000000;34.5920000000000;36.9380000000000;39.3540000000000;41.7600000000000;44.2820000000000;46.6260000000000;48.9740000000000;51.5240000000000;54.1790000000000;56.7250000000000;59.3390000000000;61.9790000000000;64.7780000000000;67.5850000000000;70.0530000000000;72.9690000000000;75.8740000000000;78.6350000000000;81.6190000000000;84.6400000000000;87.7370000000000;90.7970000000000;94.0130000000000;97.0450000000000;100.110000000000;103.220000000000;106.330000000000;109.440000000000;112.760000000000;116.010000000000;119.210000000000;122.270000000000;125.610000000000;129.190000000000;132.580000000000;135.350000000000;139.160000000000;142.430000000000;145.910000000000;149.130000000000;152.480000000000;155.830000000000;159.240000000000;162.620000000000;166.230000000000;169.540000000000;172.840000000000;175.940000000000;179.360000000000;182.850000000000;186.460000000000;190.020000000000;193.810000000000;197.440000000000;201.100000000000;204.730000000000;208.550000000000;212.030000000000;215.740000000000;219.390000000000;223.260000000000;226.920000000000;230.690000000000;234.360000000000;237.980000000000;241.810000000000;245.710000000000;249.170000000000;252.790000000000;256.050000000000;259.770000000000;263.360000000000;266.720000000000;270.430000000000;273.680000000000;277.290000000000;280.940000000000;284.880000000000;288.600000000000;292.380000000000;296.070000000000;300.080000000000;303.650000000000;307.110000000000;310.520000000000;313.730000000000;317.520000000000;320.860000000000;324.650000000000;328.390000000000;331.980000000000;335.900000000000;339.480000000000;343.010000000000;346.770000000000;350.670000000000;354.690000000000;358.180000000000;361.960000000000;365.720000000000;369.770000000000;373.860000000000;377.410000000000;380.610000000000;384.400000000000;388.220000000000;391.800000000000;395.590000000000;399.560000000000;403.790000000000;407.540000000000;411.080000000000;414.780000000000;418.350000000000;421.660000000000;426.010000000000;429.820000000000;434.190000000000;437.970000000000;442.160000000000;445.520000000000;449.660000000000;452.940000000000;456.840000000000;461;464.050000000000;467.790000000000;470.880000000000;474.550000000000;478.220000000000;481.750000000000;485.700000000000;489.830000000000;493.120000000000;497.040000000000;500.830000000000;504.140000000000;507.710000000000;511.770000000000;515.170000000000;518.700000000000;522.420000000000;525.740000000000;529.210000000000;532.610000000000;535.840000000000;539.500000000000;543.150000000000;546.340000000000;549.690000000000;552.940000000000;556.860000000000;560.650000000000;564.430000000000;567.580000000000;570.810000000000;573.790000000000;577.150000000000;580.580000000000;583.770000000000;586.720000000000;590.330000000000;593.420000000000;597.050000000000;600.510000000000;604.030000000000;606.850000000000;610.010000000000;613.790000000000;617.360000000000;620.370000000000;623.870000000000;626.580000000000;630.490000000000;634.440000000000;638.330000000000;641.960000000000;645.320000000000;648.240000000000;651.600000000000;655.160000000000;658.010000000000;661.450000000000;664.530000000000;668.180000000000;671.340000000000;674.980000000000;677.530000000000;680.630000000000;683.550000000000;687;690.820000000000;694.180000000000;697.440000000000;700.340000000000;703.710000000000;707.030000000000;710.010000000000;713.150000000000;715.930000000000;720.110000000000;723.550000000000;726.440000000000;728.920000000000;731.050000000000;733.370000000000;735.660000000000;739.950000000000;742.770000000000;745.970000000000;748.630000000000;751.460000000000;754.170000000000;755.760000000000;758.940000000000;762.840000000000;766.610000000000;768.740000000000;771.230000000000;774.150000000000;778.290000000000;781.050000000000;784.730000000000;788.800000000000;791.070000000000;793.560000000000;797.020000000000;799.930000000000;802.530000000000;804.740000000000;809.500000000000;812.750000000000;815.800000000000;819.060000000000;821.050000000000;824;826.400000000000;828.990000000000;831.470000000000;833.940000000000;836.290000000000;837.720000000000;839.530000000000;842.430000000000;844.990000000000;847.150000000000;850.640000000000;852.780000000000;854.960000000000;858;860.270000000000;862.840000000000;865.410000000000;867.940000000000;869.790000000000;872.980000000000;875.400000000000;877.830000000000;879.540000000000;882.190000000000;884.470000000000;886.550000000000;889.690000000000;891.860000000000;893.990000000000;896.130000000000;898.230000000000;901.010000000000;903.480000000000;905.540000000000;908.320000000000;910.010000000000;911.740000000000;914.100000000000;916.020000000000;918.130000000000;921.180000000000;924.320000000000;926.410000000000;928.090000000000;929.850000000000;930.940000000000;932.240000000000;935.430000000000;937.300000000000;939.460000000000;941.910000000000;943.370000000000;945.220000000000;946.810000000000;949.220000000000;950.700000000000;953.770000000000;955.550000000000;958.390000000000;959.800000000000;963.070000000000;962.700000000000;966.240000000000;968.180000000000;970.350000000000;973.290000000000;978.600000000000;947.200000000000;983.100000000000;982.050000000000;982.180000000000;983.730000000000;984.030000000000;987.250000000000;989.180000000000;990.880000000000;993;994.360000000000;995.530000000000;997.510000000000;999.400000000000;1000.70000000000;1001.60000000000;1003.50000000000;1005.20000000000;1006.20000000000;1007.80000000000;1008.30000000000;1009.30000000000;1011.20000000000;1012.30000000000;1013.70000000000;1014.70000000000;1016.80000000000;1017.80000000000;1018.80000000000;1021.10000000000;1023.10000000000;1023.70000000000;1024.60000000000;1026;1026.80000000000;1028.80000000000;1030.60000000000;1031.40000000000;1032.80000000000;1033.10000000000;1034.30000000000;1035.80000000000;1036.70000000000;1037.70000000000;1039.20000000000;1041.40000000000;1043.20000000000;1043.30000000000;1044.30000000000;1045.20000000000;1046.20000000000;1046.80000000000;1047.60000000000;1048.70000000000;1049.60000000000;1051;1051.50000000000;1052.40000000000;1053.50000000000;1054.30000000000;1056.10000000000;1056.20000000000;1057.20000000000;1058.50000000000;1058.90000000000;1058.90000000000;1060.80000000000;1061;1061.90000000000;1062.90000000000;1062.50000000000;1063.30000000000;1064.10000000000;1064.70000000000;1066.30000000000;1066.50000000000;1066.90000000000;1066.20000000000;1067.90000000000;1068;1070.10000000000;1065.70000000000;1070;1071.10000000000;1071.50000000000;1071.40000000000;1071.10000000000;1070.70000000000;1070.70000000000;1072.40000000000;1073.10000000000;1073.20000000000;1072.90000000000;1072.30000000000;1072.60000000000;1072.20000000000;1073.40000000000;1073.70000000000;1074;1075;1075.60000000000;1075.20000000000;1075.30000000000;1075.90000000000;1074.80000000000;1074.50000000000;1074.40000000000;1074.70000000000;1075.40000000000;1074.90000000000;1076.30000000000;1077;1075.90000000000;1074.80000000000;1073.60000000000;1073.70000000000;1074.20000000000;1075.10000000000;1076.50000000000;1076.70000000000;1074.80000000000;1074.20000000000;1073.30000000000;1073.80000000000;1074;1075;1072.20000000000;1071.20000000000;1070.50000000000;1070.30000000000;1070.90000000000;1071.90000000000;1070.40000000000;1071.20000000000;1070.30000000000;1068.60000000000;1068.30000000000;1065.90000000000;1065.90000000000;1065.40000000000;1065.30000000000;1065.80000000000;1066.60000000000;1048.20000000000;1033.30000000000;1063.10000000000;1060.90000000000;1061.10000000000;1059;1056.70000000000;1055.30000000000;1056.60000000000;1056;1055.30000000000;1054.40000000000;1052.90000000000;1052.30000000000;1050.60000000000;1049.30000000000;1049;1047.80000000000;1046.30000000000;1045.10000000000;1043.80000000000;1044.80000000000;1043.90000000000;1041.60000000000;1040;1039.50000000000;1039.70000000000;1039.70000000000;1038;1036.30000000000;1035.40000000000;1034.40000000000;1032.60000000000;1032.20000000000;1030.40000000000;1029.80000000000;1028.80000000000;1026.80000000000;1025.90000000000;1023.90000000000;1023.20000000000;1022.40000000000;1021;1019.80000000000;1018.10000000000;1017.10000000000;1015.30000000000;1013;1012.20000000000;1010.20000000000;1009.30000000000;1008.10000000000;1005.10000000000;1003.60000000000;1002.50000000000;999.560000000000;998.480000000000;998.230000000000;997.410000000000;996.260000000000;994.720000000000;993.170000000000;990.860000000000;988.960000000000;987.810000000000;985.840000000000;983.930000000000;982.070000000000;981.190000000000;980.700000000000;978.970000000000;975.460000000000;973.250000000000;971.780000000000;970.280000000000;969.310000000000;966.560000000000;962.310000000000;960.110000000000;958.750000000000;957.540000000000;954.580000000000;953.880000000000;952.200000000000;950.620000000000;948.900000000000;946.470000000000;944.460000000000;942.510000000000;940.380000000000;938.390000000000;935.460000000000;932.200000000000;930.150000000000;928.700000000000;926.530000000000;925.600000000000;923.740000000000;922.930000000000;919.390000000000;916.630000000000;915.240000000000;912.980000000000;911.360000000000;908.360000000000;905.900000000000;906.230000000000;905.670000000000;902.520000000000;899.450000000000;895.800000000000;891.790000000000;889.380000000000;886.780000000000;885.650000000000;883.320000000000;881.290000000000;878;875.490000000000;872.130000000000;871.250000000000;868.220000000000;864.680000000000;861.960000000000;860.300000000000;858.170000000000;855.970000000000;854.030000000000;851.780000000000;847.500000000000;845.150000000000;842.880000000000;839.270000000000;836.580000000000;833.940000000000;831.570000000000;829.600000000000;826.960000000000;823.860000000000;821.440000000000;818.220000000000;815.660000000000;813.480000000000;810.180000000000;807.650000000000;805.150000000000;803.310000000000;799.820000000000;795.910000000000;792.130000000000;790.270000000000;788.040000000000;786.850000000000;784.660000000000;780.460000000000;776.590000000000;773.400000000000;769.260000000000;766.760000000000;763.970000000000;761.080000000000;758.360000000000;756.080000000000;754.730000000000;751.910000000000;747.200000000000;743.600000000000;740.280000000000;737.330000000000;735.390000000000;731.880000000000;727.850000000000;724.200000000000;721.780000000000;718.800000000000;716.820000000000;713.910000000000;710.250000000000;707.720000000000;703.240000000000;699.070000000000;695.750000000000;693.340000000000;688.610000000000;686.950000000000;685.180000000000;682.770000000000;678.810000000000;676.270000000000;673.120000000000;669.740000000000;666.580000000000;662.910000000000;659.210000000000;656.120000000000;652.230000000000;649.300000000000;645.800000000000;642.360000000000;640.010000000000;636.430000000000;632.630000000000;629.320000000000;626.250000000000;623.120000000000;619.700000000000;615.420000000000;612.100000000000;609.410000000000;606.770000000000;604.020000000000;600.910000000000;597.190000000000;593.550000000000;590.100000000000;586.780000000000;583.100000000000;579.690000000000;576.880000000000;573.330000000000;570.130000000000;566.670000000000;562.720000000000;558.320000000000;555.220000000000;551.350000000000;547.270000000000;543.890000000000;540.710000000000;536.590000000000;533.380000000000;530.730000000000;527.310000000000;523.100000000000;518.670000000000;515.480000000000;511.630000000000;507.710000000000;504.540000000000;501.890000000000;498.050000000000;494.870000000000;491.560000000000;487.520000000000;483.620000000000;480.250000000000;476.590000000000;472.890000000000;469.290000000000;466.330000000000;463;459.460000000000;455.390000000000;451.380000000000;447.970000000000;444.190000000000;440.500000000000;436.810000000000;433.100000000000;429.030000000000;425.630000000000;422.060000000000;419.270000000000;416.320000000000;412.190000000000;408.650000000000;405.300000000000;401.180000000000;397.370000000000;394.240000000000;390.890000000000;387.580000000000;384.420000000000;380.760000000000;377.170000000000;373.690000000000;370.510000000000;366.280000000000;361.860000000000;358.270000000000;354.570000000000;351.150000000000;347.020000000000;342.690000000000;339.110000000000;335.850000000000;332.080000000000;328.760000000000;325.190000000000;321.600000000000;318.050000000000;314.430000000000;310.550000000000;307.090000000000;303.290000000000;299.090000000000;294.980000000000;291.080000000000;286.940000000000;283.010000000000;279.090000000000;275.050000000000;271.060000000000;267.100000000000;263.290000000000;259.750000000000;255.780000000000;252.320000000000;249.100000000000;245.950000000000;242.860000000000;239.560000000000;235.920000000000;232.450000000000;229.150000000000;226.100000000000;223.210000000000;219.980000000000;216.850000000000;213.480000000000;210.370000000000;207.250000000000;204.120000000000;200.890000000000;197.630000000000;194.320000000000;191.170000000000;187.610000000000;184.250000000000;180.960000000000;177.770000000000;174.110000000000;170.910000000000;167.420000000000;163.990000000000;160.840000000000;157.720000000000;154.610000000000;151.380000000000;148.200000000000;145.060000000000;141.860000000000;138.700000000000;135.420000000000;131.990000000000;128.620000000000;125.310000000000;121.930000000000;118.650000000000;115.400000000000;112.180000000000;108.950000000000;105.840000000000;102.830000000000;99.7450000000000;96.5670000000000;93.4630000000000;90.2010000000000;86.9250000000000;83.8630000000000;80.9230000000000;78.1200000000000;75.2850000000000;72.4050000000000;69.6010000000000;66.9700000000000;64.2100000000000;61.5180000000000;59.1170000000000;56.4930000000000;53.9120000000000;51.5430000000000;49.1520000000000;46.7930000000000;44.3660000000000;41.9160000000000;39.5040000000000;37.1840000000000;34.8750000000000;32.7710000000000;30.8270000000000;28.8770000000000;26.8850000000000;25.0720000000000;23.1270000000000;21.2340000000000;19.6070000000000;16.9500000000000;14.8390000000000;14.4210000000000;13.5280000000000;12.4000000000000;11.2130000000000;10.0500000000000;11.0830000000000;12.1560000000000;14.7100000000000;18.0890000000000;20.7210000000000;22.6390000000000;24.6200000000000;26.7810000000000;28.8900000000000;31.0030000000000;33.1290000000000;35.2180000000000;37.2600000000000;39.3220000000000;41.3660000000000;43.5520000000000;45.8600000000000;48.1270000000000;50.4170000000000;52.9410000000000;55.6200000000000;58.4990000000000;61.6300000000000;64.1160000000000;66.9180000000000;69.6910000000000;72.4160000000000;75.1330000000000;77.9350000000000;80.8370000000000;83.8210000000000;87.0190000000000;90.1220000000000;93.1890000000000;96.2770000000000;99.2680000000000;102.300000000000;105.530000000000;108.370000000000;111.650000000000;114.980000000000;118.280000000000;121.660000000000;125.330000000000;128.700000000000;132.110000000000;135.520000000000;139.320000000000;143.040000000000;146.720000000000;150.070000000000;153.370000000000;157.010000000000;160.860000000000;164.220000000000;167.780000000000;171.270000000000;174.930000000000;178.820000000000;182.720000000000;186.360000000000;189.880000000000;193.450000000000;197.220000000000;200.850000000000;204.590000000000;208.450000000000;212.340000000000;216.140000000000;220;223.650000000000;227.330000000000;230.960000000000;234.780000000000;238.770000000000;242.590000000000;246.470000000000;250.390000000000;254.140000000000;258.060000000000;261.780000000000;265.710000000000;269.780000000000;273.550000000000;277.460000000000;281.360000000000;285.200000000000;288.840000000000;292.660000000000;296.240000000000;299.820000000000;303.840000000000;307.700000000000;311.730000000000;315.750000000000;319.550000000000;323.230000000000;327.200000000000;331.180000000000;335.290000000000;339.320000000000;343.120000000000;347.290000000000;351.440000000000;355.250000000000;358.870000000000;363.060000000000;366.750000000000;370.630000000000;374.600000000000;378.260000000000;381.980000000000;385.820000000000;389.440000000000;393.120000000000;396.940000000000;400.380000000000;403.950000000000;407.680000000000;411.320000000000;415.090000000000;418.880000000000;421.450000000000;426.020000000000;430.120000000000;433.570000000000;437.670000000000;441.120000000000;444.880000000000;449.050000000000;452.520000000000;456.300000000000;460.410000000000;464.310000000000;468.220000000000;471.740000000000;475.270000000000;478.390000000000;482.060000000000;485.810000000000;489.380000000000;492.650000000000;496.400000000000;499.690000000000;503.580000000000;507.230000000000;510.720000000000;514.190000000000;518.100000000000;521.750000000000;525.220000000000;528.650000000000;532.130000000000;535.800000000000;539.130000000000;543.060000000000;546.540000000000;549.860000000000;553.720000000000;557.280000000000;560.460000000000;563.380000000000;567.470000000000;571.420000000000;574.850000000000;577.850000000000;581.570000000000;584.430000000000;588.250000000000;591.800000000000;595.060000000000;598.780000000000;602.370000000000;606.810000000000;610.850000000000;614.270000000000;618.520000000000;622.260000000000;625.760000000000;629.700000000000;633.340000000000;637.470000000000;640.810000000000;644.450000000000;648.070000000000;651.660000000000;654.280000000000;658.090000000000;662.300000000000;665.750000000000;669.110000000000;672.330000000000;675.680000000000;678.700000000000;682.360000000000;685.700000000000;688.340000000000;692.110000000000;695.650000000000;699.240000000000;702.200000000000;705.430000000000;708.370000000000;711.240000000000;714.320000000000;717.980000000000;721.290000000000;724.940000000000;728.850000000000;732.270000000000;735.240000000000;737.880000000000;740.510000000000;744.180000000000;747.230000000000;750.750000000000;753.670000000000;756.620000000000;759.650000000000;763.100000000000;766.490000000000;769.710000000000;772.630000000000;775.210000000000;778.860000000000;782.430000000000;784.910000000000;787.590000000000;790.580000000000;793.840000000000;797.020000000000;799.550000000000;801.730000000000;804.920000000000;808.930000000000;811.820000000000;815.880000000000;818.340000000000;821.050000000000;823.590000000000;826.560000000000;829.830000000000;832.880000000000;835.840000000000;838.640000000000;841.240000000000;844.460000000000;847.150000000000;849.250000000000;852.090000000000;854.830000000000;857.640000000000;861.080000000000;863.350000000000;865.720000000000;868.200000000000;869.690000000000;872.590000000000;876.290000000000;877.440000000000;879.090000000000;882.810000000000;887.210000000000;889.260000000000;890.400000000000;893.750000000000;896.910000000000;899.300000000000;901;902.770000000000;905.510000000000;907.640000000000;910.320000000000;911.540000000000;914.320000000000;917.420000000000;919.970000000000;922.200000000000;924.430000000000;926.930000000000;928.860000000000;932.240000000000;934.500000000000;936.300000000000;937.820000000000;939.160000000000;942.370000000000;943.630000000000;945.820000000000;950.870000000000;952.940000000000;954.190000000000;956.800000000000;957.420000000000;959.170000000000;962.210000000000;965.130000000000;966.900000000000;969.060000000000;971.040000000000;972.840000000000;975.950000000000;975.990000000000;978.490000000000;979.310000000000;981.900000000000;983.910000000000;987.450000000000;990.720000000000;989.730000000000;991.600000000000;994.300000000000;996.660000000000;997.500000000000;998.970000000000;1000.80000000000;1004.10000000000;1007.50000000000;1007.20000000000;1008.80000000000;1013.10000000000;1015.20000000000;1018.20000000000;1020.40000000000;1022.60000000000;1024.70000000000;1025.50000000000;1026.40000000000;1028.80000000000;1028.40000000000;1031.20000000000;1034.50000000000;1035.40000000000;1037;1037.80000000000;1039;1040.80000000000;1042.50000000000;1043.50000000000;1045.90000000000;1048.70000000000;1049.30000000000;1049.90000000000;1050.60000000000;1051.50000000000;1052.90000000000;1056.10000000000;1058.30000000000;1058.40000000000;1058.90000000000;1058.50000000000;1062.80000000000;1063.60000000000;1064.50000000000;1063.40000000000;1067;1067.60000000000;1069;1070.80000000000;1070.20000000000;1070.30000000000;1071.80000000000;1070.90000000000;1071.60000000000;1073.30000000000;1075;1077.30000000000;1078.70000000000;1079.50000000000;1081.60000000000;1080.80000000000;1080.50000000000;1081.20000000000;1084.10000000000;1085.90000000000;1085.90000000000;1084.90000000000;1085.20000000000;1086.80000000000;1088.10000000000;1089.20000000000;1088.70000000000;1089.60000000000;1092;1092.70000000000;1092;1092.30000000000;1092.50000000000;1093;1094.40000000000;1097.50000000000;1097.10000000000;1096.90000000000;1096.40000000000;1097.50000000000;1096.80000000000;1097.30000000000;1098.40000000000;1101.40000000000;1103.20000000000;1102;1102.10000000000;1102.20000000000;1098.60000000000;1097.70000000000;1100.30000000000;1101.90000000000;1101.60000000000;1102;1098.10000000000;1098.40000000000;1098;1099.20000000000;1101.30000000000;1102.70000000000;1103.70000000000;1105.40000000000;1104.30000000000;1104.50000000000;1106.30000000000;1106.40000000000;1104.50000000000;1103.90000000000;1104.20000000000;1104.70000000000;1103.40000000000;1102.90000000000;1101;1101.30000000000;1105.10000000000;1106.20000000000;1103.90000000000;1104;1104.50000000000;1101.80000000000;1100.90000000000;1101.40000000000;1100.30000000000;1097;1099.10000000000;1096.90000000000;1097.40000000000;1096.50000000000;1095.70000000000;1096.20000000000;1097.10000000000;1097.90000000000;1097.30000000000;1095.80000000000;1096;1095.40000000000;1093.30000000000;1091.60000000000;1090.90000000000;1088.80000000000;1088.90000000000;1089.10000000000;1087.20000000000;1087.10000000000;1085.80000000000;1084.40000000000;1084.40000000000;1084;1082.50000000000;1081.40000000000;1081.60000000000;1081;1080.40000000000;1079.10000000000;1078.20000000000;1077.70000000000;1077.10000000000;1075.30000000000;1074.10000000000;1072.40000000000;1071.80000000000;1071.40000000000;1071;1070.20000000000;1070.10000000000;1069;1067.60000000000;1067.20000000000;1066.80000000000;1064.80000000000;1064.10000000000;1062.10000000000;1061.40000000000;1060.10000000000;1058.70000000000;1058.50000000000;1058.80000000000;1058.30000000000;1056.90000000000;1055;1053.30000000000;1051.70000000000;1050.70000000000;1048.40000000000;1046.70000000000;1045.50000000000;1044.60000000000;1043;1041;1039.10000000000;1037.90000000000;1036.80000000000;1035.70000000000;1034.60000000000;1033;1031.70000000000;1030.10000000000;1029;1027.70000000000;1026.50000000000;1025.70000000000;1024.50000000000;1022.50000000000;1020.10000000000;1017;1014.50000000000;1014.30000000000;1012.30000000000;1010.70000000000;1009.20000000000;1007.80000000000;1005.80000000000;1004;1002.10000000000;999.950000000000;998.240000000000;995.450000000000;992.530000000000;990.360000000000;988.150000000000;986.230000000000;985.050000000000;982.610000000000;981.050000000000;979.160000000000;976.920000000000;975.560000000000;973.060000000000;971.750000000000;969.800000000000;968.560000000000;966.380000000000;964.570000000000;961.150000000000;958.530000000000;956.060000000000;954.540000000000;952.720000000000;950.630000000000;948.470000000000;945.700000000000;943.740000000000;940.480000000000;937.310000000000;935.210000000000;933.110000000000;930.970000000000;928.720000000000;926.560000000000;924.030000000000;921.740000000000;920.110000000000;917.960000000000;914.690000000000;912.490000000000;909.710000000000;907.560000000000;905.370000000000;902.800000000000;900.230000000000;898.220000000000;895.380000000000;893.070000000000;889.680000000000;887.040000000000;884.520000000000;882.400000000000;880.850000000000;879.060000000000;877.270000000000;874.320000000000;871.680000000000;869.040000000000;866.490000000000;863.640000000000;860.820000000000;858.330000000000;855.170000000000;853.020000000000;850.390000000000;847.570000000000;845.380000000000;842.370000000000;839.760000000000;836.820000000000;833.970000000000;831.580000000000;829.280000000000;825.980000000000;823.440000000000;819.870000000000;816.780000000000;814;810.650000000000;807.770000000000;805.510000000000;801.850000000000;799.260000000000;796.610000000000;793.500000000000;790.680000000000;787.630000000000;784.650000000000;781.420000000000;778.820000000000;775.390000000000;772.530000000000;769.860000000000;766.710000000000;763.590000000000;760.160000000000;757.020000000000;754.150000000000;750.950000000000;747.600000000000;744.570000000000;741.420000000000;738.650000000000;734.960000000000;731.630000000000;728.720000000000;725.880000000000;722.610000000000;719.450000000000;715.860000000000;712.620000000000;709.620000000000;706.400000000000;702.910000000000;700.130000000000;697.180000000000;694.090000000000;691.180000000000;687.560000000000;684.640000000000;681.050000000000;676.970000000000;673.300000000000;670.280000000000;667.250000000000;663.810000000000;660.610000000000;657.260000000000;653.880000000000;650.680000000000;646.870000000000;643.600000000000;640.160000000000;636.620000000000;633.440000000000;629.900000000000;626.470000000000;623.340000000000;619.850000000000;616.700000000000;613.270000000000;609.890000000000;606.290000000000;602.960000000000;599.300000000000;595.640000000000;592.270000000000;588.510000000000;584.620000000000;581.220000000000;578.070000000000;574.790000000000;571.420000000000;568.310000000000;564.380000000000;560.350000000000;556.960000000000;553.580000000000;550.170000000000;546.690000000000;542.960000000000;539.530000000000;536.090000000000;532.660000000000;529.160000000000;525.040000000000;521.500000000000;517.870000000000;514.360000000000;511.120000000000;507.510000000000;503.930000000000;500.940000000000;497.490000000000;494.310000000000;490.490000000000;487.080000000000;483.740000000000;480.290000000000;476.910000000000;473.360000000000;469.440000000000;465.690000000000;461.630000000000;457.800000000000;453.580000000000;449.980000000000;446.440000000000;443.010000000000;439.560000000000;436.100000000000;432.340000000000;428.690000000000;424.550000000000;420.630000000000;416.730000000000;412.550000000000;408.520000000000;405.080000000000;401.160000000000;397.080000000000;393.180000000000;389;384.630000000000;380.360000000000;376.220000000000;372.460000000000;368.430000000000;364.660000000000;360.850000000000;357.410000000000;353.770000000000;349.890000000000;346.200000000000;342.680000000000;339.130000000000;335.340000000000;331.620000000000;327.970000000000;324.150000000000;320.440000000000;316.890000000000;313.340000000000;309.860000000000;306.230000000000;302.120000000000;298.450000000000;294.560000000000;290.570000000000;286.600000000000;282.960000000000;279.230000000000;275.350000000000;271.720000000000;268.160000000000;264.410000000000;260.790000000000;257.450000000000;253.780000000000;249.930000000000;245.910000000000;242.290000000000;238.820000000000;235.370000000000;231.930000000000;228.230000000000;224.610000000000;220.830000000000;216.930000000000;212.990000000000;209.080000000000;205.410000000000;201.640000000000;198.130000000000;194.520000000000;191;187.690000000000;184.120000000000;180.590000000000;176.850000000000;173.160000000000;169.760000000000;166.160000000000;162.510000000000;158.840000000000;155.130000000000;151.460000000000;147.810000000000;144.170000000000;140.540000000000;137.120000000000;133.780000000000;130.540000000000;126.920000000000;123.510000000000;120.210000000000;117.040000000000;113.760000000000;110.460000000000;107.170000000000;104.170000000000;101.220000000000;98.1380000000000;95.2060000000000;92.3310000000000;89.3830000000000;86.3160000000000;83.1740000000000;80.0450000000000;76.8200000000000;73.6510000000000;70.6730000000000;67.9340000000000;65.1700000000000;62.3040000000000;59.5930000000000;56.7150000000000;53.8170000000000;50.8490000000000;48.0370000000000;45.3780000000000;42.8320000000000;40.3920000000000;38.1140000000000;35.9660000000000;33.8790000000000;31.7270000000000;29.7750000000000;27.8700000000000;26.0610000000000;24.1230000000000;22.3370000000000;20.5510000000000;19.1330000000000;17.1310000000000;14.6120000000000;13.3290000000000;12.7010000000000;11.7650000000000;10.6690000000000;9.62120000000000;8.77210000000000;11.6500000000000;12.4690000000000;15.1160000000000;18.6260000000000;21.3230000000000;23.3940000000000;25.6200000000000;27.7000000000000;29.6890000000000;31.8060000000000;34.1110000000000;36.3750000000000;38.6560000000000;40.8870000000000;43.2040000000000;45.7070000000000;48.5130000000000;51.5130000000000;54.3960000000000;56.9520000000000;59.5850000000000;62.2300000000000;64.9530000000000;67.7190000000000;70.5520000000000;73.3620000000000;76.2570000000000;78.9300000000000;81.8450000000000;84.6610000000000;87.6710000000000;90.8530000000000;94.0790000000000;97.1980000000000;100.160000000000;103.250000000000;106.360000000000;109.380000000000;112.340000000000;115.370000000000;118.550000000000;121.640000000000;124.980000000000;128.540000000000;132.130000000000;135.410000000000;138.690000000000;142.090000000000;145.580000000000;149.210000000000;152.710000000000;156.340000000000;159.980000000000;163.640000000000;167.250000000000;171;174.770000000000;178.510000000000;182.330000000000;186.070000000000;189.650000000000;193.050000000000;196.680000000000;200.290000000000;204.060000000000;207.690000000000;211.320000000000;215.070000000000;218.700000000000;222.130000000000;226.070000000000;229.910000000000;233.590000000000;237.560000000000;241.720000000000;245.680000000000;249.250000000000;253.040000000000;257.020000000000;260.860000000000;265.030000000000;269.300000000000;273.010000000000;276.420000000000;280.070000000000;284.010000000000;287.850000000000;291.740000000000;295.330000000000;299.010000000000;302.760000000000;306.660000000000;310.810000000000;314.390000000000;317.940000000000;321.940000000000;325.480000000000;328.900000000000;332.920000000000;336.920000000000;340.950000000000;344.680000000000;348.900000000000;352.790000000000;356.130000000000;360.330000000000;363.870000000000;367.940000000000;371.740000000000;375.180000000000;378.650000000000;382.890000000000;386.650000000000;390.100000000000;393.740000000000;397.650000000000;401.770000000000;404.790000000000;408.470000000000;412.360000000000;416.220000000000;419.290000000000;423.180000000000;427.640000000000;431.510000000000;435.090000000000;439.960000000000;443.510000000000;447.380000000000;451.330000000000;454.480000000000;458.370000000000;463.420000000000;466.750000000000;471.610000000000;474.930000000000;478.190000000000;483.670000000000;487.150000000000;490.410000000000;495.400000000000;499.930000000000;502.720000000000;506.660000000000;510.240000000000;514.660000000000;518.600000000000;521.480000000000;525.680000000000;528.710000000000;532.570000000000;535.060000000000;539.190000000000;542.120000000000;544.730000000000;548.920000000000;552.170000000000;555.400000000000;559.800000000000;565.260000000000;568.710000000000;573.040000000000;576.710000000000;580.690000000000;584.640000000000;588.630000000000;591.990000000000;595.680000000000;599.710000000000;603.630000000000;607.660000000000;610.760000000000;614.480000000000;617.510000000000;621.200000000000;624.400000000000;627.470000000000;631.460000000000;634.580000000000;638.510000000000;642.130000000000;646.330000000000;650.300000000000;653.340000000000;657.490000000000;661.320000000000;664.670000000000;667.740000000000;670.150000000000;673.180000000000;676;679.490000000000;682.850000000000;686.560000000000;689.330000000000;692.400000000000;695.990000000000;698.360000000000;701.120000000000;703.740000000000;707.630000000000;710.450000000000;712.970000000000;716.680000000000;720.050000000000;722.850000000000;726.420000000000;729.900000000000;731.730000000000;735.630000000000;739.260000000000;742.050000000000;744.930000000000;747.130000000000;750.520000000000;754.430000000000;758.300000000000;761;764.090000000000;767.330000000000;770.330000000000;773.310000000000;776.570000000000;779.140000000000;782.260000000000;785.420000000000;788.320000000000;791.040000000000;794.130000000000;796.990000000000;801.660000000000;805.370000000000;807.220000000000;810.040000000000;812.940000000000;815.790000000000;818.640000000000;822.690000000000;825.240000000000;827.170000000000;829.200000000000;831.890000000000;835.350000000000;838.540000000000;841.200000000000;844.930000000000;848.260000000000;849.490000000000;854.210000000000;855.490000000000;858.640000000000;861.120000000000;863.580000000000;865.840000000000;869.810000000000;872.410000000000;873.490000000000;878.180000000000;881.140000000000;883.730000000000;886.470000000000;887.730000000000;891.150000000000;893.280000000000;895.740000000000;900.890000000000;902.320000000000;905.830000000000;908.200000000000;910.370000000000;912.500000000000;915.630000000000;917.250000000000;919.290000000000;923;925.670000000000;928.760000000000;931.970000000000;932.680000000000;936.390000000000;937.880000000000;939.970000000000;941.930000000000;944.010000000000;946.140000000000;948.720000000000;950.810000000000;953;955.080000000000;957.420000000000;958.730000000000;961.060000000000;962.670000000000;964.940000000000;966.220000000000;968.710000000000;970.530000000000;972.770000000000;975.470000000000;977.250000000000;979.040000000000;981.110000000000;983.370000000000;985.150000000000;986.760000000000;989.680000000000;992.150000000000;994.410000000000;996.760000000000;999.250000000000;1000.30000000000;1002.10000000000;1003.50000000000;1004.60000000000;1007.30000000000;1008.90000000000;1010.60000000000;1012.30000000000;1014.20000000000;1016.50000000000;1018.50000000000;1020.20000000000;1021.70000000000;1022.80000000000;1024.60000000000;1026.20000000000;1028.20000000000;1030.80000000000;1032;1033.60000000000;1035.70000000000;1037;1038.60000000000;1039.60000000000;1040;1041.60000000000;1044;1045.20000000000;1045.80000000000;1046.60000000000;1047.60000000000;1050.50000000000;1052.50000000000;1053.10000000000;1054.90000000000;1056.20000000000;1057.80000000000;1059.60000000000;1060.90000000000;1061.60000000000;1063.40000000000;1064.20000000000;1066.20000000000;1068;1069.30000000000;1070;1071.40000000000;1071.90000000000;1073.50000000000;1074.60000000000;1075.70000000000;1076.80000000000;1075.80000000000;1079.50000000000;1081.30000000000;1083.30000000000;1084.10000000000;1085;1086.40000000000;1087;1087.50000000000;1088.30000000000;1088.50000000000;1089.10000000000;1090.40000000000;1091.50000000000;1092.10000000000;1092.70000000000;1093.30000000000;1094.10000000000;1094.40000000000;1095;1095;1095.80000000000;1096.60000000000;1097.20000000000;1097.90000000000;1098.50000000000;1099.50000000000;1100;1100.90000000000;1101.30000000000;1102.10000000000;1102.50000000000;1102;1101.80000000000;1102;1102.90000000000;1103.70000000000;1104.20000000000;1104.50000000000;1106;1106;1105.50000000000;1105.40000000000;1106.60000000000;1106.10000000000;1106.50000000000;1107.20000000000;1107.80000000000;1108.30000000000;1108.70000000000;1109.20000000000;1109.90000000000;1108.70000000000;1109;1109.40000000000;1109.30000000000;1109.20000000000;1110.70000000000;1109.50000000000;1110.20000000000;1110.30000000000;1109.10000000000;1109.60000000000;1109.70000000000;1108.50000000000;1108.40000000000;1109;1109.10000000000;1108.80000000000;1109.20000000000;1108.90000000000;1108.80000000000;1109.70000000000;1108.90000000000;1108.60000000000;1108.70000000000;1108;1108.20000000000;1109.10000000000;1108.20000000000;1107.60000000000;1107.30000000000;1106.10000000000;1106.20000000000;1105.60000000000;1105;1105.10000000000;1104.90000000000;1103.90000000000;1104.50000000000;1103.20000000000;1102.70000000000;1102.10000000000;1101.40000000000;1101.50000000000;1100.70000000000;1099.80000000000;1099.90000000000;1098.50000000000;1097.20000000000;1096.80000000000;1096.30000000000;1095.60000000000;1094.30000000000;1091.50000000000;1092.40000000000;1092.20000000000;1091.20000000000;1090.40000000000;1088.80000000000;1087.40000000000;1086.80000000000;1086;1085.60000000000;1085.60000000000;1085;1083.20000000000;1082.40000000000;1080.90000000000;1080.20000000000;1078.50000000000;1077.50000000000;1076.60000000000;1075.40000000000;1074.30000000000;1073.10000000000;1071.30000000000;1070.60000000000;1069.80000000000;1068.80000000000;1067.80000000000;1067;1065.50000000000;1063.90000000000;1061.90000000000;1060.30000000000;1058.40000000000;1057.50000000000;1056.30000000000;1053.90000000000;1053;1052.90000000000;1051;1048.70000000000;1047.20000000000;1045.50000000000;1044.20000000000;1043.50000000000;1041.90000000000;1040.20000000000;1039;1036.50000000000;1035.40000000000;1033.80000000000;1032.10000000000;1030.30000000000;1027.70000000000;1025.60000000000;1024.30000000000;1022.90000000000;1021.60000000000;1020.20000000000;1018.80000000000;1016.50000000000;1014.80000000000;1013.80000000000;1012.10000000000;1010.20000000000;1008.60000000000;1006;1003.20000000000;1000.90000000000;998.980000000000;997.270000000000;995.530000000000;994.420000000000;992.760000000000;989.780000000000;988.440000000000;980.090000000000;972.920000000000;981.060000000000;979.110000000000;978.280000000000;976.330000000000;973.390000000000;970.660000000000;966.720000000000;962.850000000000;963.100000000000;964.960000000000;961.790000000000;959.170000000000;956.620000000000;954.590000000000;951.950000000000;949.630000000000;947.230000000000;944.080000000000;941.530000000000;939.230000000000;938.100000000000;934.710000000000;931.730000000000;930.210000000000;927.990000000000;925.920000000000;923.550000000000;921.440000000000;919.400000000000;917.810000000000;914.520000000000;912.010000000000;910.150000000000;908.140000000000;904.890000000000;901.600000000000;900.360000000000;897.640000000000;895.270000000000;892.520000000000;888.910000000000;886.170000000000;882.410000000000;879.980000000000;875.870000000000;873.520000000000;873.600000000000;871.480000000000;868.580000000000;865.520000000000;862.290000000000;858.610000000000;855.230000000000;851.700000000000;849.600000000000;847.370000000000;844.390000000000;842.280000000000;838.470000000000;835.240000000000;832.550000000000;830.390000000000;826.760000000000;823.300000000000;817.950000000000;815.870000000000;814.760000000000;812.270000000000;809.480000000000;807.200000000000;804.620000000000;800.710000000000;797.240000000000;793.810000000000;790.450000000000;787.530000000000;784.090000000000;781.310000000000;778.640000000000;775.240000000000;771.590000000000;768.510000000000;765.760000000000;762.700000000000;759.670000000000;755.790000000000;752.920000000000;750.840000000000;748.200000000000;744.180000000000;740.560000000000;736.810000000000;733.140000000000;729.710000000000;726.140000000000;722.770000000000;719.300000000000;715.680000000000;712.400000000000;708.860000000000;706.110000000000;704.930000000000;703.080000000000;702.150000000000;701.390000000000;699.730000000000;698.020000000000;694.880000000000;689.740000000000;687.090000000000;682.010000000000;679.220000000000;676.040000000000;673.470000000000;670.770000000000;668.440000000000;663.900000000000;659.440000000000;654.290000000000;649.460000000000;644.640000000000;640.440000000000;635.680000000000;632.010000000000;628.300000000000;625.300000000000;622;617.870000000000;613.570000000000;609.460000000000;605.270000000000;601.990000000000;598.500000000000;595.240000000000;591.640000000000;588.570000000000;584.780000000000;581.200000000000;577.950000000000;575;572.370000000000;567.070000000000;561.530000000000;549.230000000000;550.540000000000;546.030000000000;548.380000000000;535.170000000000;531.450000000000;527.180000000000;522.170000000000;518.720000000000;509.100000000000;512.710000000000;516.230000000000;513.780000000000;488.900000000000;481.700000000000;476.040000000000;291.290000000000;119.590000000000;106.080000000000;105.250000000000;111.770000000000;137.250000000000;225.390000000000;319.820000000000;401.700000000000;323.720000000000;189.890000000000;166.330000000000;137.380000000000;170.680000000000;220.280000000000;221.350000000000;259.020000000000;278.480000000000;349.890000000000;280.970000000000;387.370000000000;347.610000000000;357.580000000000;401.640000000000;413.980000000000;417.950000000000;417.500000000000;410.890000000000;405.180000000000;402.890000000000;399.490000000000;395.200000000000;389.280000000000;385.930000000000;378.810000000000;372.700000000000;360.790000000000;338.630000000000;321.150000000000;319.680000000000;295.860000000000;290.980000000000;283.460000000000;264.230000000000;194.100000000000;165.580000000000;166.180000000000;162.830000000000;150.600000000000;125.750000000000;156.690000000000;200.110000000000;222.800000000000;252.430000000000;277.840000000000;276.880000000000;288.370000000000;289.750000000000;288.990000000000;284.610000000000;277.870000000000;269.590000000000;264.170000000000;260.480000000000;258.130000000000;237.840000000000;236.970000000000;249.940000000000;247.430000000000;242.180000000000;237.380000000000;232.770000000000;227.710000000000;221.410000000000;195.140000000000;175.780000000000;161.790000000000;171.370000000000;204.250000000000;196.930000000000;185.770000000000;182.530000000000;174.800000000000;171.050000000000;151.610000000000;116.130000000000;94.2240000000000;87.8100000000000;97.8320000000000;110.420000000000;118.850000000000;116.290000000000;112.840000000000;104.940000000000;108.310000000000;115.650000000000;125.110000000000;128.990000000000;129.750000000000;125.880000000000;93.9280000000000;57.6480000000000;46.3470000000000;44.7610000000000;41.6010000000000;39.7870000000000;38.3480000000000;37.0230000000000;35.9970000000000;35.3790000000000;35.3690000000000;37.8190000000000;41.8580000000000;43.2900000000000;46.9870000000000;53.7640000000000;61.2900000000000;64.3450000000000;62.4110000000000;60.1170000000000;55.3460000000000;55.4220000000000;56.1380000000000;54.0880000000000;52.2150000000000;50.5740000000000;48.5480000000000;46.3000000000000;43.5600000000000;39.7920000000000;33.9190000000000;29.0930000000000;31.4620000000000;30.4770000000000;25.2200000000000;20.9800000000000;18.9980000000000;18.8250000000000;19.7450000000000;19.2740000000000;17.8050000000000;16.0650000000000;13.9210000000000;12.1150000000000;13.2550000000000;14.5910000000000;16.0660000000000;17.6540000000000;19.4030000000000;21.1750000000000;23.1360000000000;24.7960000000000;26.5820000000000;28.1120000000000;29.6290000000000;31.3350000000000;33.4240000000000;35.4760000000000;37.7000000000000;39.9660000000000;41.9060000000000;44.0910000000000;46.8220000000000;49.5750000000000;52.2690000000000;54.8130000000000;57.6510000000000;60.1990000000000;63.0400000000000;65.9210000000000;68.4940000000000;71.2670000000000;74.2680000000000;76.8780000000000;79.7670000000000;82.7060000000000;85.6920000000000;88.3980000000000;91.8680000000000;94.9720000000000;97.9930000000000;101.460000000000;104.550000000000;107.650000000000;111.020000000000;113.950000000000;117.160000000000;120.120000000000;122.880000000000;126.110000000000;129.630000000000;133.560000000000;136.620000000000;140.180000000000;143.480000000000;146.390000000000;149.790000000000;152.730000000000;156.850000000000;160.120000000000;163.150000000000;166.560000000000;170.290000000000;173.790000000000;177.280000000000;181.150000000000;184.670000000000;188.430000000000;191.220000000000;195.360000000000;198.130000000000;201.810000000000;205.270000000000;209.240000000000;213.070000000000;216.640000000000;220.450000000000;223.690000000000;227.400000000000;231.160000000000;234.530000000000;238.710000000000;242.840000000000;246.500000000000;248.970000000000;252.530000000000;256.230000000000;260.710000000000;264.010000000000;267.600000000000;271.310000000000;274.780000000000;278.700000000000;281.580000000000;286.060000000000;290.030000000000;293.270000000000;297.110000000000;301.490000000000;305.050000000000;308.720000000000;312.520000000000;316.520000000000;319.700000000000;323.210000000000;327.470000000000;331.370000000000;334.650000000000;338.730000000000;342.710000000000;345.940000000000;349.480000000000;353.380000000000;356.590000000000;360.130000000000;363.550000000000;365.970000000000;370.260000000000;374.070000000000;377.510000000000;381.610000000000;385.340000000000;389.150000000000;392.920000000000;396.570000000000;399.650000000000;403.200000000000;406.800000000000;411.130000000000;415;418.740000000000;422.640000000000;426.510000000000;430.080000000000;433.450000000000;437.390000000000;441.410000000000;444.740000000000;448.660000000000;452.080000000000;456.080000000000;459.210000000000;462.910000000000;466.720000000000;470.550000000000;474.370000000000;478.640000000000;481.980000000000;485.330000000000;488.560000000000;491.920000000000;495.400000000000;499.120000000000;502.320000000000;506.090000000000;509.950000000000;513.500000000000;517.220000000000;520.420000000000;523.280000000000;527.420000000000;531.190000000000;534.520000000000;537.760000000000;541.570000000000;545.350000000000;548.380000000000;551.340000000000;555.600000000000;558.520000000000;562.770000000000;565.850000000000;569.240000000000;572.960000000000;575.900000000000;579.650000000000;583.200000000000;586.330000000000;590.030000000000;593.660000000000;597.940000000000;601.200000000000;604.280000000000;608.150000000000;611.210000000000;615.100000000000;618.530000000000;621.420000000000;624.410000000000;628.960000000000;631.500000000000;633.800000000000;636.320000000000;640.190000000000;644.220000000000;648.150000000000;650.850000000000;653.950000000000;656.830000000000;660.860000000000;664.930000000000;668.930000000000;672.570000000000;675.270000000000;678.930000000000;682.580000000000;686.700000000000;689.810000000000;692.130000000000;695;697.950000000000;701.040000000000;704.070000000000;706.920000000000;710.170000000000;713.600000000000;716.760000000000;719.760000000000;722.690000000000;724.970000000000;728.010000000000;731.220000000000;735.080000000000;738.060000000000;740.810000000000;744.060000000000;747.550000000000;749.980000000000;752.320000000000;755.550000000000;757.940000000000;760.440000000000;764.120000000000;767.260000000000;770.120000000000;772.560000000000;776.390000000000;779.050000000000;782.710000000000;785.450000000000;787.640000000000;789.850000000000;793.310000000000;796.230000000000;798.650000000000;802.300000000000;805.250000000000;807.350000000000;811.320000000000;814.370000000000;816.990000000000;818.710000000000;822.490000000000;825.260000000000;826.420000000000;829.040000000000;831.200000000000;834.290000000000;837.590000000000;839.840000000000;843.150000000000;845.950000000000;847.580000000000;849.650000000000;851.080000000000;853.960000000000;856.380000000000;858.410000000000;861.500000000000;865.340000000000;867.540000000000;869.630000000000;871.810000000000;874.170000000000;877.180000000000;879.600000000000;881.070000000000;884.390000000000;887.140000000000;889.320000000000;891.630000000000;895.170000000000;897.510000000000;900.070000000000;902.240000000000;904.860000000000;906.740000000000;909.140000000000;911.410000000000;913.830000000000;915.590000000000;917.520000000000;919.440000000000;922.290000000000;924.680000000000;926.800000000000;928.140000000000;930.120000000000;932.580000000000;935.200000000000;936.310000000000;938.010000000000;939.470000000000;941.230000000000;943.550000000000;946.220000000000;948.320000000000;950.010000000000;951.260000000000;953.810000000000;955.720000000000;958.170000000000;960.170000000000;961.940000000000;963.940000000000;966.270000000000;968.410000000000;970.250000000000;971.190000000000;973.670000000000;975;977.080000000000;978.900000000000;980.370000000000;982.810000000000;985.400000000000;985.310000000000;986.440000000000;987.980000000000;989.100000000000;991.660000000000;993.230000000000;994.370000000000;995.350000000000;996.390000000000;997.640000000000;1000;1001.80000000000;1004.10000000000;1004.50000000000;1005.30000000000;1005.90000000000;1007.60000000000;1009.10000000000;1011.40000000000;1012.60000000000;1013.70000000000;1015.50000000000;1017.30000000000;1018.90000000000;1020.50000000000;1021.50000000000;1023;1024.30000000000;1025.50000000000;1027.80000000000;1029.30000000000;1030.60000000000;1032;1032.90000000000;1033.50000000000;1034.30000000000;1035.40000000000;1036.80000000000;1037.90000000000;1039.40000000000;1041.30000000000;1041.90000000000;1043.20000000000;1043.80000000000;1043.90000000000;1044.90000000000;1045.70000000000;1047;1048.80000000000;1049.30000000000;1049.80000000000;1051;1052.90000000000;1053.90000000000;1054.70000000000;1054.90000000000;1055.50000000000;1056.70000000000;1058;1058.60000000000;1059.10000000000;1059;1061.70000000000;1062.50000000000;1063.40000000000;1064.80000000000;1069.60000000000;1048.10000000000;825.480000000000;924.790000000000;985.280000000000;1035.30000000000;1093.80000000000;1080.30000000000;1074.30000000000;1071.90000000000;1071.10000000000;1069.70000000000;1070.70000000000;1071.40000000000;1071.30000000000;1072.30000000000;1073.30000000000;1070.70000000000;1070.50000000000;1073.70000000000;1074.50000000000;1076;1076.40000000000;1077.40000000000;1079;1079;1079.40000000000;1079.70000000000;1079.60000000000;1080.10000000000;1083;1085;1086.60000000000;1090.30000000000;1093.60000000000;1098;1101.60000000000;1103.60000000000;1106.10000000000;1108.50000000000;1110.80000000000;1104.60000000000;1112.10000000000;1120.60000000000;1129.90000000000;1141.80000000000;1158.10000000000;1186.30000000000;1208.90000000000;882.760000000000;1221.50000000000;725.510000000000;802.160000000000;1030.90000000000;1053.30000000000;1041.20000000000;1114.80000000000;1103.80000000000;1100.50000000000;1095.60000000000;1092.40000000000]; 37 | % % sample corresponding REST2 clear-sky ghi 38 | % ghics = [7.15470000000000;8.97030000000000;10.8560000000000;12.8050000000000;14.8110000000000;16.8720000000000;18.9850000000000;21.1470000000000;23.3580000000000;25.6170000000000;27.9220000000000;30.2730000000000;32.6690000000000;35.1080000000000;37.5890000000000;40.1120000000000;42.6760000000000;45.2780000000000;47.9190000000000;50.5970000000000;53.3110000000000;56.0600000000000;58.8430000000000;61.6590000000000;64.5070000000000;67.3850000000000;70.2940000000000;73.2320000000000;76.1970000000000;79.1900000000000;82.2100000000000;85.2550000000000;88.3240000000000;91.4180000000000;94.5350000000000;97.6750000000000;100.840000000000;104.020000000000;107.220000000000;110.450000000000;113.690000000000;116.950000000000;120.230000000000;123.530000000000;126.850000000000;130.180000000000;133.530000000000;136.890000000000;140.270000000000;143.660000000000;147.070000000000;150.500000000000;153.930000000000;157.380000000000;160.850000000000;164.320000000000;167.810000000000;171.310000000000;174.820000000000;178.340000000000;181.870000000000;185.420000000000;188.970000000000;192.530000000000;196.100000000000;199.690000000000;203.280000000000;206.880000000000;210.480000000000;214.100000000000;217.730000000000;221.360000000000;225;228.640000000000;232.290000000000;235.960000000000;239.630000000000;243.300000000000;246.990000000000;250.680000000000;254.370000000000;258.070000000000;261.780000000000;265.490000000000;269.210000000000;272.930000000000;276.660000000000;280.390000000000;284.120000000000;287.860000000000;291.600000000000;295.350000000000;299.100000000000;302.850000000000;306.610000000000;310.370000000000;314.130000000000;317.890000000000;321.660000000000;325.430000000000;329.200000000000;332.970000000000;336.750000000000;340.520000000000;344.300000000000;348.080000000000;351.860000000000;355.640000000000;359.430000000000;363.210000000000;366.990000000000;370.780000000000;374.560000000000;378.350000000000;382.130000000000;385.920000000000;389.700000000000;393.490000000000;397.270000000000;401.050000000000;404.830000000000;408.610000000000;412.390000000000;416.170000000000;419.950000000000;423.730000000000;427.500000000000;431.270000000000;435.050000000000;438.810000000000;442.580000000000;446.350000000000;450.110000000000;453.870000000000;457.630000000000;461.380000000000;465.140000000000;468.900000000000;472.650000000000;476.400000000000;480.140000000000;483.890000000000;487.630000000000;491.370000000000;495.100000000000;498.830000000000;502.560000000000;506.280000000000;510;513.710000000000;517.420000000000;521.130000000000;524.830000000000;528.530000000000;532.220000000000;535.910000000000;539.600000000000;543.280000000000;546.950000000000;550.620000000000;554.280000000000;557.940000000000;561.590000000000;565.240000000000;568.880000000000;572.520000000000;576.150000000000;579.780000000000;583.390000000000;587.010000000000;590.610000000000;594.210000000000;597.810000000000;601.390000000000;604.970000000000;608.550000000000;612.110000000000;615.670000000000;619.230000000000;622.770000000000;626.310000000000;629.840000000000;633.370000000000;636.880000000000;640.390000000000;643.890000000000;647.390000000000;650.870000000000;654.350000000000;657.820000000000;661.280000000000;664.730000000000;668.180000000000;671.610000000000;675.040000000000;678.460000000000;681.870000000000;685.270000000000;688.670000000000;692.050000000000;695.420000000000;698.780000000000;702.130000000000;705.470000000000;708.790000000000;712.110000000000;715.420000000000;718.710000000000;722;725.270000000000;728.540000000000;731.790000000000;735.030000000000;738.260000000000;741.490000000000;744.700000000000;747.890000000000;751.080000000000;754.260000000000;757.430000000000;760.580000000000;763.730000000000;766.860000000000;769.980000000000;773.100000000000;776.200000000000;779.290000000000;782.370000000000;785.440000000000;788.490000000000;791.540000000000;794.580000000000;797.600000000000;800.620000000000;803.620000000000;806.610000000000;809.600000000000;812.570000000000;815.530000000000;818.480000000000;821.420000000000;824.350000000000;827.260000000000;830.170000000000;833.070000000000;835.950000000000;838.830000000000;841.690000000000;844.550000000000;847.390000000000;850.230000000000;853.050000000000;855.860000000000;858.670000000000;861.460000000000;863.010000000000;865.790000000000;868.550000000000;871.310000000000;874.050000000000;876.770000000000;879.490000000000;882.190000000000;884.880000000000;887.550000000000;890.210000000000;892.860000000000;895.500000000000;898.120000000000;900.720000000000;903.320000000000;905.900000000000;908.470000000000;911.020000000000;913.560000000000;916.080000000000;918.600000000000;921.090000000000;923.580000000000;926.050000000000;928.500000000000;930.940000000000;933.370000000000;935.780000000000;938.180000000000;940.560000000000;942.930000000000;945.280000000000;947.620000000000;949.950000000000;952.260000000000;954.550000000000;956.830000000000;959.100000000000;961.350000000000;963.580000000000;965.800000000000;968.010000000000;970.200000000000;972.370000000000;974.530000000000;976.670000000000;978.800000000000;980.920000000000;983.010000000000;985.090000000000;987.160000000000;989.210000000000;991.250000000000;993.260000000000;995.270000000000;997.250000000000;999.230000000000;1001.20000000000;1003.10000000000;1005;1007;1008.80000000000;1010.70000000000;1012.60000000000;1014.40000000000;1016.30000000000;1018.10000000000;1019.90000000000;1021.70000000000;1023.40000000000;1025.20000000000;1026.90000000000;1028.60000000000;1030.30000000000;1032;1033.60000000000;1035.30000000000;1036.90000000000;1038.50000000000;1040.10000000000;1041.70000000000;1043.30000000000;1044.80000000000;1046.40000000000;1047.90000000000;1049.40000000000;1050.80000000000;1052.30000000000;1053.80000000000;1055.20000000000;1056.60000000000;1058;1059.40000000000;1060.70000000000;1062.10000000000;1063.40000000000;1064.70000000000;1066;1067.20000000000;1068.50000000000;1069.70000000000;1070.90000000000;1072.10000000000;1073.30000000000;1074.50000000000;1075.60000000000;1076.80000000000;1077.90000000000;1079;1080.10000000000;1081.10000000000;1082.20000000000;1083.20000000000;1084.20000000000;1085.20000000000;1086.10000000000;1087.10000000000;1088;1088.90000000000;1089.80000000000;1090.70000000000;1091.60000000000;1092.40000000000;1093.20000000000;1094;1094.80000000000;1095.50000000000;1096.30000000000;1097;1097.70000000000;1098.30000000000;1099;1099.60000000000;1100.20000000000;1100.80000000000;1101.30000000000;1101.90000000000;1102.40000000000;1102.90000000000;1103.40000000000;1103.90000000000;1104.30000000000;1104.70000000000;1105.10000000000;1105.50000000000;1105.90000000000;1106.20000000000;1106.50000000000;1106.80000000000;1107.10000000000;1107.40000000000;1107.70000000000;1107.90000000000;1108.10000000000;1108.30000000000;1108.50000000000;1108.60000000000;1108.80000000000;1108.90000000000;1109;1109.10000000000;1109.20000000000;1109.20000000000;1109.30000000000;1109.30000000000;1109.30000000000;1109.30000000000;1109.30000000000;1109.20000000000;1109.20000000000;1109.10000000000;1109;1108.90000000000;1108.80000000000;1108.70000000000;1108.50000000000;1108.40000000000;1108.20000000000;1108;1107.80000000000;1107.60000000000;1107.30000000000;1107.10000000000;1106.80000000000;1106.50000000000;1106.20000000000;1105.90000000000;1105.50000000000;1105.10000000000;1104.70000000000;1104.30000000000;1103.90000000000;1103.50000000000;1103;1102.50000000000;1102;1101.50000000000;1101;1100.40000000000;1099.90000000000;1099.30000000000;1098.70000000000;1098;1097.40000000000;1096.70000000000;1096.10000000000;1095.40000000000;1094.60000000000;1093.90000000000;1093.10000000000;1092.40000000000;1091.60000000000;1090.80000000000;1090;1089.10000000000;1088.20000000000;1087.40000000000;1086.50000000000;1085.60000000000;1084.60000000000;1083.70000000000;1082.70000000000;1081.70000000000;1080.70000000000;1079.70000000000;1078.60000000000;1077.60000000000;1076.50000000000;1075.40000000000;1074.30000000000;1073.20000000000;1072;1070.90000000000;1069.70000000000;1068.50000000000;1067.30000000000;1066;1064.80000000000;1063.50000000000;1062.20000000000;1060.90000000000;1059.60000000000;1058.30000000000;1056.90000000000;1055.60000000000;1054.20000000000;1052.80000000000;1051.40000000000;1049.90000000000;1048.50000000000;1047;1045.50000000000;1044;1042.50000000000;1040.90000000000;1039.40000000000;1037.80000000000;1036.20000000000;1034.60000000000;1033;1031.30000000000;1029.70000000000;1028;1026.30000000000;1024.60000000000;1022.90000000000;1021.20000000000;1019.40000000000;1017.60000000000;1015.80000000000;1014;1012.20000000000;1010.40000000000;1008.50000000000;1006.70000000000;1004.80000000000;1002.90000000000;1000.90000000000;999.010000000000;997.060000000000;995.100000000000;993.120000000000;991.120000000000;989.110000000000;987.080000000000;985.040000000000;982.980000000000;980.900000000000;978.820000000000;976.710000000000;974.590000000000;972.450000000000;970.300000000000;968.140000000000;965.960000000000;963.760000000000;961.550000000000;959.320000000000;957.080000000000;954.830000000000;952.560000000000;950.280000000000;947.990000000000;945.680000000000;943.360000000000;941.030000000000;938.680000000000;936.320000000000;933.950000000000;931.560000000000;929.150000000000;926.740000000000;924.310000000000;921.870000000000;919.410000000000;916.940000000000;914.450000000000;911.960000000000;909.450000000000;906.920000000000;904.380000000000;901.830000000000;899.270000000000;896.690000000000;894.100000000000;891.490000000000;888.870000000000;886.240000000000;883.600000000000;880.940000000000;878.270000000000;875.590000000000;872.890000000000;870.180000000000;867.450000000000;864.720000000000;861.970000000000;859.210000000000;856.430000000000;853.640000000000;850.840000000000;848.030000000000;845.200000000000;842.360000000000;839.510000000000;836.640000000000;833.760000000000;830.870000000000;827.970000000000;825.060000000000;822.130000000000;819.190000000000;816.230000000000;813.270000000000;810.290000000000;807.300000000000;804.300000000000;801.280000000000;798.250000000000;795.220000000000;792.170000000000;789.120000000000;786.050000000000;782.980000000000;779.890000000000;776.790000000000;773.670000000000;770.550000000000;767.420000000000;764.270000000000;761.120000000000;757.950000000000;754.780000000000;751.590000000000;748.390000000000;745.190000000000;741.970000000000;738.740000000000;735.500000000000;732.260000000000;729;725.730000000000;722.460000000000;719.170000000000;715.870000000000;712.570000000000;709.250000000000;705.930000000000;702.600000000000;699.260000000000;695.900000000000;692.540000000000;689.180000000000;685.800000000000;682.410000000000;679.020000000000;675.620000000000;672.210000000000;668.790000000000;665.360000000000;661.930000000000;658.490000000000;655.040000000000;651.580000000000;648.110000000000;644.640000000000;641.160000000000;637.670000000000;634.180000000000;630.670000000000;627.170000000000;623.650000000000;620.130000000000;616.600000000000;613.060000000000;609.520000000000;605.970000000000;602.420000000000;598.860000000000;595.290000000000;591.730000000000;588.160000000000;584.580000000000;581;577.410000000000;573.810000000000;570.210000000000;566.610000000000;562.990000000000;559.370000000000;555.750000000000;552.120000000000;548.490000000000;544.850000000000;541.200000000000;537.550000000000;533.900000000000;530.240000000000;526.570000000000;522.910000000000;519.230000000000;515.560000000000;511.880000000000;508.190000000000;504.500000000000;500.810000000000;497.110000000000;493.410000000000;489.710000000000;486;482.300000000000;478.580000000000;474.870000000000;471.150000000000;467.430000000000;463.700000000000;459.980000000000;456.250000000000;452.520000000000;448.790000000000;445.050000000000;441.320000000000;437.580000000000;433.840000000000;430.100000000000;426.350000000000;422.610000000000;418.870000000000;415.120000000000;411.370000000000;407.630000000000;403.880000000000;400.130000000000;396.380000000000;392.630000000000;388.880000000000;385.130000000000;381.390000000000;377.640000000000;373.890000000000;370.150000000000;366.410000000000;362.670000000000;358.930000000000;355.180000000000;351.450000000000;347.710000000000;343.970000000000;340.230000000000;336.500000000000;332.760000000000;329.030000000000;325.300000000000;321.580000000000;317.850000000000;314.130000000000;310.410000000000;306.690000000000;302.970000000000;299.260000000000;295.550000000000;291.850000000000;288.150000000000;284.450000000000;280.760000000000;277.070000000000;273.380000000000;269.700000000000;266.020000000000;262.350000000000;258.690000000000;255.020000000000;251.370000000000;247.720000000000;244.070000000000;240.440000000000;236.800000000000;233.180000000000;229.560000000000;225.950000000000;222.340000000000;218.750000000000;215.160000000000;211.580000000000;208;204.440000000000;200.880000000000;197.340000000000;193.800000000000;190.270000000000;186.750000000000;183.250000000000;179.750000000000;176.260000000000;172.780000000000;169.320000000000;165.870000000000;162.430000000000;159;155.550000000000;152.100000000000;148.660000000000;145.230000000000;141.830000000000;138.440000000000;135.060000000000;131.710000000000;128.370000000000;125.060000000000;121.760000000000;118.480000000000;115.220000000000;111.980000000000;108.770000000000;105.570000000000;102.400000000000;99.2500000000000;96.1240000000000;93.0220000000000;89.9450000000000;86.8930000000000;83.8670000000000;80.8690000000000;77.8970000000000;74.9550000000000;72.0410000000000;69.1570000000000;66.3050000000000;63.4840000000000;60.6960000000000;57.9410000000000;55.2210000000000;52.5370000000000;49.8890000000000;47.2800000000000;44.7090000000000;42.1770000000000;39.6870000000000;37.2390000000000;34.8340000000000;32.4730000000000;30.1580000000000;27.8880000000000;25.6660000000000;23.4910000000000;21.3650000000000;19.2890000000000;17.2640000000000;15.2920000000000;13.3730000000000;11.5100000000000;9.70710000000000;7.96950000000000;6.30440000000000;4.72280000000000;3.23920000000000;1.87340000000000;9.01800000000000;10.8610000000000;12.7690000000000;14.7360000000000;16.7590000000000;18.8360000000000;20.9650000000000;23.1440000000000;25.3730000000000;27.6490000000000;29.9740000000000;32.3440000000000;34.7600000000000;37.2190000000000;39.7220000000000;42.2660000000000;44.8510000000000;47.4760000000000;50.1390000000000;52.8390000000000;55.5760000000000;58.3470000000000;61.1530000000000;63.9920000000000;66.8620000000000;69.7630000000000;72.6950000000000;75.6550000000000;78.6430000000000;81.6590000000000;84.7000000000000;87.7680000000000;90.8600000000000;93.9760000000000;97.1150000000000;100.280000000000;103.460000000000;106.670000000000;109.890000000000;113.140000000000;116.400000000000;119.690000000000;122.990000000000;126.310000000000;129.650000000000;133;136.370000000000;139.750000000000;143.160000000000;146.570000000000;150;153.450000000000;156.910000000000;160.380000000000;163.860000000000;167.360000000000;170.870000000000;174.390000000000;177.920000000000;181.460000000000;185.020000000000;188.580000000000;192.160000000000;195.740000000000;199.340000000000;202.940000000000;206.550000000000;210.180000000000;213.810000000000;217.440000000000;221.090000000000;224.740000000000;228.410000000000;232.080000000000;235.760000000000;239.440000000000;243.140000000000;246.840000000000;250.550000000000;254.260000000000;257.980000000000;261.710000000000;265.440000000000;269.180000000000;272.920000000000;276.660000000000;280.420000000000;284.170000000000;287.930000000000;291.700000000000;295.470000000000;299.240000000000;303.020000000000;306.800000000000;310.580000000000;314.370000000000;318.160000000000;321.950000000000;325.750000000000;329.550000000000;333.350000000000;337.150000000000;340.950000000000;344.760000000000;348.570000000000;352.380000000000;356.190000000000;360;363.810000000000;367.630000000000;371.440000000000;375.260000000000;379.070000000000;382.890000000000;386.710000000000;390.520000000000;394.340000000000;398.150000000000;401.970000000000;405.780000000000;409.600000000000;413.410000000000;417.220000000000;421.030000000000;424.840000000000;428.650000000000;432.460000000000;436.260000000000;440.060000000000;443.870000000000;447.660000000000;451.460000000000;455.260000000000;459.050000000000;462.850000000000;466.640000000000;470.430000000000;474.220000000000;478;481.790000000000;485.570000000000;489.340000000000;493.120000000000;496.890000000000;500.660000000000;504.420000000000;508.180000000000;511.940000000000;515.690000000000;519.440000000000;523.190000000000;526.930000000000;530.670000000000;534.400000000000;538.130000000000;541.860000000000;545.580000000000;549.290000000000;553.010000000000;556.710000000000;560.410000000000;564.110000000000;567.800000000000;571.480000000000;575.160000000000;578.840000000000;582.510000000000;586.170000000000;589.830000000000;593.480000000000;597.120000000000;600.760000000000;604.390000000000;608.020000000000;611.640000000000;615.250000000000;618.860000000000;622.460000000000;626.050000000000;629.640000000000;633.220000000000;636.790000000000;640.360000000000;643.910000000000;647.460000000000;651;654.540000000000;658.070000000000;661.580000000000;665.100000000000;668.600000000000;672.090000000000;675.580000000000;679.060000000000;682.530000000000;685.980000000000;689.420000000000;692.850000000000;696.260000000000;699.650000000000;703.030000000000;706.400000000000;709.760000000000;713.100000000000;716.430000000000;719.740000000000;723.040000000000;726.330000000000;729.600000000000;732.860000000000;736.110000000000;739.340000000000;742.560000000000;745.770000000000;748.970000000000;752.150000000000;755.320000000000;758.480000000000;761.630000000000;764.770000000000;767.890000000000;771;774.100000000000;777.190000000000;780.270000000000;783.330000000000;786.390000000000;789.430000000000;792.470000000000;795.490000000000;798.510000000000;801.510000000000;804.500000000000;807.490000000000;810.460000000000;813.430000000000;816.390000000000;819.340000000000;822.280000000000;825.210000000000;828.130000000000;831.050000000000;833.960000000000;836.860000000000;839.750000000000;842.640000000000;845.520000000000;848.400000000000;851.270000000000;854.130000000000;856.990000000000;859.850000000000;862.700000000000;864.310000000000;867.150000000000;869.970000000000;872.790000000000;875.590000000000;878.380000000000;881.150000000000;883.920000000000;886.670000000000;889.400000000000;892.130000000000;894.840000000000;897.530000000000;900.220000000000;902.880000000000;905.540000000000;908.180000000000;910.810000000000;913.420000000000;916.020000000000;918.610000000000;921.180000000000;923.740000000000;926.290000000000;928.820000000000;931.330000000000;933.840000000000;936.320000000000;938.800000000000;941.250000000000;943.700000000000;946.130000000000;948.540000000000;950.940000000000;953.330000000000;955.700000000000;958.060000000000;960.400000000000;962.720000000000;965.040000000000;967.330000000000;969.610000000000;971.880000000000;974.130000000000;976.360000000000;978.580000000000;980.790000000000;982.980000000000;985.150000000000;987.310000000000;989.450000000000;991.580000000000;993.690000000000;995.790000000000;997.870000000000;999.930000000000;1002;1004;1006;1008;1010;1012;1013.90000000000;1015.90000000000;1017.80000000000;1019.70000000000;1021.60000000000;1023.50000000000;1025.40000000000;1027.20000000000;1029;1030.80000000000;1032.60000000000;1034.40000000000;1036.20000000000;1037.90000000000;1039.70000000000;1041.40000000000;1043.10000000000;1044.80000000000;1046.40000000000;1048.10000000000;1049.70000000000;1051.30000000000;1052.90000000000;1054.50000000000;1056.10000000000;1057.60000000000;1059.10000000000;1060.60000000000;1062.10000000000;1063.60000000000;1065.10000000000;1066.50000000000;1067.90000000000;1069.30000000000;1070.70000000000;1072.10000000000;1073.40000000000;1074.80000000000;1076.10000000000;1077.40000000000;1078.70000000000;1079.90000000000;1081.20000000000;1082.40000000000;1083.60000000000;1084.80000000000;1085.90000000000;1087.10000000000;1088.20000000000;1089.30000000000;1090.40000000000;1091.50000000000;1092.50000000000;1093.60000000000;1094.60000000000;1095.60000000000;1096.50000000000;1097.50000000000;1098.40000000000;1099.40000000000;1100.30000000000;1101.10000000000;1102;1102.90000000000;1103.70000000000;1104.50000000000;1105.30000000000;1106.10000000000;1106.80000000000;1107.60000000000;1108.30000000000;1109;1109.70000000000;1110.30000000000;1111;1111.60000000000;1112.20000000000;1112.80000000000;1113.40000000000;1114;1114.50000000000;1115;1115.50000000000;1116;1116.50000000000;1116.90000000000;1117.30000000000;1117.70000000000;1118.10000000000;1118.50000000000;1118.80000000000;1119.20000000000;1119.50000000000;1119.80000000000;1120.10000000000;1120.30000000000;1120.60000000000;1120.80000000000;1121;1121.20000000000;1121.40000000000;1121.50000000000;1121.60000000000;1121.70000000000;1121.80000000000;1121.90000000000;1122;1122;1122;1122;1122;1122;1121.90000000000;1121.80000000000;1121.80000000000;1121.60000000000;1121.50000000000;1121.40000000000;1121.20000000000;1121;1120.80000000000;1120.60000000000;1120.30000000000;1120.10000000000;1119.80000000000;1119.50000000000;1119.20000000000;1118.80000000000;1118.50000000000;1118.10000000000;1117.70000000000;1117.30000000000;1116.80000000000;1116.40000000000;1115.90000000000;1115.40000000000;1114.90000000000;1114.40000000000;1113.80000000000;1113.30000000000;1112.70000000000;1112.10000000000;1111.40000000000;1110.80000000000;1110.10000000000;1109.40000000000;1108.70000000000;1108;1107.30000000000;1106.50000000000;1105.70000000000;1105;1104.10000000000;1103.30000000000;1102.50000000000;1101.60000000000;1100.70000000000;1099.80000000000;1098.90000000000;1097.90000000000;1097;1096;1095;1094;1093;1091.90000000000;1090.90000000000;1089.80000000000;1088.70000000000;1087.60000000000;1086.40000000000;1085.30000000000;1084.10000000000;1082.90000000000;1081.70000000000;1080.50000000000;1079.30000000000;1078;1076.70000000000;1075.50000000000;1074.10000000000;1072.80000000000;1071.50000000000;1070.10000000000;1068.80000000000;1067.40000000000;1066;1064.50000000000;1063.10000000000;1061.60000000000;1060.20000000000;1058.70000000000;1057.20000000000;1055.60000000000;1054.10000000000;1052.50000000000;1050.90000000000;1049.30000000000;1047.70000000000;1046.10000000000;1044.50000000000;1042.80000000000;1041.10000000000;1039.40000000000;1037.70000000000;1036;1034.20000000000;1032.50000000000;1030.70000000000;1028.90000000000;1027.10000000000;1025.20000000000;1023.40000000000;1021.50000000000;1019.60000000000;1017.70000000000;1015.80000000000;1013.90000000000;1012;1010;1008;1006;1004;1002;999.940000000000;997.880000000000;995.810000000000;993.710000000000;991.610000000000;989.480000000000;987.340000000000;985.190000000000;983.020000000000;980.830000000000;978.630000000000;976.410000000000;974.170000000000;971.920000000000;969.660000000000;967.380000000000;965.090000000000;962.780000000000;960.460000000000;958.120000000000;955.760000000000;953.390000000000;951;948.600000000000;946.180000000000;943.750000000000;941.300000000000;938.840000000000;936.360000000000;933.870000000000;931.360000000000;928.840000000000;926.300000000000;923.750000000000;921.180000000000;918.600000000000;916;913.390000000000;910.770000000000;908.130000000000;905.480000000000;902.810000000000;900.130000000000;897.440000000000;894.730000000000;892.010000000000;889.280000000000;886.530000000000;883.770000000000;881;878.210000000000;875.410000000000;872.600000000000;869.780000000000;866.940000000000;864.090000000000;861.230000000000;858.350000000000;855.460000000000;852.560000000000;849.650000000000;846.730000000000;843.790000000000;840.850000000000;837.890000000000;834.920000000000;831.940000000000;828.940000000000;825.940000000000;822.930000000000;819.900000000000;816.860000000000;813.810000000000;810.750000000000;807.690000000000;804.620000000000;801.530000000000;798.440000000000;795.330000000000;792.210000000000;789.080000000000;785.940000000000;782.790000000000;779.630000000000;776.460000000000;773.280000000000;770.080000000000;766.880000000000;763.670000000000;760.440000000000;757.210000000000;753.960000000000;750.710000000000;747.440000000000;744.170000000000;740.880000000000;737.590000000000;734.280000000000;730.970000000000;727.640000000000;724.310000000000;720.970000000000;717.610000000000;714.250000000000;710.880000000000;707.500000000000;704.110000000000;700.710000000000;697.310000000000;693.890000000000;690.470000000000;687.030000000000;683.590000000000;680.140000000000;676.680000000000;673.210000000000;669.740000000000;666.250000000000;662.760000000000;659.260000000000;655.750000000000;652.240000000000;648.710000000000;645.180000000000;641.640000000000;638.100000000000;634.540000000000;630.980000000000;627.410000000000;623.830000000000;620.250000000000;616.660000000000;613.060000000000;609.460000000000;605.850000000000;602.250000000000;598.630000000000;595.010000000000;591.380000000000;587.750000000000;584.110000000000;580.460000000000;576.810000000000;573.150000000000;569.490000000000;565.820000000000;562.140000000000;558.460000000000;554.770000000000;551.080000000000;547.390000000000;543.680000000000;539.980000000000;536.260000000000;532.550000000000;528.820000000000;525.100000000000;521.370000000000;517.630000000000;513.890000000000;510.150000000000;506.400000000000;502.650000000000;498.890000000000;495.130000000000;491.370000000000;487.610000000000;483.840000000000;480.060000000000;476.290000000000;472.510000000000;468.720000000000;464.940000000000;461.150000000000;457.360000000000;453.570000000000;449.770000000000;445.980000000000;442.180000000000;438.380000000000;434.570000000000;430.770000000000;426.960000000000;423.150000000000;419.340000000000;415.530000000000;411.720000000000;407.910000000000;404.100000000000;400.280000000000;396.470000000000;392.650000000000;388.840000000000;385.020000000000;381.210000000000;377.400000000000;373.590000000000;369.780000000000;365.970000000000;362.160000000000;358.350000000000;354.540000000000;350.730000000000;346.930000000000;343.120000000000;339.320000000000;335.520000000000;331.720000000000;327.920000000000;324.120000000000;320.330000000000;316.540000000000;312.750000000000;308.960000000000;305.180000000000;301.400000000000;297.620000000000;293.850000000000;290.080000000000;286.310000000000;282.550000000000;278.790000000000;275.040000000000;271.290000000000;267.540000000000;263.800000000000;260.070000000000;256.340000000000;252.620000000000;248.900000000000;245.190000000000;241.480000000000;237.780000000000;234.090000000000;230.400000000000;226.730000000000;223.060000000000;219.390000000000;215.740000000000;212.090000000000;208.450000000000;204.820000000000;201.200000000000;197.590000000000;193.990000000000;190.400000000000;186.810000000000;183.240000000000;179.680000000000;176.130000000000;172.590000000000;169.070000000000;165.550000000000;162.050000000000;158.540000000000;155.010000000000;151.490000000000;147.990000000000;144.510000000000;141.050000000000;137.600000000000;134.180000000000;130.770000000000;127.380000000000;124.010000000000;120.660000000000;117.330000000000;114.030000000000;110.740000000000;107.480000000000;104.240000000000;101.020000000000;97.8290000000000;94.6620000000000;91.5200000000000;88.4040000000000;85.3160000000000;82.2550000000000;79.2230000000000;76.2200000000000;73.2470000000000;70.3050000000000;67.3960000000000;64.5190000000000;61.6770000000000;58.8690000000000;56.0970000000000;53.3620000000000;50.6660000000000;48.0090000000000;45.3910000000000;42.8160000000000;40.2830000000000;37.7930000000000;35.3490000000000;32.9500000000000;30.5980000000000;28.2940000000000;26.0390000000000;23.8340000000000;21.6800000000000;19.5770000000000;17.5270000000000;15.5310000000000;13.5910000000000;11.7100000000000;9.89030000000000;8.13820000000000;6.46110000000000;4.86980000000000;3.37890000000000;2.00800000000000;0.782120000000000;9.53270000000000;11.4150000000000;13.3620000000000;15.3690000000000;17.4320000000000;19.5510000000000;21.7210000000000;23.9430000000000;26.2150000000000;28.5360000000000;30.9050000000000;33.3200000000000;35.7800000000000;38.2850000000000;40.8330000000000;43.4230000000000;46.0530000000000;48.7240000000000;51.4320000000000;54.1780000000000;56.9600000000000;59.7780000000000;62.6290000000000;65.5120000000000;68.4280000000000;71.3740000000000;74.3500000000000;77.3550000000000;80.3880000000000;83.4480000000000;86.5330000000000;89.6440000000000;92.7800000000000;95.9390000000000;99.1220000000000;102.330000000000;105.550000000000;108.800000000000;112.070000000000;115.350000000000;118.660000000000;121.980000000000;125.330000000000;128.690000000000;132.060000000000;135.460000000000;138.870000000000;142.290000000000;145.730000000000;149.190000000000;152.650000000000;156.140000000000;159.630000000000;163.140000000000;166.660000000000;170.190000000000;173.740000000000;177.290000000000;180.860000000000;184.440000000000;188.030000000000;191.630000000000;195.240000000000;198.850000000000;202.480000000000;206.120000000000;209.760000000000;213.420000000000;217.080000000000;220.750000000000;224.420000000000;228.110000000000;231.800000000000;235.510000000000;239.220000000000;242.930000000000;246.650000000000;250.380000000000;254.120000000000;257.860000000000;261.600000000000;265.360000000000;269.110000000000;272.870000000000;276.640000000000;280.410000000000;284.180000000000;287.960000000000;291.750000000000;295.530000000000;299.320000000000;303.120000000000;306.910000000000;310.710000000000;314.510000000000;318.320000000000;322.130000000000;325.940000000000;329.750000000000;333.560000000000;337.380000000000;341.200000000000;345.020000000000;348.840000000000;352.660000000000;356.480000000000;360.310000000000;364.130000000000;367.960000000000;371.780000000000;375.610000000000;379.440000000000;383.270000000000;387.090000000000;390.920000000000;394.750000000000;398.570000000000;402.400000000000;406.220000000000;410.050000000000;413.870000000000;417.690000000000;421.510000000000;425.330000000000;429.150000000000;432.970000000000;436.780000000000;440.600000000000;444.410000000000;448.220000000000;452.020000000000;455.830000000000;459.630000000000;463.440000000000;467.240000000000;471.040000000000;474.830000000000;478.630000000000;482.410000000000;486.200000000000;489.980000000000;493.760000000000;497.530000000000;501.300000000000;505.070000000000;508.830000000000;512.590000000000;516.340000000000;520.090000000000;523.830000000000;527.570000000000;531.310000000000;535.040000000000;538.770000000000;542.490000000000;546.200000000000;549.910000000000;553.620000000000;557.320000000000;561.020000000000;564.710000000000;568.390000000000;572.070000000000;575.740000000000;579.410000000000;583.070000000000;586.730000000000;590.380000000000;594.020000000000;597.660000000000;601.290000000000;604.920000000000;608.540000000000;612.150000000000;615.760000000000;619.350000000000;622.950000000000;626.530000000000;630.110000000000;633.690000000000;637.250000000000;640.810000000000;644.360000000000;647.910000000000;651.440000000000;654.970000000000;658.490000000000;662.010000000000;665.520000000000;669.020000000000;672.510000000000;675.990000000000;679.470000000000;682.940000000000;686.410000000000;689.860000000000;693.310000000000;696.750000000000;700.180000000000;703.600000000000;707.020000000000;710.420000000000;713.820000000000;717.200000000000;720.580000000000;723.950000000000;727.300000000000;730.650000000000;733.990000000000;737.320000000000;740.640000000000;743.950000000000;747.250000000000;750.540000000000;753.820000000000;757.090000000000;760.350000000000;763.600000000000;766.840000000000;770.060000000000;773.280000000000;776.490000000000;779.680000000000;782.870000000000;786.040000000000;789.200000000000;792.350000000000;795.490000000000;798.620000000000;801.740000000000;804.840000000000;807.940000000000;811.020000000000;814.090000000000;817.150000000000;820.190000000000;823.230000000000;826.250000000000;829.260000000000;832.260000000000;835.240000000000;838.210000000000;841.170000000000;844.120000000000;847.050000000000;849.980000000000;852.880000000000;855.780000000000;858.660000000000;861.530000000000;864.390000000000;867.230000000000;868.830000000000;871.660000000000;874.470000000000;877.260000000000;880.050000000000;882.810000000000;885.570000000000;888.310000000000;891.030000000000;893.740000000000;896.440000000000;899.120000000000;901.790000000000;904.440000000000;907.080000000000;909.700000000000;912.310000000000;914.910000000000;917.490000000000;920.060000000000;922.610000000000;925.140000000000;927.660000000000;930.170000000000;932.660000000000;935.140000000000;937.600000000000;940.050000000000;942.480000000000;944.890000000000;947.300000000000;949.680000000000;952.050000000000;954.410000000000;956.750000000000;959.080000000000;961.390000000000;963.680000000000;965.960000000000;968.230000000000;970.480000000000;972.710000000000;974.930000000000;977.130000000000;979.320000000000;981.490000000000;983.650000000000;985.790000000000;987.910000000000;990.020000000000;992.120000000000;994.200000000000;996.260000000000;998.300000000000;1000.30000000000;1002.40000000000;1004.40000000000;1006.30000000000;1008.30000000000;1010.30000000000;1012.20000000000;1014.10000000000;1016;1017.90000000000;1019.80000000000;1021.60000000000;1023.50000000000;1025.30000000000;1027.10000000000;1028.90000000000;1030.70000000000;1032.40000000000;1034.10000000000;1035.90000000000;1037.60000000000;1039.20000000000;1040.90000000000;1042.60000000000;1044.20000000000;1045.80000000000;1047.40000000000;1049;1050.50000000000;1052.10000000000;1053.60000000000;1055.10000000000;1056.60000000000;1058.10000000000;1059.60000000000;1061;1062.40000000000;1063.80000000000;1065.20000000000;1066.60000000000;1068;1069.30000000000;1070.60000000000;1071.90000000000;1073.20000000000;1074.50000000000;1075.70000000000;1076.90000000000;1078.20000000000;1079.40000000000;1080.50000000000;1081.70000000000;1082.80000000000;1084;1085.10000000000;1086.20000000000;1087.20000000000;1088.30000000000;1089.30000000000;1090.40000000000;1091.40000000000;1092.40000000000;1093.30000000000;1094.30000000000;1095.20000000000;1096.10000000000;1097;1097.90000000000;1098.80000000000;1099.60000000000;1100.50000000000;1101.30000000000;1102.10000000000;1102.90000000000;1103.60000000000;1104.40000000000;1105.10000000000;1105.80000000000;1106.50000000000;1107.10000000000;1107.80000000000;1108.40000000000;1109;1109.60000000000;1110.20000000000;1110.80000000000;1111.30000000000;1111.80000000000;1112.30000000000;1112.80000000000;1113.30000000000;1113.70000000000;1114.20000000000;1114.60000000000;1115;1115.30000000000;1115.70000000000;1116;1116.40000000000;1116.70000000000;1116.90000000000;1117.20000000000;1117.40000000000;1117.70000000000;1117.90000000000;1118.10000000000;1118.20000000000;1118.40000000000;1118.50000000000;1118.70000000000;1118.70000000000;1118.80000000000;1118.90000000000;1118.90000000000;1119;1119;1118.90000000000;1118.90000000000;1118.90000000000;1118.80000000000;1118.70000000000;1118.60000000000;1118.50000000000;1118.30000000000;1118.20000000000;1118;1117.80000000000;1117.60000000000;1117.40000000000;1117.10000000000;1116.80000000000;1116.50000000000;1116.20000000000;1115.90000000000;1115.60000000000;1115.20000000000;1114.80000000000;1114.40000000000;1114;1113.60000000000;1113.10000000000;1112.60000000000;1112.10000000000;1111.60000000000;1111.10000000000;1110.60000000000;1110;1109.40000000000;1108.80000000000;1108.20000000000;1107.50000000000;1106.90000000000;1106.20000000000;1105.50000000000;1104.80000000000;1104.10000000000;1103.30000000000;1102.60000000000;1101.80000000000;1101;1100.10000000000;1099.30000000000;1098.40000000000;1097.60000000000;1096.70000000000;1095.80000000000;1094.80000000000;1093.90000000000;1092.90000000000;1091.90000000000;1090.90000000000;1089.90000000000;1088.90000000000;1087.80000000000;1086.80000000000;1085.70000000000;1084.60000000000;1083.50000000000;1082.30000000000;1081.20000000000;1080;1078.80000000000;1077.60000000000;1076.40000000000;1075.10000000000;1073.80000000000;1072.60000000000;1071.30000000000;1070;1068.60000000000;1067.30000000000;1065.90000000000;1064.50000000000;1063.10000000000;1061.70000000000;1060.30000000000;1058.80000000000;1057.40000000000;1055.90000000000;1054.40000000000;1052.90000000000;1051.30000000000;1049.80000000000;1048.20000000000;1046.60000000000;1045;1043.40000000000;1041.70000000000;1040.10000000000;1038.40000000000;1036.70000000000;1035;1033.30000000000;1031.60000000000;1029.80000000000;1028;1026.20000000000;1024.40000000000;1022.60000000000;1020.80000000000;1018.90000000000;1017.10000000000;1015.20000000000;1013.30000000000;1011.40000000000;1009.40000000000;1007.50000000000;1005.50000000000;1003.50000000000;1001.50000000000;999.540000000000;997.510000000000;995.470000000000;993.420000000000;991.350000000000;989.260000000000;987.160000000000;985.040000000000;982.910000000000;980.760000000000;978.600000000000;976.430000000000;974.240000000000;972.030000000000;969.810000000000;967.580000000000;965.330000000000;963.080000000000;960.810000000000;958.530000000000;956.230000000000;953.930000000000;951.610000000000;949.270000000000;946.930000000000;944.570000000000;942.190000000000;939.810000000000;937.410000000000;935;932.570000000000;930.130000000000;927.680000000000;925.220000000000;922.740000000000;920.250000000000;917.740000000000;915.220000000000;912.690000000000;910.140000000000;907.590000000000;905.010000000000;902.430000000000;899.830000000000;897.210000000000;894.590000000000;891.950000000000;889.290000000000;886.620000000000;883.940000000000;881.240000000000;878.530000000000;875.810000000000;873.070000000000;870.320000000000;867.560000000000;864.780000000000;861.990000000000;859.180000000000;856.360000000000;853.520000000000;850.670000000000;847.810000000000;844.930000000000;842.040000000000;839.140000000000;836.220000000000;833.290000000000;830.340000000000;827.380000000000;824.400000000000;821.410000000000;818.410000000000;815.390000000000;812.350000000000;809.310000000000;806.250000000000;803.180000000000;800.110000000000;797.020000000000;793.910000000000;790.800000000000;787.680000000000;784.540000000000;781.390000000000;778.230000000000;775.060000000000;771.880000000000;768.690000000000;765.480000000000;762.270000000000;759.040000000000;755.800000000000;752.550000000000;749.300000000000;746.030000000000;742.750000000000;739.460000000000;736.160000000000;732.850000000000;729.520000000000;726.190000000000;722.850000000000;719.500000000000;716.140000000000;712.770000000000;709.390000000000;706;702.600000000000;699.200000000000;695.780000000000;692.350000000000;688.920000000000;685.470000000000;682.020000000000;678.560000000000;675.090000000000;671.610000000000;668.120000000000;664.620000000000;661.120000000000;657.600000000000;654.080000000000;650.560000000000;647.020000000000;643.470000000000;639.920000000000;636.360000000000;632.790000000000;629.220000000000;625.640000000000;622.050000000000;618.450000000000;614.850000000000;611.240000000000;607.620000000000;604;600.380000000000;596.750000000000;593.120000000000;589.470000000000;585.830000000000;582.170000000000;578.510000000000;574.840000000000;571.170000000000;567.490000000000;563.800000000000;560.110000000000;556.410000000000;552.700000000000;548.990000000000;545.280000000000;541.560000000000;537.830000000000;534.100000000000;530.360000000000;526.620000000000;522.880000000000;519.130000000000;515.370000000000;511.610000000000;507.850000000000;504.080000000000;500.310000000000;496.530000000000;492.750000000000;488.970000000000;485.180000000000;481.390000000000;477.590000000000;473.790000000000;469.990000000000;466.190000000000;462.380000000000;458.570000000000;454.760000000000;450.950000000000;447.130000000000;443.310000000000;439.490000000000;435.670000000000;431.840000000000;428.010000000000;424.190000000000;420.360000000000;416.520000000000;412.690000000000;408.860000000000;405.030000000000;401.190000000000;397.360000000000;393.520000000000;389.680000000000;385.850000000000;382.010000000000;378.180000000000;374.340000000000;370.510000000000;366.680000000000;362.840000000000;359.010000000000;355.180000000000;351.340000000000;347.510000000000;343.680000000000;339.850000000000;336.020000000000;332.190000000000;328.370000000000;324.540000000000;320.720000000000;316.900000000000;313.080000000000;309.270000000000;305.450000000000;301.650000000000;297.840000000000;294.040000000000;290.240000000000;286.440000000000;282.650000000000;278.870000000000;275.090000000000;271.310000000000;267.540000000000;263.770000000000;260.010000000000;256.260000000000;252.510000000000;248.760000000000;245.030000000000;241.300000000000;237.570000000000;233.860000000000;230.150000000000;226.450000000000;222.760000000000;219.070000000000;215.400000000000;211.730000000000;208.070000000000;204.430000000000;200.790000000000;197.160000000000;193.540000000000;189.940000000000;186.340000000000;182.760000000000;179.180000000000;175.620000000000;172.080000000000;168.540000000000;165.020000000000;161.510000000000;158.020000000000;154.510000000000;150.990000000000;147.490000000000;144;140.530000000000;137.090000000000;133.660000000000;130.250000000000;126.860000000000;123.490000000000;120.140000000000;116.820000000000;113.520000000000;110.240000000000;106.980000000000;103.750000000000;100.540000000000;97.3640000000000;94.2110000000000;91.0850000000000;87.9870000000000;84.9190000000000;81.8800000000000;78.8710000000000;75.8940000000000;72.9500000000000;70.0380000000000;67.1620000000000;64.3200000000000;61.5150000000000;58.7470000000000;56.0180000000000;53.3280000000000;50.6790000000000;48.0710000000000;45.5060000000000;42.9850000000000;40.5100000000000;38.0800000000000;35.6970000000000;33.3620000000000;31.0750000000000;28.8390000000000;26.6520000000000;24.5170000000000;22.4330000000000;20.4010000000000;18.4210000000000;16.4940000000000;14.6200000000000;12.8000000000000;11.0360000000000;9.33150000000000;7.93070000000000;9.46480000000000;11.0470000000000;12.6730000000000;14.3430000000000;16.0540000000000;17.8070000000000;19.6040000000000;21.4440000000000;23.3270000000000;25.2560000000000;27.2290000000000;29.2470000000000;31.3090000000000;33.4170000000000;35.5700000000000;37.7660000000000;40.0070000000000;42.2910000000000;44.6170000000000;46.9840000000000;49.3930000000000;51.8410000000000;54.3290000000000;56.8540000000000;59.4170000000000;62.0160000000000;64.6500000000000;67.3180000000000;70.0200000000000;72.7540000000000;75.5200000000000;78.3170000000000;81.1430000000000;83.9980000000000;86.8820000000000;89.7920000000000;92.7300000000000;95.6930000000000;98.6810000000000;101.690000000000;104.730000000000;107.790000000000;110.870000000000;113.970000000000;117.090000000000;120.240000000000;123.400000000000;126.580000000000;129.780000000000;133;136.240000000000;139.490000000000;142.760000000000;146.050000000000;149.350000000000;152.660000000000;156;159.340000000000;162.700000000000;166.070000000000;169.460000000000;172.850000000000;176.260000000000;179.690000000000;183.120000000000;186.560000000000;190.020000000000;193.490000000000;196.960000000000;200.450000000000;203.950000000000;207.460000000000;210.970000000000;214.500000000000;218.040000000000;221.580000000000;225.140000000000;228.700000000000;232.270000000000;235.840000000000;239.430000000000;243.020000000000;246.610000000000;250.220000000000;253.830000000000;257.440000000000;261.060000000000;264.690000000000;268.320000000000;271.960000000000;275.600000000000;279.240000000000;282.890000000000;286.550000000000;290.210000000000;293.870000000000;297.530000000000;301.200000000000;304.870000000000;308.550000000000;312.230000000000;315.910000000000;319.590000000000;323.280000000000;326.960000000000;330.650000000000;334.340000000000;338.040000000000;341.730000000000;345.430000000000;349.120000000000;352.820000000000;356.520000000000;360.220000000000;363.910000000000;367.610000000000;371.310000000000;375.010000000000;378.710000000000;382.410000000000;386.110000000000;389.810000000000;393.510000000000;397.200000000000;400.900000000000;404.590000000000;408.280000000000;411.980000000000;415.670000000000;419.360000000000;423.040000000000;426.740000000000;430.430000000000;434.120000000000;437.800000000000;441.490000000000;445.170000000000;448.860000000000;452.540000000000;456.220000000000;459.890000000000;463.570000000000;467.240000000000;470.910000000000;474.580000000000;478.240000000000;481.900000000000;485.560000000000;489.210000000000;492.860000000000;496.510000000000;500.150000000000;503.790000000000;507.420000000000;511.050000000000;514.670000000000;518.290000000000;521.910000000000;525.520000000000;529.130000000000;532.730000000000;536.320000000000;539.910000000000;543.500000000000;547.080000000000;550.650000000000;554.220000000000;557.780000000000;561.330000000000;564.880000000000;568.420000000000;571.950000000000;575.480000000000;579;582.520000000000;586.020000000000;589.520000000000;593.010000000000;596.500000000000;599.970000000000;603.440000000000;606.900000000000;610.360000000000;613.800000000000;617.240000000000;620.660000000000;624.080000000000;627.490000000000;630.890000000000;634.280000000000;637.670000000000;641.040000000000;644.410000000000;647.770000000000;651.110000000000;654.450000000000;657.770000000000;661.090000000000;664.390000000000;667.690000000000;670.970000000000;674.250000000000;677.510000000000;680.770000000000;684.010000000000;687.250000000000;690.470000000000;693.680000000000;696.890000000000;700.080000000000;703.260000000000;706.440000000000;709.600000000000;712.750000000000;715.900000000000;719.030000000000;722.150000000000;725.260000000000;728.360000000000;731.450000000000;734.530000000000;737.610000000000;740.670000000000;743.720000000000;746.760000000000;749.780000000000;752.800000000000;755.810000000000;758.810000000000;761.800000000000;764.780000000000;767.750000000000;770.700000000000;773.650000000000;776.590000000000;779.510000000000;782.430000000000;785.340000000000;788.230000000000;791.120000000000;793.990000000000;796.860000000000;799.710000000000;802.560000000000;805.390000000000;808.210000000000;811.030000000000;813.830000000000;816.620000000000;819.410000000000;821;823.770000000000;826.530000000000;829.280000000000;832.020000000000;834.750000000000;837.460000000000;840.170000000000;842.870000000000;845.550000000000;848.220000000000;850.880000000000;853.530000000000;856.170000000000;858.800000000000;861.410000000000;864.010000000000;866.600000000000;869.180000000000;871.740000000000;874.290000000000;876.830000000000;879.360000000000;881.870000000000;884.370000000000;886.860000000000;889.330000000000;891.790000000000;894.240000000000;896.670000000000;899.090000000000;901.490000000000;903.880000000000;906.260000000000;908.620000000000;910.970000000000;913.300000000000;915.620000000000;917.930000000000;920.220000000000;922.490000000000;924.750000000000;926.990000000000;929.220000000000;931.430000000000;933.630000000000;935.810000000000;937.980000000000;940.130000000000;942.260000000000;944.380000000000;946.480000000000;948.570000000000;950.640000000000;952.690000000000;954.730000000000;956.750000000000;958.750000000000;960.740000000000;962.700000000000;964.660000000000;966.590000000000;968.520000000000;970.420000000000;972.310000000000;974.190000000000;976.040000000000;977.880000000000;979.710000000000;981.520000000000;983.310000000000;985.090000000000;986.850000000000;988.590000000000;990.320000000000;992.030000000000;993.730000000000;995.410000000000;997.070000000000;998.710000000000;1000.30000000000;1002;1003.60000000000;1005.10000000000;1006.70000000000;1008.20000000000;1009.80000000000;1011.30000000000;1012.80000000000;1014.30000000000;1015.70000000000;1017.20000000000;1018.60000000000;1020;1021.40000000000;1022.80000000000;1024.10000000000;1025.50000000000;1026.80000000000;1028.10000000000;1029.40000000000;1030.70000000000;1031.90000000000;1033.20000000000;1034.40000000000;1035.60000000000;1036.80000000000;1038;1039.10000000000;1040.30000000000;1041.40000000000;1042.50000000000;1043.60000000000;1044.60000000000;1045.70000000000;1046.70000000000;1047.70000000000;1048.70000000000;1049.70000000000;1050.70000000000;1051.60000000000;1052.60000000000;1053.50000000000;1054.40000000000;1055.30000000000;1056.10000000000;1057;1057.80000000000;1058.60000000000;1059.40000000000;1060.20000000000;1060.90000000000;1061.70000000000;1062.40000000000;1063.10000000000;1063.80000000000;1064.40000000000;1065.10000000000;1065.70000000000;1066.30000000000;1066.90000000000;1067.50000000000;1068.10000000000;1068.60000000000;1069.10000000000;1069.60000000000;1070.10000000000;1070.60000000000;1071;1071.50000000000;1071.90000000000;1072.30000000000;1072.60000000000;1073;1073.30000000000;1073.70000000000;1074;1074.20000000000;1074.50000000000;1074.80000000000;1075;1075.20000000000;1075.40000000000;1075.50000000000;1075.70000000000;1075.80000000000;1075.90000000000;1076;1076.10000000000;1076.20000000000;1076.20000000000;1076.20000000000;1076.20000000000;1076.20000000000;1076.10000000000;1076.10000000000;1076;1075.90000000000;1075.80000000000;1075.70000000000;1075.50000000000;1075.30000000000;1075.10000000000;1074.90000000000;1074.70000000000;1074.50000000000;1074.20000000000;1073.90000000000;1073.60000000000;1073.30000000000;1073;1072.60000000000;1072.30000000000;1071.90000000000;1071.50000000000;1071;1070.60000000000;1070.10000000000;1069.60000000000]; 39 | % % run the clear-sky detection routine. 40 | % csd = Zhang2018CSD(ghi,ghics,zen,1); %plot figure set to 1 so an output is plotted 41 | % 42 | function csd = Zhang2018CSD(ghi,ghics,plot_figure) 43 | % safety checks 44 | if ~iscolumn(ghi) 45 | ghi = ghi'; 46 | if ~iscolumn(ghi) 47 | error('var ghi must be a column vector') 48 | end 49 | end 50 | if ~iscolumn(ghics) 51 | ghics = ghics'; 52 | if ~iscolumn(ghics) 53 | error('var ghics must be a column vector') 54 | end 55 | end 56 | if length(unique([length(ghi),length(ghics)]))~=1 57 | error('vars must be equal in length') 58 | end 59 | 60 | gamma_limit = 0.1; 61 | % the methodology is to be made on 30min ghics linearly interpolated. 62 | %build 30min ghics. 63 | ghics30 = nanmean(hankel(ghics,[ghics(end),NaN(1,29)]),2); 64 | ghi30 = nanmean(hankel(ghi,[ghi(end),NaN(1,29)]),2); 65 | x = 1:length(ghics30); 66 | xx = linspace(1,length(ghics30),length(ghics)); 67 | ghics30lin = interp1(x,ghics30,xx)'; 68 | ghi30lin = interp1(x,ghi30,xx)'; 69 | 70 | % principal based on 71 | % dghi(t) = ghi(t) -ghi(t-1); 72 | % dghics(t) = ghics(t) -ghics(t-1); 73 | % gamma = max(abs(dghi(t)-dghics(t))); 74 | % where gamma is taken as a maximum for the day. should it be greater than 75 | % 0.1, the day is said to be cloudy 76 | dghi = [NaN;diff(ghi30lin)]; 77 | dghics = [NaN;diff(ghics30lin)]; 78 | gamma = abs(dghi-dghics); 79 | 80 | csd = zeros(size(ghi)); 81 | csd(gamma>gamma_limit)=1; 82 | 83 | %% figure example 84 | if exist('plot_figure','var') 85 | figure('name','Zhang CSD example','color','w'); 86 | hold on 87 | plot(ghi) 88 | CSD = ghi; 89 | CSD(csd==1)=NaN; 90 | plot(CSD,'linewidth',2,'color','k') 91 | hold off 92 | legend('GHI','Clear detected') 93 | ylabel('Irradiance [Wm^{-2}]') 94 | set(gca,'xtick',[]); 95 | xlabel('Time') 96 | end 97 | end --------------------------------------------------------------------------------