|
Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
|
#include <libpq-fe.h>#include <stdio.h>#include <stdlib.h>#include <log.h>#include "BOM/stations.h"#include "FoodAuthority/harvest_area.h"#include "WillyWeather/location.h"#include "utils.h"Go to the source code of this file.
Data Structures | |
| struct | T_LocationLookup_TypeDef |
| Structure of a location (i.e. program location) More... | |
| struct | T_LocationsLookup_TypeDef |
| Locations lookup table structure. More... | |
| struct | T_Outlook_Typedef |
| Harvest area outlook / prediction information. More... | |
| struct | T_OutlookData_TypeDef |
| struct | T_OutlookDataset_TypeDef |
Macros | |
| #define | T_MAX_N_LOCATIONS 50 |
| Maximum number of locations. More... | |
| #define | T_TIMESTAMP_SIZE 50 |
| Maximum size of timestamp (num chars) More... | |
| #define | T_OUTLOOK_BUF_SIZE 200 |
| Outlook buffer size. More... | |
| #define | T_EST_CLOSURE_BUF_SIZE 20 |
| Outlook closue time code. More... | |
| #define | T_DATA_TYPE_SIZE 30 |
| Data type size. More... | |
| #define | T_DATA_QUERY_LENGTH 15 |
| #define | T_DATA_WINDOW_SIZE 7 |
Functions | |
| 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, int program_id) |
| Window transform Z-Score values into a probability of flooding event. More... | |
| void | T_NormaliseWindowedPrecipitation (PGconn *psql_conn, int program_id) |
| Normalise summed moving window precipitation between 0 and 1. More... | |
| #define T_DATA_QUERY_LENGTH 15 |
| #define T_DATA_TYPE_SIZE 30 |
Data type size.
| #define T_DATA_WINDOW_SIZE 7 |
| #define T_EST_CLOSURE_BUF_SIZE 20 |
Outlook closue time code.
| #define T_MAX_N_LOCATIONS 50 |
Maximum number of locations.
| #define T_OUTLOOK_BUF_SIZE 200 |
Outlook buffer size.
| #define T_TIMESTAMP_SIZE 50 |
Maximum size of timestamp (num chars)
| 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.
| locations | Unique locations information. |
| psql_conn | PostgreSQL connection handler. |
| 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.
| psql_conn | PostgreSQL connection. |
| 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.
| psql_conn | PostgreSQL connection. |
| void T_WindowDataset | ( | PGconn * | psql_conn, |
| const int | program_id | ||
| ) |
Window transform Z-Score values into a probability of flooding event.
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.
w_start and w_end variables in this function.| psql_conn | PostgreSQL connection. |
| program_id | Food authority program ID. |