Пример #1
0
    def setup_class(cls):
        # initialize with data to avoid pulling multiple times

        cls.sim_config = Config.make_sim_config(
            identifier=[
                "DYD_dummy_data",
            ],  # test file
            latitude=33.481136,
            longitude=-112.078232,
            start_utc=[
                "2018-01-01 00:00:00",
            ],
            end_utc=[
                "2018-12-31 23:55:00",
            ],
            min_sim_period="3D",
            min_chunk_period="30D",
            sim_step_size_seconds=300,
            output_step_size_seconds=300,
        )

        cls.data_client = DataClient(
            source=LocalSource(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
            destination=LocalDestination(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
        )
        cls.data_client.sim_config = cls.sim_config.iloc[0]

        cls.data_client.get_data()
    def test_make_fmu(self, test_sim_config, building_model):
        """test that make_fmu produces fmu file"""
        dc = DataClient(
            source=LocalSource(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
            destination=LocalDestination(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
            nrel_dev_api_key=os.environ.get("NREL_DEV_API_KEY"),
            nrel_dev_email=os.environ.get("NREL_DEV_EMAIL"),
            archive_tmy3_meta=os.environ.get("ARCHIVE_TMY3_META"),
            archive_tmy3_data_dir=os.environ.get("ARCHIVE_TMY3_DATA_DIR"),
            ep_tmy3_cache_dir=os.environ.get("EP_TMY3_CACHE_DIR"),
            simulation_epw_dir=os.environ.get("SIMULATION_EPW_DIR"),
        )
        dc.sim_config = test_sim_config
        dc.get_data()

        fmu = building_model.create_model_fmu(
            sim_config=test_sim_config,
            weather_channel=dc.weather,
            datetime_channel=dc.datetime,
        )
        assert os.path.exists(fmu)

        # @pytest.mark.usefixtures("building_model")
        # def test_fmu_compliance(self, building_model):
        """test that fmu file is compliant with FMI."""
        output_path = os.path.join(os.environ.get("OUTPUT_DIR"),
                                   "compliance_check_output.csv")
        # use `bash expect` to run non-interactive
        # Note: if this test fails check ./Output_EPExport_Slave/Furnace_prep.err
        cmd = (
            "expect 'Press enter to continue.' {{ send '\r' }} |"
            f' {os.environ.get("EXT_DIR")}/FMUComplianceChecker/fmuCheck.linux64'
            f" -h {self.step_size}"
            " -s 172800"
            f" -o {output_path} {building_model.fmu_path}")
        logger.info("FMU compliance checker command:")
        logger.info(cmd)
        # shlex causes FMUComplianceChecker to run with options, use cmd string
        out = subprocess.run(cmd,
                             shell=True,
                             capture_output=False,
                             text=True,
                             input="\n")

        assert out.returncode == 0
Пример #3
0
    def setup_class(cls):
        # initialize with data to avoid pulling multiple times
        cls.sim_config = Config.make_sim_config(
            identifier=[
                "DYD_dummy_data",
            ],  # test file
            latitude=33.481136,
            longitude=-112.078232,
            start_utc=[
                "2018-01-01 00:00:00",
            ],
            end_utc=[
                "2018-12-31 23:55:00",
            ],
            min_sim_period="3D",
            min_chunk_period="30D",
            sim_step_size_seconds=300,
            output_step_size_seconds=300,
        )

        cls.data_clients = []
        cls.data_client = DataClient(
            source=LocalSource(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
            destination=LocalDestination(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
            nrel_dev_api_key=os.environ.get("NREL_DEV_API_KEY"),
            nrel_dev_email=os.environ.get("NREL_DEV_EMAIL"),
            archive_tmy3_dir=os.environ.get("ARCHIVE_TMY3_DIR"),
            archive_tmy3_meta=os.environ.get("ARCHIVE_TMY3_META"),
            archive_tmy3_data_dir=os.environ.get("ARCHIVE_TMY3_DATA_DIR"),
            ep_tmy3_cache_dir=os.environ.get("EP_TMY3_CACHE_DIR"),
            simulation_epw_dir=os.environ.get("SIMULATION_EPW_DIR"),
        )

        for _idx, _sim_config in cls.sim_config.iterrows():
            dc = copy.deepcopy(cls.data_client)
            dc.sim_config = _sim_config

            dc.get_data()

            cls.data_clients.append(dc)
Пример #4
0
    def setup_class(cls):
        # initialize with data to avoid pulling multiple times
        cls.sim_config = Config.make_sim_config(
            identifier=[
                "DYD_dummy_data",  # test file
            ],
            latitude=33.481136,
            longitude=-112.078232,
            start_utc=[
                "2018-01-01 00:00:00",
            ],
            end_utc=[
                "2018-12-31 23:55:00",
            ],
            min_sim_period="3D",
            min_chunk_period="30D",
            sim_step_size_seconds=300,
            output_step_size_seconds=300,
        )

        cls.data_client = DataClient(
            source=LocalSource(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
            destination=GCSDestination(
                gcp_project=os.environ.get("BCS_GOOGLE_CLOUD_PROJECT"),
                gcs_uri_base=os.environ.get("BCS_OUTPUT_GCS_URI_BASE"),
                data_spec=DonateYourDataSpec(),
                local_cache=None,
            ),
            nrel_dev_api_key=os.environ.get("NREL_DEV_API_KEY"),
            nrel_dev_email=os.environ.get("NREL_DEV_EMAIL"),
            archive_tmy3_dir=os.environ.get("ARCHIVE_TMY3_DIR"),
            archive_tmy3_meta=os.environ.get("ARCHIVE_TMY3_META"),
            archive_tmy3_data_dir=os.environ.get("ARCHIVE_TMY3_DATA_DIR"),
            ep_tmy3_cache_dir=os.environ.get("EP_TMY3_CACHE_DIR"),
            simulation_epw_dir=os.environ.get("SIMULATION_EPW_DIR"),
        )
        cls.data_client.sim_config = cls.sim_config.iloc[0]

        cls.data_client.get_data()
Пример #5
0
    def setup_class(cls):
        # initialize with data to avoid pulling multiple times
        cls.sim_config = Config.make_sim_config(
            identifier=[
                "d310f1c1f600c374d8975c753f7c0fb8de9c96b1",
                "8c00c9bb17bfcca53809cb1b2d033a448bc017df",  # has full data periods
                "6773291da5427ae87d34bb75022ee54ee3b1fc17",  # file not found
            ],
            latitude=33.481136,
            longitude=-112.078232,
            start_utc=[
                "2018-01-01 00:00:00",
                "2018-01-01 00:00:00",
                "2018-01-01 00:00:00",
            ],
            end_utc=[
                "2018-12-31 23:55:00",
                "2018-12-31 23:55:00",
                "2018-12-31 23:55:00",
            ],
            min_sim_period="7D",
            min_chunk_period="30D",
            sim_step_size_seconds=300,
            output_step_size_seconds=300,
        )

        cls.data_clients = []

        # set local_cache=None to avoid caching locally and always testing connection with GCS
        cls.data_client = DataClient(
            source=GCSDYDSource(
                gcp_project=os.environ.get("DYD_GOOGLE_CLOUD_PROJECT"),
                gcs_uri_base=os.environ.get("DYD_GCS_URI_BASE"),
                local_cache=None,
            ),
            destination=LocalDestination(data_spec=DonateYourDataSpec(), ),
        )

        for _idx, _sim_config in cls.sim_config.iterrows():
            dc = copy.deepcopy(cls.data_client)
            dc.sim_config = _sim_config

            if _sim_config["identifier"] in [
                    "6773291da5427ae87d34bb75022ee54ee3b1fc17",
            ]:
                with pytest.raises(ValueError):
                    dc.get_data()
            else:
                dc.get_data()

            cls.data_clients.append(dc)
    def setup_class(cls):
        # initialize with data to avoid pulling multiple times
        cls.sim_config = Config.make_sim_config(
            identifier=["9958f46d13419344ec0c21fb60f9b0b3990ac0ef"],
            latitude=33.481136,
            longitude=-112.078232,
            start_utc=[
                "2018-01-01 00:00:00",
            ],
            end_utc=[
                "2018-12-31 23:55:00",
            ],
            min_sim_period="7D",
            min_chunk_period="30D",
            sim_step_size_seconds=300,
            output_step_size_seconds=300,
        )

        cls.data_clients = []
        cls.data_client = DataClient(
            source=GCSDYDSource(
                gcp_project=os.environ.get("DYD_GOOGLE_CLOUD_PROJECT"),
                gcs_uri_base=os.environ.get("DYD_GCS_URI_BASE"),
            ),
            destination=LocalDestination(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
            nrel_dev_api_key=os.environ.get("NREL_DEV_API_KEY"),
            nrel_dev_email=os.environ.get("NREL_DEV_EMAIL"),
            archive_tmy3_dir=os.environ.get("ARCHIVE_TMY3_DIR"),
            archive_tmy3_meta=os.environ.get("ARCHIVE_TMY3_META"),
            archive_tmy3_data_dir=os.environ.get("ARCHIVE_TMY3_DATA_DIR"),
            ep_tmy3_cache_dir=os.environ.get("EP_TMY3_CACHE_DIR"),
            simulation_epw_dir=os.environ.get("SIMULATION_EPW_DIR"),
        )

        for _idx, _sim_config in cls.sim_config.iterrows():
            dc = copy.deepcopy(cls.data_client)
            dc.sim_config = _sim_config

            dc.get_data()

            cls.data_clients.append(dc)
Пример #7
0
 def test_generate_dummy_data(self):
     _sim_config = Config.make_sim_config(
         identifier=[
             "generated_dummy_data",
         ],  # test file
         latitude=33.481136,
         longitude=-112.078232,
         start_utc=[
             "2018-01-01 00:00:00",
         ],
         end_utc=[
             "2018-12-31 23:55:00",
         ],
         min_sim_period="3D",
         min_chunk_period="30D",
         sim_step_size_seconds=300,
         output_step_size_seconds=300,
     )
     _df = DataClient.generate_dummy_data(sim_config=_sim_config,
                                          spec=DonateYourDataSpec())
     assert len(_df) == 105120
     assert all(_df["Schedule"].value_counts().values == [74460, 30660])
    def setup_class(cls):
        # initialize with data to avoid pulling multiple times
        cls.sim_config = Config.make_sim_config(
            identifier=[
                "d310f1c1f600c374d8975c753f7c0fb8de9c96b1",
                "8c00c9bb17bfcca53809cb1b2d033a448bc017df",  # has full data periods
                "6773291da5427ae87d34bb75022ee54ee3b1fc17",  # file not found
            ],
            latitude=33.481136,
            longitude=-112.078232,
            start_utc=[
                "2018-01-01 00:00:00",
                "2018-01-01 00:00:00",
                "2018-01-01 00:00:00",
            ],
            end_utc=[
                "2018-12-31 23:55:00",
                "2018-12-31 23:55:00",
                "2018-12-31 23:55:00",
            ],
            min_sim_period="7D",
            min_chunk_period="30D",
            sim_step_size_seconds=300,
            output_step_size_seconds=300,
        )

        cls.data_clients = []

        # set local_cache=None to test connection with GCS
        cls.data_client = DataClient(
            source=GCSDYDSource(
                gcp_project=os.environ.get("DYD_GOOGLE_CLOUD_PROJECT"),
                gcs_uri_base=os.environ.get("DYD_GCS_URI_BASE"),
                local_cache=None,
            ),
            destination=LocalDestination(
                local_cache=os.environ.get("LOCAL_CACHE_DIR"),
                data_spec=DonateYourDataSpec(),
            ),
            nrel_dev_api_key=os.environ.get("NREL_DEV_API_KEY"),
            nrel_dev_email=os.environ.get("NREL_DEV_EMAIL"),
            archive_tmy3_dir=os.environ.get("ARCHIVE_TMY3_DIR"),
            archive_tmy3_meta=os.environ.get("ARCHIVE_TMY3_META"),
            archive_tmy3_data_dir=os.environ.get("ARCHIVE_TMY3_DATA_DIR"),
            ep_tmy3_cache_dir=os.environ.get("EP_TMY3_CACHE_DIR"),
            simulation_epw_dir=os.environ.get("SIMULATION_EPW_DIR"),
        )

        for _idx, _sim_config in cls.sim_config.iterrows():
            dc = copy.deepcopy(cls.data_client)
            dc.sim_config = _sim_config

            if _sim_config["identifier"] in [
                "6773291da5427ae87d34bb75022ee54ee3b1fc17",
            ]:
                with pytest.raises(ValueError):
                    dc.get_data()
            else:
                dc.get_data()

            cls.data_clients.append(dc)
     "latitude": 41.8781,
     "longitude": -87.6298,
     "start_utc": "2018-05-16",
     "end_utc": "2018-06-01",
     "min_sim_period": "1D",
     "sim_step_size_seconds": 900,
     "output_step_size_seconds": 300,
 },
 "data_client": {
     "is_local_source": True,
     "is_gcs_source": False,
     "is_gbq_source": False,
     "gcp_project": None,
     "gcs_uri_base": None,
     "gbq_table": None,
     "source_data_spec": DonateYourDataSpec(),
     "source_local_cache": os.environ.get("LOCAL_CACHE_DIR"),
     "is_local_destination": True,
     "is_gcs_destination": False,
     "is_gbq_destination": False,
     "destination_data_spec": DonateYourDataSpec(),
     "destination_local_cache": os.environ.get("LOCAL_CACHE_DIR"),
 },
 "building_model": {
     "is_energyplus_building": True,
     "idf_name": "Furnace.idf",
     "epw_name": "USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw",
     "building_config": {},
 },
 "controller_model": {
     "is_deadband": True,