Skip to content

Commit

Permalink
updated changes from PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-g-long committed Sep 12, 2023
1 parent 93be5d5 commit 988b108
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
14 changes: 7 additions & 7 deletions alternative_solar_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AlternativeSolarProfiles:
num_trials: Number of solar profiles to create
length_trials: Length of solar profiles in days
length_trials: Length of solar profiles in hours
start_year: Start year for solar data download
Expand Down Expand Up @@ -608,7 +608,7 @@ def create_trial_data(self, start_datetimes=None, validate=True):
self.state_prob_daily: dataframe holding the probabilities of transition to a
given daily state, given the from-state.
self.num_trials: number of solar profiles to generate
self.length_trials: length of profiles in days
self.length_trials: length of profiles in hours
outputs:
self.solar_trials: dict containing a dataframe for each trial
Expand Down Expand Up @@ -717,7 +717,7 @@ def generate_trial_date_ranges(self, start_datetimes=None):
start_datetimes: list of datetime objects. If set as None (default), these are
generated randomly.
self.nrel_data_df: historical solar data
self.length_trials: number of days in each trial
self.length_trials: number of hours in each trial
self.num_trials: number of trials to generate
outputs
Expand All @@ -727,12 +727,12 @@ def generate_trial_date_ranges(self, start_datetimes=None):

# Randomly generate start times for each trial
if start_datetimes is None:
start_datetimes = self.nrel_data_df.iloc[:-self.length_trials * 24].sample(
start_datetimes = self.nrel_data_df.iloc[:-self.length_trials].sample(
self.num_trials)['datetime'].values

# Create a date range object for each start datetime
date_ranges = [pd.date_range(start=start_date,
periods=self.length_trials * 24,
periods=self.length_trials,
freq='H')
for start_date in start_datetimes]

Expand Down Expand Up @@ -805,7 +805,7 @@ def generate_random_state_daily(self, date_range):
inputs:
date_range: datetimeindex object for the trial
self.length_trials: length of profiles in days
self.length_trials: length of profiles in hours
self.state_prob_daily_grouped: dataframe holding the probabilities of transition
to a given daily state, given the from-state, grouped by month and from-state.
self.simple_prob_daily_grouped: dataframe holding the probabilities of
Expand Down Expand Up @@ -979,7 +979,7 @@ def generate_random_state_hourly(self, hourly_date_range, night_states,
night_states: list containing a Boolean indicating if it is night-time for each
hour in the day
current_state: array with hourly state from previous hour
self.length_trials: length of profiles in days
self.length_trials: length of profiles in hours
self.nrel_data_df: historical solar data
self.state_prob_hourly_grouped: dataframe holding the probabilities of transition
to a given daily state, given the from-state, grouped by month, hour,
Expand Down
4 changes: 2 additions & 2 deletions generate_solar_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SolarProfileGenerator:
num_trials: Number of solar profiles to create
length_trials: Length of solar profiles in days
length_trials: Length of solar profiles in hours
pv_racking: Type of pv racking (options: [roof, ground, carport])
Default = ground
Expand Down Expand Up @@ -545,7 +545,7 @@ def get_power_profiles_from_upload(self, annual_production, temperature=None,

# Create a date range object for each start datetime
date_ranges = [pd.date_range(start=start_date,
periods=self.length_trials * 24,
periods=self.length_trials,
freq='H')
for start_date in start_datetimes]

Expand Down
4 changes: 3 additions & 1 deletion main_files/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def run_mcor(input_dict):
# Go back to main working directory
os.chdir('..')

days_to_hours = 24

# Define parameters and populate dict for run_mcor()
input_dict = {}

Expand All @@ -127,7 +129,7 @@ def run_mcor(input_dict):
input_dict["system_inputs"]["timezone"] = 'US/Pacific'
input_dict["system_inputs"]["altitude"] = 0
input_dict["system_inputs"]["num_trials"] = 200
input_dict["system_inputs"]["length_trials"] = 14
input_dict["system_inputs"]["length_trials"] = 14 * days_to_hours

# PV dictionary
input_dict["pv_inputs"] = {}
Expand Down
2 changes: 2 additions & 0 deletions tests/system_tests/parameter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ def test_lat_long_changes(self):
# Check that for different latitude and longitude, pv and battery sizes are different
self.latitude = self.latitude + 5
self.longitude = self.longitude - 3
self.length_trials = self.length_trials * 24
optim = self.run_main(generate_solar_data=True, generate_solar_profiles=True)
self.compare_series('pv_capacity', 'not_equal', optim)
self.compare_series('battery_capacity', 'not_equal', optim)
Expand All @@ -565,6 +566,7 @@ def test_solar_source(self):
# error
self.latitude = -18.04
self.longitude = 178.04
self.length_trials = self.length_trials * 24
self.timezone = 'Pacific/Fiji'
self.solar_source = 'himawari'
self.solar_data_start_year = 2016
Expand Down
10 changes: 5 additions & 5 deletions tests/unit_tests/test_asp.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def setUp(self) -> None:
self.asp = AlternativeSolarProfiles(latitude=46.34,
longitude=-119.28,
num_trials=10,
length_trials=3)
length_trials=3 * 24)

def tearDown(self) -> None:
"""Runs after each test"""
Expand Down Expand Up @@ -375,7 +375,7 @@ def test_generate_trial_date_ranges(self):

# for each date range assert they have the appropriate number of
# datetime objects and that they are that many hours apart
range_length = self.asp.length_trials * 24
range_length = self.asp.length_trials
for date_range in test_ranges:
self.assertEqual(len(date_range), range_length)
first_hour = date_range[0]
Expand Down Expand Up @@ -466,7 +466,7 @@ def test_generate_random_state_daily(self):
self.load_daily_grouped_probabilities()

# create date_range to generate random states for
range_length = self.asp.length_trials * 24
range_length = self.asp.length_trials
date_range = pd.date_range(start='2009-02-09 15:00:00', periods=range_length,
freq='H')

Expand Down Expand Up @@ -605,7 +605,7 @@ def test_compare_hourly_daily_states(self):
daily_state.index = daily_state.index.date

# create date_range to generate random states for
range_length = self.asp.length_trials * 24
range_length = self.asp.length_trials
date_range = pd.date_range(start='2009-02-09 15:00:00', periods=range_length,
freq='H')

Expand Down Expand Up @@ -676,4 +676,4 @@ def test_create_trial_data(self, fake_preprocess):
asp = AlternativeSolarProfiles(latitude=46.34,
longitude=-119.28,
num_trials=10,
length_trials=3)
length_trials=3)

0 comments on commit 988b108

Please sign in to comment.