|
Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
|
#include <time.h>#include <curl/curl.h>#include <ctype.h>#include <libpq-fe.h>#include <stdint.h>#include "transform.h"#include "BOM/stations.h"#include "ftp.h"Go to the source code of this file.
Data Structures | |
| struct | BOM_WeatherDataset_TypeDef |
Macros | |
| #define | BOM_RESPONSE_BUFFER_SIZE 200 |
| Max number of items in weather dataset. More... | |
| #define | BOM_TIME_STR_BUFFER_SIZE 30 |
| Max number of chars in timestamp buffer. More... | |
| #define | BOM_MAX_RESPONSE_SIZE 10000 |
| Max buffer size to read into memory (size of .csv file from BOM FTP server) More... | |
Functions | |
| CURLcode | BOM_GetWeather (BOM_WeatherDataset_TypeDef *dataset, BOM_WeatherStation_TypeDef *station, const char *year_month) |
| Get historical weather for a particular BOM weather station. More... | |
| int8_t | BOM_LoadWeatherFromCSV (const char *filename, BOM_WeatherDataset_TypeDef *dataset, BOM_WeatherStation_TypeDef *station) |
| Load BOM weather station dataset from .csv file. More... | |
| void | BOM_HistoricalWeatherToDB (BOM_WeatherStation_TypeDef *weather_station, BOM_WeatherDataset_TypeDef *dataset, PGconn *psql_conn) |
| Write observed weather to PostgreSQL table (weather_bom) More... | |
| void | BOM_TimeseriesToDB (const char *start_time, PGconn *psql_conn) |
| #define BOM_MAX_RESPONSE_SIZE 10000 |
Max buffer size to read into memory (size of .csv file from BOM FTP server)
| #define BOM_RESPONSE_BUFFER_SIZE 200 |
Max number of items in weather dataset.
| #define BOM_TIME_STR_BUFFER_SIZE 30 |
Max number of chars in timestamp buffer.
| CURLcode BOM_GetWeather | ( | BOM_WeatherDataset_TypeDef * | dataset, |
| BOM_WeatherStation_TypeDef * | station, | ||
| const char * | year_month | ||
| ) |
Get historical weather for a particular BOM weather station.
Get a file from the Bureau of Meterology FTP server.
The BOM provides formatted .csv files for certain locations in Australia. These .csv files can be downloaded from the BOM's FTP server. Currently, it is unknown when the data is updated (sometime daily).
| dataset | Timeseries dataset to populate with data. |
| filename | Station filename obtained from BOM_Stations_TypeDef. |
| year_month | Year and month of interest e.g. 202206 for 2022 06 (June) |
| void BOM_HistoricalWeatherToDB | ( | BOM_WeatherStation_TypeDef * | weather_station, |
| BOM_WeatherDataset_TypeDef * | dataset, | ||
| PGconn * | psql_conn | ||
| ) |
Write observed weather to PostgreSQL table (weather_bom)
Turn a weather station dataset from the BOM into database values.
Rows that already exist are overwritten, new rows are added. Need to ensure each dataset and weather station are from the same source. These data are inserted into the weather_bom PostgreSQL table.
| weather_station | BOM weather station information. |
| dataset | BOM weather station dataset. |
| psql_conn | PostgreSQL connection handler. |
| int8_t BOM_LoadWeatherFromCSV | ( | const char * | filename, |
| BOM_WeatherDataset_TypeDef * | dataset, | ||
| BOM_WeatherStation_TypeDef * | station | ||
| ) |
Load BOM weather station dataset from .csv file.
Load a BOM dataset from a cached .csv file.
| filename | File to load (includes path). |
| dataset | Dataset to populate. |
| void BOM_TimeseriesToDB | ( | const char * | start_time, |
| PGconn * | psql_conn | ||
| ) |