# MNSP_PEROFFER

> MNSP_PEROFFER shows period by period availability and other period data pertaining to a specific bid and LinkID for the given Settlement Date.
> MNSP_PEROFFER is a child to [`MNSP_DAYOFFER`](./MNSP_DAYOFFER.md) and links to [`MNSP_OFFERTRK`](./MNSP_OFFERTRK.md).

!!! tip "Deprecation Warning"
    This table is in the [HISTORICAL TABLES](../packages/HISTORICAL TABLES.md) package,
    so is likely deprecated.

> MNSP_PEROFFER shows own (confidential) data updates as bids are
> processed. All bids are available as part of next day market data.
> 
> Volume
> 
> 192, 000 per year

## Column Schema

### LINKID

> Identifier for each of the two MNSP Interconnector Links. Each link pertains to the direction from and to.

SQL Type: `VARCHAR2(10)`
Polars Type: `str`

This column is mandatory, and a primary key.

Example: `BLNKTAS`

### OFFERDATE

> Offer date for bid

!!! danger "Warning"
    Despite what the name suggests, this is a datetime, not a date.

SQL Type: `DATE`
Polars Type: `pl.Datetime()`

This column is mandatory, and a primary key.

Example: `2021/01/20 13:01:55`

### PARTICIPANTID

> Participant Identifier

For more information, see the [dedicated documentation page](../../guide/querying.md#duid-genset-id-etc).

SQL Type: `VARCHAR2(10)`
Polars Type: `pl.Categorical`

This column is mandatory, and a primary key.

Example: `BASSLINK`

### PERIODID

> Trading Interval number

SQL Type: `NUMBER(22,0)`
Polars Type: `pl.Int128`

This column is mandatory, and a primary key.

Examples:
`1`, `48`

### SETTLEMENTDATE

> Market Date from which bid is active

SQL Type: `DATE`
Polars Type: `pl.Date()`

This column is mandatory, and a primary key.

Example: `2021/02/01 00:00:00`

Note that AEMO represents dates as datetimes with a midnight time component.

### VERSIONNO

> Version of data for other key data - a higher version for same key data will take precedence

SQL Type: `NUMBER(3,0)`
Polars Type: `pl.UInt16`

This column is mandatory, and a primary key.

Examples:
`1`, `9`

### BANDAVAIL1

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### BANDAVAIL2

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### BANDAVAIL3

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### BANDAVAIL4

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Examples:
`446`, `594`

### BANDAVAIL5

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### BANDAVAIL6

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### BANDAVAIL7

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### BANDAVAIL8

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### BANDAVAIL9

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### BANDAVAIL10

> Band Availability for current Period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Examples:
`0`, `148`

### FIXEDLOAD

> Inflexibility flag and availability. Fixed unit output MW. A value of zero means no fixed load so the unit is dispatched according to bid and market (rather than zero fixed load)

SQL Type: `NUMBER(12,6)`
Polars Type: `pl.Boolean`

This column is not mandatory.

### LASTCHANGED

> Last date and time record changed

For more information, see the [dedicated documentation page](../../guide/querying.md#deduplication).

SQL Type: `DATE`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Example: `2021/01/20 13:01:56`

### MAXAVAIL

> Maximum planned availability MW

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `478`

### MR_CAPACITY

> Mandatory Restriction Offer amount

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

### PASAAVAILABILITY

> Allows for future use for energy bids, being the physical plant capability including any capability potentially available within 24 hours

SQL Type: `NUMBER(12,0)`
Polars Type: `pl.Int64`

This column is not mandatory.

Example: `478`

### RAMPUPRATE

> Ramp rate (MW / min) in the positive direction of flow for this MNSP link for this half-hour period

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `200`

## New Data Timing

> As bids are processed

## Code Examples

### Polars

Explicitly listing every column, casting to enums, categoricals etc is not essential, but may speed up parsing.
Swapping `int` for `pl.UInt16`, `pl.Int32` would also speed up parsing. However some of the datatypes are inferred, so they may be wrong.

This code deduplicates for you.
Deduplication is normally only required across multiple months.

This code assumes that all columns are present, which may not be true for older files.

```python
import polars as pl
import polars.selectors as cs

# e.g. "2029/03/15 00:05:00"
dt_s_fmt = "%Y/%m/%d %H:%M:%S"

# Dates are represented as datetimes at midnight

d_fmt = "%Y/%m/%d 00:00:00"

csv_paths = ["SOMEFILE.CSV", "OTHERFILE.CSV"]

lf = (
    pl.concat(
        [
            pl.scan_csv(
                csv_path,  # must be unzipped beforehand
                skip_rows=1,  # skip the header
                infer_schema=False,  # much faster
            )
            .filter(cs.by_index(0) == "D")  # drop the footer
            .select(~cs.by_index(range(4)))  # drop metadata columns
            for csv_path in csv_paths
        ],
        how="diagonal_relaxed",
    )
    .with_columns(
        pl.col("OFFERDATE", "LASTCHANGED").str.strptime(pl.Datetime, dt_s_fmt),
        pl.col("SETTLEMENTDATE").str.strptime(pl.Date, d_fmt),
    )
    # Polars can't cast string straight to bool. Need to go via something else.
    .cast({"FIXEDLOAD": pl.UInt8})
    .cast(
        {
            "LINKID": str,
            "PARTICIPANTID": pl.Categorical,
            "PERIODID": int,  # or pl.Int128
            "SETTLEMENTDATE": pl.Date(),
            "VERSIONNO": int,  # or pl.UInt16
            "BANDAVAIL1": int,  # or pl.Int32
            "BANDAVAIL2": int,  # or pl.Int32
            "BANDAVAIL3": int,  # or pl.Int32
            "BANDAVAIL4": int,  # or pl.Int32
            "BANDAVAIL5": int,  # or pl.Int32
            "BANDAVAIL6": int,  # or pl.Int32
            "BANDAVAIL7": int,  # or pl.Int32
            "BANDAVAIL8": int,  # or pl.Int32
            "BANDAVAIL9": int,  # or pl.Int32
            "BANDAVAIL10": int,  # or pl.Int32
            "FIXEDLOAD": pl.Boolean,
            "MAXAVAIL": int,  # or pl.Int32
            "MR_CAPACITY": int,  # or pl.Int32
            "PASAAVAILABILITY": int,  # or pl.Int64
            "RAMPUPRATE": int,  # or pl.Int32
        }
    )
    # Deduplicate
    # We want one row per ['LINKID', 'OFFERDATE', 'PARTICIPANTID', 'PERIODID', 'SETTLEMENTDATE', 'VERSIONNO']
    # Tie-breaker: greatest value of ['LASTCHANGED']
    .sort(["LASTCHANGED"], descending=False)
    .unique(
        subset=[
            "LINKID",
            "OFFERDATE",
            "PARTICIPANTID",
            "PERIODID",
            "SETTLEMENTDATE",
            "VERSIONNO",
        ],
        keep="last",
    )
)

```

### Nemosis

```py
from nemosis import dynamic_data_compiler

df = dynamic_data_compiler(
    '2024/01/01 00:00:00',
    '2024/01/31 00:00:00',
    "MNSP_PEROFFER",
    "data/"
)
```

Nemosis only includes [a subset of columns](https://github.com/UNSW-CEEM/NEMOSIS/#accessing-additional-table-columns) by default, as an optimisation. (i.e. the commonly used columns.)
To include others:

```py
from nemosis import defaults

defaults.table_columns["MNSP_PEROFFER"] += ["FIXEDLOAD", "LASTCHANGED", "MAXAVAIL", "MR_CAPACITY", "PASAAVAILABILITY", "RAMPUPRATE"]
df = dynamic_data_compiler(...)
```

## Example File

From [PUBLIC_DVD_MNSP_PEROFFER_202102010000.zip](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/2021/MMSDM_2021_02/MMSDM_Historical_Data_SQLLoader/DATA/PUBLIC_DVD_MNSP_PEROFFER_202102010000.zip)

=== "Raw Text with Metadata"
    ```csv
    C,SETP.WORLD,DVD_MNSP_PEROFFER,AEMO,PUBLIC,2021/03/06,15:45:09,0000000337773404,,0000000337773314
    I,OFFER,MNSP_PEROFFER,1,SETTLEMENTDATE,OFFERDATE,VERSIONNO,PARTICIPANTID,LINKID,PERIODID,MAXAVAIL,BANDAVAIL1,BANDAVAIL2,BANDAVAIL3,BANDAVAIL4,BANDAVAIL5,BANDAVAIL6,BANDAVAIL7,BANDAVAIL8,BANDAVAIL9,BANDAVAIL10,LASTCHANGED,FIXEDLOAD,RAMPUPRATE,PASAAVAILABILITY,MR_CAPACITY
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,1,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,2,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,3,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,4,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,5,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,6,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,7,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,8,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,9,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,10,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    D,OFFER,MNSP_PEROFFER,1,"2021/02/01 00:00:00","2021/01/20 13:01:55",1,BASSLINK,BLNKTAS,11,478,0,0,0,594,0,0,0,0,0,0,"2021/01/20 13:01:56",,200,478,
    ...
    C,"END OF REPORT",1003
    ```

## Availability

This table is in the public monthly [MMSDM archive](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/).

I have collated the list of all those files for this table into one place, in [this CSV metadata file](../../manifests/per_table/csv/MNSP_PEROFFER.csv). (Columns `year`, `month`, `url`, `compressed_size` in bytes).

    

The earliest available data is month 1 of 2015.
The most recent available data is month 2 of 2021.!!! warning Warning
    There are some months with no files.

!!! danger "Warning"

    The filenames of zips may not correspond to the tables. These can be mixed up with [`MNSP_BIDOFFERPERIOD`](./MNSP_BIDOFFERPERIOD.md). Check column 2 and 3 inside the CSV against `REPORT_NAME` and `REPORT_SUBTYPE` to be sure. I have already done this for you, and listed all URLs in [this metadata file](../../manifests/per_table/csv/MNSP_PEROFFER.csv).

## Data Size

    

Each year of data is approximately
929 KB when zipped,
9 MB as unzipped CSV.

        

    

## Deduplication and PDR Loader Configuration

The primary keys are:

- [`LINKID`](#linkid)

- [`OFFERDATE`](#offerdate)

- [`PARTICIPANTID`](#participantid)

- [`PERIODID`](#periodid)

- [`SETTLEMENTDATE`](#settlementdate)

- [`VERSIONNO`](#versionno)

The transaction type is ["insert"](https://di-help.docs.public.aemo.com.au/Content/pdrLoader/How_it_works.htm?TocPath=pdrLoader%7CAbout+pdrLoader%7C_____5#INSERT), which means that you will usually not see duplicate data.
If you do, you can deduplicate based on the primary keys, without sorting first.
Rows from different files with the same primary keys should have the same values.

[PDR Loader configuration](https://nemweb.com.au/Reports/Current/MMSDataModelReport/PDRCONFIG/PROD_PUBLIC_PDR_CONFIG_FULL.zip) is:

| Report Name | Report Subtype | Version | Undisclosed |
|---------------|-------------------|-----------|-------------|
| BID | MNSP_PEROFFER  | 1 |
| OFFER | MNSP_PEROFFER  | 1 | ⚠️ |

!!! danger "Warning"
    Some of these file mappings are not in the
    [published PDR Loader configuration file](https://nemweb.com.au/Reports/Current/MMSDataModelReport/PDRCONFIG/PROD_PUBLIC_PDR_CONFIG_FULL.zip),
    even though files for this table exist with those metadata values.
    Mappings marked with ⚠️ have been added by me after manually inspecting those files.

This means that the CSV files start with metadata columns:

```csv
I,BID,MNSP_PEROFFER,1,...
D,BID,MNSP_PEROFFER,1,...
```

or

```csv
I,OFFER,MNSP_PEROFFER,1,...
D,OFFER,MNSP_PEROFFER,1,...
```

## Indexes

- [`LASTCHANGED`](#lastchanged)

## Links

[This page as JSON](../json/tables/MNSP_PEROFFER/bespoke.json) (schema documented [here](https://gitlab.com/MatthewDavis/mms-schema/-/blob/master/schema.py?ref_type=heads), but may change)

Download a [JSON Schema](../json/tables/MNSP_PEROFFER/json-schema.json) specification for this table.

[Official AEMO schema documentation](https://nemweb.com.au/Reports/Current/MMSDataModelReport/Electricity/ElectricityDataModelReport_files/Elec65.htm#622)

## Other Information

Package: [HISTORICAL TABLES](../packages/HISTORICAL TABLES.md)
