Skip to content

Commit d2cdf0e

Browse files
author
Hugh Cutcher
committed
feat: add more noise to rooftop example
1 parent 6b3af85 commit d2cdf0e

File tree

2 files changed

+785
-786
lines changed

2 files changed

+785
-786
lines changed

docs/notebooks/3.4 Rooftop PV Tuning.ipynb

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@
3636
"id": "bba9a869-8fbe-450e-8a16-9cff24613e73",
3737
"metadata": {},
3838
"outputs": [],
39-
"source": [
40-
"# !pip install solcast plotly\n",
41-
"# !pip install -U kaleido"
42-
]
39+
"source": "# !pip install solcast plotly kaleido"
4340
},
4441
{
4542
"cell_type": "code",
@@ -151,7 +148,7 @@
151148
" api_key: str,\n",
152149
"):\n",
153150
" pre_tuned = get_rooftop_data(\n",
154-
" latitude, longitude, site_parameter_estimates, months, period, api_key\n",
151+
" latitude, longitude, site_parameter_estimates, months, PERIOD, api_key\n",
155152
" ).tz_convert(None)\n",
156153
" pre_tuned.columns = [\"solcast_pretuned_estimate\"]\n",
157154
" return pre_tuned\n",
@@ -202,7 +199,7 @@
202199
" site_parameter_estimates[\"capacity\"],\n",
203200
" args=(\n",
204201
" est[\"pv_power_rooftop\"].loc[meas.index].values,\n",
205-
" meas[power_column_name].values,\n",
202+
" meas[PV_POWER_COLUMN].values,\n",
206203
" ),\n",
207204
" )\n",
208205
" capacity_est = np.round(res.x[0] * site_parameter_estimates[\"capacity\"], 0)\n",
@@ -346,7 +343,9 @@
346343
"id": "b881add6-c456-4955-96ea-3104af0a22a0",
347344
"metadata": {},
348345
"source": [
349-
"## 1a: Input user Data"
346+
"## 1a: Input user Data\n",
347+
"\n",
348+
"Replace the variables in the following cell with your own values"
350349
]
351350
},
352351
{
@@ -356,28 +355,28 @@
356355
"metadata": {},
357356
"outputs": [],
358357
"source": [
359-
"api_key = os.environ[\"API_KEY\"]\n",
358+
"API_KEY = os.environ[\"API_KEY\"]\n",
360359
"measurement_data = pd.read_csv(\n",
361360
" \"https://solcast.github.io/solcast-api-python-sdk/notebooks/data/3.4_sample_measurements.csv\",\n",
362361
" index_col=[0],\n",
363362
" parse_dates=True,\n",
364363
") # Make sure this is in kW\n",
365-
"power_column_name = (\n",
364+
"PV_POWER_COLUMN = (\n",
366365
" \"pv_power_rooftop\" # Set this to the name of the power column in measurement_data\n",
367366
")\n",
368-
"longitude = 151.215297\n",
369-
"latitude = -33.856784\n",
370-
"period = \"PT60M\"\n",
367+
"LONGITUDE = 151.215297\n",
368+
"LATITUDE = -33.856784\n",
369+
"PERIOD = \"PT60M\"\n",
371370
"\n",
372371
"# Set this to true if User data is in local timezone and not UTC\n",
373-
"local_timezone = False\n",
372+
"LOCAL_TIMEZONE = False\n",
374373
"\n",
375374
"# Optional inputs. Only supply these if you have a high level of confidence they are close to the true value.\n",
376-
"user_input_azi = None\n",
377-
"user_input_tilt = None\n",
375+
"USER_INPUT_AZI = None\n",
376+
"USER_INPUT_TILT = None\n",
378377
"\n",
379378
"# Save output to csv?\n",
380-
"save_to_csv = False"
379+
"SAVE_TO_CSV = False"
381380
]
382381
},
383382
{
@@ -397,10 +396,10 @@
397396
"source": [
398397
"# setup estimates\n",
399398
"site_parameter_estimates = {}\n",
400-
"if user_input_azi is not None:\n",
401-
" site_parameter_estimates[\"azimuth\"] = user_input_azi\n",
402-
"if user_input_tilt is not None:\n",
403-
" site_parameter_estimates[\"tilt\"] = user_input_tilt"
399+
"if USER_INPUT_AZI is not None:\n",
400+
" site_parameter_estimates[\"azimuth\"] = USER_INPUT_AZI\n",
401+
"if USER_INPUT_TILT is not None:\n",
402+
" site_parameter_estimates[\"tilt\"] = USER_INPUT_TILT"
404403
]
405404
},
406405
{
@@ -419,9 +418,9 @@
419418
],
420419
"source": [
421420
"# align to UTC if required\n",
422-
"utc_offset = longitude // 15\n",
421+
"utc_offset = LONGITUDE // 15\n",
423422
"utc_offset = pd.Timedelta(f\"{utc_offset}h\")\n",
424-
"if local_timezone:\n",
423+
"if LOCAL_TIMEZONE:\n",
425424
" measurement_data.index = measurement_data.index - utc_offset\n",
426425
"print(\n",
427426
" \"We estimate your UTC offset is \", utc_offset, \". You can update this if incorrect.\"\n",
@@ -450,13 +449,13 @@
450449
"source": [
451450
"# required for all grid searches\n",
452451
"KWARGS = {\n",
453-
" \"latitude\": latitude,\n",
454-
" \"longitude\": longitude,\n",
452+
" \"latitude\": LATITUDE,\n",
453+
" \"longitude\": LONGITUDE,\n",
455454
" \"meas\": measurement_data,\n",
456455
" \"months\": months,\n",
457456
" \"site_parameter_estimates\": site_parameter_estimates,\n",
458-
" \"period\": period,\n",
459-
" \"api_key\": api_key,\n",
457+
" \"period\": PERIOD,\n",
458+
" \"api_key\": API_KEY,\n",
460459
"}"
461460
]
462461
},
@@ -543,11 +542,11 @@
543542
],
544543
"source": [
545544
"# take an initial capacity estimate and show an initial estimation with no tuning\n",
546-
"capacity_initial_estimate = measurement_data[power_column_name].max()\n",
545+
"capacity_initial_estimate = measurement_data[PV_POWER_COLUMN].max()\n",
547546
"site_parameter_estimates[\"capacity\"] = capacity_initial_estimate\n",
548547
"\n",
549548
"pre_tuned = get_solcast_untuned(\n",
550-
" latitude, longitude, site_parameter_estimates, months, api_key\n",
549+
" LATITUDE, LONGITUDE, site_parameter_estimates, months, API_KEY\n",
551550
")\n",
552551
"display_evaluation_plots(measurement_data, pre_tuned)"
553552
]
@@ -767,15 +766,15 @@
767766
}
768767
],
769768
"source": [
770-
"if user_input_azi is None:\n",
769+
"if USER_INPUT_AZI is None:\n",
771770
" # Use these defaults or update the range if you prefer\n",
772771
" initial_azi_min = -180\n",
773772
" initial_azi_max = 180\n",
774773
" azi_delta = 45\n",
775774
"else:\n",
776775
" azi_delta = 45\n",
777-
" initial_azi_min = user_input_azi - azi_delta\n",
778-
" initial_azi_max = user_input_azi + azi_delta\n",
776+
" initial_azi_min = USER_INPUT_AZI - azi_delta\n",
777+
" initial_azi_max = USER_INPUT_AZI + azi_delta\n",
779778
"\n",
780779
"# Initial wide search\n",
781780
"initial_azimuth_search = np.arange(\n",
@@ -962,15 +961,15 @@
962961
}
963962
],
964963
"source": [
965-
"if user_input_tilt is None:\n",
964+
"if USER_INPUT_TILT is None:\n",
966965
" # Use these defaults or update the range if you prefer\n",
967966
" initial_tilt_min = 0\n",
968967
" initial_tilt_max = 90\n",
969968
" tilt_delta = 10\n",
970969
"else:\n",
971970
" tilt_delta = 10\n",
972-
" initial_tilt_min = user_input_tilt - tilt_delta\n",
973-
" initial_tilt_max = user_input_tilt + tilt_delta\n",
971+
" initial_tilt_min = USER_INPUT_TILT - tilt_delta\n",
972+
" initial_tilt_max = USER_INPUT_TILT + tilt_delta\n",
974973
"\n",
975974
"\n",
976975
"# Initial wide search\n",
@@ -1189,23 +1188,23 @@
11891188
],
11901189
"source": [
11911190
"est_final = get_rooftop_data(\n",
1192-
" latitude, longitude, site_parameter_estimates, months, period, api_key\n",
1191+
" LATITUDE, LONGITUDE, site_parameter_estimates, months, PERIOD, API_KEY\n",
11931192
").tz_convert(None)[\"pv_power_rooftop\"]\n",
11941193
"\n",
11951194
"est_df = pd.DataFrame(\n",
11961195
" data={\n",
1197-
" \"meas\": measurement_data[power_column_name],\n",
1196+
" \"meas\": measurement_data[PV_POWER_COLUMN],\n",
11981197
" \"solcast_estimate\": est_final,\n",
11991198
" \"solcast_pre_tuned\": pre_tuned[\"solcast_pretuned_estimate\"],\n",
12001199
" },\n",
12011200
" index=measurement_data.index,\n",
12021201
")\n",
1203-
"if save_to_csv:\n",
1202+
"if SAVE_TO_CSV:\n",
12041203
" est_df.to_csv(\"Solcast_Tuned_Rooftop_PV.csv\")\n",
12051204
"\n",
12061205
"print(\"Tuned Parameter Estimates:\", site_parameter_estimates)\n",
12071206
"\n",
1208-
"results = calculate_stats(measurement_data[power_column_name], est_final, df=True)\n",
1207+
"results = calculate_stats(measurement_data[PV_POWER_COLUMN], est_final, df=True)\n",
12091208
"display_evaluation_plots(meas=measurement_data, est=est_final, untuned=pre_tuned)"
12101209
]
12111210
}

0 commit comments

Comments
 (0)