RUFAS.routines.field.manager.field_manager module#

class RUFAS.routines.field.manager.field_manager.FieldManager#

Bases: object

Manages the initialization and simulation of field instances within the simulation environment. This class is responsible for creating Field instances based on input data, managing these fields across the simulation lifecycle, and interfacing with the SimulationEngine to execute daily and annual routines.

Attributes#

fieldsList[Field]

A list of Field instances that have been initialized and are managed by this FieldManager.

output_gathererFieldDataReporter

An instance of FieldDataReporter responsible for gathering and reporting data from the managed fields.

omOutputManager

Instance of the OutputManager.

__init__() None#
get_crop_configs_to_rufas_ids() dict[str, list[int]]#

Gets a mapping of crop configurations to the RuFaS Feed IDs they may be fed as.

daily_update_routine(weather: Weather, time: RufasTime, manure_applications: list[ManureEventNutrientRequestResults]) list[HarvestedCropStorageType]#

This method will run the daily routine in the field, which will be calling the manage field method on each field.

Parameters#

weather: Weather

A weather object that contains infos to be transformed to current weather

time: RufasTime

RufasTime object containing the current year and day of the simulation.

manure_applications: list[ManureEventNutrientRequestResults]

A list containing the ManureEvents and corresponding NutrientRequestResults for each field in the simulation.

Returns#

list[HarvestedCropStorageType]

Crops that were harvested on the current day, paired with the storage types into which they will be placed.

Notes#

Because different fields can have different latitudes, the day length has to be recalculated for each field.

annual_update_routine() None#

This method will run the annual routine in the field, which will be calling the perform_annual_reset() method on each field.

get_next_harvest_dates(crops_to_look_for: list[str]) dict[str, date]#

Gets the date of the next harvest that is scheduled for each of the specified RuFaS crop configurations.

Parameters#

harvests_to_querylist[str]

List of crop harvests to find next harvest dates for.

Returns#

dict[str, date]

Mapping from crop to the date of that feeds next harvest.

static _setup_field(field_name: str, available_crop_configs: list[str]) Field#

Parameters#

field_namestr

The name of the blob in the metadata that contains the configuration for the field to be initialized.

available_crop_configslist[str]

A list of the names of the available crop configurations.

Returns#

Field

A Field instance configured with the specified input data

static _setup_field_data(field_name: str, field_configuration_data: dict[str, Any]) FieldData#

This method sets up the field data parameters using the given field name and field configuration data.

Parameters#

field_name: str

The name of the field.

field_configuration_data: dict[str, Any]

Configuration details such as field size, latitude, longitude, and other simulation parameters.

Returns#

FieldData

An instance of the FieldData class populated with the values from the field_configuration_data.

static _setup_crop_events(crop_rotation_configuration: str, available_crop_configs: list[str]) tuple[list[PlantingEvent], list[HarvestEvent]]#

Generates all planting and harvest events based on a given crop rotation configuration.

Parameters#

crop_rotation_configurationstr

Configuration for crop rotation detailing the schedule and crops to be planted.

available_crop_configslist[str]

A list of the names of the available crop configurations.

Returns#

tuple[list[PlantingEvent], list[HarvestEvent]]

A tuple containing two lists: - List of all planting events required by the crop rotation schedule. - List of all harvest events corresponding to the planting events.

static _setup_fertilizer_events(fertilizer_schedule: str) Tuple[dict[str, dict[str, float]], list[FertilizerEvent]]#

Sets up a list of fertilizer events from fertilizer schedule and the list of available fertilizer mixes.

Parameters#

fertilizer_schedulestr

Name of the metadata blob that contains the fertilizer schedule.

Returns#

Tuple[dict[str, dict[str, float], FertilizerSchedule]

Dictionary containing the specifications of the available fertilizer mixes, and a FertilizerSchedule.

static _setup_manure_events(manure_schedule: str) list[ManureEvent]#

Sets up a list of manure events from ManureSchedule.

Parameters#

manure_schedulestr

Name of the metadata blob that contains the manure schedule information.

Returns#

list[ManureEvent]

A list of generated manure events.

static _setup_tillage_events(tillage_schedule: str) list[TillageEvent]#

Sets up a list of TillageEvent from TillageSchedule.

Parameters#

tillage_schedulestr

Name of the metadata blob that contains the tillage schedule information.

Returns#

list[TillageEvent]

A list of generated tillage events.

static _setup_crop_schedules(crop_rotation: str, available_crop_configurations: list[str]) List[CropSchedule]#

Creates CropSchedules as dictated by the input specifications.

Parameters#

crop_rotationstr

Name of the metadata blob that contains the crop rotation information.

available_crop_configurationslist[str]

A list of the names of the available crop configurations.

Returns#

List[CropSchedule]

List of all crop schedules that have been created from the input specifications.

Raises#

ValueError

If the crop species in the crop rotation is not in the available crop configurations.

static _setup_soil(soil_configuration: str, field_size: float) Soil#

Sets up a Soil instance that will be used by the Field class.

Parameters#

soil_configurationstr

Name of the metadata blob that contains the soil.

field_sizefloat

Size of the field that contains this soil profile (ha).

Returns#

Soil

Soil instance that contains a SoilData instance configured to the provided specifications.

Raises#

ValueError

If no specification is provided for soil layers.

static _setup_soil_layer(field_size: float, top_depth: float, initial_residue: float, layer_config: dict[str, Any]) LayerData#

Initializes a LayerData instance to be added to a SoilData object.

Parameters#

field_sizefloat

Size of the field that contains the soil layer being created (ha)

top_depthfloat

Depth of top of the soil layer beneath the surface (mm)

initial_residuefloat

Amount of residue on the soil surface when this soil layer is initialized (kg / ha)

layer_configDict

Contains all the specifications for a layer of soil.

Returns#

LayerData

LayerData instance configured with provided data.

Notes#

Whoever wrote the JSON’s for soil profile inputs wrote “N03” (the digit zero) instead of “NO3” (the letter ‘O’), and that is why it is written with a zero and not the letter here.

check_manure_schedules(field: Field, time: RufasTime) list[ManureEventNutrientRequest]#

Checks list of ManureEvents, sends all that occur today to another method to be executed.

Parameters#

timeRufasTime

RufasTime object containing the current year and day of the simulation.