# 聚合器

## 一般描述

用于计算聚合值的实用程序类。

用户不太可能直接使用这个类。相反 *录音机* 子类将使用此功能汇总不同维度（例如时间、场景等）的结果。 [API 参考资料](https://pywr.github.io/pywr-docs/master/api/generated/pywr.recorders.Aggregator.html)

## 属性

。的

<table><thead><tr><th width="158">姓名</th><th width="473">描述</th><th>必填项</th></tr></thead><tbody><tr><td>func</td><td><p>要使用的聚合函数。可以是定义聚合函数的字符串或字典，也可以是执行聚合的可调用自定义函数。</p><p>如果是字符串，则可以是：“总和”、“最小值”、“最大值”、“平均值”、“中位数”、“乘积” 或 “计数” 之一_非零”。这些字符串映射到并导致聚合器使用相应的 <em>num</em> py</p><p>函数。</p><p>可以提供一个包含 “函数” 密钥以及可选的 “args” 和 “kwargs” 键的字典。“func” 的值应该是一个与前面提到的 numpy 函数名称相对应的字符串，并带有 “百分位数” 和 “百分位数” 等附加选项。后两个函数需要额外的参数（百分位数和分数）才能起作用，并且必须作为值在字典的 “args” 或 “kwargs” 键中提供。有关这些参数的文档，请参阅相应的 numpy（或 scipy）函数定义</p><p>。</p><p>最后，可以给出一个可调用的函数。此函数必须接受一维或二维 numpy 数组作为第一个参数，并支持 “axis” 关键字作为整数值，该整数值决定该函数应在哪个轴上应用聚合。axis 关键字仅在给出 2D 数组时提供。因此，`可调用函数的行为应与 numpy 函数类似</p></td><td></td></tr><tr><td>是的</td><td></td><td></td></tr><tr><td>func_args</td><td>func_args: 列表</td><td>是</td></tr><tr><td>函数_kwargs</td><td>func_kwargs: 字典</td><td>是的</td></tr></tbody></table>

## 示例

\`\`json { 聚合器（“总和”） 聚合器（{“func”：“百分位数”，“args”：\[95]，“kwargs”：{}}） 聚合器（{“func”：“分数百分比”，“kwargs”：{“分数”：0.5，“种类”：“等级”}}） }

```
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://water-strategy.gitbook.io/waterstrategy/zhong-guo-ren/jian-mo-ji-chu-zhi-shi/recorders/base-recorder/aggregator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
