Skip to content

Utils

compute_district_average(da, area)

Computes zonal statistics on an xarray DataArray for both observations and probabilities.

Parameters:

Name Type Description Default
da

xarray.DataArray, Input DataArray (can be observations or probabilities).

required
area

hip.analysis.aoi.analysis_area.AnalysisArea: object characterizing the area and admin level of interest.

required

Returns: xarray.DataArray, DataArray with computed district averages.

load_trigger_with_reference(params, variant_folder=None)

Load trigger data and reference trigger data for comparison.

Parameters:

Name Type Description Default
params

An object containing parameters such as data_path, iso, and calibration_year.

required
variant_folder str

If provided, modifies the data path to load from an alternative directory.

None

Returns:

Name Type Description
dict

A dictionary containing DataFrames for GT, NRT, and pilots triggers and reference triggers.

triggers_da_to_df(triggers_da, score_da)

Converts trigger and score DataArrays to a merged DataFrame.

This function processes two xarray DataArrays containing trigger values and scores, converts them to pandas DataFrames, and merges them based on specified indices.

Parameters:

Name Type Description Default
triggers_da DataArray

DataArray containing trigger information.

required
score_da DataArray

DataArray containing score information.

required

Returns:

Type Description

pandas.DataFrame: A DataFrame combining trigger values and scores, with duplicates removed.