Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
Loading...
Searching...
No Matches
transform.h
Go to the documentation of this file.
1#ifndef PROGRAM_TRANSFORM_H
2#define PROGRAM_TRANSFORM_H
3
4#include <libpq-fe.h>
5#include <stdio.h>
6#include <stdlib.h>
7#include <log.h>
8
9#include "BOM/stations.h"
12#include "utils.h"
13
15#define T_MAX_N_LOCATIONS 50
16
18#define T_TIMESTAMP_SIZE 50
19
21#define T_OUTLOOK_BUF_SIZE 200
22
24#define T_EST_CLOSURE_BUF_SIZE 20
25
27#define T_DATA_TYPE_SIZE 30
28
29#define T_DATA_QUERY_LENGTH 15
30#define T_DATA_WINDOW_SIZE 7
31
33typedef struct {
34 char last_updated[T_TIMESTAMP_SIZE];
35 char fa_program_name[FA_MAX_BUFFER];
36 char fa_program_id[FA_MAX_BUFFER];
37 char ww_location[WW_LOCATION_BUF];
38 char ww_location_id[WW_LOCATION_BUF];
41 char bom_location[BOM_STATION_NAME_SIZE];
42 char bom_location_id[BOM_STATION_ID_SIZE];
47
49typedef struct {
50 uint16_t count;
53
55typedef struct {
56 char program_name[FA_MAX_BUFFER];
57 int32_t ha_id;
58 char classification[FA_MAX_BUFFER];
59 char status[FA_MAX_BUFFER];
60 char time_processed[T_TIMESTAMP_SIZE];
61 char status_reason[FA_MAX_BUFFER];
62 bool closed;
63 bool to_close;
64 char closure_type[T_OUTLOOK_BUF_SIZE];
65 char closure_reason[T_OUTLOOK_BUF_SIZE];
66 char closure_date[T_TIMESTAMP_SIZE];
68 char est_closure_time[T_EST_CLOSURE_BUF_SIZE];
70
71typedef struct{
72 char time_processed[T_TIMESTAMP_SIZE];
73 char data_type[T_DATA_TYPE_SIZE];
76
77typedef struct{
78 int32_t count;
81
84 PGconn* psql_conn);
85
87void T_FloodPrediction(PGconn* psql_conn);
88
90void T_WindowDataset(PGconn* psql_conn, int program_id);
91
93void T_NormaliseWindowedPrecipitation(PGconn* psql_conn, int program_id);
94
95#endif //PROGRAM_TRANSFORM_H
#define FA_MAX_BUFFER
Buffer size for each HTML value from NSW Food Authority.
Definition: harvest_area.h:13
#define WW_LOCATION_BUF
Buffer for location information.
Definition: location.h:17
#define BOM_STATION_NAME_SIZE
BOM site name size (length)
Definition: stations.h:17
#define BOM_STATION_ID_SIZE
BOM site id size (length)
Definition: stations.h:13
Structure of a location (i.e. program location)
Definition: transform.h:33
float bom_longitude
BOM weather station longitude.
Definition: transform.h:44
float ww_latitude
Willy Weather location latitude.
Definition: transform.h:39
float ww_longitude
Willy Weather location longitude.
Definition: transform.h:40
float bom_distance
Distance from BOM weather station to harvest area.
Definition: transform.h:45
float bom_latitude
BOM weather station latitude.
Definition: transform.h:43
Locations lookup table structure.
Definition: transform.h:49
uint16_t count
Number of locations.
Definition: transform.h:50
Harvest area outlook / prediction information.
Definition: transform.h:55
bool closed
Is harvest area currently closed?
Definition: transform.h:62
int32_t ha_id
Harvest area unique ID.
Definition: transform.h:57
float closure_severity_index
Expected closure severity index.
Definition: transform.h:67
bool to_close
Is the harvest area predicted to close.
Definition: transform.h:63
Definition: transform.h:71
double precipitaiton
Definition: transform.h:74
Definition: transform.h:77
int32_t count
Definition: transform.h:78
void T_WindowDataset(PGconn *psql_conn, int program_id)
Window transform Z-Score values into a probability of flooding event.
Definition: transform.c:282
#define T_DATA_QUERY_LENGTH
Definition: transform.h:29
#define T_DATA_TYPE_SIZE
Data type size.
Definition: transform.h:27
void T_BuildWeatherDB(T_LocationsLookup_TypeDef *locations, PGconn *psql_conn)
Build weather table in PostgreSQL database.
Definition: transform.c:31
#define T_MAX_N_LOCATIONS
Maximum number of locations.
Definition: transform.h:15
void T_NormaliseWindowedPrecipitation(PGconn *psql_conn, int program_id)
Normalise summed moving window precipitation between 0 and 1.
Definition: transform.c:381
#define T_EST_CLOSURE_BUF_SIZE
Outlook closue time code.
Definition: transform.h:24
#define T_TIMESTAMP_SIZE
Maximum size of timestamp (num chars)
Definition: transform.h:18
#define T_OUTLOOK_BUF_SIZE
Outlook buffer size.
Definition: transform.h:21
void T_FloodPrediction(PGconn *psql_conn)
Transforms data from all harvest programs into flood prediction.
Definition: transform.c:218