-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add scale_voltage_current_power to ModelChain.pvwatts_dc #1138
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
Changes from 3 commits
d210be9
a6140ed
917737a
e078c0e
4e7f849
fb04b7e
18cb049
bdc8120
478fb34
ad2fd80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -891,7 +891,7 @@ def scale_voltage_current_power(self, data): | |
Parameters | ||
---------- | ||
data: DataFrame or tuple of DataFrame | ||
Must contain columns `'v_mp', 'v_oc', 'i_mp' ,'i_x', 'i_xx', | ||
May contain columns `'v_mp', 'v_oc', 'i_mp' ,'i_x', 'i_xx', | ||
'i_sc', 'p_mp'`. | ||
|
||
Returns | ||
|
@@ -2626,13 +2626,13 @@ def i_from_v(resistance_shunt, resistance_series, nNsVth, voltage, | |
|
||
def scale_voltage_current_power(data, voltage=1, current=1): | ||
""" | ||
Scales the voltage, current, and power of the DataFrames | ||
returned by :py:func:`singlediode` and :py:func:`sapm`. | ||
Scales the voltage, current, and power in data by the voltage | ||
and current factors. | ||
|
||
Parameters | ||
---------- | ||
data: DataFrame | ||
Must contain columns `'v_mp', 'v_oc', 'i_mp' ,'i_x', 'i_xx', | ||
May contain columns `'v_mp', 'v_oc', 'i_mp' ,'i_x', 'i_xx', | ||
'i_sc', 'p_mp'`. | ||
voltage: numeric, default 1 | ||
The amount by which to multiply the voltages. | ||
|
@@ -2648,13 +2648,16 @@ def scale_voltage_current_power(data, voltage=1, current=1): | |
|
||
# as written, only works with a DataFrame | ||
# could make it work with a dict, but it would be more verbose | ||
voltage_keys = ['v_mp', 'v_oc'] | ||
current_keys = ['i_mp', 'i_x', 'i_xx', 'i_sc'] | ||
power_keys = ['p_mp'] | ||
data = data.copy() | ||
voltages = ['v_mp', 'v_oc'] | ||
currents = ['i_mp', 'i_x', 'i_xx', 'i_sc'] | ||
voltages = voltage_keys and data.columns | ||
currents = current_keys and data.columns | ||
powers = power_keys and data.columns | ||
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. I was thinking of something like this: In [28]: voltage = 5
In [29]: current = 10
In [30]: df = pd.DataFrame([[1, 1, 1]], columns=['p_mp', 'v_mp', 'i_mp'])
In [31]: df
Out[31]:
p_mp v_mp i_mp
0 1 1 1
In [32]: voltage_keys = ['v_mp', 'v_oc']
...: current_keys = ['i_mp', 'i_x', 'i_xx', 'i_sc']
...: power_keys = ['p_mp']
In [33]: df.filter(voltage_keys, axis=1) * voltage
Out[33]:
v_mp
0 5
In [34]: df.filter(current_keys, axis=1) * current
Out[34]:
i_mp
0 10 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.
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. I don't know how to scale a power other than 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 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. I was still in the mindset that we could provide a DataFrame with In [42]: df = pd.DataFrame([[1, 1, 1]], columns=['p_mp', 'v_mp', 'i_mp'])
In [43]: voltage_df = df.filter(voltage_keys, axis=1) * voltage
In [44]: current_df = df.filter(current_keys, axis=1) * current
In [45]: power_df = df.filter(power_keys, axis=1) * voltage * current
In [49]: concat_df = pd.concat([voltage_df, current_df, power_df], axis=1)
In [50]: concat_df = concat_df[df.columns]
In [51]: concat_df
Out[51]:
p_mp v_mp i_mp
0 50 5 10 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. One issue with the temporary DataFrame: when converting back to Series, the column label 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. no concern. pandas |
||
data[voltages] *= voltage | ||
data[currents] *= current | ||
data['p_mp'] *= voltage * current | ||
|
||
data[powers] *= voltage * current | ||
return data | ||
|
||
|
||
|
@@ -2675,20 +2678,20 @@ def pvwatts_dc(g_poa_effective, temp_cell, pdc0, gamma_pdc, temp_ref=25.): | |
Parameters | ||
---------- | ||
g_poa_effective: numeric | ||
Irradiance transmitted to the PV cells in units of W/m**2. To be | ||
Irradiance transmitted to the PV cells. To be | ||
fully consistent with PVWatts, the user must have already | ||
applied angle of incidence losses, but not soiling, spectral, | ||
etc. | ||
etc. [W/m^2] | ||
temp_cell: numeric | ||
Cell temperature in degrees C. | ||
Cell temperature [C]. | ||
pdc0: numeric | ||
Power of the modules at 1000 W/m2 and cell reference temperature. | ||
Power of the modules at 1000 W/m^2 and cell reference temperature. [W] | ||
gamma_pdc: numeric | ||
The temperature coefficient in units of 1/C. Typically -0.002 to | ||
-0.005 per degree C. | ||
The temperature coefficient of power. Typically -0.002 to | ||
-0.005 per degree C. [1/C] | ||
temp_ref: numeric, default 25.0 | ||
Cell reference temperature. PVWatts defines it to be 25 C and | ||
is included here for flexibility. | ||
is included here for flexibility. [C] | ||
|
||
Returns | ||
------- | ||
|
Uh oh!
There was an error while loading. Please reload this page.