Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions extensions/investspec/investspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from docutils import utils
from docutils.parsers import rst
from natcap.invest import set_locale
from natcap.invest import spec_utils


def parse_rst(text):
Expand Down Expand Up @@ -84,8 +83,8 @@ def invest_spec(name, rawtext, text, lineno, inliner, options={}, content=[]):
language = inliner.document.settings.env.app.config.language
set_locale(language if language else 'en')

spec_utils = importlib.import_module('natcap.invest.spec_utils')
rst = spec_utils.describe_arg_from_name(module_name, *keys)
spec = importlib.import_module('natcap.invest.spec')
rst = spec.describe_arg_from_name(module_name, *keys)
return parse_rst(rst), []


Expand Down
22 changes: 14 additions & 8 deletions extensions/investspec/test/test_module/test_module/test_module.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import pint
from natcap.invest import spec

ureg = pint.UnitRegistry()
ureg.define('none = []')

MODEL_SPEC = {
"model_name": "Forest Carbon Edge Effect Model",
"module": __name__,
"userguide_html": "carbon_edge.html",
MODEL_SPEC = spec.build_model_spec({
"model_id": "forest_carbon",
"model_title": "Forest Carbon Edge Effect Model",
"userguide": "carbon_edge.html",
"aliases": set(),
"args_with_spatial_overlap": {
"spatial_keys": ["aoi_vector_path", "lulc_raster_path"],
},
"ui_spec": {
"order": []
},
"args": {
"number_input": {
"name": "Foo",
Expand Down Expand Up @@ -61,7 +66,7 @@
},
"raster_input": {
"type": "raster",
"bands": {1: {"type": "code"}},
"bands": {1: {"type": "integer"}},
"about": "Rasters are pretty simple.",
"name": "Opq"
},
Expand Down Expand Up @@ -103,7 +108,7 @@
"type": "csv",
"required": False,
"columns": {
"id": {"type": "code"},
"id": {"type": "integer"},
"description": {
"type": "freestyle_string",
"required": False,
Expand All @@ -119,5 +124,6 @@
}
}
}
}
}
},
"outputs": {}
})
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
git-lfs
natcap.invest
natcap.invest@git+https://github.com/natcap/invest@feature/plugins
pint
setuptools_scm
sphinx
Expand Down
32 changes: 19 additions & 13 deletions source/en/ndr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ The model has options to calculate nitrogen, phosphorus, or both. You must provi
Columns:

- :investspec:`ndr.ndr biophysical_table_path.columns.lucode`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_[NUTRIENT]`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_p`

.. note::
Loads are the sources of nutrients associated with each LULC class. This value is the total load from all sources. If you want to represent different levels of fertilizer application, you will need to create separate LULC classes, for example one class called "crops - high fertilizer use" a separate class called "crops - low fertilizer use" etc.
Expand All @@ -278,20 +279,26 @@ The model has options to calculate nitrogen, phosphorus, or both. You must provi
.. note::
Data sources may provide loading values as either the nutrient application rate (e.g., fertilizer, livestock waste, atmospheric deposition); or as measured contaminant runoff, which are empirical values representing the contribution of a parcel to the nutrient budget (e.g., nutrient export running off urban areas, crops, etc.). These two types of loading values are denoted *application-rate* and *measured-runoff*, respectively, in the biophysical table. Since the model equations require measured runoff values, if you supply application rate values, the model will adjust for the nutrient retention provided on the pixel itself, using the application rate and retention efficiency value (*eff_n* or *eff_p*) for that land cover type:

_loading = application rate * (1 - retention efficiency)_
:math:`loading = application rate * (1 - retention efficiency)`

using the specific biophysical table fields for nitrogen:
using the specific biophysical table fields for nitrogen:

_loading = load_n_ * (1 - eff_n_)_
:math:`loading = load_n * (1 - eff_n_)`

Note that you can provide a mix of _measured-runoff_ and _application-rate_ values, and the model will only adjust the _application-rate_ values as described; _measured-runoff_ values do not need to be adjusted.
Note that you can provide a mix of *measured-runoff* and *application-rate* values, and the model will only adjust the *application-rate* values as described; *measured-runoff* values do not need to be adjusted. For example, if the nitrogen application rate for an agricultural LULC class is 10 kg/ha/year, and the retention efficiency is 0.4, the model will adjust the value to 6.0 kg/ha/year (= 10 kg/ha/year * (1 - 0.4)). If you have measured/nutrient export values, denoted as *measured-runoff* in the biophysical table, then the model will use these directly without adjustment.

For example, if the nitrogen application rate for an agricultural LULC class is 10 kg/ha/year, and the retention efficiency is 0.4, the model will adjust the value to 6.0 kg/ha/year (= 10 kg/ha/year * (1 - 0.4)). If you have measured/nutrient export values, denoted as *measured-runoff* in the biophysical table, then the model will use these directly without adjustment.

- :investspec:`ndr.ndr biophysical_table_path.columns.eff_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.eff_p`

- :investspec:`ndr.ndr biophysical_table_path.columns.eff_[NUTRIENT]` The nutrient retention capacity for a given vegetation type is expressed as a proportion of the amount of nutrient from upslope. For example, high values (0.6 to 0.8) may be assigned to all natural vegetation types (such as forests, natural pastures, wetlands, or prairie), indicating that 60-80% of nutrient is retained.
.. note::
The nutrient retention capacity for a given vegetation type is expressed as a proportion of the amount of nutrient from upslope. For example, high values (0.6 to 0.8) may be assigned to all natural vegetation types (such as forests, natural pastures, wetlands, or prairie), indicating that 60-80% of nutrient is retained.

- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_[NUTRIENT]` If nutrients travel a distance smaller than the retention length, the retention efficiency will be less than the maximum value *eff_x*, following an exponential decay (see Nutrient Delivery section).
- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_p`

.. note::
If nutrients travel a distance smaller than the retention length, the retention efficiency will be less than the maximum value *eff_x*, following an exponential decay (see Nutrient Delivery section).

- :investspec:`ndr.ndr biophysical_table_path.columns.proportion_subsurface_n`

Expand Down Expand Up @@ -436,16 +443,15 @@ For all water quality parameters (nutrient load, retention efficiency, and reten

Data sources may provide loading values as either the nutrient application rate (e.g., fertilizer, livestock waste, atmospheric deposition); or as measured contaminant runoff, which are empirical values representing the contribution of a parcel to the nutrient budget (e.g., nutrient export running off urban areas, crops, etc.). These two types of loading values are denoted *application-rate* and *measured-runoff*, respectively, in the biophysical table. Since the model equations require measured runoff values, if you supply application rate values, the model will adjust for the nutrient retention provided on the pixel itself, using the application rate and retention efficiency value (*eff_n* or *eff_p*) for that land cover type:

_loading = application rate * (1 - retention efficiency)_
:math:`loading = application rate * (1 - retention efficiency)`

using the specific biophysical table fields for nitrogen:

_loading = load_n_ * (1 - eff_n_)_
:math:`loading = load_n_ * (1 - eff_n_)`

Note that you can provide a mix of _measured-runoff_ and _application-rate_ values, and the model will only adjust the _application-rate_ values as described; _measured-runoff_ values do not need to be adjusted.

For example, if the nitrogen application rate for an agricultural LULC class is 10 kg/ha/year, and the retention efficiency is 0.4, the model will adjust the value to 6.0 kg/ha/year (= 10 kg/ha/year * (1 - 0.4)). If you have measured/nutrient export values, denoted as *measured-runoff* in the biophysical table, then the model will use these directly without adjustment.
Note that you can provide a mix of *measured-runoff* and *application-rate* values, and the model will only adjust the *application-rate* values as described; *measured-runoff* values do not need to be adjusted.

For example, if the nitrogen application rate for an agricultural LULC class is 10 kg/ha/year, and the retention efficiency is 0.4, the model will adjust the value to 6.0 kg/ha/year (= 10 kg/ha/year * (1 - 0.4)). If you have measured/nutrient export values, denoted as *measured-runoff* in the biophysical table, then the model will use these directly without adjustment.

Examples of export coefficients (“extensive” measures) for the US can be found in the EPA PLOAD User’s Manual and in a review by Lin (2004). Note that the examples in the EPA guide are in lbs/ac/yr and must be converted to kg/ha/yr.

Expand Down
20 changes: 16 additions & 4 deletions source/es/ndr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,29 @@ El modelo tiene opciones para calcular el nitrógeno, el fósforo o ambos. Debe
Columnas:

- :investspec:`ndr.ndr biophysical_table_path.columns.lucode`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_[NUTRIENT]`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_p`

.. note::
Las cargas son las fuentes de nutrientes asociadas a cada píxel del paisaje. En consonancia con la bibliografía sobre coeficientes de exportación (California Regional Water Quality Control Board Central Coast Region, 2013; Reckhow et al., 1980), los valores de carga para cada clase de LULC se derivan de medidas empíricas de exportación de nutrientes (por ejemplo, exportación de nutrientes que escurren de zonas urbanas, cultivos, etc.). Alternativamente, si se dispone de información sobre la cantidad de nutrientes aplicados (por ejemplo, fertilizantes, residuos ganaderos, deposición atmosférica), es posible utilizarla estimando el uso de nutrientes en el píxel y aplicando este factor de corrección para obtener los parámetros de carga. Para más información, véase la sección Necesidades de datos.
Las cargas son las fuentes de nutrientes asociadas a cada píxel del paisaje. En consonancia con la bibliografía sobre coeficientes de exportación (California Regional Water Quality Control Board Central Coast Region, 2013; Reckhow et al., 1980), los valores de carga para cada clase de LULC se derivan de medidas empíricas de exportación de nutrientes (por ejemplo, exportación de nutrientes que escurren de zonas urbanas, cultivos, etc.). Alternativamente, si se dispone de información sobre la cantidad de nutrientes aplicados (por ejemplo, fertilizantes, residuos ganaderos, deposición atmosférica), es posible utilizarla estimando el uso de nutrientes en el píxel y aplicando este factor de corrección para obtener los parámetros de carga. Para más información, véase la sección Necesidades de datos.

- :investspec:`ndr.ndr biophysical_table_path.columns.load_type_p`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_type_n`

.. note::
Las fuentes de datos pueden proporcionar valores de carga como la cantidad de nutrientes aplicados (por ejemplo, fertilizantes, residuos ganaderos, deposición atmosférica); o como medidas "extensivas" de contaminantes, que son valores empíricos que representan la contribución de una parcela al balance de nutrientes (por ejemplo, exportación de nutrientes que escurren de zonas urbanas, cultivos, etc.). En el caso de tener valores de nutrientes aplicados, estos deben corregirse en función de la retención de nutrientes proporcionada por el propio píxel, utilizando la tasa de aplicación y el valor de eficiencia de retención (*eff_n* o *eff_p*) para ese tipo de cubierta terrestre:

- :investspec:`ndr.ndr biophysical_table_path.columns.eff_[NUTRIENT]` La capacidad de retención de nutrientes de un determinado tipo de vegetación se expresa como una proporción de la cantidad de nutrientes procedentes de la ladera. Por ejemplo, se pueden asignar valores altos (de 0,6 a 0,8) a todos los tipos de vegetación natural (como bosques, pastos naturales, humedales o praderas), lo que indica que se retiene entre el 60 y el 80% de los nutrientes.
- :investspec:`ndr.ndr biophysical_table_path.columns.eff_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.eff_p`

.. note::
La capacidad de retención de nutrientes de un determinado tipo de vegetación se expresa como una proporción de la cantidad de nutrientes procedentes de la ladera. Por ejemplo, se pueden asignar valores altos (de 0,6 a 0,8) a todos los tipos de vegetación natural (como bosques, pastos naturales, humedales o praderas), lo que indica que se retiene entre el 60 y el 80% de los nutrientes.

- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_[NUTRIENT]` Si los nutrientes recorren una distancia menor que la longitud de retención, la eficiencia de retención será menor que el valor máximo *eff_x*, siguiendo un decaimiento exponencial (véase la sección Suministro de nutrientes).
- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_p`

.. note::
Si los nutrientes recorren una distancia menor que la longitud de retención, la eficiencia de retención será menor que el valor máximo *eff_x*, siguiendo un decaimiento exponencial (véase la sección Suministro de nutrientes).

- :investspec:`ndr.ndr biophysical_table_path.columns.proportion_subsurface_n` Por defecto, este valor debe fijarse en 0, lo que indica que todos los nutrientes se suministran a través del flujo superficial. No existe un equivalente para el fósforo.

Expand Down
18 changes: 15 additions & 3 deletions source/zh/ndr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,29 @@ NDR模型没有直接量化景观上持留的养分量。但是,如果您有
列:

- :investspec:`ndr.ndr biophysical_table_path.columns.lucode`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_[NUTRIENT]`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_p`

.. note::
负荷是与每个LULC类型相关的养分来源。这个值是来自所有源的总负荷。如果你想表示不同的施肥水平,你需要创建单独的LULC类,比如一个类叫做“作物-高肥料使用量”,另一个类叫做“作物-低肥料使用量”,等等。

- :investspec:`ndr.ndr biophysical_table_path.columns.load_type_p`
- :investspec:`ndr.ndr biophysical_table_path.columns.load_type_n`

.. note::
负荷值可以表示为养分施用量(例如肥料、禽畜废物、大气沉降);也可以表示为污染物的“广泛”量度,即代表一块土地对养分收支的贡献的经验值(例如城市地区、农作物等的养分输出)。在后一种情况下,应根据同一LULC的下坡像元的养分持留对负载进行校正。例如,如果测得的(或根据经验得出的)森林出口值为3千克/公顷/年,持留效率为0.8,则用户应在生物物理表的n_Load栏中输入15(千克/公顷/年);模型将计算从森林像元流出的养分为15*(1-0.8)=3千克/公顷/年。

- :investspec:`ndr.ndr biophysical_table_path.columns.eff_[NUTRIENT]` 给定植被类型的养分持留能力是以上坡的养分量的比例表示的。例如,所有的自然植被类型(如森林、天然牧场、湿地或草原)都有较高的值(0.6至0.8),这表明60%-80%的养分被持留了下来。
- :investspec:`ndr.ndr biophysical_table_path.columns.eff_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.eff_p`

.. note::
给定植被类型的养分持留能力是以上坡的养分量的比例表示的。例如,所有的自然植被类型(如森林、天然牧场、湿地或草原)都有较高的值(0.6至0.8),这表明60%-80%的养分被持留了下来。

- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_[NUTRIENT]` 如果养分移动的距离小于持留长度,持留效率将小于最大值*eff_x*,然后呈指数衰减(参见养分输送部分)。
- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_n`
- :investspec:`ndr.ndr biophysical_table_path.columns.crit_len_p`

.. note::
如果养分移动的距离小于持留长度,持留效率将小于最大值*eff_x*,然后呈指数衰减(参见养分输送部分)。

- :investspec:`ndr.ndr biophysical_table_path.columns.proportion_subsurface_n` 默认情况下,这个值应该设置为0,表示所有养分物质都是通过表面流传递的。对于磷来说,则没有相关等效值。

Expand Down
Loading