Skip to content

Commit

Permalink
Merge pull request #11 from dec-heim/develop
Browse files Browse the repository at this point in the history
v0.3.2: Bug fixes to v0.3
  • Loading branch information
dec-heim committed Jan 15, 2023
2 parents 6929e1c + 16e2ade commit e148812
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<!--next-version-placeholder-->

## 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
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/nemed/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions src/nemed/helper_functions/mod_xml_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/nemed/nemed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions src/nemed/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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')]
Expand Down

0 comments on commit e148812

Please sign in to comment.