Skip to main content

A package and CLI utility to check for available data and download tables from AEMO's Monthly Data Archive

Project description

AEMO Monthly Data Archive Tool

PyPI version Continuous Integration and Deployment codecov Code style: black

A CLI utility to find and obtain data made available through AEMO's MMS Monthly Data Archive.

Note

This package and its CLI have some overlap with NEMOSIS and NEMSEER. However:

  • NEMOSIS does not provide access to the monthly data archive, and does not allow a user to download certain tables such as bid data tables (BIDPEROFFER).
  • NEMSEER only handles PASA and pre-dispatch tables available in the monthly data archive, though it provides a lot of useful utilities for handling these tables

Installation

Recommended that you use pipx to install the CLI as it prevents dependency conflicts.

pipx install mms-monthly-cli

However, you can still install via pip if you wish to:

pip install mms-monthly-cli

Usage

You can use this package as a module (source code functions within mms_monthly.py) or as a CLI tool to:

  1. Inspect what data is available
  2. Download and unzip a table CSV for a particular period (i.e. a month within a year)

Python module

Simply import mms_monthly_cli as follows:

import mms_monthly_cli.mms_monthly as mms_monthly

This will expose the following functions (accessed using mms_monthly.<func_name>):

get_years_and_months() -> Dict[int, List[int]]
Years and months with data on NEMWeb MMSDM Historical Data Archive
Returns:
    Months mapped to each year. Data is available for each of these months.
get_available_tables(year: int, month: int, data_dir: str) -> List[str]
Tables that can be requested from MMSDM Historical Data Archive for a
   particular month and year.
Args:
    year: Year
    month: Month
    data_dir: Directory within monthly archives

Returns:
    List of tables associated with that forecast type for that period
get_table_names_and_sizes(year: int, month: int, data_dir: str) -> Dict
Returns table names and sizes from MMSDM Historical Data Archive page

For a year and month in the MMSDM Historical Data Archive, returns a list of
tuples each consisting of:
- A table name (obtained via captured regex group)
- The size of the associated zip file

Args:
    year: Year
    month: Month
    data_dir: Directory within monthly archives
Returns:
    Tuple of table names and file sizes
get_and_unzip_table_csv(year: int, month: int, data_dir: str, table: str, cache: pathlib.Path) -> None
Unzipped (single) csv file downloaded from `url` to `cache`

This function:

1. Downloads zip file in chunks to limit memory use and enable progress bar
2. Validates that the zip contains a single file that has the same name as the zip

Args:
    year: Year
    month: Month
    data_dir: Directory within monthly archives
    table: Table name
    cache: Path to save zip.
Returns:
    None. Extracts csv to `cache`

CLI tool

The CLI tool uses Typer.

Usage is documented within the tool:

mms-monthly-cli --help

...which returns:

Usage: mms-monthly-cli [OPTIONS] COMMAND [ARGS]...

 A CLI utility to find and obtain data made available through AEMO's MMS Monthly Data
 Archive: http://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/

╭─ Options ───────────────────────────────────────────────────────────────────────────────╮
│ --install-completion          Install completion for the current shell.                 │
│ --show-completion             Show completion for the current shell, to copy it or      │
│                               customize the installation.                               │
│ --help                        Show this message and exit.                               │
╰─────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────╮
│ available-periods  Displays years and the months within them for which data is          │
│                    available                                                            │
│ available-tables   Displays available tables for a period (i.e. supplied month and      │
│                    year)                                                                │
│ get-table          Download and unzip monthly data zip file to get data table CSV in    │
│                    cache. To see available periods, use the `available_periods` command │
│                    To see available tables for a given period, use the                  │
│                    `available_tables` command                                           │
╰─────────────────────────────────────────────────────────────────────────────────────────╯

License

This tool and associated source code (reused from nemseer, which is licensed under GNU GPL-3.0-or-later) was created by Abhijith Prakash.

This tool and its source code is licensed under the terms of GNU GPL-3.0-or-later licences.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mms_monthly_cli-1.0.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

mms_monthly_cli-1.0.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file mms_monthly_cli-1.0.0.tar.gz.

File metadata

  • Download URL: mms_monthly_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1042-azure

File hashes

Hashes for mms_monthly_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bd0571f166b05b0d2114364a08479c72ff0f16873c9338e8d09eddfc2e96548e
MD5 a8cb16ce39283661bf7f334a7e1ac4e8
BLAKE2b-256 0516a14ba4d71c2ed258d72c633486b3f30a2e77917e949943188a7e6ddad944

See more details on using hashes here.

File details

Details for the file mms_monthly_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mms_monthly_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1042-azure

File hashes

Hashes for mms_monthly_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf8e77f9d35d16dc93bf34833537a582dda88db1c39a7da0f0b01a3f125d97be
MD5 caf4c08bfd43a62fc16716d6f5c55d04
BLAKE2b-256 6a160d76f927651e5335ebae6f3899ddf735aca3b79506c7fd377d0155b5cd4b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page