WSL/SLF GitLab Repository

sun.cc 1.97 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#include <stdlib.h>
#include <meteoio/MeteoIO.h>

int main(int /*argc*/, char** argv) {
	mio::SunObject Sun(46.77181, 9.86820, 2192.); //Stillberg station
	const double slope_azi=38., slope_elev=35.;   //Stillberg station
	const double TZ=1.;
	const double TA = 273.15+11., RH = 0.5, mean_albedo = 0.5;

	mio::Date d1;
	d1.setTimeZone(TZ);
13
	mio::IOUtils::convertString(d1,argv[1], TZ); //get date and time
14
	Sun.setDate(d1.getJulian(), d1.getTimeZone()); //local julian date and timezone
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

	double iswr_ref;
	mio::IOUtils::convertString(iswr_ref,argv[2]); //get measured global incoming radiation

	Sun.calculateRadiation(TA, RH, mean_albedo);
	std::cout << Sun;

	//radiation in the beam
	double B_toa, B_direct, B_diffuse;
	Sun.getBeamRadiation(B_toa, B_direct, B_diffuse);
	const double Md_beam=Sun.getSplitting(B_toa,iswr_ref);

	//radiation on the horizontal
	double H_toa, H_direct, H_diffuse;
	Sun.getHorizontalRadiation(H_toa, H_direct, H_diffuse);
	const double Md_horizontal=Sun.getSplitting(H_toa,iswr_ref);

	//radiation on the slope
	double S_toa, S_direct, S_diffuse;
	Sun.getSlopeRadiation(slope_azi, slope_elev, S_toa, S_direct, S_diffuse);
	const double Md_slope=Sun.getSplitting(S_toa,iswr_ref);

	//outputing the results for beam, horizontal and slope
	const unsigned int colw=10;
	std::cout << std::setw(colw) << "Slope" << std::fixed << std::setw(colw) << std::setprecision(1) << S_toa;
	std::cout << std::fixed << std::setw(colw) << std::setprecision(1) << S_direct;
	std::cout << std::fixed << std::setw(colw) << std::setprecision(1) << S_diffuse;
	std::cout << std::fixed << std::setw(colw) << std::setprecision(1) << S_direct+S_diffuse << "\n\n";
	printf("Slope: azi=%g angle=%g ",slope_azi,slope_elev);
	printf("Angle of incidence=%g\n",Sun.position.getAngleOfIncidence(slope_azi,slope_elev));
	printf("Beam Splitting coefficient=%g\n",Md_beam);
	printf("Horizontal Splitting coefficient=%g\n",Md_horizontal);
	printf("Slope Splitting coefficient=%g\n",Md_slope);
48

49
50
	return 0;
}