-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenerate_ac_obs.py
56 lines (44 loc) · 1.98 KB
/
generate_ac_obs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
48
49
50
51
52
53
54
55
56
import numpy as np
import pandas as pd
from solarforecastarbiter import datamodel
from solarforecastarbiter import pvmodel
from pvlib.location import Location
# define metadata
modeling_params = datamodel.SingleAxisModelingParameters(
ac_capacity=10, dc_capacity=14, temperature_coefficient=-0.004,
dc_loss_factor=0, ac_loss_factor=0,
axis_tilt=0, axis_azimuth=0, ground_coverage_ratio=.4,
backtrack=True, max_rotation_angle=45)
metadata = datamodel.SolarPowerPlant(
name='Boulder Power Plant', latitude=40., longitude=-105.,
elevation=1650., timezone='America/Denver', provider='Sandia',
modeling_parameters=modeling_params)
times = pd.date_range(
start='20190801', end='20191001', freq='5min', closed='left')
solpos = pvmodel.calculate_solar_position(
metadata.latitude, metadata.longitude, metadata.elevation, times)
cs = pvmodel.calculate_clearsky(
metadata.latitude, metadata.longitude, metadata.elevation,
solpos['apparent_zenith'])
ac_clear = pvmodel.irradiance_to_power(
modeling_params, solpos['apparent_zenith'], solpos['azimuth'],
cs['ghi'], cs['dni'], cs['dhi'])
ac_clear_1h = ac_clear.resample('1h').mean()
ac_clear_1h = pd.DataFrame({'value': ac_clear_1h, 'quality_flag': 0})
ac_clear_1h.to_csv('boulder_clear_aug_sept.csv', index_label='timestamp')
# make it cloudy, but apply clipping
random = np.random.random(size=len(times)) + 0.5
random = random.clip(max=1)
ac = ac_clear * random
ac_1h = ac.resample('1h').mean()
ac_1h = pd.DataFrame({'value': ac_1h, 'quality_flag': 0})
ac_1h.to_csv('boulder_cloudy_aug_sept.csv', index_label='timestamp')
fx_demo = ac_1h['value'].shift(1)
fx_demo.to_csv('boulder_fx_demo_aug_sept.csv',
header=['value'], index_label='timestamp')
csi = ac / ac_clear
csi = csi.fillna(0) # account for divide by 0
ac_csi = csi.shift(12) * ac_clear
holmgren_demo = ac_csi.resample('1h').mean()
holmgren_demo.to_csv('boulder_fx_holmgren_aug_sept.csv',
header=['value'], index_label='timestamp')