1
+ import logging
2
+ pvl_logger = logging .getLogger ('pvlib' )
3
+
4
+ import datetime
5
+
6
+ import numpy as np
7
+ import pandas as pd
8
+
9
+ from nose .tools import raises , assert_almost_equals
10
+ from nose .plugins .skip import SkipTest
11
+ from pandas .util .testing import assert_frame_equal
12
+
13
+ from pvlib .location import Location
14
+ from pvlib import solarposition
15
+ from pvlib import tracking
16
+
17
+
18
+ def test_solar_noon ():
19
+ apparent_zenith = pd .Series ([10 ])
20
+ apparent_azimuth = pd .Series ([180 ])
21
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
22
+ axis_tilt = 0 , axis_azimuth = 0 ,
23
+ max_angle = 90 , backtrack = True ,
24
+ gcr = 2.0 / 7.0 )
25
+
26
+ expect = pd .DataFrame ({'aoi' : 10 , 'surface_azimuth' : np .nan ,
27
+ 'surface_tilt' : 90 , 'tracker_theta' : 0 },
28
+ index = [0 ], dtype = np .float64 )
29
+
30
+ assert_frame_equal (expect , tracker_data )
31
+
32
+
33
+ def test_azimuth_north_south ():
34
+ apparent_zenith = pd .Series ([60 ])
35
+ apparent_azimuth = pd .Series ([90 ])
36
+
37
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
38
+ axis_tilt = 0 , axis_azimuth = 180 ,
39
+ max_angle = 90 , backtrack = True ,
40
+ gcr = 2.0 / 7.0 )
41
+
42
+ expect = pd .DataFrame ({'aoi' : 0 , 'surface_azimuth' : 90 ,
43
+ 'surface_tilt' : 30 , 'tracker_theta' : - 60 },
44
+ index = [0 ], dtype = np .float64 )
45
+
46
+ assert_frame_equal (expect , tracker_data )
47
+
48
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
49
+ axis_tilt = 0 , axis_azimuth = 0 ,
50
+ max_angle = 90 , backtrack = True ,
51
+ gcr = 2.0 / 7.0 )
52
+
53
+ expect ['tracker_theta' ] *= - 1
54
+
55
+ assert_frame_equal (expect , tracker_data )
56
+
57
+
58
+ def test_max_angle ():
59
+ apparent_zenith = pd .Series ([60 ])
60
+ apparent_azimuth = pd .Series ([90 ])
61
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
62
+ axis_tilt = 0 , axis_azimuth = 0 ,
63
+ max_angle = 45 , backtrack = True ,
64
+ gcr = 2.0 / 7.0 )
65
+
66
+ expect = pd .DataFrame ({'aoi' : 15 , 'surface_azimuth' : 90 ,
67
+ 'surface_tilt' : 45 , 'tracker_theta' : 45 },
68
+ index = [0 ], dtype = np .float64 )
69
+
70
+ assert_frame_equal (expect , tracker_data )
71
+
72
+
73
+ def test_backtrack ():
74
+ apparent_zenith = pd .Series ([80 ])
75
+ apparent_azimuth = pd .Series ([90 ])
76
+
77
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
78
+ axis_tilt = 0 , axis_azimuth = 0 ,
79
+ max_angle = 90 , backtrack = False ,
80
+ gcr = 2.0 / 7.0 )
81
+
82
+ expect = pd .DataFrame ({'aoi' : 0 , 'surface_azimuth' : 90 ,
83
+ 'surface_tilt' : 10 , 'tracker_theta' : 80 },
84
+ index = [0 ], dtype = np .float64 )
85
+
86
+ assert_frame_equal (expect , tracker_data )
87
+
88
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
89
+ axis_tilt = 0 , axis_azimuth = 0 ,
90
+ max_angle = 90 , backtrack = True ,
91
+ gcr = 2.0 / 7.0 )
92
+
93
+ expect = pd .DataFrame ({'aoi' : 52.5716 , 'surface_azimuth' : 90 ,
94
+ 'surface_tilt' : 62.5716 , 'tracker_theta' : 27.4283 },
95
+ index = [0 ], dtype = np .float64 )
96
+
97
+ assert_frame_equal (expect , tracker_data )
98
+
99
+
100
+ def test_axis_tilt ():
101
+ apparent_zenith = pd .Series ([30 ])
102
+ apparent_azimuth = pd .Series ([135 ])
103
+
104
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
105
+ axis_tilt = 30 , axis_azimuth = 180 ,
106
+ max_angle = 90 , backtrack = True ,
107
+ gcr = 2.0 / 7.0 )
108
+
109
+ expect = pd .DataFrame ({'aoi' : 7.286245 , 'surface_azimuth' : 142.6573 ,
110
+ 'surface_tilt' : 54.0125 , 'tracker_theta' : - 20.88121 },
111
+ index = [0 ], dtype = np .float64 )
112
+
113
+ assert_frame_equal (expect , tracker_data )
114
+
115
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
116
+ axis_tilt = 30 , axis_azimuth = 0 ,
117
+ max_angle = 90 , backtrack = True ,
118
+ gcr = 2.0 / 7.0 )
119
+
120
+ expect = pd .DataFrame ({'aoi' : 47.6632 , 'surface_azimuth' : 50.9696 ,
121
+ 'surface_tilt' : 47.4847 , 'tracker_theta' : 31.6655 },
122
+ index = [0 ], dtype = np .float64 )
123
+
124
+ assert_frame_equal (expect , tracker_data )
125
+
126
+
127
+ def test_axis_azimuth ():
128
+ apparent_zenith = pd .Series ([30 ])
129
+ apparent_azimuth = pd .Series ([90 ])
130
+
131
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
132
+ axis_tilt = 0 , axis_azimuth = 90 ,
133
+ max_angle = 90 , backtrack = True ,
134
+ gcr = 2.0 / 7.0 )
135
+
136
+ expect = pd .DataFrame ({'aoi' : 30 , 'surface_azimuth' : np .nan ,
137
+ 'surface_tilt' : 90 , 'tracker_theta' : 0 },
138
+ index = [0 ], dtype = np .float64 )
139
+
140
+ assert_frame_equal (expect , tracker_data )
141
+
142
+ apparent_zenith = pd .Series ([30 ])
143
+ apparent_azimuth = pd .Series ([180 ])
144
+
145
+ tracker_data = tracking .singleaxis (apparent_zenith , apparent_azimuth ,
146
+ axis_tilt = 0 , axis_azimuth = 90 ,
147
+ max_angle = 90 , backtrack = True ,
148
+ gcr = 2.0 / 7.0 )
149
+
150
+ expect = pd .DataFrame ({'aoi' : 0 , 'surface_azimuth' : 0 ,
151
+ 'surface_tilt' : 60 , 'tracker_theta' : 30 },
152
+ index = [0 ], dtype = np .float64 )
153
+
154
+ assert_frame_equal (expect , tracker_data )
0 commit comments