agroecometrics package

Submodules

data

agroecometrics.data.df_as_dict(df: DataFrame, cols: ndarray | None, idx: ndarray | None) dict[str, list[float]][source]

Extracts values from a DataFrame into a dictionary

Allows users to create a dictionary from a Dataframe. Column names are used for the dictionary keys. Only the columns the user provides are added to the dictionary. If no columns are provided all columns are added. The value stored in each key is a list of data from the given DataFrame column Only the data for

Parameters:
  • df – The DataFrame containing weather data

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

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

Returns:

values}.

Return type:

A dictionary of {column_name

agroecometrics.data.interpolate_df(df: DataFrame, col_names: list[str] | None = None, method: str = 'linear') DataFrame[source]

Interpolates missing data within a DataFrame.

Interpolates data using dataframes interpolate function. If a list of column names are provided only those columns are interpolated.

Parameters:
  • df – The DataFrame to interpolate

  • col_names – An optional list of columns names to interpolate the data for

  • method – The dataframe interpolation method to use

Returns:

The DataFrame.

Raises:

KeyError – If one of the col_names was not found in the dataframe

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

Loads data from a csv file into a DataFrame while filtering and cleaning the data.

Loads data from a csv file into a DataFrame. Strips the column names of whitespace on either end and removes apostrophes. Filters data by the given dates. If no start or end date is specified the oldest and newest dates in the data are used respectively. Converts the date time column to Date Time objects and numeric columns to Numeric Data Types Adds columns for the date_norm, DOY, and Year.

  • Column names can be found by running AEM.settings.calc_calculation_labels().

  • date_norm stores the date normalized to contain the same time, midnight.

  • doy stores the number of days since January 1st, where January 1st = 0 and December 31st = 364 or 365 during a leap year.

  • year stores the current year.

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.match_datetimes(target_dt: ndarray, desired_dt: ndarray) Tuple[ndarray, ndarray, ndarray, ndarray][source]

Matches each datetime in ‘desired_dt’ to the closest datetime in ‘target_dt’.

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

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

Returns:

A tuple of 4 numpy arrays The first contains the original desired_dt The second contains the date_times matched from the target_dt. The third contains the indices of the matched date_times in the original target_dt The fourth contains the the difference in time between the desired and matched times

agroecometrics.data.save_data_csv(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.

Returns:

The Path to the newly saved file.

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.

equations

agroecometrics.equations.cummulative_water_infiltration(water_vol_fraction: float, avg_sat_hydraulic_conductivity: float, infultration_water_potential: float, wetting_front_water_potential: float, max_time: int, interpolations: int = 100) array[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 [0 to max_time].

Parameters:
  • water_vol_fraction – The Volume Fraction of water.

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

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

  • wetting_front_water_potential – The wetting front’s water potential (J / kg).

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

  • interpolations – The number of interpolated times to calculate.

Returns:

A numpy array of length ‘interpolations’ representing the cummulative vertical water infultration.

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

Models soil temperature at a set of depths on a particular day of the year

Estimates the soil temperature at the number of depths specified. The first depth is max_depth/num_depths and the last depth is max_depth.

Parameters:
  • doy – The day of year, days since January 1st. (January 1st = 0 and December 31st = 364)

  • max_depth – The maximum depth to model the soil temperature. (m)

  • num_depths – The number of depths to caluculate soil temperature at. (None)

  • surface_temp – The annual average surface temperature. (°C)

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

  • thermal_dif – The thermal diffusivity of the soil to estimate. (mm^2 / s)

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

Returns:

A tuple containing two numpy arrays.
  • The first contains the soil temperature predictions. (°C)

  • The second contains the depth of each prediction. (m)

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 – A numpy array of minimum daily temperatures. (°C)

  • temp_max – A numpy array of maximum daily temperatures. (°C)

  • RH_min – A numpy array of minimum daily relative humidities. (range: 0.0-1.0)

  • RH_max – A numpy array of maximum daily relative humidities. (range: 0.0-1.0)

  • wind_speed – A numpy array of average daily wind speeds. (m/s)

Returns:

Daily evapotranspiration clipped to a minimum of zero. (mm/day)

Raises:

ValueError – If all of the numpy arrays are not the same size

agroecometrics.equations.hargreaves(temp_min: ndarray, temp_max: ndarray, doys: ndarray, lat: float) ndarray[source]

Computes evapotranspiration using the Hargreaves model

Parameters:
  • temp_min – A numpy array of minimum daily temperatures. (°C)

  • temp_max – A numpy array of maximum daily temperatures. (°C)

  • doys – A numpy array containing the day of year, days since January 1st. (January 1st = 0 and December 31st = 364)

  • lat – The latitude of the location data is calculated at. (Degrees, North is positive)

Returns:

Daily evapotranspiration clipped to a minimum of zero. (mm/day)

Raises:

ValueError – If all of the numpy arrays are not the same size

agroecometrics.equations.hydraulic_conductivity(sat_hydraulic_conductivity: float, air_entry_water_potential: float, volumetric_water_content: float, sat_water_content: float, b: float) float[source]

Estimates the hydraulic conductivity of soil.

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

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

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

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

  • b – Is the exponent of moisture release.

Returns:

The calculated hydraulic conductivity of the soil given the parameters.

agroecometrics.equations.jensen_haise(temp_min: ndarray, temp_max: ndarray, doys: ndarray, lats: ndarray) ndarray[source]

Computes evapotranspiration using the Jensen model

Parameters:
  • temp_min – A numpy array of minimum daily temperatures. (°C)

  • temp_max – A numpy array of maximum daily temperatures. (°C)

  • doys – A numpy array containing the day of year, days since January 1st. (January 1st = 0 and December 31st = 364)

  • lats – A numpy array of latitudes. (Degrees, North is positive)

Returns:

Daily evapotranspiration clipped to a minimum of zero. (mm/day)

Raises:

ValueError – If all of the numpy arrays are not the same size

agroecometrics.equations.model_3d_soil_temp(air_temps: ndarray, max_depth: float, num_depths: int = 1000, thermal_dif: float = 0.203) Tuple[ndarray, ndarray, ndarray][source]

Models soil temperature over a full day across depth using air temperature data to parameterize a sinusoidal model.

Parameters:
  • air_temps – Soil surface air temperatures for a given day. (°C)

  • max_depth – Maximum depth to model the soil temperature. (m)

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

  • thermal_dif – The thermal diffusivity of the soil to model. (mm^2 / s)

Returns:

  • time_grid: varies across columns. (seconds in day)

  • depth_grid: varies across rows. (m)

  • temp_grid: soil temperature (°C) at each depth and time.

Return type:

(time_grid, depth_grid, temp_grid), each a 2D NumPy array

agroecometrics.equations.model_air_temp(temps: ndarray, date_times: ndarray) ndarray[source]

Generates a daily air temperature estimate by creating a model from actual air temperatures.

Creates a sinusoidal model of air temperature using best fit on the provided data. Then creates daily air temperature predictions over the entire range of dates provided.

Parameters:
  • temps – A numpy array of average daily air temperatures. (°C)

  • date_times – A numpy array of date time objects correspoinding to the air temperatures.

Returns:

A numpy array of predicted daily temperatures from the first to the last day provided, inclusive.

agroecometrics.equations.model_gdd(temp_avg: ndarray, temp_base: float, temp_opt: float | None = None, temp_upper: float | None = None, time_duration: float = 1.0) Tuple[ndarray, 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. If only a base temperature is provided GDD start accumulating above the base temperature, and accumulate faster the higher the temperature gets. If optimal and upper temperature are provided the accumulation starts above the base temperature, is greatest at the optimal temperature, and then decreases linearly down to zero at the upper temperature.

Parameters:
  • temp_avg – A numpy array of average temperatures. (°C)

  • temp_base – The minimum temperature to accumulate GDD. (°C)

  • temp_opt – The optimal temperature to accumulate GDD. (°C)

  • temp_upper – The maximum temperature to accumulate GDD. (°C)

  • time_duration – The length of time each temp_avg represents. (Days)

Returns:

A tuple containing two numpy arrays.
  • The first contains Growing Degree Days for each day.

  • The second contains the cummulative sum of Growing Degree Days for each day.

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

Uses Curve Number to estimate runoff from rainfall

Parameters:
  • precipitation – A numpy array of daily precipitation. (mm)

  • curve_number – The curve number.

Returns:

The runoff estimation. (mm)

agroecometrics.equations.model_soil_temp(air_temps: ndarray, depth: float, thermal_dif: int = 1e-06) ndarray[source]

Creates soil temperature predictions for each air temperature provided over the course of a day

Creates a sinusodial model of air temperature using best fir on the provided data Then uses that model to estimate soil temperature at the given depth for each temperature given. Air temperature are assumed to represent a single day and be equally spaced out through the entire day.

Parameters:
  • air_temps – A numpy array of air temperatures at the soil surface. (°C)

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

  • thermal_dif – The thermal diffusivity of the soil to model. (m^2 / s)

Returns:

A numpy array containing the predicted temperatures. (°C)

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 – A numpy array of minimum daily temperatures. (°C)

  • temp_max – A numpy array of maximum daily temperatures. (°C)

  • RH_min – A numpy array of minimum daily relative humidities. (range: 0.0-1.0)

  • RH_max – A numpy array of maximum daily relative humidities. (range: 0.0-1.0)

  • wind_speed – A numpy array of average daily wind speeds. (m/s)

Returns:

Daily evapotranspiration clipped to a minimum of zero. (mm/day)

Raises:

ValueError – If all of the numpy arrays are not the same size

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, doys: ndarray, lat: float, alt: float, solar_rad: ndarray | None = None, wind_height: float = 1.5) ndarray[source]

Computed evapotranspiration using the penman-monteith model

Parameters:
  • temp_min – A numpy array of minimum daily temperatures. (°C)

  • temp_max – A numpy array of maximum daily temperatures. (°C)

  • RH_min – A numpy array of minimum daily relative humidities. (range: 0.0-1.0)

  • RH_max – A numpy array of maximum daily relative humidities. (range: 0.0-1.0)

  • p_min – A numpy array of minimum daily atmospheric pressure. (Pa)

  • p_max – A numpy array of maximum daily atmospheric pressure. (Pa)

  • wind_speed – A numpy array of average daily wind speeds. (m/s)

  • doys – A numpy array containing the day of year, days since January 1st. (January 1st = 0 and December 31st = 364)

  • lat – The latitude of the location. (Degrees, North is positive)

  • alt – The altitude of the location. (m)

  • day. (solar_rad The soloar radiation occuring over the whole)

  • wind_height – Height of for wind speed measurments. (m)

Returns:

Daily evapotranspiration clipped to a minimum of zero. (mm/day)

Raises:

ValueError – If all of the numpy arrays are not the same size

agroecometrics.equations.photoperiod_at_lat(doys: ndarray, lat: float) Tuple[array, float, float, array, array, array][source]

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

Parameters:
  • doys – A numpy array containing the day of year, days since January 1st. (January 1st = 0 and December 31st = 364)

  • lat – The latitude to compute photoperiod at. (Degrees, North is positive)

Returns:

A tuple containing
  • Photoperiod, daylight hours, at the given latitude for the given days.

  • The angle of the sun below the horizon.

  • The zenithal distance of the sun in degrees.

  • The mean anomaly of the sun.

  • Lambda.

  • Delta.

agroecometrics.equations.photoperiod_on_day(doys: ndarray, lats: ndarray) Tuple[array, array, array, array, array, array][source]

Computes photoperiod for a given near polar regions.

Parameters:
  • doys – A numpy array containing the day of year, days since January 1st. (January 1st = 0 and December 31st = 364)

  • lats – A numpy array of latitudes to compute photoperiod at. (Degrees, North is positive)

Returns:

A tuple containing

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.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 – A numpy array of minimum daily temperatures. (°C)

  • temp_max – A numpy array of maximum daily temperatures. (°C)

  • RH_min – A numpy array of minimum daily relative humidities. (range: 0.0-1.0)

  • RH_max – A numpy array of maximum daily relative humidities. (range: 0.0-1.0)

Returns:

Daily evapotranspiration clipped to a minimum of zero. (mm/day)

Raises:

ValueError – If all of the numpy arrays are not the same size

agroecometrics.equations.yearly_3d_soil_temp(max_depth: int, num_depths: int = 1000, surface_temp: int = 25, thermal_amp: int = 10, thermal_dif: float = 0.203, timelag: int = 15) Tuple[ndarray, ndarray, ndarray][source]

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

Estimates the soil temperature at the number of depths specified for each day of the year. The first depth is max_depth/num_depths and the last depth is max_depth. Creates a matrix of estimations for each day of the year at each depth.

Parameters:
  • max_depth – The maximum depth in centimeters to model the soil temperature. (m)

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

  • surface_temp – The annual average surface temperature. (°C)

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

  • thermal_dif – The thermal diffusivity of the soil to model. (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.
  • doy_grid: varies across columns. (same DOY per column)

  • z_grid: varies across rows. (same depth per row) (m)

  • temp_grid: soil temperature at each depth and DOY. (°C)

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

Models average soil temperature at a given depth for each day of a year

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

  • surface_temp – The annual average surface temperature. (°C)

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

  • thermal_dif – The thermal diffusivity of the soil to estimate. (mm^2 / s)

  • time_lag – The difference between January 1st and the coldest day of the year. (Days)

Returns:

A numpy array of the daily soil temperature predictions. (°C).

visualizations

agroecometrics.visualizations.plot_3d_modeled_soil_temp(time_grid: ndarray, depth_grid: ndarray, temp_grid: ndarray, file_path: 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. (min)

  • depth_grid – A 2D numpy array matching time_grid, where each value is the depth. (m)

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

  • 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_air_temp(air_temps: ndarray, pred_temps: ndarray, date_times: ndarray, file_path: Path) Path[source]

Creates a plot of air temperature and predicted air temperatures over the time.

The actual air temperature are plotted as a scatter plot and the predicted air temperatures are ploted as a graph.

Parameters:
  • air_temps – A numpy array of actual air temperatures. (°C)

  • pred_temps – A numpy array of the predicted air temperatures. (°C)

  • date_times – A numpy array of date times corrosponding to the air temperatures.

  • 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(soil_temps: ndarray, depth: int, file_path: Path) Path[source]

Creates a plot of modeled soil temperature at a given depth.

Parameters:
  • soil_temp – A numpy array of the predicted soil temperatures. (°C)

  • depth – 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(pred_evapos: ndarray, date_times: ndarray, model_labels: list[str], file_path: Path, colors: list[str] = ['#0072b2', '#009e73', '#cc79a7', '#d55e00', '#F0E442']) Path[source]

Creates a plot of different evapotraspiration data over time..

Parameters:
  • pred_evapos – A 2d Numpy array of evapotranspirations, each row represents a different model. (mm/day)

  • date_times – A numpy array of date times corrosponding to the evapotranspiration data of each model.

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

  • model_labels – A list of labels corrosponding to each row of the provided evapotranspiration data.

  • colors – A list of strings providing the color codes to use for the plot. 5 color blind friendly colors are provided.

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.

  • ValueError – If the length of evapotranspiration data per depth is not equal to the number of date times provided.

  • ValueError – IF the number of model labels is not equal to the number of evapotranspiration models provided.

  • ValueError – If the number of of depths provided is greater than the number of colors provided.

agroecometrics.visualizations.plot_gdd(gdd: ndarray, date_times: ndarray, file_path: Path) Path[source]

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

Parameters:
  • gdd – The Growing Degree Days that occured

  • date_times – The datetime objects corresponding to the each actual and predicted temp.

  • 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(gdd_sum: ndarray, date_times: ndarray, file_path: Path) Path[source]

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

Parameters:
  • gdd_sum – The cummulative Growing Degree Days that have occured since the start of the data.

  • date_times – The datetime objects corresponding to the each actual and predicted temp.

  • 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_modeled_soil_temp(air_temp: ndarray, pred_temps: ndarray, depths: ndarray, file_path: Path, soil_temp: ndarray | None = None, colors: list[str] = ['#0072b2', '#009e73', '#cc79a7', '#d55e00', '#F0E442']) Path[source]

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

Creates a plot showing the given air temperature as a scatter plot, the actual soil temperature as a scatter plot if provided, and a graphed approximation of the predicted soil temperature at each of the provided depths. The first provided color is used for the air temperature, the next is used for actual soil temperatures if provided, and the next available is used for the predicted soil temperatures.

Parameters:
  • air_temp – A numpy array of the air temperature collected over a single day. (°C)

  • pred_temps – A 2d numpy array where each row is a set of predicted soil temperatures corrosponding to the provided air temperatures. Each row corrospondes to the depth in depths. (°C)

  • depths – The depth that the soil temperature was predicted at. (m)

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

  • soil_temp – A numpy array of the collected soil temperature at the same interval as air temperature.

  • colors – A list of strings providing the color codes to use for the plot. 5 color blind friendly colors are provided.

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.

  • ValueError – If the number of predicted temperatures per set is not equal to the number of provided air temperatures.

  • ValueError – If the number of predicted temperature sets is not equal to the number of provided depths.

  • ValueError – If the number of required colors is greater than the number of available colors.

agroecometrics.visualizations.plot_rainfall(rainfall: ndarray, runoff: ndarray, date_times: ndarray, file_path: 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’.

  • FileNotFoundError – If the parent directory does not exist.

agroecometrics.visualizations.plot_yearly_3d_soil_temp(doy_grid: ndarray, depth_grid: ndarray, temp_grid: ndarray, file_path: 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. (m)

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

  • 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_photoperiod(lat: float, file_path: Path)[source]

Creates a plot of the photoperiod at a specified latitude over a year’s time. Not accurate near polar regions.

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_temps: ndarray, file_path: Path) Path[source]

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

Parameters:
  • soil_temps – A numpy array of soil temperatures for each day of the year. (°C)

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