|
Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
|
#include "IBM_EIS/timeseries.h"Functions | |
| static void | IBM_ParseTimeseries (cJSON *response, IBM_TimeseriesDataset_TypeDef *dataset) |
| Parse timeseries response. More... | |
| static void | IBM_ParseTimeseriesAlt (cJSON *response, IBM_TimeseriesDataset_TypeDef *dataset) |
| Parse timeseries response from alternative endpoint. More... | |
| static void | IBM_BuildURL (IBM_TimeseriesReq_TypeDef *req, char *url) |
| Build IBM EIS request URL. More... | |
| static void | IBM_BuildURLAlt (IBM_TimeseriesReq_TypeDef *req, char *url) |
| Build IBM EIS request URL for alternative endpoint. More... | |
| CURLcode | IBM_GetTimeseries (IBM_AuthHandle_TypeDef *auth_handle, IBM_TimeseriesReq_TypeDef *request, IBM_TimeseriesDataset_TypeDef *dataset, uint8_t alt_flag) |
| Get timeseries data from IBM EMS. More... | |
| int8_t | IBM_TimeseriesToCSV (IBM_TimeseriesReq_TypeDef *request, IBM_TimeseriesDataset_TypeDef *dataset) |
| Write timeseries dataset to .csv file. More... | |
| IBM_TimeseriesDataset_TypeDef | IBM_TimeseriesFromCSV (const char *filename) |
| Load IBM timeseries dataset from local .csv file. More... | |
| void | IBM_TimeseriesToDB (IBM_TimeseriesReq_TypeDef *req_info, IBM_TimeseriesDataset_TypeDef *dataset, T_LocationLookup_TypeDef *location, PGconn *psql_conn) |
| Write timeseries dataset to PostgreSQL table. More... | |
| void | IBM_BuildTSDatabase (T_LocationsLookup_TypeDef *locations, const char *start_time, const char *end_time, PGconn *psql_conn) |
| void IBM_BuildTSDatabase | ( | T_LocationsLookup_TypeDef * | locations, |
| const char * | start_time, | ||
| const char * | end_time, | ||
| PGconn * | psql_conn | ||
| ) |
|
static |
Build IBM EIS request URL.
Build a URL for IBM EIS at endpoint https://pairs.res.ibm.com
Takes a request structure and formulates the appropriate URL.
| req | Request information to populate URL with. |
| url | URL to modify. |
|
static |
Build IBM EIS request URL for alternative endpoint.
Build a URL for IBM EIS at endpoint https://ibmpairs-mvp2-api.mybluemix.net
Takes a request structure and formulates the appropriate URL.
| req | Request information to populate URL with. |
| url | URL to modify. |
| CURLcode IBM_GetTimeseries | ( | IBM_AuthHandle_TypeDef * | auth_handle, |
| IBM_TimeseriesReq_TypeDef * | request, | ||
| IBM_TimeseriesDataset_TypeDef * | dataset, | ||
| uint8_t | alt_flag | ||
| ) |
Get timeseries data from IBM EMS.
IBM EIS get timeseries data as a JSON response.
IBM EIS provides two endpoints to get data from:
The responses from these requests have different formats therefore they need to be treated seperatly. Luckly similar data is used for each request making the use of TimeseriesReq_TypeDef possible for both requests.
| auth_handle | IBM authentication handler |
| request | Request struct with corresponding data. |
| dataset | The dataset to populate. |
| alt_flag | A flag representing if the alt enpoint should be used. |
|
static |
Parse timeseries response.
Parse timeseries data from IBM URL response.
This function takes JSON data received from the endpoint https://pairs.res.ibm.com (IBM_REQUEST_URL) to formulate a dataset (TimeseriesDataset_TypeDef).
| response | The JSON to parse. |
| dataset | The dataset to populate. |
|
static |
Parse timeseries response from alternative endpoint.
Parse timeseries data from alternative IBM URL response.
This function takes JSON data received from the endpoint https://ibmpairs-mvp2-api.mybluemix.net (IBM_ALT_REQUEST_URL) to formulate a dataset (TimeseriesDataset_TypeDef).
| response | The JSON to parse. |
| dataset | The dataset to populate. |
| IBM_TimeseriesDataset_TypeDef IBM_TimeseriesFromCSV | ( | const char * | filename | ) |
Load IBM timeseries dataset from local .csv file.
Load timeseries dataset from a cached .csv for .txt file.
Requires the file to be formatted as Unix;Date;Value
| filename | Filename of file to open, including path. |
| int8_t IBM_TimeseriesToCSV | ( | IBM_TimeseriesReq_TypeDef * | request, |
| IBM_TimeseriesDataset_TypeDef * | dataset | ||
| ) |
Write timeseries dataset to .csv file.
IBM timeseires dataset to csv.
Creates required directories and then builds a csv files with the downloaded dataset.
| request | Timeseries request information (layer ID is needed). |
| dataset | Dataset to write to file. Count is provided here too. |
| void IBM_TimeseriesToDB | ( | IBM_TimeseriesReq_TypeDef * | req_info, |
| IBM_TimeseriesDataset_TypeDef * | dataset, | ||
| T_LocationLookup_TypeDef * | location, | ||
| PGconn * | psql_conn | ||
| ) |
Write timeseries dataset to PostgreSQL table.
Insert an IBM dataset into a PostgreSQL table.
This function handles precipitation, min and max temperatures. Several other datasets are required to give context regarding the IBM datasets location and relevance.
| req_info | Request information provided to IBM. |
| dataset | Dataset to insert into table. |
| location | Location information from PostgreSQL lookup table. |
| psql_conn | PostgreSQL database connection handler. |