Skip to content

Commit

Permalink
Merge branch 'development' into Kempe_Gap_Calc
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-springer committed May 6, 2024
2 parents ebdf490 + dbde447 commit cfba3b2
Show file tree
Hide file tree
Showing 242 changed files with 67,371 additions and 3,947 deletions.
19 changes: 19 additions & 0 deletions docs/source/whatsnew/releases/v0.3.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
v0.3.2 (2024-XX-XX)
=======================

Enhancements
------------

Documentation
-------------
* Renamted pvdeg_tutorials folder to tutorials_and_tools, and added more tutorials
to be run easily in google collab.
* Jupyter Journals now have information regarding the version of the programs used near
the beginning, to simplify debugging and user support.

Contributors
~~~~~~~~~~~~
* Martin Springer (:ghuser:`martin-springer`)
* Mike Kempe (:ghuser:`MDKempe`)
* Silvana Ovaitt (:ghuser:`shirubana`)
* Tobin Ford (:ghuser:`tobin-ford`)
13 changes: 9 additions & 4 deletions pvdeg/geospatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ def calc_block(weather_ds_block, future_meta_df, func, func_kwargs):
Dataset with results for a block of gids.
"""

res = weather_ds_block.groupby("gid").map(
res = weather_ds_block.groupby("gid", squeeze=False).map(
lambda ds_gid: calc_gid(
ds_gid=ds_gid,
meta_gid=future_meta_df.loc[ds_gid["gid"].values].to_dict(),
ds_gid=ds_gid.squeeze(),
meta_gid=future_meta_df.loc[ds_gid["gid"].values[0]].to_dict(),
func=func,
**func_kwargs,
)
Expand Down Expand Up @@ -179,9 +179,14 @@ def analysis(weather_ds, meta_df, func, template=None, **func_kwargs):
# lons = stacked.longitude.values.flatten()
stacked = stacked.drop(["gid"])
# stacked = stacked.drop_vars(['latitude', 'longitude'])
stacked.coords["gid"] = pd.MultiIndex.from_arrays(
# stacked.coords["gid"] = pd.MultiIndex.from_arrays(
# [meta_df["latitude"], meta_df["longitude"]], names=["latitude", "longitude"]
# )
mindex_obj = pd.MultiIndex.from_arrays(
[meta_df["latitude"], meta_df["longitude"]], names=["latitude", "longitude"]
)
mindex_coords = xr.Coordinates.from_pandas_multiindex(mindex_obj, "gid")
stacked = stacked.assign_coords(mindex_coords)

stacked = stacked.drop_duplicates("gid")
res = stacked.unstack("gid") # , sparse=True
Expand Down
2 changes: 1 addition & 1 deletion pvdeg/humidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def back_encap(
Csat = _csat(temp_module=temp_module, So=So, Eas=Eas)
Ceq = _ceq(Csat=Csat, rh_SurfaceOutside=rh_surface)

start = Ceq[0]
start = Ceq.iloc[0]

# Need to convert these series to numpy arrays for numba function
temp_module_numba = temp_module.to_numpy()
Expand Down
22 changes: 17 additions & 5 deletions pvdeg/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,24 @@ def poa_irradiance(

# TODO: change for handling HSAT tracking passed or requested
if tilt is None:
tilt = float(meta["latitude"])
try:
tilt = float(meta["tilt"])
except:
tilt = float(meta["latitude"])
print(
f"The array tilt angle was not provided, therefore the latitude tilt of {tilt:.1f} was used."
)
if azimuth is None: # Sets the default orientation to equator facing.
if float(meta["latitude"]) < 0:
azimuth = 0
else:
azimuth = 180
try:
azimuth = float(meta["azimuth"])
except:
if float(meta["latitude"]) < 0:
azimuth = 0
else:
azimuth = 180
print(
f"The array azimuth was not provided, therefore an azimuth of {azimuth:.1f} was used."
)

if sol_position is None:
sol_position = solar_position(weather_df, meta)
Expand Down
73 changes: 32 additions & 41 deletions pvdeg/standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def eff_gap_parameters(
temp_model : str, optional
Options: 'sapm'. 'pvsyst' and 'faiman' and others from PVlib.
Performs the calculation for the cell temperature.
conf_0 : str, optional
conf_0 : str, optional
Model for the high temperature module on the exponential decay curve.
Default: 'insulated_back_glass_polymer'
conf_inf : str, optional
Expand Down Expand Up @@ -96,24 +96,16 @@ def eff_gap_parameters(
elif weather_df is None:
weather_df, meta = weather.get(**weather_kwarg)

if tilt == None:
try:
tilt = meta["tilt"]
except:
tilt = meta["latitude"]
print("The array tilt angle was not provided, therfore the latitude tilt of" & "%.1f" % tilt & "was used.")

if azimuth == None: # Sets the default orientation to equator facing.
try:
azimuth = meta["azimuth"]
except:
if float(meta["latitude"]) < 0:
azimuth = 0
else:
azimuth = 180
print("The array azimuth was not provided, therfore an azimuth of" & "%.1f" % azimuth & "was used.")
if "wind_height" not in meta.keys(): #if the anenometer hight is not give, this will make it just use the unadjusted wind speed as given.
wind_factor = 1
# if tilt == None:
# tilt = meta["latitude"]

# if azimuth == None: # Sets the default orientation to equator facing. MSP: Defaults are already set in temperature.py
# if float(meta["latitude"]) < 0:
# azimuth = 0
# else:
# azimuth = 180
# if "wind_height" not in meta.keys():
# wind_factor = 1

solar_position = spectral.solar_position(weather_df, meta)
poa = spectral.poa_irradiance(
Expand Down Expand Up @@ -168,10 +160,10 @@ def eff_gap(T_0, T_inf, T_measured, T_ambient, poa, x_0=6.5, poa_min=400, t_amb_
Thermal decay constant [cm], [Kempe, PVSC Proceedings 2023].
According to edition 2 of IEC TS 63126 a value of 6.5 cm is recommended.
poa_min : float
The minimum value for which the data will be used, [W/m²].
The minimum value for which the data will be used, [W/m²].
400 W/m² is recommended.
t_amb_min : float
The minimum ambient temperature for which the calculation will be made, [°C].
The minimum ambient temperature for which the calculation will be made, [°C].
A value of 0 °C is recommended to avoid data where snow might be present.
Returns
Expand Down Expand Up @@ -212,7 +204,7 @@ def standoff(
weather_df=None,
meta=None,
weather_kwarg=None,
tilt=0,
tilt=None,
azimuth=None,
sky_model="isotropic",
temp_model="sapm",
Expand Down Expand Up @@ -283,13 +275,13 @@ def standoff(
to IEC TS 63126, PVSC Proceedings 2023
"""

if azimuth == None: # Sets the default orientation to equator facing.
if float(meta["latitude"]) < 0:
azimuth = 0
else:
azimuth = 180
if "wind_height" not in meta.keys():
wind_factor = 1
# if azimuth == None: # Sets the default orientation to equator facing.
# if float(meta["latitude"]) < 0:
# azimuth = 0
# else:
# azimuth = 180
# if "wind_height" not in meta.keys():
# wind_factor = 1
parameters = ["temp_air", "wind_speed", "dhi", "ghi", "dni"]

if isinstance(weather_df, dd.DataFrame):
Expand Down Expand Up @@ -331,9 +323,8 @@ def standoff(
try:
x = -x_0 * np.log(1 - (T98_0 - T98) / (T98_0 - T98_inf))
except RuntimeWarning as e:
x = (
np.nan
) # results if the specified T₉₈ is cooler than an open_rack temperature
x = np.nan
# results if the specified T₉₈ is cooler than an open_rack temperature
if x < 0:
x = 0

Expand Down Expand Up @@ -508,16 +499,16 @@ def T98_estimate(
"""

if tilt == None:
tilt = meta["latitude"]
# if tilt == None:
# tilt = meta["latitude"]

if azimuth == None: # Sets the default orientation to equator facing.
if float(meta["latitude"]) < 0:
azimuth = 0
else:
azimuth = 180
if "wind_height" not in meta.keys():
wind_factor = 1
# if azimuth == None: # Sets the default orientation to equator facing.
# if float(meta["latitude"]) < 0:
# azimuth = 0
# else:
# azimuth = 180
# if "wind_height" not in meta.keys():
# wind_factor = 1
parameters = ["temp_air", "wind_speed", "dhi", "ghi", "dni"]

if isinstance(weather_df, dd.DataFrame):
Expand Down
14 changes: 8 additions & 6 deletions pvdeg/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def read(file_in, file_type, map_variables=True, **kwargs):
if weather_df.index.tzinfo is None:
tz = "Etc/GMT%+d" % -meta["tz"]
weather_df = weather_df.tz_localize(tz)

return weather_df, meta


Expand Down Expand Up @@ -196,9 +196,11 @@ def csv_read(filename):
metadata_values = file1.readline().split(",")
metadata_values[-1] = metadata_values[-1].strip() # strip trailing newline
meta = dict(zip(metadata_fields, metadata_values))
for key in meta: #converts everything to a float that is possible to convert to a float
try:
meta[key]=float(meta[key])
for (
key
) in meta: # converts everything to a float that is possible to convert to a float
try:
meta[key] = float(meta[key])
except:
pass
# get the column headers
Expand Down Expand Up @@ -462,8 +464,8 @@ def ini_h5_geospatial(fps):
ds = xr.merge(dss)
ds = xr.decode_cf(ds)

# Rechunk time axis - TODO: fix this
# ds = ds.chunk(chunks={"time": -1, "gid": ds.chunks["gid"]})
# Rechunk time axis
ds = ds.chunk(chunks={"time": -1, "gid": ds.chunks["gid"]})

weather_ds = ds

Expand Down
22 changes: 0 additions & 22 deletions pvdeg_tutorials/_toc.yml

This file was deleted.

310 changes: 0 additions & 310 deletions pvdeg_tutorials/tutorials/5 - Weather Database Access.ipynb

This file was deleted.

Loading

0 comments on commit cfba3b2

Please sign in to comment.