surveyweathertool.src.weather.source_weather_data

Module Contents

Functions

preprocess_data(source_path, dest_path, weather, ...)

Preprocess weather data by filling missing values, grouping, and saving as Pickle files.

get_weather_data(spi_path, GEO_COLUMNS[, ...])

Fetches and processes weather data based on provided file paths.

surveyweathertool.src.weather.source_weather_data.preprocess_data(source_path, dest_path, weather, coordinate_limits)

Preprocess weather data by filling missing values, grouping, and saving as Pickle files.

Parameters: source_path (str): Directory containing source CSV files. dest_path (str): Directory where processed files will be saved. coordinate_limits (list): List of latitude and longitude coordinate limits.

Notes: This function assumes that the CSV files have columns ‘lat’, ‘lon’, and ‘precip’.

surveyweathertool.src.weather.source_weather_data.get_weather_data(spi_path: str, GEO_COLUMNS: list, source_weather_data: bool = False, nigeria_shape_path: str = None, data_path_temperature: str = None, data_path_precipitation: str = None, interpolate=False, clip=False)

Fetches and processes weather data based on provided file paths. NB: Sourcing from internet is not currently functional

Parameters:

spi_path: str

File path name to save the SPI file. if the file already don’t exist, SPI will be calculated and saved again.

nigeria_shape_path: str, optional

Path to the Nigeria shapefile. If not provided, an attempt to source the data from the internet is made.

data_path_temperature: str, optional

Path to the file containing temperature data. If not provided, an attempt to source the data from the internet is made.

data_path_precipitation: str, optional

Path to the file containing precipitation data. If not provided, an attempt to source the data from the internet is made.

Returns:

tuple

A tuple containing: - nigeria_shape_df: geopandas.GeoDataFrame representing the Nigeria shapefile. - weather_temperature_df: DataFrame containing temperature data. - weather_precipitation_df: DataFrame containing precipitation data. - weather_spi_df: DataFrame representing the calculated Standardized Precipitation Index (SPI).