pipeline.src.flows.controls

Functions

extract_controls(→ pandas.DataFrame)

Extracts controls data from FMC database for the specified number of months, going

extract_catch_controls(→ pandas.DataFrame)

extract_ports(→ pandas.DataFrame)

Extracts ports as a DataFrame.

extract_fao_areas(→ geopandas.GeoDataFrame)

Extracts FAO areas as a GeoDataFrame.

transform_catch_controls(→ pandas.DataFrame)

transform_controls(controls)

compute_controls_fao_areas(→ pandas.DataFrame)

Compute the FAO area(s) of controls.

compute_controls_facade(→ pandas.DataFrame)

Compute the facade of controls.

merge_controls_data(→ pandas.DataFrame)

make_missions_actions_and_missions_control_units(...)

load_missions_and_missions_control_units(missions, ...)

load_mission_actions(mission_actions, loading_mode)

controls_flow(loading_mode, number_of_months[, ...])

Controls flow - extracts and processes control data from FMC database

Module Contents

pipeline.src.flows.controls.extract_controls(number_of_months: int) pandas.DataFrame[source]

Extracts controls data from FMC database for the specified number of months, going back at most to January 1st 2013.

Parameters:

number_of_months (int) – number of months of controls data to extract, going backwards from the present. If the computed start date of the extraction is before January 1st 2013, the data will be extracted from January 1st 2013 to the present.

Returns:

DataFrame with controls data.

Return type:

pd.DataFrame

pipeline.src.flows.controls.extract_catch_controls() pandas.DataFrame[source]
pipeline.src.flows.controls.extract_ports() pandas.DataFrame[source]

Extracts ports as a DataFrame.

Returns:

DataFrame of ports.

Return type:

pd.DataFrame

pipeline.src.flows.controls.extract_fao_areas() geopandas.GeoDataFrame[source]

Extracts FAO areas as a GeoDataFrame.

Returns:

GeoDataFrame of FAO areas.

Return type:

gpd.GeoDataFrame

pipeline.src.flows.controls.transform_catch_controls(catch_controls: pandas.DataFrame) pandas.DataFrame[source]
pipeline.src.flows.controls.transform_controls(controls: pandas.DataFrame)[source]
pipeline.src.flows.controls.compute_controls_fao_areas(controls: pandas.DataFrame, fao_areas: geopandas.GeoDataFrame, ports: pandas.DataFrame) pandas.DataFrame[source]

Compute the FAO area(s) of controls.

For controls with a location (latitude and longitude), the FAO area of the location of the control is returned.

For controls with a port (locode), the FAO area(s) of the port are taken.

NB : controls that have no fao_area (because they lack location or port information or because their location / ports does not belong to an FAO area) will not be included in the result.

Parameters:
  • controls (pd.DataFrame) – controls with at least id, latitude, longitude and port_locode columns

  • fao_areas (gpd.GeoDataFrame) – FAO areas with f_code column (and geometry)

  • ports (pd.DataFrame) – ports with locode and fao_areas columns

Returns:

controls with FAO areas added

Return type:

pd.DataFrame

pipeline.src.flows.controls.compute_controls_facade(controls: pandas.DataFrame, facade_areas: geopandas.GeoDataFrame, ports: pandas.DataFrame) pandas.DataFrame[source]

Compute the facade of controls.

For controls with a location (latitude and longitude), the facade of the location of the control is returned.

For controls with a port (locode), the facade of the port is taken.

NB : controls that have no facade (because they lack location or port information or because their location / ports does not belong to a facade area) will not be included in the result.

Parameters:
  • controls (pd.DataFrame) – controls with at least id, latitude, longitude and port_locode columns

  • facade_areas (gpd.GeoDataFrame) – facades with facade column (and geometry)

  • ports (pd.DataFrame) – ports with locode and facade columns

Returns:

DataFrame with columns id and facade

Return type:

pd.DataFrame

pipeline.src.flows.controls.merge_controls_data(controls: pandas.DataFrame, catch_controls: pandas.DataFrame, controls_fao_areas: pandas.DataFrame, controls_facade: pandas.DataFrame) pandas.DataFrame[source]
pipeline.src.flows.controls.make_missions_actions_and_missions_control_units(controls: pandas.DataFrame) Tuple[pandas.DataFrame, pandas.DataFrame, pandas.DataFrame][source]
pipeline.src.flows.controls.load_missions_and_missions_control_units(missions: pandas.DataFrame, missions_control_units: pandas.DataFrame, loading_mode: str)[source]
pipeline.src.flows.controls.load_mission_actions(mission_actions: pandas.DataFrame, loading_mode: str)[source]
pipeline.src.flows.controls.controls_flow(loading_mode: str, number_of_months: int, extract_controls_fn: Callable = extract_controls, extract_catch_controls_fn: Callable = extract_catch_controls, load_missions_and_missions_control_units_fn: Callable = load_missions_and_missions_control_units)[source]

Controls flow - extracts and processes control data from FMC database

Parameters:
  • loading_mode – Either “replace” or “upsert” mode for loading data

  • number_of_months – Number of months of data to extract