Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
Loading...
Searching...
No Matches
transform.c File Reference
#include "transform.h"
Include dependency graph for transform.c:

Functions

static float T_Normalise (const float value, const float min, const float max)
 Helper function for nomalising data. More...
 
void T_BuildWeatherDB (T_LocationsLookup_TypeDef *locations, PGconn *psql_conn)
 Build weather table in PostgreSQL database. More...
 
void T_FloodPrediction (PGconn *psql_conn)
 Transforms data from all harvest programs into flood prediction. More...
 
void T_WindowDataset (PGconn *psql_conn, const int program_id)
 Window dataset into sum of next 8-days and previous 5-days. More...
 
void T_NormaliseWindowedPrecipitation (PGconn *psql_conn, const int program_id)
 Normalise summed moving window precipitation between 0 and 1. More...
 

Function Documentation

◆ T_BuildWeatherDB()

void T_BuildWeatherDB ( T_LocationsLookup_TypeDef locations,
PGconn *  psql_conn 
)

Build weather table in PostgreSQL database.

Main weather table for each location.

This table contains both forecasted and historical weather information for each harvest location. One column contains precipitation data where forecasted weather is added first, then overwritten using observed values. Both forecasted and observed data are stored in seperate columns.

Note
This function requires weather_ibm_eis and weather_bom tables to be populated.
Parameters
locationsUnique locations information.
psql_connPostgreSQL connection handler.

◆ T_FloodPrediction()

void T_FloodPrediction ( PGconn *  psql_conn)

Transforms data from all harvest programs into flood prediction.

@breif Main entry point for calculating the risk of a harvest area closure.

Gets a list of the harvest areas. Loops through each of these locations to calcualte a windowed moving average of precipitation and then normalises this window to provide a value between 0 and 1.

Parameters
psql_connPostgreSQL connection.

◆ T_Normalise()

static float T_Normalise ( const float  value,
const float  min,
const float  max 
)
inlinestatic

Helper function for nomalising data.

Parameters
valueRaw input value.
minRaw maxiumum value.
maxRaw miniumum value.
Returns
Normalised input value (between 0 and 1).

◆ T_NormaliseWindowedPrecipitation()

void T_NormaliseWindowedPrecipitation ( PGconn *  psql_conn,
const int  program_id 
)

Normalise summed moving window precipitation between 0 and 1.

@breif Normalise precipiation data between 0 and 1.

After a summed window average has been completed by T_WindowDataset the data can then be normalised. This normalisation is program specific i.e. each normalisations max and min are based on that program only and not the max and min of all programs in NSW.

Parameters
psql_connPostgreSQL connection.

◆ T_WindowDataset()

void T_WindowDataset ( PGconn *  psql_conn,
const int  program_id 
)

Window dataset into sum of next 8-days and previous 5-days.

Window transform Z-Score values into a probability of flooding event.

For each program_id calcualte the sum of the next 8-days precipitation and the previous 5-days preciptiation. This acts as a moving window across all available data.

Note
The outlook and hindlook can be adjusted by altering the w_start and w_end variables in this function.
Parameters
psql_connPostgreSQL connection.
program_idFood authority program ID.