diff --git a/data_adapter_oemof/build_datapackage.py b/data_adapter_oemof/build_datapackage.py index b301595..ece448c 100644 --- a/data_adapter_oemof/build_datapackage.py +++ b/data_adapter_oemof/build_datapackage.py @@ -255,8 +255,12 @@ def get_periods_from_parametrized_sequences( pass return pd.DataFrame() - def save_datapackage_to_csv(self, location_to_save_to: str = None, datapackage_name: str = "datapackage.json", - tsam: bool = False) -> None: + def save_datapackage_to_csv( + self, + location_to_save_to: str = None, + datapackage_name: str = "datapackage.json", + tsam: bool = False, + ) -> None: """ Saving the datapackage to a given destination in oemof.tabular readable format @@ -281,11 +285,12 @@ def save_datapackage_to_csv(self, location_to_save_to: str = None, datapackage_n elif self.location_to_save_to: location_to_save_to = self.location_to_save_to else: - raise ValueError("Please state location_to_save_to either in datapackage or saving call") + raise ValueError( + "Please state location_to_save_to either in datapackage or saving call" + ) if tsam: - location_to_save_to = location_to_save_to+"_tsam" - + location_to_save_to = location_to_save_to + "_tsam" # Check if filestructure is existent. Create folders if not: elements_path = os.path.join(location_to_save_to, "data", "elements") @@ -351,7 +356,9 @@ def save_datapackage_to_csv(self, location_to_save_to: str = None, datapackage_n ) # re-initialize Package with added foreign keys and save datapackage.json - Package(package.descriptor).save(os.path.join(location_to_save_to, datapackage_name)) + Package(package.descriptor).save( + os.path.join(location_to_save_to, datapackage_name) + ) return None @@ -400,7 +407,6 @@ def yearly_scalars_to_periodic_values(scalar_dataframe) -> None: ) return scalar_dataframe - def time_series_aggregation(self, tsam_config: str, destination: str = None): """ Aggregates time series in datapackage and saves the new datapackage with updated @@ -416,7 +422,11 @@ def time_series_aggregation(self, tsam_config: str, destination: str = None): """ # Refactor sequences into one Dataframe self.save_datapackage_to_csv(location_to_save_to=destination) - sequences = pd.concat(self.parametrized_sequences.values(), axis = 1, keys=self.parametrized_sequences.keys()) + sequences = pd.concat( + self.parametrized_sequences.values(), + axis=1, + keys=self.parametrized_sequences.keys(), + ) sequences.index = self.periods.index sequences["periods"] = self.periods.periods @@ -425,23 +435,29 @@ def time_series_aggregation(self, tsam_config: str, destination: str = None): for period, period_sequence in sequences.groupby(by="periods"): index_old = period_sequence["periods"].index period_sequence.drop(["periods"], axis=1, inplace=True) - aggregation = tsam.TimeSeriesAggregation( - period_sequence, - **tsam_config - ) + aggregation = tsam.TimeSeriesAggregation(period_sequence, **tsam_config) aggregation = aggregation.createTypicalPeriods() - aggregation.index = index_old[:len(aggregation)] + aggregation.index = index_old[: len(aggregation)] tsam_aggregated_typical_periods.append(aggregation) - tsam_aggregated_typical_periods= pd.concat(tsam_aggregated_typical_periods, ignore_index=False) + tsam_aggregated_typical_periods = pd.concat( + tsam_aggregated_typical_periods, ignore_index=False + ) - for sequence_file_name in tsam_aggregated_typical_periods.columns.get_level_values(level=0).unique(): - sequence = tsam_aggregated_typical_periods.loc[:, tsam_aggregated_typical_periods.columns.get_level_values(level=0)==sequence_file_name] + for ( + sequence_file_name + ) in tsam_aggregated_typical_periods.columns.get_level_values(level=0).unique(): + sequence = tsam_aggregated_typical_periods.loc[ + :, + tsam_aggregated_typical_periods.columns.get_level_values(level=0) + == sequence_file_name, + ] sequence.columns = sequence.columns.droplevel() self.parametrized_sequences[sequence_file_name] = sequence - self.periods = self.get_periods_from_parametrized_sequences(self.parametrized_sequences) + self.periods = self.get_periods_from_parametrized_sequences( + self.parametrized_sequences + ) self.save_datapackage_to_csv(tsam=True) - @classmethod def build_datapackage( cls, @@ -449,7 +465,7 @@ def build_datapackage( process_adapter_map: Optional[dict] = PROCESS_ADAPTER_MAP, parameter_map: Optional[dict] = PARAMETER_MAP, bus_map: Optional[dict] = BUS_MAP, - location_to_save_to: str = None + location_to_save_to: str = None, ): """ Creating a Datapackage from the oemof_data_adapter that fits oemof.tabular Datapackages. @@ -543,5 +559,5 @@ def build_datapackage( adapter=adapter, foreign_keys=foreign_keys, periods=periods, - location_to_save_to=location_to_save_to + location_to_save_to=location_to_save_to, ) diff --git a/tests/_files/build_datapackage_goal/datapackage.json b/tests/_files/build_datapackage_goal/datapackage.json index b0a9d9c..4f2b7ff 100644 --- a/tests/_files/build_datapackage_goal/datapackage.json +++ b/tests/_files/build_datapackage_goal/datapackage.json @@ -1,600 +1,600 @@ { - "profile": "tabular-data-package", - "resources": [ - { - "path": "data/sequences/modex_tech_Load_sequence.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_Load_sequence", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "string", - "format": "default" - }, - { - "name": "Load_BB", - "type": "number", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] - } - }, - { - "path": "data/sequences/modex_tech_storage_battery_sequence.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_storage_battery_sequence", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] + "profile": "tabular-data-package", + "resources": [ + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_Load_sequence", + "path": "data/sequences/modex_tech_Load_sequence.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "string" + }, + { + "format": "default", + "name": "Load_BB", + "type": "number" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_storage_battery_sequence", + "path": "data/sequences/modex_tech_storage_battery_sequence.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "string" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_generator_gas_sequence", + "path": "data/sequences/modex_tech_generator_gas_sequence.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "string" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_wind_turbine_onshore_sequence", + "path": "data/sequences/modex_tech_wind_turbine_onshore_sequence.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "string" + }, + { + "format": "default", + "name": "onshore_BB", + "type": "number" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_photovoltaic_utility_sequence", + "path": "data/sequences/modex_tech_photovoltaic_utility_sequence.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "string" + }, + { + "format": "default", + "name": "photovoltaic_BB", + "type": "number" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "periods", + "path": "data/periods/periods.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "timeindex", + "type": "string" + }, + { + "format": "default", + "name": "periods", + "type": "integer" + }, + { + "format": "default", + "name": "timeincrement", + "type": "integer" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ] + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "bus", + "path": "data/elements/bus.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "balanced", + "type": "boolean" + } + ], + "foreignKeys": [], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_storage_battery", + "path": "data/elements/modex_tech_storage_battery.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "carrier", + "type": "string" + }, + { + "format": "default", + "name": "tech", + "type": "string" + }, + { + "format": "default", + "name": "capacity", + "type": "number" + }, + { + "format": "default", + "name": "fixed_costs", + "type": "array" + }, + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "region", + "type": "string" + }, + { + "format": "default", + "name": "year", + "type": "array" + }, + { + "format": "default", + "name": "invest_relation_output_capacity", + "type": "number" + }, + { + "format": "default", + "name": "bus", + "type": "string" + } + ], + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/sequences/modex_tech_generator_gas_sequence.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_generator_gas_sequence", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_generator_gas", + "path": "data/elements/modex_tech_generator_gas.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "carrier", + "type": "string" + }, + { + "format": "default", + "name": "tech", + "type": "string" + }, + { + "format": "default", + "name": "condensing_efficiency", + "type": "array" + }, + { + "format": "default", + "name": "electric_efficiency", + "type": "array" + }, + { + "format": "default", + "name": "thermal_efficiency", + "type": "array" + }, + { + "format": "default", + "name": "capacity", + "type": "number" + }, + { + "format": "default", + "name": "carrier_cost", + "type": "array" + }, + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "region", + "type": "string" + }, + { + "format": "default", + "name": "year", + "type": "array" + }, + { + "format": "default", + "name": "electricity_bus", + "type": "string" + }, + { + "format": "default", + "name": "heat_bus", + "type": "string" + }, + { + "format": "default", + "name": "fuel_bus", + "type": "string" + } + ], + "foreignKeys": [ + { + "fields": "electricity_bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/sequences/modex_tech_wind_turbine_onshore_sequence.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_wind_turbine_onshore_sequence", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "string", - "format": "default" - }, - { - "name": "onshore_BB", - "type": "number", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] + }, + { + "fields": "heat_bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/sequences/modex_tech_photovoltaic_utility_sequence.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_photovoltaic_utility_sequence", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "string", - "format": "default" - }, - { - "name": "photovoltaic_BB", - "type": "number", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] + }, + { + "fields": "fuel_bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/periods/periods.csv", - "profile": "tabular-data-resource", - "name": "periods", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "timeindex", - "type": "string", - "format": "default" - }, - { - "name": "periods", - "type": "integer", - "format": "default" - }, - { - "name": "timeincrement", - "type": "integer", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [] - } - }, - { - "path": "data/elements/bus.csv", - "profile": "tabular-data-resource", + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_photovoltaic_utility", + "path": "data/elements/modex_tech_photovoltaic_utility.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "carrier", + "type": "string" + }, + { + "format": "default", + "name": "tech", + "type": "string" + }, + { + "format": "default", + "name": "profile", + "type": "string" + }, + { + "format": "default", + "name": "lifetime", + "type": "array" + }, + { + "format": "default", + "name": "fixed_costs", + "type": "array" + }, + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "region", + "type": "string" + }, + { + "format": "default", + "name": "year", + "type": "array" + }, + { + "format": "default", "name": "bus", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "balanced", - "type": "boolean", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [], - "primaryKey": "name" + "type": "string" + } + ], + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/elements/modex_tech_storage_battery.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_storage_battery", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "carrier", - "type": "string", - "format": "default" - }, - { - "name": "tech", - "type": "string", - "format": "default" - }, - { - "name": "capacity", - "type": "number", - "format": "default" - }, - { - "name": "fixed_costs", - "type": "array", - "format": "default" - }, - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "region", - "type": "string", - "format": "default" - }, - { - "name": "year", - "type": "array", - "format": "default" - }, - { - "name": "invest_relation_output_capacity", - "type": "number", - "format": "default" - }, - { - "name": "bus", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "bus", - "reference": { - "fields": "name", - "resource": "bus" - } - } - ], - "primaryKey": "name" + }, + { + "fields": "profile", + "reference": { + "resource": "modex_tech_photovoltaic_utility_sequence" } - }, - { - "path": "data/elements/modex_tech_generator_gas.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_generator_gas", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "carrier", - "type": "string", - "format": "default" - }, - { - "name": "tech", - "type": "string", - "format": "default" - }, - { - "name": "condensing_efficiency", - "type": "array", - "format": "default" - }, - { - "name": "electric_efficiency", - "type": "array", - "format": "default" - }, - { - "name": "thermal_efficiency", - "type": "array", - "format": "default" - }, - { - "name": "capacity", - "type": "number", - "format": "default" - }, - { - "name": "carrier_cost", - "type": "array", - "format": "default" - }, - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "region", - "type": "string", - "format": "default" - }, - { - "name": "year", - "type": "array", - "format": "default" - }, - { - "name": "electricity_bus", - "type": "string", - "format": "default" - }, - { - "name": "heat_bus", - "type": "string", - "format": "default" - }, - { - "name": "fuel_bus", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "electricity_bus", - "reference": { - "fields": "name", - "resource": "bus" - } - }, - { - "fields": "heat_bus", - "reference": { - "fields": "name", - "resource": "bus" - } - }, - { - "fields": "fuel_bus", - "reference": { - "fields": "name", - "resource": "bus" - } - } - ], - "primaryKey": "name" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_wind_turbine_onshore", + "path": "data/elements/modex_tech_wind_turbine_onshore.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "carrier", + "type": "string" + }, + { + "format": "default", + "name": "tech", + "type": "string" + }, + { + "format": "default", + "name": "profile", + "type": "string" + }, + { + "format": "default", + "name": "lifetime", + "type": "array" + }, + { + "format": "default", + "name": "fixed_costs", + "type": "array" + }, + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "region", + "type": "string" + }, + { + "format": "default", + "name": "year", + "type": "array" + }, + { + "format": "default", + "name": "bus", + "type": "string" + } + ], + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/elements/modex_tech_photovoltaic_utility.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_photovoltaic_utility", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "carrier", - "type": "string", - "format": "default" - }, - { - "name": "tech", - "type": "string", - "format": "default" - }, - { - "name": "profile", - "type": "string", - "format": "default" - }, - { - "name": "lifetime", - "type": "array", - "format": "default" - }, - { - "name": "fixed_costs", - "type": "array", - "format": "default" - }, - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "region", - "type": "string", - "format": "default" - }, - { - "name": "year", - "type": "array", - "format": "default" - }, - { - "name": "bus", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "bus", - "reference": { - "fields": "name", - "resource": "bus" - } - }, - { - "fields": "profile", - "reference": { - "resource": "modex_tech_photovoltaic_utility_sequence" - } - } - ], - "primaryKey": "name" + }, + { + "fields": "profile", + "reference": { + "resource": "modex_tech_wind_turbine_onshore_sequence" } - }, - { - "path": "data/elements/modex_tech_wind_turbine_onshore.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_wind_turbine_onshore", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "carrier", - "type": "string", - "format": "default" - }, - { - "name": "tech", - "type": "string", - "format": "default" - }, - { - "name": "profile", - "type": "string", - "format": "default" - }, - { - "name": "lifetime", - "type": "array", - "format": "default" - }, - { - "name": "fixed_costs", - "type": "array", - "format": "default" - }, - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "region", - "type": "string", - "format": "default" - }, - { - "name": "year", - "type": "array", - "format": "default" - }, - { - "name": "bus", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "bus", - "reference": { - "fields": "name", - "resource": "bus" - } - }, - { - "fields": "profile", - "reference": { - "resource": "modex_tech_wind_turbine_onshore_sequence" - } - } - ], - "primaryKey": "name" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + }, + { + "encoding": "utf-8", + "format": "csv", + "mediatype": "text/csv", + "name": "modex_tech_Load", + "path": "data/elements/modex_tech_Load.csv", + "profile": "tabular-data-resource", + "schema": { + "fields": [ + { + "format": "default", + "name": "type", + "type": "string" + }, + { + "format": "default", + "name": "amount", + "type": "array" + }, + { + "format": "default", + "name": "profile", + "type": "string" + }, + { + "format": "default", + "name": "name", + "type": "string" + }, + { + "format": "default", + "name": "region", + "type": "string" + }, + { + "format": "default", + "name": "year", + "type": "array" + }, + { + "format": "default", + "name": "bus", + "type": "string" + } + ], + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "fields": "name", + "resource": "bus" } - }, - { - "path": "data/elements/modex_tech_Load.csv", - "profile": "tabular-data-resource", - "name": "modex_tech_Load", - "format": "csv", - "mediatype": "text/csv", - "encoding": "utf-8", - "schema": { - "fields": [ - { - "name": "type", - "type": "string", - "format": "default" - }, - { - "name": "amount", - "type": "array", - "format": "default" - }, - { - "name": "profile", - "type": "string", - "format": "default" - }, - { - "name": "name", - "type": "string", - "format": "default" - }, - { - "name": "region", - "type": "string", - "format": "default" - }, - { - "name": "year", - "type": "array", - "format": "default" - }, - { - "name": "bus", - "type": "string", - "format": "default" - } - ], - "missingValues": [ - "" - ], - "foreignKeys": [ - { - "fields": "bus", - "reference": { - "fields": "name", - "resource": "bus" - } - }, - { - "fields": "profile", - "reference": { - "resource": "modex_tech_Load_sequence" - } - } - ], - "primaryKey": "name" + }, + { + "fields": "profile", + "reference": { + "resource": "modex_tech_Load_sequence" } - } - ] -} \ No newline at end of file + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name" + } + } + ] +} diff --git a/tests/_files/tsam/tsam_config.json b/tests/_files/tsam/tsam_config.json index 44d98bf..48050cd 100644 --- a/tests/_files/tsam/tsam_config.json +++ b/tests/_files/tsam/tsam_config.json @@ -1,9 +1,9 @@ { - "noTypicalPeriods": 2, + "clusterMethod": "hierarchical", + "distributionPeriodWise": false, "hoursPerPeriod": 1, - "segmentation": true, "noSegments": 2, + "noTypicalPeriods": 2, "representationMethod": "distributionAndMinMaxRepresentation", - "distributionPeriodWise": false, - "clusterMethod": "hierarchical" + "segmentation": true } diff --git a/tests/test_build_datapackage.py b/tests/test_build_datapackage.py index 5e57119..02a0bd8 100644 --- a/tests/test_build_datapackage.py +++ b/tests/test_build_datapackage.py @@ -1,7 +1,5 @@ -import os -from unittest import mock -import tsam.timeseriesaggregation as tsam import json +import os import pandas as pd import pytest @@ -60,7 +58,7 @@ def test_build_datapackage(): mock = define_mock() result = DataPackage.build_datapackage( - adapter= mock.mock_adapter, + adapter=mock.mock_adapter, process_adapter_map=mock.process_adapter_map, parameter_map=mock.parameter_map, ) @@ -195,6 +193,7 @@ def test_period_csv_creation(): sequence_goal.index.name = "timeindex" pd.testing.assert_frame_equal(sequence_goal, sequence_created) + def test_tsam(): """ Uses Mock to create datapackage and then applies timeseries aggregation to it. @@ -212,7 +211,7 @@ def test_tsam(): adapter=mock.mock_adapter, process_adapter_map=mock.process_adapter_map, parameter_map=mock.parameter_map, - location_to_save_to=tsam_folder + location_to_save_to=tsam_folder, ) ############################################################################# @@ -225,4 +224,3 @@ def test_tsam(): tsam_config = json.load(f) result.time_series_aggregation(tsam_config=tsam_config) -