# MTPASA_REGIONSOLUTION

> [`MTPASA_CASESOLUTION`](./MTPASA_CASESOLUTION.md) is obsolete from 2017 End of Year DM4.27 Release.
> The MTPASA_REGIONSOLUTION table shows the results of the regional capacity, maximum surplus reserve and maximum spare capacity evaluations for each day and ldcblock of the study.

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

> MTPASA_REGIONSOLUTION is public so is available to all participants.
> 
> Source
> 
> MTPASA_REGIONSOLUTION is updated each MTPASA run (i.e. weekly).
> 
> Volume
> 
> Rows per week: 29400
> 
> To store only the latest solution, divide these figures by 5 (number of
> weeks per month rounded up).

## Column Schema

### DAY

> Day this solution is for. Generated from the solution file periodid

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

This column is mandatory, and a primary key.

Example: `2018/05/06 00:00:00`

### ENERGYBLOCK

> Sunday at start of the week for this solutions energy block. Generated from the solution file energy block

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

This column is mandatory, and a primary key.

Example: `2018/05/06 00:00:00`

### LDCBLOCK

> LDC block this solution is for. Generated from the solution file periodid

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

This column is mandatory, and a primary key.

Example: `1`

### REGIONID

> The unique region identifier

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

The SQL type is `VARCHAR2(10)`.
This is actually a factor/enum, with values:

- `QLD1`

- `VIC1`

- `TAS1`

- `NSW1`

- `SA1`

- `SNOWY1`

This column is mandatory, and a primary key.

### RUN_DATETIME

> Date processing of the run begins

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

This column is mandatory, and a primary key.

Example: `2018/05/01 12:00:00`

### RUN_NO

> Unique run id. Generated from the solution file caseid

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

This column is mandatory, and a primary key.

Example: `20`

### RUNTYPE

> Type of run. Values are RELIABILITY_LRC and OUTAGE_LRC

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

This column is mandatory, and a primary key.

Example: `RELIABILITY_LRC`

### AGGREGATECAPACITYAVAILABLE

> Sum of MAXAVAIL quantities offered by all Scheduled Generators in a given Region for a given PERIODID.

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`1820`, `15147`

### AGGREGATEPASAAVAILABILITY

> Sum of PASAAVAILABILITY quantities offered by all Scheduled Generators in a given Region for a given PERIODID.

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

This column is not mandatory.

Examples:
`1820`, `15147`

### AGGREGATESCHEDULEDLOAD

> Sum of MAXAVAIL quantities bid by of all Scheduled Loads in a given Region for a given PERIODID.

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Example: `0`

### CALCULATEDLOR1LEVEL

> Region Reserve Level for LOR1 used. Can be static value or calculated value if an interconnector is a credible contingency

SQL Type: `NUMBER(16,6)`
Polars Type: `pl.Float64`

This column is not mandatory.

### CALCULATEDLOR2LEVEL

> Region Reserve Level for LOR2 used. Can be static value or calculated value if an interconnector is a credible contingency

SQL Type: `NUMBER(16,6)`
Polars Type: `pl.Float64`

This column is not mandatory.

### CONSTRAINEDCAPACITY

> Region energy constrained MW capacity subject to energy and network security constraints

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

This column is not mandatory.

Examples:
`0`, `285`, `8645`

### DEFICITRESERVE

> Regional reserve deficit (MW)

SQL Type: `NUMBER(16,6)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`76.428732`, `0`, `432.8090`

### DEMAND10

> Input value for 10% probability demand

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`1263.73`, `7006`, `14143.73`, `13473`

### DEMAND50

> Input value for 50% probability demand

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`1168.36`, `6698`, `13082.32`, `8531`

### DEMAND_AND_NONSCHEDGEN

> Sum of Cleared Scheduled generation, imported generation (at the region boundary) and allowances made for non-scheduled generation (MW).

SQL Type: `NUMBER(15,5)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`1302.0020`, `1593`, `14369.0040`, `9497`

### ENERGYREQDEMAND10

> Sum of: (Region Period Demand - given Demand10)/PeriodLength(sum by Energy Block, entered in first period of energy block, GWh)

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`167.07`, `0`, `220`, `1907.88`

### ENERGYREQDEMAND50

> Sum of: (Region Period Demand - given Demand50)/PeriodLength (sum by Energy Block, entered in first period of energy block, GWh)

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`152.25`, `0`, `199`, `1751.81`

### LASTCHANGED

> Date the solution was loaded

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: `2018/05/01 12:31:15`

### LOR_SEMISCHEDULEDCAPACITY

> Aggregate Regional UIGF availability for LOR

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Example: `0`

### LORCONDITION

> The LOR Condition determined from the Maximum Spare Capacity value: 0 = no condition, 1 = LOR1 condition, 2 = LOR2 condition, 3 = LOR3 condition

SQL Type: `NUMBER(1,0)`
Polars Type: `pl.UInt8`

This column is not mandatory.

### LORNETINTERCHANGEUNDERSCARCITY

> Net interconnector flow from the region for this interval from the LOR assessment

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

### LORTOTALINTERMITTENTGENERATION

> Allowance made for non-scheduled generation in the LOR assessment

SQL Type: `NUMBER(15,5)`
Polars Type: `pl.Float64`

This column is not mandatory.

### MAXSPARECAPACITY

> The Maximum Spare Capacity evaluated for this region in this period. Calculated for each region in turn

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

### MAXSURPLUSRESERVE

> The Maximum generation (MW) that could be withdrawn from this region without incurring a Low Reserve Condition.

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

### MAXUSEFULRESPONSE

> The Maximum market response (MW) needed for the region to eliminate a Low Reserve Condition (LRC)

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Example: `0`

### MSRNETINTERCHANGEUNDERSCARCITY

> Net interconnector flow from the region for this interval from the MSR assessment

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

### MURNETINTERCHANGEUNDERSCARCITY

> Net interconnector flow from the region for this interval from the MRR assessment

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

### NETINTERCHANGEUNDERSCARCITY

> Calculated in capacity adequacy evaluation: Export if > 0, Import if < 0.

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`-330.45`, `0.45`, `0`, `330`

### RESERVECONDITION

> The regional reserve condition: 0 = Adequate, 1 = LRC

SQL Type: `NUMBER(1,0)`
Polars Type: `pl.Int8`

This column is not mandatory.

Examples:
`0`, `1`

### SEMISCHEDULEDCAPACITY

> Aggregate Regional UIGF availability

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`1.76`, `0`, `109.74`

### SURPLUSCAPACITY

> Regional surplus capacity MW, +/- values indicate surplus/deficit capacity

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`-6.72`, `14.6`, `-368`, `4163`

### TOTALINTERMITTENTGENERATION

> Allowance made for non-scheduled generation in the demand forecast (MW).

SQL Type: `NUMBER(15,5)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`34.821`, `422`, `244.154`, `428`

### UIGF

> Regional aggregated Unconstrained Intermittent Generation Forecast of Semi-scheduled generation (MW).

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is not mandatory.

Examples:
`1.76`, `0`, `109.74`

### UNCONSTRAINEDCAPACITY

> Region energy unconstrained MW capacity subject to network security constraints

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

This column is not mandatory.

Examples:
`985`, `10482`

### CAPACITYREQ {: .unused-column }

> Not used from 21/05/2010. Prior to 21/05/2010: CA Demand + Reserve Requirement

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is unused.

### RESERVEREQ {: .unused-column }

> Not used from 21/05/2010. Prior to 21/05/2010: Input reserve requirement

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is unused.

### SURPLUSRESERVE {: .unused-column }

> Not used from 21/05/2010. Prior to 21/05/2010: Regional reserve surplus. +/-0 values indicate surplus/deficit reserve

SQL Type: `NUMBER(12,2)`
Polars Type: `pl.Float64`

This column is unused.

## New Data Timing

> On MTPASA solution published to the market (usually once per week)

## 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"

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("DAY", "ENERGYBLOCK", "RUN_DATETIME", "LASTCHANGED").str.strptime(
            pl.Datetime, dt_s_fmt
        ),
    )
    .cast(
        {
            "LDCBLOCK": int,  # or pl.Int16
            "REGIONID": pl.Enum(["QLD1", "VIC1", "TAS1", "NSW1", "SA1", "SNOWY1"]),
            "RUN_NO": int,  # or pl.Int16
            "RUNTYPE": pl.Categorical,
            "AGGREGATECAPACITYAVAILABLE": pl.Float64,
            "AGGREGATEPASAAVAILABILITY": int,  # or pl.Int64
            "AGGREGATESCHEDULEDLOAD": pl.Float64,
            "CALCULATEDLOR1LEVEL": pl.Float64,
            "CALCULATEDLOR2LEVEL": pl.Float64,
            "CONSTRAINEDCAPACITY": int,  # or pl.Int64
            "DEFICITRESERVE": pl.Float64,
            "DEMAND10": pl.Float64,
            "DEMAND50": pl.Float64,
            "DEMAND_AND_NONSCHEDGEN": pl.Float64,
            "ENERGYREQDEMAND10": pl.Float64,
            "ENERGYREQDEMAND50": pl.Float64,
            "LOR_SEMISCHEDULEDCAPACITY": pl.Float64,
            "LORCONDITION": int,  # or pl.UInt8
            "LORNETINTERCHANGEUNDERSCARCITY": pl.Float64,
            "LORTOTALINTERMITTENTGENERATION": pl.Float64,
            "MAXSPARECAPACITY": pl.Float64,
            "MAXSURPLUSRESERVE": pl.Float64,
            "MAXUSEFULRESPONSE": pl.Float64,
            "MSRNETINTERCHANGEUNDERSCARCITY": pl.Float64,
            "MURNETINTERCHANGEUNDERSCARCITY": pl.Float64,
            "NETINTERCHANGEUNDERSCARCITY": pl.Float64,
            "RESERVECONDITION": int,  # or pl.Int8
            "SEMISCHEDULEDCAPACITY": pl.Float64,
            "SURPLUSCAPACITY": pl.Float64,
            "TOTALINTERMITTENTGENERATION": pl.Float64,
            "UIGF": pl.Float64,
            "UNCONSTRAINEDCAPACITY": int,  # or pl.Int64
            "CAPACITYREQ": pl.Float64,
            "RESERVEREQ": pl.Float64,
            "SURPLUSRESERVE": pl.Float64,
        }
    )
    # Drop deprecated/unused columns
    .drop("CAPACITYREQ", "RESERVEREQ", "SURPLUSRESERVE")
    # Deduplicate
    # We want one row per ['DAY', 'ENERGYBLOCK', 'LDCBLOCK', 'REGIONID', 'RUN_DATETIME', 'RUN_NO', 'RUNTYPE']
    # Tie-breaker: greatest value of ['LASTCHANGED']
    .sort(["LASTCHANGED"], descending=False)
    .unique(
        subset=[
            "DAY",
            "ENERGYBLOCK",
            "LDCBLOCK",
            "REGIONID",
            "RUN_DATETIME",
            "RUN_NO",
            "RUNTYPE",
        ],
        keep="last",
    )
)

```

### Nemosis

This table is not yet available in [Nemosis](https://github.com/UNSW-CEEM/NEMOSIS/#static_table).

## Example File

From [PUBLIC_DVD_MTPASA_REGIONSOLUTION_201805010000.zip](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/2018/MMSDM_2018_05/MMSDM_Historical_Data_SQLLoader/DATA/PUBLIC_DVD_MTPASA_REGIONSOLUTION_201805010000.zip)

=== "Raw Text with Metadata"
    ```csv
    C,SETP.WORLD,DVD_MTPASA_REGIONSOLUTION,AEMO,PUBLIC,2018/06/07,00:35:03,0000000295553420,,0000000295553313
    I,MTPASA,REGIONSOLUTION,6,RUN_DATETIME,RUN_NO,ENERGYBLOCK,DAY,LDCBLOCK,REGIONID,DEMAND10,RESERVEREQ,CAPACITYREQ,ENERGYREQDEMAND10,UNCONSTRAINEDCAPACITY,CONSTRAINEDCAPACITY,NETINTERCHANGEUNDERSCARCITY,SURPLUSCAPACITY,SURPLUSRESERVE,RESERVECONDITION,MAXSURPLUSRESERVE,MAXSPARECAPACITY,LORCONDITION,AGGREGATECAPACITYAVAILABLE,AGGREGATESCHEDULEDLOAD,LASTCHANGED,AGGREGATEPASAAVAILABILITY,RUNTYPE,CALCULATEDLOR1LEVEL,CALCULATEDLOR2LEVEL,MSRNETINTERCHANGEUNDERSCARCITY,LORNETINTERCHANGEUNDERSCARCITY,TOTALINTERMITTENTGENERATION,DEMAND50,DEMAND_AND_NONSCHEDGEN,UIGF,SEMISCHEDULEDCAPACITY,LOR_SEMISCHEDULEDCAPACITY,DEFICITRESERVE,MAXUSEFULRESPONSE,MURNETINTERCHANGEUNDERSCARCITY,LORTOTALINTERMITTENTGENERATION,ENERGYREQDEMAND50
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/06 00:00:00",1,NSW1,10158,,,1431.59,5212,7759,330,2482.6,,0,,,,13034,0,"2018/05/01 12:31:15",13034,RELIABILITY_LRC,,,,,195.005,9842.29,10353.0050,3.59,3.59,0,0,0,,,1385.85
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/06 00:00:00",1,QLD1,7535,,,1092.89,10482,940,0,3887.02,,0,,,,11830,0,"2018/05/01 12:31:15",11830,RELIABILITY_LRC,,,,,422,7222,7957,0,0,0,0,0,,,1047.18
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/06 00:00:00",1,SA1,2008.18,,,270.22,1050,780,0,-177.87,,0,,,,1895,0,"2018/05/01 12:31:15",1895,RELIABILITY_LRC,,,,,34.821,1858.9,2043.0010,35.31,35.31,0,0,0,,,247.62
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/06 00:00:00",1,TAS1,1533.24,,,201.63,2229,0,0,695.71,,0,,,,2213,0,"2018/05/01 12:31:15",2213,RELIABILITY_LRC,,,,,77.76,1444.85,1611,15.95,15.95,0,0,0,,,188.47
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/06 00:00:00",1,VIC1,6288.72,,,1012.74,5529,2687,-330,2257.72,,0,,,,8187,0,"2018/05/01 12:31:15",8187,RELIABILITY_LRC,,,,,161.276,6045.52,6449.9960,29.44,29.44,0,0,0,,,973.11
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/07 00:00:00",1,NSW1,11283,,,0,5212,7244,330,842.6,,0,,,,12452,0,"2018/05/01 12:31:15",12452,RELIABILITY_LRC,,,,,195.005,10938.29,11478.0050,3.59,3.59,0,0,0,,,0
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/07 00:00:00",1,QLD1,7496,,,0,10450,971,3.55,3921.7,,0,,,,11830,0,"2018/05/01 12:31:15",11830,RELIABILITY_LRC,,,,,422,7185,7918,0,0,0,0,0,,,0
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/07 00:00:00",1,SA1,2202.18,,,0,1170,880,0,-151.84,,0,,,,2015,0,"2018/05/01 12:31:15",2015,RELIABILITY_LRC,,,,,34.821,2044.9,2237.0010,35.34,35.34,0,0,0,,,0
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/07 00:00:00",1,TAS1,1622.24,,,0,2117,0,0,494.71,,0,,,,2101,0,"2018/05/01 12:31:15",2101,RELIABILITY_LRC,,,,,77.76,1531.85,1700,15.95,15.95,0,0,0,,,0
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/07 00:00:00",1,VIC1,7197.72,,,0,5899,2687,-333.55,1722.26,,0,,,,8557,0,"2018/05/01 12:31:15",8557,RELIABILITY_LRC,,,,,161.276,6926.52,7358.9960,29.44,29.44,0,0,0,,,0
    D,MTPASA,REGIONSOLUTION,6,"2018/05/01 12:00:00",20,"2018/05/06 00:00:00","2018/05/08 00:00:00",1,NSW1,11833,,,0,5212,7244,330,292.6,,0,,,,12452,0,"2018/05/01 12:31:15",12452,RELIABILITY_LRC,,,,,195.005,11473.29,12028.0050,3.59,3.59,0,0,0,,,0
    ...
    C,"END OF REPORT",1003
    ```

## Availability

Visibility: Public

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 into one place, in [this CSV metadata file](../../manifests/per_table/csv/MTPASA_REGIONSOLUTION.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 5 of 2018.

 Every month in between has a file. (No gaps.)

## Data Size

Each year of data is approximately
4 MB when zipped,
39 MB as unzipped CSV.

## Deduplication and PDR Loader Configuration

The primary keys are:

- [`DAY`](#day)

- [`ENERGYBLOCK`](#energyblock)

- [`LDCBLOCK`](#ldcblock)

- [`REGIONID`](#regionid)

- [`RUN_DATETIME`](#run_datetime)

- [`RUN_NO`](#run_no)

- [`RUNTYPE`](#runtype)

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

| Report Name | Report Subtype | Version | Undisclosed |
|---------------|-------------------|-----------|-------------|
| MTPASA | REGIONSOLUTION  | 6 | ⚠️ |

!!! 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,MTPASA,REGIONSOLUTION,6,...
D,MTPASA,REGIONSOLUTION,6,...
```

## Indexes

- [`LASTCHANGED`](#lastchanged)

## Links

[This page as JSON](../json/tables/MTPASA_REGIONSOLUTION/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/MTPASA_REGIONSOLUTION/json-schema.json) specification for this table.

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

## Other Information

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