Skip to content

Commit

Permalink
Merge pull request #178 from WISDEM/release-2.4.1
Browse files Browse the repository at this point in the history
Release 2.4.1:

This pull request fixes some obsolete Pandas syntax.
  • Loading branch information
akey7 authored Feb 7, 2022
2 parents 82c74e3 + ab20fed commit 1920f8e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 39 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI_LandBOSSE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: False
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
fail-fast: False
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: [3.8]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -60,7 +60,7 @@ jobs:
with:
miniconda-version: "latest"
auto-update-conda: true
python-version: 3.8
python-version: ${{ matrix.python-version }}
environment-file: environment.yml

# Install
Expand Down
2 changes: 1 addition & 1 deletion landbosse/excelio/WeatherWindowCSVReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def read_weather_window(weather_data, local_timezone='America/Denver'):
weather_data.drop(columns=['Date', 'Date UTC'])

# create time window for normal (8am to 6pm) versus long (24 hour) time window for operation
weather_data['Time window'] = weather_data['Hour'].between(8, 18, inclusive=True)
weather_data['Time window'] = weather_data['Hour'].between(8, 18, inclusive='both')
boolean_dictionary = {True: 'normal', False: 'long'}
weather_data['Time window'] = weather_data['Time window'].map(boolean_dictionary)

Expand Down
2 changes: 1 addition & 1 deletion landbosse/landbosse_omdao/WeatherWindowCSVReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def read_weather_window(weather_data, local_timezone="America/Denver"):
weather_data.drop(columns=["Date", "Date UTC"])

# create time window for normal (8am to 6pm) versus long (24 hour) time window for operation
weather_data["Time window"] = weather_data["Hour"].between(8, 18, inclusive=True)
weather_data["Time window"] = weather_data["Hour"].between(8, 18, inclusive='both')
boolean_dictionary = {True: "normal", False: "long"}
weather_data["Time window"] = weather_data["Time window"].map(boolean_dictionary)

Expand Down
9 changes: 5 additions & 4 deletions landbosse/model/CollectionCost.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,10 @@ def calculate_costs(self, calculate_costs_input_dict, calculate_costs_output_dic

# Combine all calculated cost items into the 'collection_cost' dataframe:
collection_cost = pd.DataFrame([],columns = ['Type of cost', 'Cost USD', 'Phase of construction'])
collection_cost = collection_cost.append(trenching_equipment_rental_cost_df)
collection_cost = collection_cost.append(trenching_labor_cost_df)
collection_cost = collection_cost.append(cable_cost_usd_per_LF_df)
collection_cost = pd.concat( (collection_cost,
trenching_equipment_rental_cost_df,
trenching_labor_cost_df,
cable_cost_usd_per_LF_df) )

# Calculate Mobilization Cost and add to collection_cost dataframe.
# For utility scale plants, mobilization is assumed to be 5% of the sum of labor, equipment, and material costs.
Expand All @@ -864,7 +865,7 @@ def calculate_costs(self, calculate_costs_input_dict, calculate_costs_output_dic

mobilization_cost = pd.DataFrame([['Mobilization', calculate_costs_output_dict['mob_cost'], 'Collection']],
columns=['Type of cost', 'Cost USD', 'Phase of construction'])
collection_cost = collection_cost.append(mobilization_cost)
collection_cost = pd.concat((collection_cost, mobilization_cost))

calculate_costs_output_dict['total_collection_cost'] = collection_cost

Expand Down
19 changes: 10 additions & 9 deletions landbosse/model/ErectionCost.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class Point(object):
def __init__(self, x, y):
if type(x) == type(pd.Series()):
if type(x) == type(pd.Series(dtype=np.float_)):
self.x = float(x.values[0])
self.y = float(y.values[0])
elif type(x) == type(np.array([])):
Expand Down Expand Up @@ -692,7 +692,7 @@ def calculate_crane_lift_polygons(self, crane_grouped):
'Max wind speed m per s', 'Setup time hr', 'Breakdown time hr',
'Hoist speed m per min', 'Speed of travel km per hr',
'Crew type ID', 'Crane poly'])
crane_poly = crane_poly.append(df, sort=True)
crane_poly = pd.concat((crane_poly, df), sort=True)
return crane_poly

def calculate_component_lift_max_wind_speed(self, *, component_group, crane_poly, component_max_speed, operation):
Expand Down Expand Up @@ -762,7 +762,7 @@ def calculate_component_lift_max_wind_speed(self, *, component_group, crane_poly

# Transform the "Lift boolean" indexes in the series to a list of booleans
# that signify if the crane can lift a component.
bool_list = list()
bool_list = []
for component in component_group['Component']:
if crane['Lift boolean {component}'.format(component=component)] is False:
crane_bool = False
Expand All @@ -787,7 +787,7 @@ def calculate_component_lift_max_wind_speed(self, *, component_group, crane_poly
component_group_new['Boom system'] = crane['Boom system']
component_group_new['crane_bool'] = bool_list

component_max_speed = component_max_speed.append(component_group_new, sort=True)
component_max_speed = pd.concat((component_max_speed, component_group_new), sort=True)

crane_poly_new = crane_poly.copy()
crane_poly_new['Crane bool {}'.format(operation)] = min(bool_list)
Expand Down Expand Up @@ -1033,14 +1033,15 @@ def find_minimum_cost_cranes(self):
# find the crane that corresponds to the minimum cost for each operation
crane = separate_basetop[separate_basetop['Total cost USD'] == min_val]
cost = crane.groupby('Operation').min()
total_separate_cost = total_separate_cost.append(cost, sort=True)
total_separate_cost = pd.concat((total_separate_cost, cost), sort=True)

# reset index for separate crane costs
total_separate_cost = total_separate_cost.reset_index()

# duplicate offload records because assuming two offload cranes are on site
total_separate_cost = total_separate_cost.append(
total_separate_cost.loc[total_separate_cost['Operation'] == 'Offload'], sort=True)
total_separate_cost = pd.concat((total_separate_cost,
total_separate_cost.loc[total_separate_cost['Operation'] == 'Offload']),
sort=True)

# sum costs for separate cranes to get total for all cranes
cost_chosen_separate = total_separate_cost['Total cost USD'].sum()
Expand Down Expand Up @@ -1149,8 +1150,8 @@ def calculate_costs(self):

# append data for offloading
if len(offload_specs) != 0:
crane_specs_withoffload = crane_specs.append(offload_specs, sort=True)
operation_time_withoffload = operation_time.append(offload_time, sort=True)
crane_specs_withoffload = pd.concat((crane_specs, offload_specs), sort=True)
operation_time_withoffload = pd.concat((operation_time, offload_time), sort=True)
else:
raise Exception('ErectionCost calculate_costs(): offload_specs empty')

Expand Down
6 changes: 2 additions & 4 deletions landbosse/model/FoundationCost.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,7 @@ def calculate_costs(self, calculate_costs_input_dict, calculate_costs_output_dic
columns=['Type of cost', 'Cost USD', 'Phase of construction'])

# Append all cost items to foundation_cost
foundation_cost = foundation_cost.append(equipment_costs)
foundation_cost = foundation_cost.append(labor_costs)
foundation_cost = foundation_cost.append(material_costs)
foundation_cost = pd.concat( (foundation_cost,equipment_costs,labor_costs,material_costs) )

# Calculate mobilization cost as percentage of total foundation cost and add to foundation_cost
# Assumed 5% of total foundation cost and add to foundation_cost for utility scale plant
Expand All @@ -682,7 +680,7 @@ def calculate_costs(self, calculate_costs_input_dict, calculate_costs_output_dic

mob_cost = pd.DataFrame([['Mobilization', mobilization_cost, 'Foundation']], columns=['Type of cost', 'Cost USD', 'Phase of construction'])

foundation_cost = foundation_cost.append(mob_cost)
foundation_cost = pd.concat((foundation_cost, mob_cost))

# todo: we add a separate tab in the output file for costs (all costs will be the same format but it's a different format than other data)
# columns in cost tab would include project_id, module, operation_id, type_of_cost, total_or_per_turbine, cost_usd
Expand Down
21 changes: 11 additions & 10 deletions landbosse/model/Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .ErectionCost import ErectionCost
from .DevelopmentCost import DevelopmentCost

import pandas as pd

class Manager:
"""
Expand Down Expand Up @@ -91,16 +92,16 @@ def execute_landbosse(self, project_name):
road_cost.loc[index, 'Cost USD'] = other['Cost USD'] - amount_shorter_than_input_construction_time * 55500
self.output_dict['total_road_cost'] = road_cost

total_costs = self.output_dict['total_collection_cost']
total_costs = total_costs.append(self.output_dict['total_road_cost'], sort=False)
total_costs = total_costs.append(self.output_dict['total_transdist_cost'], sort=False)
total_costs = total_costs.append(self.output_dict['total_substation_cost'], sort=False)
total_costs = total_costs.append(self.output_dict['total_foundation_cost'], sort=False)
total_costs = total_costs.append(self.output_dict['total_erection_cost'], sort=False)
total_costs = total_costs.append(self.output_dict['total_development_cost'], sort=False)

self.input_dict['project_value_usd'] = total_costs.sum(numeric_only=True)[0]
self.input_dict['foundation_cost_usd'] = self.output_dict['total_foundation_cost'].sum(numeric_only=True)[0]
total_costs = pd.concat( (self.output_dict['total_collection_cost'],
self.output_dict['total_road_cost'],
self.output_dict['total_transdist_cost'],
self.output_dict['total_substation_cost'],
self.output_dict['total_foundation_cost'],
self.output_dict['total_erection_cost'],
self.output_dict['total_development_cost'],
) )
self.input_dict['project_value_usd'] = float(total_costs['Cost USD'].sum())
self.input_dict['foundation_cost_usd'] = self.output_dict['total_foundation_cost']['Cost USD'].sum()

management_cost = ManagementCost(input_dict=self.input_dict, output_dict=self.output_dict, project_name=project_name)
management_cost.run_module()
Expand Down
11 changes: 4 additions & 7 deletions landbosse/model/SitePreparationCost.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def estimate_construction_time(self, estimate_construction_time_input, estimate_
for unit in list_units:
unit_quantity = pd.DataFrame([[unit, material_quantity_dict[unit]]],
columns=['Units', 'Quantity of material'])
material_needs = material_needs.append(unit_quantity)
material_needs = pd.concat((material_needs, unit_quantity))

estimate_construction_time_output['material_needs'] = material_needs

Expand Down Expand Up @@ -655,10 +655,7 @@ def calculate_costs(self, calculate_cost_input_dict, calculate_cost_output_dict)
additional_costs = pd.DataFrame([['Other', cost_adder, 'Roads']],
columns=['Type of cost', 'Cost USD', 'Phase of construction'])

road_cost = road_cost.append(material_costs)
road_cost = road_cost.append(equipment_costs)
road_cost = road_cost.append(labor_costs)
road_cost = road_cost.append(additional_costs)
road_cost = pd.concat((road_cost,material_costs,equipment_costs,labor_costs,additional_costs))

# set mobilization cost equal to 5% of total road cost for utility scale model and function of
# of turbine size for distributed wind:
Expand All @@ -680,7 +677,7 @@ def calculate_costs(self, calculate_cost_input_dict, calculate_cost_output_dict)
columns=['Type of cost', 'Cost USD', 'Phase of construction'])


road_cost = road_cost.append(mobilization_costs)
road_cost = pd.concat((road_cost, mobilization_costs))
total_road_cost = road_cost
calculate_cost_output_dict['total_road_cost'] = total_road_cost
calculate_cost_output_dict['siteprep_construction_months'] = siteprep_construction_months
Expand Down Expand Up @@ -880,4 +877,4 @@ def run_module(self):
except Exception as error:
traceback.print_exc()
print(f"Fail {self.project_name} SitePreparationCost")
return 1, error # module did not run successfully
return 1, error # module did not run successfully

0 comments on commit 1920f8e

Please sign in to comment.