From 174664316f60ea4a2212d56e0dea6e005a85f5f9 Mon Sep 17 00:00:00 2001 From: bayc Date: Thu, 8 Aug 2024 15:36:31 -0600 Subject: [PATCH 1/2] update resource file path for a couple tests --- hopp/utilities/utils_for_tests.py | 4 ++-- tests/greenheart/test_openmdao.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hopp/utilities/utils_for_tests.py b/hopp/utilities/utils_for_tests.py index 6ff72284c..fcea96c1a 100644 --- a/hopp/utilities/utils_for_tests.py +++ b/hopp/utilities/utils_for_tests.py @@ -1,8 +1,8 @@ from hopp import ROOT_DIR from hopp.simulation.technologies.sites import SiteInfo, flatirons_site -DEFAULT_SOLAR_RESOURCE_FILE = ROOT_DIR.parent / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv" -DEFAULT_WIND_RESOURCE_FILE = ROOT_DIR.parent / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw" +DEFAULT_SOLAR_RESOURCE_FILE = ROOT_DIR / "simulation" / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv" +DEFAULT_WIND_RESOURCE_FILE = ROOT_DIR / "simulation" / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw" def create_default_site_info(**kwargs): return SiteInfo( diff --git a/tests/greenheart/test_openmdao.py b/tests/greenheart/test_openmdao.py index 5ce940b19..9c31a7110 100644 --- a/tests/greenheart/test_openmdao.py +++ b/tests/greenheart/test_openmdao.py @@ -7,13 +7,14 @@ from hopp.simulation import HoppInterface from hopp.utilities import load_yaml +from hopp import ROOT_DIR from greenheart.tools.optimization.openmdao import HOPPComponent, TurbineDistanceComponent, BoundaryDistanceComponent import unittest -solar_resource_file = Path(__file__).absolute().parent.parent.parent / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv" -wind_resource_file = Path(__file__).absolute().parent.parent.parent / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw" +solar_resource_file = ROOT_DIR / "simulation" / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv" +wind_resource_file = ROOT_DIR / "simulation" / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw" floris_input_file = Path(__file__).absolute().parent / "inputs" / "floris_input.yaml" hopp_config_filename = Path(__file__).absolute().parent / "inputs" / "hopp_config.yaml" From 2169d89e6a0e2e4dae6f0e4691f84c6ce41833d9 Mon Sep 17 00:00:00 2001 From: bayc Date: Thu, 8 Aug 2024 16:34:33 -0600 Subject: [PATCH 2/2] remove yamlinclude import --- tests/greenheart/hopp_tools_test.py | 11 ++++++----- .../test_hydrogen/test_greenheart_system.py | 7 +------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/greenheart/hopp_tools_test.py b/tests/greenheart/hopp_tools_test.py index b14dacde2..3c96b5e10 100644 --- a/tests/greenheart/hopp_tools_test.py +++ b/tests/greenheart/hopp_tools_test.py @@ -7,11 +7,11 @@ import matplotlib.pyplot as plt import yaml import re -from yamlinclude import YamlIncludeConstructor -YamlIncludeConstructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir='/your/conf/dir') - +# from yamlinclude import YamlIncludeConstructor +# YamlIncludeConstructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir='/your/conf/dir') # HOPP functionss +from hopp.utilities import load_yaml from greenheart.to_organize.H2_Analysis.hopp_for_h2 import hopp_for_h2 from hopp.simulation.technologies.sites import SiteInfo from greenheart.to_organize.H2_Analysis.simple_dispatch import SimpleDispatch @@ -88,8 +88,9 @@ def set_turbine_model(turbine_model, scenario, parent_path, floris_dir): ################################ turbine_file = floris_dir + 'floris_input' + turbine_model + '_' + site_number + '.yaml' - with open(turbine_file, 'r') as f: - floris_config = yaml.load(f, yaml.FullLoader) + floris_config = load_yaml(turbine_file) + # with open(turbine_file, 'r') as f: + # floris_config = yaml.load(f, yaml.FullLoader) # floris_config = yaml.load(f, yaml.SafeLoader) nTurbs = len(floris_config['farm']['layout_x']) # turbine_type = floris_config['farm']['turbine_type'][0] diff --git a/tests/greenheart/test_hydrogen/test_greenheart_system.py b/tests/greenheart/test_hydrogen/test_greenheart_system.py index b1c136c86..4a50586bd 100644 --- a/tests/greenheart/test_hydrogen/test_greenheart_system.py +++ b/tests/greenheart/test_hydrogen/test_greenheart_system.py @@ -8,18 +8,13 @@ from hopp.utilities.keys import set_nrel_key_dot_env set_nrel_key_dot_env() -import yaml -from yamlinclude import YamlIncludeConstructor - from pathlib import Path from ORBIT.core.library import initialize_library + dirname = os.path.dirname(__file__) orbit_library_path = os.path.join(dirname, "input_files/") -YamlIncludeConstructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir=os.path.join(orbit_library_path, 'floris/')) -YamlIncludeConstructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir=os.path.join(orbit_library_path, 'turbines/')) - initialize_library(orbit_library_path) class TestSimulationWind(unittest.TestCase):