diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d4a595..68abf33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ +## v0.3.2 Bug fixes (15/01/2023) +- Fix function argument errors +- v0.3.0 and v0.3.1 have known issues. Use v0.3.2 + ## v0.3.1 Major update to Marginal Emissions (15/01/2023) - Refined extraction of price-setter files for marginal emissions data. - Updated example for marginal emissions diff --git a/docs/source/conf.py b/docs/source/conf.py index 6f881fc..97cc8ea 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,7 +23,7 @@ author = "Declan Heim, Shayan Naderi" # The full version, including alpha/beta/rc tags -release = "0.3.1" +release = "0.3.2" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 6689156..8cd657e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "NEMED" -version = "0.3.1" +version = "0.3.2" description = "NEM Emissions Data tool" authors = ["Declan Heim","Shayan Naderi"] license = "Licence" diff --git a/src/nemed/downloader.py b/src/nemed/downloader.py index c767f6a..7255b4b 100644 --- a/src/nemed/downloader.py +++ b/src/nemed/downloader.py @@ -115,7 +115,7 @@ def read_plant_auxload_csv(select_columns=['EFFECTIVEFROM', 'DUID', 'PCT_AUXILIA return table[table.columns[table.columns.isin(select_columns)]] -def download_plant_emissions_factors(cache, start_date, end_date): +def download_plant_emissions_factors(start_date, end_date, cache): """Retrieves CO2-equivalent emissions intensity factors (tCO2-e/MWh) for each generator. Metric is reflective of sent-out generation. Underlying data is sourced from the 'GENUNITS' table of AEMO MMS at monthly time resolution. @@ -664,7 +664,7 @@ def _check_interventions(table): return table -def download_pricesetter_files(cache, start_time, end_time): +def download_pricesetter_files(start_time, end_time, cache): """Download NEM Price Setter files from MMS table. First caches raw XML files as JSON and then reads and returns data in the form of pandas.DataFrame. Processed data only considers the marginal generator for the Energy market. @@ -725,7 +725,7 @@ def download_pricesetter_files(cache, start_time, end_time): logger.warning("PriceSetter Download for {} failed. Continuing with remaining dates...".format(date)) # Read cached JSON Price Setter Files - table = read_json_to_df(cache, start_dt=start_time, end_dt=end_time) + table = read_json_to_df(start_time, end_time, cache) return table diff --git a/src/nemed/helper_functions/mod_xml_cache.py b/src/nemed/helper_functions/mod_xml_cache.py index c514b7d..4baa28f 100644 --- a/src/nemed/helper_functions/mod_xml_cache.py +++ b/src/nemed/helper_functions/mod_xml_cache.py @@ -55,7 +55,7 @@ def overwrite_xmlcachemanager_with_pricesetter_config(): XMLCacheManager.get_file_name = modpricesetter_get_file_name XMLCacheManager._download_xml_from_nemweb = modpricesetter_download_xml_from_nemweb -def convert_xml_to_json(cache, start_date_str, end_date_str, clean_up=False): +def convert_xml_to_json(start_date_str, end_date_str, cache, clean_up=False): """Converts all XML files found in cache to JSON format. Best to use an entirely separate cache folder from other nemosis or nempy projects! @@ -94,7 +94,7 @@ def convert_xml_to_json(cache, start_date_str, end_date_str, clean_up=False): os.remove(os.path.join(cache, filename)) -def read_json_to_df(cache, start_dt, end_dt): +def read_json_to_df(start_dt, end_dt, cache): """Reads JSON files found in cache and returns price setter data as pandas dataframe. Parameters diff --git a/src/nemed/nemed.py b/src/nemed/nemed.py index 4941901..e1abf9a 100644 --- a/src/nemed/nemed.py +++ b/src/nemed/nemed.py @@ -116,6 +116,6 @@ def get_marginal_emissions(start_time, end_time, cache): # Check if cache folder exists hp._check_cache(cache) - result = nd.get_marginal_emitter(cache, start_time, end_time) + result = nd.get_marginal_emitter(start_time, end_time, cache) return result diff --git a/src/nemed/process.py b/src/nemed/process.py index 4edc707..9fe9d50 100644 --- a/src/nemed/process.py +++ b/src/nemed/process.py @@ -171,9 +171,9 @@ def _total_emissions_process(start_time, end_time, cache, filter_regions=None, return result -def _get_duid_emissions_intensities(cache, start_time, end_time): +def _get_duid_emissions_intensities(start_time, end_time, cache): """Merges emissions factors from GENSETID to DUID and cleans data""" - co2factors_df = download_plant_emissions_factors(cache, start_time, end_time) + co2factors_df = download_plant_emissions_factors(start_time, end_time, cache) genset_map = download_genset_map(cache) co2factors_df = co2factors_df.merge(right=genset_map[["GENSETID", "DUID"]], on=["GENSETID"], @@ -259,7 +259,7 @@ def _calculate_sent_out(energy_df): return so_df -def get_marginal_emitter(cache, start_time, end_time): +def get_marginal_emitter(start_time, end_time, cache): """Retrieves the marginal emissions intensity for each dispatch interval and region. This factor being the weighted sum of the generators contributing to price-setting. Although not necessarily common, there may be times where multiple technology types contribute to the marginal emissions - note however that the 'DUID' and 'CO2E_ENERGY_SOURCE' @@ -295,8 +295,8 @@ def get_marginal_emitter(cache, start_time, end_time): # Download CDEII, Price Setter Files and Generation Information ## gen_info = download_generators_info(cache) logger.warning('Warning: Gen_info table only has most recent NEM registration and exemption list. Does not account for retired generators') - co2_factors = _get_duid_emissions_intensities(cache, start_time, end_time) - price_setters = download_pricesetter_files(cache, start_time, end_time) + co2_factors = _get_duid_emissions_intensities(start_time, end_time, cache) + price_setters = download_pricesetter_files(start_time, end_time, cache) # Drop Basslink filt_df = price_setters[~price_setters['Unit'].str.contains('T-V-MNSP1')]