8
8
9
9
from pvlib .tools import cosd , sind
10
10
from pvlib .pvsystem import PVSystem
11
+ from pvlib .location import Location
12
+ from pvlib import irradiance , atmosphere
11
13
12
14
# should this live next to PVSystem? Is this even a good idea?
13
15
# possibly should inherit from an abstract base class Tracker
@@ -30,9 +32,124 @@ def __init__(self, axis_tilt=0, axis_azimuth=0,
30
32
31
33
32
34
def singleaxis (self , apparent_zenith , apparent_azimuth ):
33
- return singleaxis (apparent_azimuth , apparent_zenith ,
34
- self .axis_tilt , self .axis_azimuth , self .max_angle ,
35
- self .backtrack , self .gcr )
35
+ tracking_data = singleaxis (apparent_zenith , apparent_azimuth ,
36
+ self .axis_tilt , self .axis_azimuth ,
37
+ self .max_angle ,
38
+ self .backtrack , self .gcr )
39
+
40
+ return tracking_data
41
+
42
+
43
+ def localize (self , location = None , latitude = None , longitude = None ,
44
+ ** kwargs ):
45
+ """Creates a :py:class:`LocalizedSingleAxisTracker`
46
+ object using this object and location data.
47
+ Must supply either location object or
48
+ latitude, longitude, and any location kwargs
49
+
50
+ Parameters
51
+ ----------
52
+ location : None or Location
53
+ latitude : None or float
54
+ longitude : None or float
55
+ **kwargs : see Location
56
+
57
+ Returns
58
+ -------
59
+ localized_system : LocalizedSingleAxisTracker
60
+ """
61
+
62
+ if location is None :
63
+ location = Location (latitude , longitude , ** kwargs )
64
+
65
+ return LocalizedSingleAxisTracker (pvsystem = self , location = location )
66
+
67
+
68
+ def get_irradiance (self , dni , ghi , dhi ,
69
+ dni_extra = None , airmass = None , model = 'haydavies' ,
70
+ ** kwargs ):
71
+ """
72
+ Uses the :func:`irradiance.total_irrad` function to calculate
73
+ the plane of array irradiance components on a tilted surface
74
+ defined by
75
+ ``self.surface_tilt``, ``self.surface_azimuth``, and
76
+ ``self.albedo``.
77
+
78
+ Parameters
79
+ ----------
80
+ solar_zenith : float or Series.
81
+ Solar zenith angle.
82
+ solar_azimuth : float or Series.
83
+ Solar azimuth angle.
84
+ dni : float or Series
85
+ Direct Normal Irradiance
86
+ ghi : float or Series
87
+ Global horizontal irradiance
88
+ dhi : float or Series
89
+ Diffuse horizontal irradiance
90
+ dni_extra : float or Series
91
+ Extraterrestrial direct normal irradiance
92
+ airmass : float or Series
93
+ Airmass
94
+ model : String
95
+ Irradiance model.
96
+
97
+ **kwargs
98
+ Passed to :func:`irradiance.total_irrad`.
99
+
100
+ Returns
101
+ -------
102
+ poa_irradiance : DataFrame
103
+ Column names are: ``total, beam, sky, ground``.
104
+ """
105
+
106
+ surface_tilt = kwargs .pop ('surface_tilt' , self .surface_tilt )
107
+ surface_azimuth = kwargs .pop ('surface_azimuth' , self .surface_azimuth )
108
+ solar_zenith = kwargs .pop ('solar_zenith' , self .solar_zenith )
109
+ solar_azimuth = kwargs .pop ('solar_azimuth' , self .solar_azimuth )
110
+
111
+ # not needed for all models, but this is easier
112
+ if dni_extra is None :
113
+ dni_extra = irradiance .extraradiation (solar_zenith .index )
114
+ dni_extra = pd .Series (dni_extra , index = solar_zenith .index )
115
+
116
+ if airmass is None :
117
+ airmass = atmosphere .relativeairmass (solar_zenith )
118
+
119
+ return irradiance .total_irrad (surface_tilt ,
120
+ surface_azimuth ,
121
+ solar_zenith ,
122
+ solar_azimuth ,
123
+ dni , ghi , dhi ,
124
+ dni_extra = dni_extra , airmass = airmass ,
125
+ model = model ,
126
+ albedo = self .albedo ,
127
+ ** kwargs )
128
+
129
+
130
+ class LocalizedSingleAxisTracker (SingleAxisTracker , Location ):
131
+ """Highly experimental."""
132
+
133
+ def __init__ (self , pvsystem = None , location = None , ** kwargs ):
134
+
135
+ # get and combine attributes from the pvsystem and/or location
136
+ # with the rest of the kwargs
137
+
138
+ if pvsystem is not None :
139
+ pv_dict = pvsystem .__dict__
140
+ else :
141
+ pv_dict = {}
142
+
143
+ if location is not None :
144
+ loc_dict = location .__dict__
145
+ else :
146
+ loc_dict = {}
147
+
148
+ new_kwargs = dict (list (pv_dict .items ()) +
149
+ list (loc_dict .items ()) +
150
+ list (kwargs .items ()))
151
+
152
+ super (LocalizedSingleAxisTracker , self ).__init__ (** new_kwargs )
36
153
37
154
38
155
def singleaxis (apparent_zenith , apparent_azimuth ,
0 commit comments