get clearsky and solar position data
This commit is contained in:
		
							parent
							
								
									0a4d980f4f
								
							
						
					
					
						commit
						a086431c46
					
				| @ -12,6 +12,15 @@ from Utilities.Processes import ( | |||||||
| 
 | 
 | ||||||
| logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||||
| 
 | 
 | ||||||
|  | def get_location(c): | ||||||
|  |     location = pvlib.location.Location( | ||||||
|  |         latitude=c["environment"]["location"]["latitude"], | ||||||
|  |         longitude=c["environment"]["location"]["longitude"], | ||||||
|  |         tz=c["simulation_date_time"]["tz"], | ||||||
|  |     ) | ||||||
|  |      | ||||||
|  |     return location | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def define_grid_layout(c): | def define_grid_layout(c): | ||||||
|     # get number of panels required |     # get number of panels required | ||||||
| @ -36,14 +45,14 @@ def define_grid_layout(c): | |||||||
|     max__panels_per_row = np.floor( |     max__panels_per_row = np.floor( | ||||||
|         ( |         ( | ||||||
|             c["environment"]["roof"]["dimensions"]["width"] |             c["environment"]["roof"]["dimensions"]["width"] | ||||||
|             - 2 * c["array"]["edge_setback"] |             - (2 * c["array"]["edge_setback"] + c["panel"]["dimensions"]["width"]) | ||||||
|         ) |         ) | ||||||
|         / c["panel"]["dimensions"]["width"] |         / c["panel"]["dimensions"]["width"] | ||||||
|     ) |     ) | ||||||
|     max_number_of_rows = np.floor( |     max_number_of_rows = np.floor( | ||||||
|         ( |         ( | ||||||
|             c["environment"]["roof"]["dimensions"]["length"] |             c["environment"]["roof"]["dimensions"]["length"] | ||||||
|             - 2 * c["array"]["edge_setback"] |             - (2 * c["array"]["edge_setback"] + c["panel"]["dimensions"]["length"]) | ||||||
|         ) |         ) | ||||||
|         / pitch |         / pitch | ||||||
|     ) |     ) | ||||||
| @ -77,7 +86,7 @@ def define_grid_layout(c): | |||||||
|             if counter < no_of_panels: |             if counter < no_of_panels: | ||||||
|                 x.append(i * c["panel"]["dimensions"]["width"]) |                 x.append(i * c["panel"]["dimensions"]["width"]) | ||||||
|                 y.append( |                 y.append( | ||||||
|                     j * (c["panel"]["dimensions"]["thickness"] + c["array"]["spacing"]) |                     j * pitch | ||||||
|                 ) |                 ) | ||||||
|                 z.append(0) |                 z.append(0) | ||||||
|                 counter += 1 |                 counter += 1 | ||||||
| @ -101,28 +110,21 @@ def get_solar_data(c): | |||||||
|     """ |     """ | ||||||
|     Function to get solar position from PVLib |     Function to get solar position from PVLib | ||||||
|     """ |     """ | ||||||
|     latitude = c["environment"]["location"]["latitude"] |     location = get_location(c) | ||||||
|     longitude = c["environment"]["location"]["longitude"] |  | ||||||
|     tz = c["simulation_date_time"]["tz"] |  | ||||||
| 
 | 
 | ||||||
|     times = pd.date_range( |     times = pd.date_range( | ||||||
|         c["simulation_date_time"]["start"], |         c["simulation_date_time"]["start"], | ||||||
|         c["simulation_date_time"]["end"], |         c["simulation_date_time"]["end"], | ||||||
|         freq="15min", |         freq="15min", | ||||||
|         tz=tz, |         tz=location.tz, | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     # Get solar position data using PVLib |     # Get solar position data using PVLib | ||||||
|     solar_positions = pvlib.solarposition.get_solarposition(times, latitude, longitude) |     solar_positions = location.get_solarposition(times) | ||||||
|  |     clearsky_data = location.get_clearsky(times) | ||||||
| 
 | 
 | ||||||
|     return solar_positions |     return solar_positions, clearsky_data | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def calculate_shading(c, coordinates, solar_positions): | def calculate_shading(c, coordinates, solar_positions): | ||||||
|     # calculate shading row by row |      | ||||||
|     logger.info("Calculating shading for each row of panels") |  | ||||||
|     row_coordinates = np.unique(coordinates["y"]) |  | ||||||
|     for row in row_coordinates: |  | ||||||
|         # get number of panels in row for width of row |  | ||||||
|         panels_in_row = coordinates[coordinates["y"] == row].shape[0] |  | ||||||
|         row_width = panels_in_row * c["panel"]["dimensions"]["width"] |  | ||||||
| @ -3,7 +3,7 @@ array: | |||||||
|   spacing: 1.5 # spacing between adjacent panel rows in m |   spacing: 1.5 # spacing between adjacent panel rows in m | ||||||
|   edge_setback: 1.8 # distance from the edge of the roof to the array |   edge_setback: 1.8 # distance from the edge of the roof to the array | ||||||
|   front_face_azimuth: 90 # 90=east, 180=south, 270=west |   front_face_azimuth: 90 # 90=east, 180=south, 270=west | ||||||
|   tilt: 90 |   tilt: 90 # just 0 and 90 are supported for now | ||||||
|   slope: 0 # degrees from horizontal (+ve means shaded row is higher than the row in front) |   slope: 0 # degrees from horizontal (+ve means shaded row is higher than the row in front) | ||||||
| 
 | 
 | ||||||
| simulation_date_time: | simulation_date_time: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user