agroecometrics package

Submodules

data

agroecometrics.data.csv_file_exists(file_path: Path)[source]

Checks is the a Path to a csv file is valid

Parameters:

file_path – The Path to the csv file

Returns:

True if the csv file at the given Path already exists and False otherwise

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.csv’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.data.interpolate_missing_data(df: DataFrame, label_keys: list[str] | None = None, method: str = 'linear')[source]
Interpolates missing data within a DataFrame. Interpolates LABELS based on

list of keys in label_keys or all data is label_keys is None.

Parameters:
  • df – The DataFrame to interpolate data on

  • LABELS – A list of the label keys to interpolate data on.

  • method – The pandas interpolation type to use on the data

agroecometrics.data.load_data(file_path: Path, date_format: str = '%m/%d/%Y %I:%M %p', start_date: str | None = None, end_date: str | None = None) DataFrame[source]

Loads data into a DataFrame from a given CSV file filtered by date and cleaned

Loads the data from between the two specificed dates inclusive. If no start or end

date is specified the oldest and newest dates in the data are used respectively. Adss a column with the Date normalized Adds a column with the DOY from January 1st. Ie, January 1st = 0 and December 31st = 364 Adds a column with the Year in an integer representation

Parameters:
  • file_path – The path to your csv data file

  • start_date – Optional. The date to start filtering from (Inclusive)

  • end_date – Optional. The date to stop filtering on (Inclusive)

  • date_format – The date_format to use on the file

Returns:

A DataFrame with the information from the csv file filtered by the specified dates

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.csv’.

  • FileNotFoundError – If the file could not be found.

agroecometrics.data.save_data(df: DataFrame, file_path: Path) Path[source]

Saves your DataFrame to the given csv file

Parameters:
  • df – The dataframe to be saved

  • file_path – A Path to where you would like to save the data

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.csv’.

  • FileNotFoundError – If the parent directory does not exist.

  • FileExistsError – If the file already exists and the user selects not to override it

equations

agroecometrics.equations.EvapoTranspiration_to_df(df: DataFrame, model_name: str, temp_min: ndarray | None = None, temp_max: ndarray | None = None, RH_min: ndarray | None = None, RH_max: ndarray | None = None, wind_speed: ndarray | None = None, p_min: ndarray | None = None, p_max: ndarray | None = None, doy: ndarray | None = None, latitude: float | None = None, altitude: float | None = None, wind_height: int = 1.5) DataFrame[source]

Adds daily evapotranspiration and its cumulative sum to the given DataFrame using a specified model and its required parameters.

Parameters:
  • df – The DataFrame to add the evapotranspiration data to

  • model_name – Name of the model to use. Options: [“dalton”, “penman”, “romanenko”, “jensen_haise”, “hargreaves”, “penman_monteith”]

  • temp_min – The minimum daily temperature (°C)

  • temp_max – The maximum daily temperature (°C)

  • RH_min – The minimum daily relative humidity (range: 0.0-1.0)

  • RH_max – The maximum daily relative humidity (range: 0.0-1.0)

  • wind_speed – The average daily wind speed in meters per second

  • p_min – The minimum daily atmospheric pressure in Pa

  • p_max – The maximum daily atmospheric pressure in Pa

  • doy – Day of year (0-365) where January 1st is 0 and 365

  • latitude – Latitude in decimal degress. Where the northern hemisphere is positive and the southern hemisphere is negative

  • altitude – Altitude of the location in meters

  • wind_height – Height of measurement for wind speed in meters

agroecometrics.equations.compute_Ra(doy: ndarray, latitude: float) ndarray[source]

Computes extra-terrestrial solar radiation using the FAO Penman-Monteith method

Parameters:
  • doy – Day of year (0-365) where January 1st is 0 and 365

  • latitude – Latitude in decimal degress. Where the northern hemisphere is positive and the southern hemisphere is negative

Returns:

Extra-terrestrial solar radiation (Ra) in MJ/m²/day

agroecometrics.equations.compute_esat(temp: ndarray) ndarray[source]

Computes saturation vapor pressure based Tetens formula

Parameters:

temp – Temperature to calculate the saturation vapor pressure (°C)

Returns:

Computed saturation vapor pressure (kPa)

agroecometrics.equations.cummulative_water_infultration(delta_theta: float, K_avg: float, psi_mi: float, psi_mf: float, time: int, Nz: int = 100)[source]

Calculates the cummulative vertical water infultration.

Calculates the cummulative vertical water infultration for the given soil parameters.

Calculations are made for equally spaced times from [time/Nz to time]

Parameters:
  • delta_theta – The Volume Fraction of water

  • K_avg – The average hydraulic conductivity of the wet soil (kg * s /m^3)

  • psi_mi – The infultration boudary’s water potential (J / kg)

  • psi_mf – The wetting front’s water potentail (J / kg)

  • time – The length of time to calcute the cummulative water infultration (s)

  • Nz – The number of interpolated times to calculate

Returns:

A numpy array of length Nz representing the cummulative vertical water

infultration over time. Where the first value represents the infultraiton after zero time, the second value represents the infultration after time/Nz time, and the last vaule represents the infultration after time.

agroecometrics.equations.dalton(temp_min: ndarray, temp_max: ndarray, RH_min: ndarray, RH_max: ndarray, wind_speed: ndarray) ndarray[source]

Computes Evapotranspiration using the Dalton model

Parameters:
  • temp_min – The minimum daily temperature (°C)

  • temp_max – The maximum daily temperature (°C)

  • RH_min – The minimum daily relative humidity (range: 0.0-1.0)

  • RH_max – The maximum daily relative humidity (range: 0.0-1.0)

  • wind_speed – The average daily wind speed in meters per second

Returns:

The Dalton models predictions for evapotranspiration clipped to a minimum of zero

agroecometrics.equations.gdd_to_df(df: DataFrame, temp_avg: ndarray, temp_base: float, temp_opt: float | None = None, temp_upper: float | None = None, duration_time: float = 1)[source]
Models Growing Degree days using a minimum base temperature, an optional

optimal temperature, an optional maximum growing temperature, and the average temperature over the recorded durations. Adds the Growing Degree days and cummulative GDD to the given DataFrame

Parameters:
  • df – The DataFrame to add the GDD data to

  • temp_avg – The average temperature over the duration_time (°C)

  • temp_base – The minimum temperature a given crop will grow at (°C)

  • temp_optimal – The optimal temperature a given crop will grow (°C), above this temperature growing will slow linearly

  • temp_upper – The maximum temperature a given crop will grow (°C)

  • duration_time – The number of days that each temp_avg represents

agroecometrics.equations.get_weather_data_from_cols(weather_df: DataFrame, weather_cols: list[str], indices: ndarray) dict[str, list[float]][source]

Extracts values from weather columns at given matched indices.

Parameters:
  • weather_df – The DataFrame containing weather data

  • weather_cols – The key names to be used in the dictionary

  • indices – The indices in the DataFrame to be used in the dictionary

Returns:

values}.

Return type:

A dictionary of {column_name

agroecometrics.equations.hargreaves(temp_min: ndarray, temp_max: ndarray, doy: ndarray, latitude: float) ndarray[source]

Computes evapotranspiration using the Hargreaves model

Parameters:
  • temp_min – The minimum daily temperature (°C)

  • temp_max – The maximum daily temperature (°C)

  • doy – Day of year (0-365) where January 1st is 0 and 365

  • latitude – Latitude in decimal degress. Where the northern hemisphere is positive and the southern hemisphere is negative

Returns:

The Hargreaves models predictions for evapotranspiration clipped to a minimum of zero

agroecometrics.equations.hydraulic_conductivity(k_s: float, psi_e: float, theta: float, theta_s: float, b: float)[source]

Estimates the hydraulic conductivity of soil

Parameters:
  • k_s – The saturated conductivity of the soil (kg * s / m^3)

  • psi_e – The air entry water potential of the soil (J / kg)

  • theta – Is the volumetric water content of the soil (m^3 / m^3)

  • theta_s – Is the saturation water content of the soil (m^3 / m^3)

  • b – Is the exponent of moisture release parameter

Returns:

The calculated hydraulic conductivity of the soil given the parameters ()

agroecometrics.equations.jensen_haise(temp_min: ndarray, temp_max: ndarray, doy: ndarray, latitude: ndarray) ndarray[source]

Computes evapotranspiration using the Jensen model

Parameters:
  • temp_min – The minimum daily temperature (°C)

  • temp_max – The maximum daily temperature (°C)

  • doy – Day of year (0-365) where January 1st is 0 and 365

  • latitude – Latitude in decimal degress. Where the northern hemisphere is positive and the southern hemisphere is negative

Returns:

The Jensen-Haise models predictions for evapotranspiration clipped to a minimum of zero

agroecometrics.equations.match_weather_datetime(weather_dt: ndarray, data_dt: ndarray) Tuple[ndarray, ndarray, ndarray, ndarray][source]
Matches each datetime in data_datetime_col to the closest datetime

in weather_datetime_col.

Parameters:
  • weather_dt – The np array of actual weather date_times

  • data_dt – The np array of date_times to find the closest match for

Returns:

A tuple of (original times, matched weather times, matched indices, time differences)

agroecometrics.equations.model_air_temp(df: DataFrame) ndarray[source]

Creates an Air temperature model and creates air temperature estimates using model

Parameters:

df – DataFrame containing temperature data

Returns:

A numpy array of predicted daily temperatures over the period of the dataframe

agroecometrics.equations.model_gdd(temp_avg: ndarray, temp_base: float, temp_opt: float | None = None, temp_upper: float | None = None, duration_time: float = 1.0) ndarray[source]

Model how many growing degree days have passed

Models Growing Degree days using a minimum base temperature, an optional

optimal temperature, an optional maximum growing temperature, and the average temperature over the recorded durations

Parameters:
  • temp_avg – The average temperature over the duration_time (°C)

  • temp_base – The minimum temperature a given crop will grow at (°C)

  • temp_opt – The optimal temperature a given crop will grow (°C), above this temperature growing will slow linearly

  • temp_upper – The maximum temperature a given crop will grow (°C)

  • duration_time – The number of days that each temp_avg represents

Returns:

An np.ndarray with the calculated Growing Degree Days for each daily temperature

agroecometrics.equations.model_runoff(precip: ndarray, cn: int = 75) DataFrame[source]

Uses Curve Number to estimate runoff from rainfall

Parameters:
  • precip – The daily amount of precipitation in millimeters

  • cn – The curve number to use in the calculation

Returns:

The estimated runoff

agroecometrics.equations.model_soil_temp_at_depth_from_air_temp(df: DataFrame, max_depth: float, date: str, Nz: int = 1000, date_format: str = '%m/%d/%Y %I:%M %p', thermal_dif: float = 0.203) Tuple[ndarray, ndarray, ndarray][source]

Models soil temperature over a full day (in 5-minute intervals) across depth using air temperature data to parameterize a sinusoidal model.

Parameters:
  • df – DataFrame containing temperature data; must contain ‘5_minute_temp’ and datetime.

  • max_depth – Maximum depth in centimeters to model the soil temperature.

  • date – The date (string) for which parameters will be estimated.

  • Nz – Number of interpolated depth points.

  • date_format – The format used for the date string.

  • thermal_dif – Thermal diffusivity [mm^2/s] from KD2 Pro instrument.

Returns:

A tuple of (time_grid, depth_grid, temp_grid), each a 2D NumPy array.

agroecometrics.equations.model_soil_temp_from_air_temp(df: DataFrame, depth: float, date: str, date_format: str = '%m/%d/%Y %I:%M %p', thermal_dif: int = 0.203) ndarray[source]

Creates temperature predictions for every 5 minutes for a modeled date

Estimates the parameters for a sinusodial function modeling the daily surface temperature. Uses the parameter estimations to create a model of soil temperatures at different depths

Parameters:
  • df – DataFrame containing temperature data, must contain 5_minute_temp as defined in settings.

  • depth – The depth in centimeters to model the soil temperature

  • date – Is the date which parameters will be estimated for.

  • date_format – Is the format that the date variable and data use for the date.

  • thermal_dif – The Thermal diffusivity obtained from KD2 Pro instrument [mm^2/s]

Returns:

A numpy array containing the predicted temperatures (°C) every 5 minutes

starting at midnight at the specified depth and a numpy array containing the given air temperatures

agroecometrics.equations.penman(temp_min: ndarray, temp_max: ndarray, RH_min: ndarray, RH_max: ndarray, wind_speed: ndarray) ndarray[source]

Computes evapotranspiration using the Penman model

Parameters:
  • temp_min – The minimum daily temperature (°C)

  • temp_max – The maximum daily temperature (°C)

  • RH_min – The minimum daily relative humidity (range: 0.0-1.0)

  • RH_max – The maximum daily relative humidity (range: 0.0-1.0)

  • wind_speed – The average daily wind speed in meters per second

Returns:

The Penman models predictions for evapotranspiration clipped to a minimum of zero

agroecometrics.equations.penman_monteith(temp_min: ndarray, temp_max: ndarray, RH_min: ndarray, RH_max: ndarray, p_min: ndarray, p_max: ndarray, wind_speed: ndarray, doy: ndarray, latitude: float, altitude: float, wind_height: int = 1.5) ndarray[source]

PComputer evapotranspiration using the penman-monteith model

Parameters:
  • temp_min – The minimum daily temperature (°C)

  • temp_max – The maximum daily temperature (°C)

  • RH_min – The minimum daily relative humidity (range: 0.0-1.0)

  • RH_max – The maximum daily relative humidity (range: 0.0-1.0)

  • p_min – The minimum daily atmospheric pressure in Pa

  • p_max – The maximum daily atmospheric pressure in Pa

  • wind_speed – The average daily wind speed in meters per second

  • doy – Day of year (0-365) where January 1st is 0 and 365

  • latitude – Latitude in decimal degress. Where the northern hemisphere is positive and the southern hemisphere is negative

  • altitude – Altitude of the location in meters

  • wind_height – Height of measurment for wind speed

Returns:

The Hargreaves models predictions for evapotranspiration clipped to

a minimum of zero

agroecometrics.equations.photoperiod_at_latitude(latitude: float, doy: ndarray)[source]

Computes photoperiod for a given latitude and day of year. Not accurate near polar regions.

Parameters:
  • latitude – Latitude in decimal degress. Where the northern hemisphere is positive and the southern hemisphere is negative

  • doy – np.ndarray of the days of year (0-365) where January 1st is 0 and 365

Returns:

Photoperiod, daylight hours, at the given latitude for the given days. The angle of the sum below the horizon. The zenithal distance of the sun in degrees The mean anomaly of the sun The declination of the sun in degrees Lambda Delta

agroecometrics.equations.photoperiod_on_day(latitude: ndarray, doys: ndarray)[source]

Computes photoperiod for a given near polar regions.

Parameters:
  • latitude – Latitude in decimal degress. Where the northern hemisphere is positive and the southern hemisphere is negative

  • doys – The day of year (0-365) where January 1st is 0 and 365 to perform the calculation

Returns:

Photoperiod, daylight hours, for the given latitudes on the given day. The angle of the sum below the horizon. The zenithal distance of the sun in degrees The mean anomaly of the sun The declination of the sun in degrees Lambda from the equation Delta from the equation

References

Keisling, T.C., 1982. Calculation of the Length of Day 1. Agronomy Journal, 74(4), pp.758-759.

agroecometrics.equations.rainfall_runoff_to_df(df: DataFrame, cn: int = 75)[source]

Adds rainfall sum, runoff sum, and runoff to the DataFrame

Parameters:
  • df – The DataFrame containing the rainfall data

  • cn – The curve number to be used in the runoff calculation

agroecometrics.equations.romanenko(temp_min: ndarray, temp_max: ndarray, RH_min: ndarray, RH_max: ndarray) ndarray[source]

Potential evaporation model proposed by Romanenko in 1961

Parameters:
  • temp_min – The minimum daily temperature (°C)

  • temp_max – The maximum daily temperature (°C)

  • RH_min – The minimum daily relative humidity (range: 0.0-1.0)

  • RH_max – The maximum daily relative humidity (range: 0.0-1.0)

Returns:

The Romanenko models predictions for evapotranspiration clipped to a minimum of zero

agroecometrics.equations.soil_temp_at_depth(depth: int, avg_temp: int = 25, thermal_amp: int = 10, thermal_dif: float = 0.203, time_lag: int = 15) ndarray[source]

Models soil temperature over one year at the given depth

Parameters:
  • depth – The depth to model the soil temperature (m)

  • avg_temp – The annual average surface temperature (°C)

  • thermal_amp – The annual thermal amplitude of the soil surface (°C)

  • thermal_dif – The Thermal diffusivity obtained from KD2 Pro instrument (mm^2 / s)

  • time_lag – The time lag between Jaunary 1st and the coldest day of the year (days)

Returns:

Predicted soil temperature at the given depth for each day of the year (°C)

agroecometrics.equations.soil_temp_at_depth_on_day(max_depth: int, Nz: int = 1000, avg_temp: int = 25, thermal_amp: int = 10, thermal_dif: int = 0.203, timelag: int = 15) tuple[ndarray, ndarray, ndarray][source]

Models soil temperature over a full year (0–365) and across depth.

Parameters:
  • max_depth – The maximum depth in centimeters to model the soil temperature

  • Nz – The number of interpolated depths to calculate soil temperature at

  • avg_temp – The annual average surface temperature (°C)

  • thermal_amp – The annual thermal amplitude of the soil surface (°C)

  • thermal_dif – The Thermal diffusivity obtained from KD2 Pro instrument [mm^2/s]

  • timelag – The time lag in days (0-365) where January 1st is 0 and 365

Returns:

A tuple of (doy_grid, z_grid, temp_grid), where each is a 2D NumPy array.

agroecometrics.equations.soil_temp_on_day(doy: int, max_depth: int, Nz: int = 100, avg_temp: int = 25, thermal_amp: int = 10, thermal_dif: int = 0.203, timelag: int = 15) Tuple[ndarray, ndarray][source]

Models soil temperature on a particular day of the year

Parameters:
  • doy – Day of year (0-365) where January 1st is 0 and 365

  • max_depth – The maximum depth in centimeters to model the soil temperature

  • Nz – The number of interpolated depths to caluculate soil temperature at

  • avg_temp – The annual average surface temperature (°C)

  • thermal_amp – The annual thermal amplitude of the soil surface (°C)

  • thermal_dif – The Thermal diffusivity obtained from KD2 Pro instrument [mm^2/s]

  • time_lag – The time lag in days (0-365) where January 1st is 0 and 365

Returns:

An np array of the soil temps and an np array of the depths of the soil temps (°C)

visualizations

agroecometrics.visualizations.check_png_filename(file_path: Path)[source]

Validates that the provided file path ends with ‘.png’ and that the directory exists.

Parameters:

file_path – A Path object representing the output file path.

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_3d_daily_soil_temp(time_grid: ndarray, depth_grid: ndarray, temp_grid: ndarray, file_path: Path)[source]

Creates a 3D plot of predicted soil temperature over the course of a single day at different depths.

Parameters:
  • time_grid – A 2D numpy array of shape (n_depths, n_times), where each value is time in minutes.

  • depth_grid – A 2D numpy array matching time_grid, where each value is the depth in cm.

  • temp_grid – A 2D numpy array of predicted soil temperatures (same shape as time_grid).

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’ or if the needed label(s) isn’t found in the df

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_3d_soil_temp(doy_grid: ndarray, z_grid: ndarray, t_grid: ndarray, file_path: Path)[source]

Creates a 3d plot of soil temperature at different depths over the course of a year

Parameters:
  • doy_gird – A 2d np.ndarray with shape (Nz, 365) containing the day of year for each plot point.

  • z_grid – A 2d np.ndarray with shape (Nz, 365) containing the soil depth for each plot point.

  • t_grid – A 2d np.ndarray with shape (Nz, 365) containing the soil temperature for each plot point.

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_air_temp(df: DataFrame, T_pred: ndarray, file_path: Path)[source]

Creates a plot of air temperature over the time

Parameters:
  • df – DataFrame with temperature data

  • T_pred – Predicted temperature array

  • file_path – A Path object representing the output file path.

Returns:

The resolved file path where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_daily_photoperiod(doys: ndarray, file_path: Path)[source]

Creates a plot of the photoperiod from -45 to 45 degree latitude on the given day of year

Parameters:
  • doys – A np.ndarray of the days of year (0-365) where January 1st is 0 and 365 to perform the calculation

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_daily_soil_temp(air_temp: ndarray, pred_temp: ndarray, depth: int, file_path: Path, soil_temp: ndarray | None = None)[source]

Creates a plot of air temperature and the predicted soil temperature on a particular date

Creates a plot showing the given air temperature and the predicted soil temperature

for the given depth. Optionally plots the actual soil temperature for comparision

Parameters:
  • air_temp – The air temperature collected every 5 minutes

  • pred_temp – The soil temperature prediction given in 5 minute intervals

  • depth – The depth that the soil temperature was predicted at

  • file_path – A Path object representing the output file path.

  • soil_temp – The collected soil temperature given in 5 minute intervals

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’ or if the needed label(s) isn’t found in the df

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_day_soil_temp(soil_temp: ndarray, depths: int, file_path: Path)[source]

Creates a plot of modeled soil temperature at a given depth

Parameters:
  • soil_temp – Is the predicted soil temperatures (°C)

  • depth – Is the depth that the soil temperature predictions are made at. (m)

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_evapo_data(df: DataFrame, file_path: Path, model_data: ndarray, model_labels: list[str])[source]

Creates a plot of different evapotraspiration data over time

Creates a plot over time of the predicted evapotranspiration in mm/day.

Creates labels and uses different colors for each of the models. Creates a legend of the model names and colors.

Parameters:
  • df – The DataFrame that the evapotranspiration models were run on.

  • file_path – A Path object representing the output file path.

  • model_data – Is a 2d numpy array of size len(model_labels) x #of days

  • model_labels – Is a list of the names of the models used in model data.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’ or if the needed label(s) isn’t found in the df

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_gdd(df: DataFrame, file_path: Path)[source]

Creates a plot of the Growing Degree Days that occured over each time segment in the data

Parameters:
  • df – The DataFrame that Growing Degree Days was calculated on.

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’ or if the needed label(s) isn’t found in the df

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_gdd_sum(df: DataFrame, file_path: Path)[source]

Creates a plot of the Cumulative Growing Degree Days that occured over the data

Parameters:
  • df – The DataFrame that Growing Degree Days was calculated on.

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’ or if the needed label isn’t found in the df

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_rainfall(df: DataFrame, file_path: Path)[source]

Creates a plot of rainfall and runoff over time.

Parameters:
  • df – DataFrame with cumulative rainfall and runoff

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’ or if the needed label(s) isn’t found in the df

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_yearly_photoperiod(latitude: float, file_path: Path)[source]

Creates a plot of the photoperiod at a specified latitude over a year’s time

Parameters:
  • latitude – Latitude in decimal degress. Where the northern hemisphere is positive and the southern hemisphere is negative

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_yearly_soil_temp(soil_temp: ndarray, file_path: Path)[source]

Creates a plot of modeled soil temperature over a year’s time

Parameters:
  • T_soil – A numpy array of soil temperatures for each day of the year in order

  • file_path – A Path object representing the output file path.

Returns:

The filename where the plot was saved

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.save_plot(file_path: Path)[source]

Prepares plot to be saved and saves it.

Adds labels to plt figure if they exist, saves the plot to the given file_path, and

closes the plt plot after saving

Parameters:

file_path – A Path object representing the output file path.

Raises:
  • TypeError – If file_path is not a Path object.

  • ValueError – If the file extension is not ‘.png’.

  • FileNotFoundError – If the parent directory does not exist.

settings

agroecometrics.settings.get_calculation_lables()[source]

Return: The current labels used to store calculated data

agroecometrics.settings.get_labels()[source]

Return: The current label dictionary.

agroecometrics.settings.set_labels(**kwargs)[source]

Override default labels with user-defined ones.