Skip to content

Commit

Permalink
Docstyle updated to Numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
kvantricht committed Jun 27, 2024
1 parent c3c317a commit 3437b23
Showing 1 changed file with 57 additions and 34 deletions.
91 changes: 57 additions & 34 deletions src/worldcereal/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,35 @@ def generate_map(
output_path: Optional[Union[Path, str]],
product_type: WorldCerealProduct = WorldCerealProduct.CROPLAND,
out_format: str = "GTiff",
):
) -> InferenceResults:
"""Main function to generate a WorldCereal product.
Args:
spatial_extent (BoundingBoxExtent): spatial extent of the map
temporal_extent (TemporalContext): temporal range to consider
backend_context (BackendContext): backend to run the job on
output_path (Union[Path, str]): output path to download the product to
product (str, optional): product describer. Defaults to "cropland".
format (str, optional): Output format. Defaults to "GTiff".
Raises:
ValueError: if the product is not supported
ValueError: if the out_format is not supported
ValueError: if a cropland mask is applied on a cropland workflow
Parameters
----------
spatial_extent : BoundingBoxExtent
spatial extent of the map
temporal_extent : TemporalContext
temporal range to consider
backend_context : BackendContext
backend to run the job on
output_path : Optional[Union[Path, str]]
output path to download the product to
product_type : WorldCerealProduct, optional
product describer, by default WorldCerealProduct.CROPLAND
out_format : str, optional
Output format, by default "GTiff"
Returns
-------
InferenceResults
Results of the finished WorldCereal job.
Raises
------
ValueError
if the product is not supported
ValueError
if the out_format is not supported
"""

if product_type not in PRODUCT_SETTINGS.keys():
Expand Down Expand Up @@ -172,18 +184,20 @@ def collect_inputs(
temporal_extent: TemporalContext,
backend_context: BackendContext,
output_path: Union[Path, str],
) -> DataCube:
):
"""Function to retrieve preprocessed inputs that are being
used in the generation of WorldCereal products.
Args:
spatial_extent (BoundingBoxExtent): spatial extent of the map
temporal_extent (TemporalContext): temporal range to consider
backend_context (BackendContext): backend to run the job on
output_path (Union[Path, str]): output path to download the product to
Raises:
ValueError: if the product is not supported
Parameters
----------
spatial_extent : BoundingBoxExtent
spatial extent of the map
temporal_extent : TemporalContext
temporal range to consider
backend_context : BackendContext
backend to run the job on
output_path : Union[Path, str]
output path to download the product to
"""

Expand Down Expand Up @@ -211,11 +225,15 @@ def _cropland_map(inputs: DataCube) -> DataCube:
"""Method to produce cropland map from preprocessed inputs, using
a Presto feature extractor and a CatBoost classifier.
Args:
inputs (DataCube): preprocessed input cube
Parameters
----------
inputs : DataCube
preprocessed input cube
Returns:
DataCube: binary labels and probability
Returns
-------
DataCube
binary labels and probability
"""

# Run feature computer
Expand Down Expand Up @@ -267,12 +285,17 @@ def _croptype_map(inputs: DataCube, cropland_mask: DataCube = None) -> DataCube:
"""Method to produce croptype map from preprocessed inputs, using
a Presto feature extractor and a CatBoost classifier.
Args:
inputs (DataCube): preprocessed input cube
cropland_mask (DataCube): optional cropland mask
Returns:
DataCube: croptype labels and probability
Parameters
----------
inputs : DataCube
preprocessed input cube
cropland_mask : DataCube, optional
optional cropland mask, by default None
Returns
-------
DataCube
croptype labels and probability
"""

# Run feature computer
Expand Down

0 comments on commit 3437b23

Please sign in to comment.