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

Functions

static int8_t BOM_ParseWeather (Utils_ReqData_TypeDef *stream, BOM_WeatherDataset_TypeDef *dataset, BOM_WeatherStation_TypeDef *station)
 
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)
 

Function Documentation

◆ BOM_GetWeather()

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).

See also
http://www.bom.gov.au/catalogue/anon-ftp.shtml
Parameters
datasetTimeseries dataset to populate with data.
filenameStation filename obtained from BOM_Stations_TypeDef.
year_monthYear and month of interest e.g. 202206 for 2022 06 (June)
Returns
Returns cURL status code.

◆ BOM_HistoricalWeatherToDB()

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.

Parameters
weather_stationBOM weather station information.
datasetBOM weather station dataset.
psql_connPostgreSQL connection handler.

◆ BOM_LoadWeatherFromCSV()

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.

Parameters
filenameFile to load (includes path).
datasetDataset to populate.
Returns
Status code.

◆ BOM_ParseWeather()

static int8_t BOM_ParseWeather ( Utils_ReqData_TypeDef stream,
BOM_WeatherDataset_TypeDef dataset,
BOM_WeatherStation_TypeDef station 
)
static

Saves a downloaded .csv dataset to a file. Also parses the data into a BOM dataset struct.

Parameters
streamContains raw string with .csv file.
datasetDataset to populate.
Returns
Status code OK = 0 ... ERROR = -1

◆ BOM_TimeseriesToDB()

void BOM_TimeseriesToDB ( const char *  start_time,
PGconn *  psql_conn 
)