Merge pull request #1246 from pierotofy/mulfix

Plant Health Enhancements
pull/1247/head
Piero Toffanin 2022-10-01 16:08:07 -04:00 zatwierdzone przez GitHub
commit 3af0db1b84
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 23 dodań i 10 usunięć

Wyświetl plik

@ -9,23 +9,28 @@ from django.utils.translation import gettext_lazy as _
algos = {
'NDVI': {
'expr': '(N - R) / (N + R)',
'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.')
'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.'),
'range': (-1, 1)
},
'NDYI': {
'expr': '(G - B) / (G + B)',
'help': _('Normalized difference yellowness index (NDYI), best model variability in relative yield potential in Canola.')
'help': _('Normalized difference yellowness index (NDYI), best model variability in relative yield potential in Canola.'),
'range': (-1, 1)
},
'NDRE': {
'expr': '(N - Re) / (N + Re)',
'help': _('Normalized Difference Red Edge Index shows the amount of green vegetation of permanent or later stage crops.')
'help': _('Normalized Difference Red Edge Index shows the amount of green vegetation of permanent or later stage crops.'),
'range': (-1, 1)
},
'NDWI': {
'expr': '(G - N) / (G + N)',
'help': _('Normalized Difference Water Index shows the amount of water content in water bodies.')
'help': _('Normalized Difference Water Index shows the amount of water content in water bodies.'),
'range': (-1, 1)
},
'NDVI (Blue)': {
'expr': '(N - B) / (N + B)',
'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.')
'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.'),
'range': (-1, 1)
},
'ENDVI':{
'expr': '((N + G) - (2 * B)) / ((N + G) + (2 * B))',
@ -59,7 +64,8 @@ algos = {
},
'GNDVI':{
'expr': '(N - G) / (N + G)',
'help': _('Green Normalized Difference Vegetation Index is similar to NDVI, but measures the green spectrum instead of red.')
'help': _('Green Normalized Difference Vegetation Index is similar to NDVI, but measures the green spectrum instead of red.'),
'range': (-1, 1)
},
'GRVI':{
'expr': 'N / G',
@ -153,7 +159,7 @@ def lookup_formula(algo, band_order = 'RGB'):
raise ValueError("Cannot find algorithm " + algo)
input_bands = tuple(b for b in re.split(r"([A-Z][a-z]*)", band_order) if b != "")
def repl(matches):
b = matches.group(1)
try:

Wyświetl plik

@ -55,7 +55,9 @@ export default class Histogram extends React.Component {
const st = {
min: minX.toFixed(3),
max: maxX.toFixed(3)
max: maxX.toFixed(3),
minInput: minX.toFixed(3),
maxInput: maxX.toFixed(3)
};
if (!this.state){
@ -235,6 +237,9 @@ export default class Histogram extends React.Component {
}
componentDidUpdate(prevProps, prevState){
if (prevState.min !== this.state.min) this.state.minInput = this.state.min;
if (prevState.max !== this.state.max) this.state.maxInput = this.state.max;
if (prevState.min !== this.state.min ||
prevState.max !== this.state.max ||
prevProps.colorMap !== this.props.colorMap ||
@ -271,6 +276,7 @@ export default class Histogram extends React.Component {
}
handleChangeMax = (e) => {
this.setState({maxInput: e.target.value});
const val = parseFloat(e.target.value);
if (val >= this.state.min && val <= this.rangeX[1]){
@ -279,6 +285,7 @@ export default class Histogram extends React.Component {
}
handleChangeMin = (e) => {
this.setState({minInput: e.target.value});
const val = parseFloat(e.target.value);
if (val <= this.state.max && val >= this.rangeX[0]){
@ -290,8 +297,8 @@ export default class Histogram extends React.Component {
return (<div className={"histogram " + (this.props.loading ? "disabled" : "")}>
<div ref={(domNode) => { this.hgContainer = domNode; }}>
</div>
<label>{_("Min:")}</label> <input onChange={this.handleChangeMin} type="number" className="form-control min-max" size={5} value={this.state.min} />
<label>{_("Max:")}</label> <input onChange={this.handleChangeMax} type="number" className="form-control min-max" size={5} value={this.state.max} />
<label>{_("Min:")}</label> <input onChange={this.handleChangeMin} type="number" className="form-control min-max" size={5} value={this.state.minInput} />
<label>{_("Max:")}</label> <input onChange={this.handleChangeMax} type="number" className="form-control min-max" size={5} value={this.state.maxInput} />
</div>);
}
}