-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Calculating horizon profiles and associated shading losses #758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
691d353
first pass at horizon code in pvlib
JPalakapillyKWH 99426ba
added most of horizon shading code
JPalakapillyKWH 39302d6
wrapped up most code and added docstrings to irradiance
JPalakapillyKWH 2daa5c6
added more documentation
JPalakapillyKWH 6cb7399
reverted setup
JPalakapillyKWH df724e5
linted
JPalakapillyKWH 808af03
more lints + moved import of gmaps
JPalakapillyKWH 7573763
added scipy to setup.py and fixed bug in modelchain
JPalakapillyKWH 3421899
moved some horizon functions to tools and fixed naming. Also wrote 2 …
JPalakapillyKWH b600e16
added test_horizon.py and code restructuring
JPalakapillyKWH b0c9193
moved horizon adjustmen to isotropic. Fixed some tests
JPalakapillyKWH e6beb32
removed gmaps from horizon. Deleted remnants of horizon adjusment model
JPalakapillyKWH 10baccd
major code restructuring. much more numpy friendly now. still need to…
JPalakapillyKWH 345eaa0
updated docstrings
JPalakapillyKWH 5405d75
docstring changes
JPalakapillyKWH cc481c7
made some changes to modelchain and location due to restructuring of …
JPalakapillyKWH 15e59eb
added one more test to modelchain
JPalakapillyKWH 33c0bb8
threw code and some docs into horizon.rst
JPalakapillyKWH 18ccd1a
reverted irradiance, location and modelchain (and tests) to master
JPalakapillyKWH d1119ab
changed dip angles to elevation angles
JPalakapillyKWH 57c2035
removed horizon.rst for now
JPalakapillyKWH 00017e2
added DNI correction to horizon.py
JPalakapillyKWH a87b797
added a test case to get 100% of diff hit
JPalakapillyKWH aeb5f95
minor test fix
JPalakapillyKWH b022f9e
docstring changes and improvement to filter_points
JPalakapillyKWH d07e66f
added tests for functions added in tools.py. Some docstring changes a…
JPalakapillyKWH 2411520
minor improvements and docstring changes
JPalakapillyKWH 210fd1c
docstring changes
JPalakapillyKWH a630acc
reference update
JPalakapillyKWH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
updated docstrings
- Loading branch information
commit 345eaa062a31de054d9aa1d47ee1e62436d5c9af
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,12 +64,12 @@ def dip_calc(pt1, pt2): | |
pt1 : ndarray | ||
Nx3 array that contains lat, lon, and elev values that correspond | ||
to the origin points from which the dip angles are to be calculated. | ||
The observer points. | ||
The observer points. (will also take a 1darray with 3 elements) | ||
|
||
pt2 : ndarray | ||
Nx3 array that contains lat, lon, and elev values that correspond | ||
to the target points to which the dip angles are to be calculated. | ||
The observee points. | ||
The observee points. (will also take a 1darray with 3 elements) | ||
|
||
Returns | ||
------- | ||
|
@@ -157,9 +157,13 @@ def calculate_horizon_points(lat_grid, lon_grid, elev_grid, | |
|
||
Returns | ||
------- | ||
horizon_points: list | ||
List of (azimuth, dip_angle) tuples that define the horizon at the | ||
point at the center of the grid. | ||
bearing_deg: Nx1 ndarray | ||
The bearings from the "site" to sampled points in degrees | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bearings from the grid center to horizon points |
||
East of North. | ||
|
||
dip_angle_dip: Nx1 ndarray | ||
The dip angles that the sampled points make with the horizontal | ||
as observed from the the "site". | ||
|
||
""" | ||
assert(lat_grid.shape == lon_grid.shape == elev_grid.shape) | ||
|
@@ -189,20 +193,37 @@ def calculate_horizon_points(lat_grid, lon_grid, elev_grid, | |
def sample_using_grid(lat_grid, lon_grid, elev_grid): | ||
""" | ||
Calculates the dip angle from the site (center of the grid) | ||
to every point on the grid and uses the results as the | ||
horizon profile. | ||
to every point on the grid. | ||
|
||
Parameters | ||
---------- | ||
lat_grid : ndarray | ||
A 2d array containing latitude values that correspond to the other | ||
two input grids. | ||
|
||
lon_grid : ndarray | ||
A 2d array containing longitude values that correspond to the other | ||
two input grids. | ||
|
||
elev_grid : ndarray | ||
A 2d array containing elevation values that correspond to the other | ||
two input grids. | ||
|
||
|
||
Returns | ||
------- | ||
all_samples: Nx3 ndarray | ||
Array of lat, lon, elev points that are grid points. | ||
""" | ||
assert(lat_grid.shape == lon_grid.shape == elev_grid.shape) | ||
cwhanse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
lats = lat_grid.flatten() | ||
lons = lon_grid.flatten() | ||
elevs = elev_grid.flatten() | ||
samples = np.stack([lats, lons, elevs], axis=1) | ||
assert(samples.shape[1] == 3) | ||
# remove site from samples | ||
cwhanse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
all_samples = np.delete(samples, samples.shape[0]//2, axis=0) | ||
assert(all_samples.shape[1] == 3) | ||
return all_samples | ||
|
||
|
||
|
@@ -214,17 +235,26 @@ def sample_using_triangles(lat_grid, lon_grid, elev_grid, | |
|
||
Parameters | ||
---------- | ||
grid : ndarray | ||
Grid that contains lat lon and elev information. | ||
lat_grid : ndarray | ||
A 2d array containing latitude values that correspond to the other | ||
two input grids. | ||
|
||
lon_grid : ndarray | ||
A 2d array containing longitude values that correspond to the other | ||
two input grids. | ||
|
||
elev_grid : ndarray | ||
A 2d array containing elevation values that correspond to the other | ||
two input grids. | ||
|
||
samples_per_triangle : numeric | ||
The number of random samples to be uniformly taken from the surface | ||
of each triangle. | ||
|
||
Returns | ||
------- | ||
all_samples: list | ||
List of (azimuth, dip_angle) tuples that were sampled from the grid | ||
all_samples: Nx3 ndarray | ||
Array of [lat, lon, elev] points that were sampled from the grid. | ||
|
||
[1] http://graphics.stanford.edu/courses/cs468-08-fall/pdf/osada.pdf | ||
""" | ||
|
@@ -302,8 +332,17 @@ def sample_using_interpolator(lat_grid, lon_grid, elev_grid, num_samples): | |
|
||
Parameters | ||
---------- | ||
grid : ndarray | ||
Grid that contains lat lon and elev information. | ||
lat_grid : ndarray | ||
A 2d array containing latitude values that correspond to the other | ||
two input grids. | ||
|
||
lon_grid : ndarray | ||
A 2d array containing longitude values that correspond to the other | ||
two input grids. | ||
|
||
elev_grid : ndarray | ||
A 2d array containing elevation values that correspond to the other | ||
two input grids. | ||
|
||
num_samples : tuple | ||
A tuple containing two integers. The first is the desired number of | ||
|
@@ -314,7 +353,7 @@ def sample_using_interpolator(lat_grid, lon_grid, elev_grid, num_samples): | |
Returns | ||
8000 | ------- | |
all_samples: list | ||
List of (azimuth, dip_angle) tuples taken from the polar grid | ||
Array of [lat, lon, elev] points that were sampled using the polar grid. | ||
|
||
""" | ||
assert(lat_grid.shape == lon_grid.shape == elev_grid.shape) | ||
|
@@ -352,21 +391,24 @@ def uniformly_sample_triangle(p1, p2, p3, num_samples): | |
|
||
Parameters | ||
---------- | ||
pt1 : tuple | ||
A (lat, lon, elev) tuple that defines one vertex of the triangle. | ||
pt2 : tuple | ||
A (lat, lon, elev) tuple that defines another vertex of the triangle. | ||
pt3 : tuple | ||
A (lat, lon, elev) tuple that defines the last vertex of the triangle. | ||
pt1 : ndarray | ||
An array conaining (lat, lon, elev) values that define one vertex | ||
of the triangle. | ||
pt2 : ndarray | ||
An array conaining (lat, lon, elev) values that define another vertex | ||
of the triangle. | ||
pt3 : ndarray | ||
An array conaining (lat, lon, elev) values that define the last vertex | ||
of the triangle. | ||
|
||
num_samples : tuple | ||
The number of random samples to be uniformly taken from the surface | ||
of the triangle. | ||
|
||
Returns | ||
------- | ||
points: list | ||
List of (lat, lon, elev) tuples that lie on the surface of the | ||
points: Nx3 ndarray | ||
Array with N (lat, lon, elev) points that lie on the surface of the | ||
triangle. | ||
|
||
[1] http://graphics.stanford.edu/courses/cs468-08-fall/pdf/osada.pdf | ||
|
@@ -393,14 +435,29 @@ def filter_points(horizon_azimuths, horizon_angles, bin_size=1): | |
|
||
Parameters | ||
---------- | ||
horizon_points : list | ||
List of (azimuth, dip_angl 8000 e) tuples that define the horizon. | ||
horizon_azimuths: numeric | ||
Azimuth values for points that define the horizon profile. The ith | ||
element in this array corresponds to the ith element in horizon_angles. | ||
|
||
horizon_angle: numeric | ||
Dip angle values for points that define the horizon profile. The ith | ||
element in this array corresponds to the ith element in | ||
horizon_azimuths. | ||
|
||
bin_size : int | ||
The bin size of azimuth values. | ||
The width of the bins for the azimuth values. | ||
cwhanse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Returns | ||
------- | ||
filtered_azimuths: numeric | ||
Azimuth values for points that define the horizon profile. The ith | ||
element in this array corresponds to the ith element in | ||
filtered_angles. | ||
|
||
filtered_angles: numeric | ||
Dip angle values for points that define the horizon profile. The ith | ||
element in this array corresponds to the ith element in | ||
filtered_azimuths. | ||
|
||
""" | ||
assert(horizon_azimuths.shape[0] == horizon_angles.shape[0]) | ||
|
@@ -472,6 +529,36 @@ def calculate_dtf(horizon_azimuths, horizon_angles, | |
""" | ||
Calculate the diffuse tilt factor that is adjusted with the horizon | ||
profile. | ||
|
||
Parameters | ||
---------- | ||
horizon_azimuths: Nx1 numeric | ||
Azimuth values for points that define the horizon profile. The ith | ||
element in this array corresponds to the ith element in horizon_angles. | ||
|
||
horizon_angles: Nx1 numeric | ||
Dip angle values for points that define the horizon profile. The ith | ||
element in this array corresponds to the ith element in | ||
horizon_azimuths. | ||
|
||
surface_tilt : numeric | ||
Surface tilt angles in decimal degrees. surface_tilt must be >=0 | ||
and <=180. The tilt angle is defined as degrees from horizontal | ||
(e.g. surface facing up = 0, surface facing horizon = 90) | ||
|
||
surface_azimuth : numeric | ||
Surface azimuth angles in decimal degrees. surface_azimuth must | ||
be >=0 and <=360. The azimuth convention is defined as degrees | ||
east of north (e.g. North = 0, South=180 East = 90, West = 270). | ||
|
||
Returns | ||
------- | ||
dtf: numeric | ||
The diffuse tilt factor that can be multiplied with the diffuse | ||
horizontal irradiance (DHI) to get the incident irradiance from | ||
the sky that is adjusted for the horizon profile and the tilt of | ||
the plane. | ||
|
||
""" | ||
assert(horizon_azimuths.shape[0] == horizon_angles.shape[0]) | ||
tilt_rad = np.radians(surface_tilt) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add units, spell out latitude, longitude and elevation. Describe the sign convention for longitude.