Skip to content

Commit

Permalink
Merge branch 'faster_combined_update' into combined_update
Browse files Browse the repository at this point in the history
Only merging clearsky_temperature
  • Loading branch information
Michael Deceglie committed Oct 1, 2017
2 parents c503be5 + 462a54c commit 5ed3a10
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rdtools/clearsky_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import math
import pandas as pd
import pkg_resources
import numpy as np


def get_clearsky_tamb(times, latitude, longitude, window_size=40, gauss_std=20):
Expand Down Expand Up @@ -69,12 +70,12 @@ def get_clearsky_tamb(times, latitude, longitude, window_size=40, gauss_std=20):

def solar_noon_offset(utc_offset):
return longitude / 180.0 * 12.0 - utc_offset
df['solar_noon_offset'] = [solar_noon_offset(utc_offset) for utc_offset in utc_offsets]

df['solar_noon_offset'] = solar_noon_offset(np.array(utc_offsets))

df['hour_of_day'] = df.index.hour + df.index.minute / 60.0
df['Clear Sky Temperature (C)'] = df.apply(lambda x:
_get_temperature(x['hour_of_day'], x['night'],
x['day'], x['solar_noon_offset']), axis=1)
df['Clear Sky Temperature (C)'] = _get_temperature(df['hour_of_day'].values, df['night'].values,\
df['day'].values, df['solar_noon_offset'].values)
return df['Clear Sky Temperature (C)']


Expand Down Expand Up @@ -104,6 +105,6 @@ def _get_temperature(hour_of_day, night_temp, day_temp, solar_noon_offset):
temp_scaler = 0.7
t_diff = day_temp - night_temp
t_ave = (day_temp + night_temp) / 2.0
v = math.cos((hour_of_day + hour_offset) / 24.0 * 2.0 * math.pi)
v = np.cos((hour_of_day + hour_offset) / 24.0 * 2.0 * np.pi)
t = t_diff * 0.5 * v * temp_scaler + t_ave
return t

0 comments on commit 5ed3a10

Please sign in to comment.