Skip to content

Commit 1158ffb

Browse files
authored
Merge pull request #119 from ISI-MIP/min-max
Add valid values to output variables table
2 parents 93ff3ce + d805e2e commit 1158ffb

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed

app/src/components/tables/VariableTable.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component} from 'react'
22
import ReactMarkdown from 'react-markdown'
33
import PropTypes from 'prop-types'
4+
import { isUndefined } from 'lodash'
45

56
import Sectors from '../badges/Sectors'
67
import { GroupToggleLink, filterGroups, filterField, toggleGroups } from '../../utils'
@@ -184,6 +185,36 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
184185
}
185186
}
186187

188+
const getUnit = (row) => {
189+
const unit = filterField(config, row.units)
190+
return !isUndefined(unit) && (
191+
<>
192+
<p className="mb-1">
193+
<strong>Unit:</strong>
194+
</p>
195+
<p>
196+
{unit}
197+
</p>
198+
</>
199+
)
200+
}
201+
202+
const getValid = (row) => {
203+
const valid_min = filterField(config, row.valid_min)
204+
const valid_max = filterField(config, row.valid_max)
205+
return !isUndefined(valid_min) && !isUndefined(valid_max) && (
206+
<>
207+
<div className="separator"></div>
208+
<p className="mb-1">
209+
<strong>Valid range:</strong>
210+
</p>
211+
<p>
212+
{valid_min} - {valid_max}
213+
</p>
214+
</>
215+
)
216+
}
217+
187218
return (
188219
<div className="w-100">
189220
<table className="table table-bordered table-fixed">
@@ -194,7 +225,7 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
194225
<tr>
195226
<th style={{width: '20%'}}>Variable long name</th>
196227
<th style={{width: '15%'}}>Variable specifier</th>
197-
<th style={{width: '15%'}}>Unit</th>
228+
<th style={{width: '15%'}}>Unit / Valid range</th>
198229
<th style={{width: '15%'}}>Resolution</th>
199230
<th style={{width: '35%'}}>
200231
Comments
@@ -223,7 +254,10 @@ const VariableTable = function({ config, caption, rows, groups, actions }) {
223254
<tr key={index}>
224255
<td>{row.long_name}</td>
225256
<td>{getSpecifier(row)}</td>
226-
<td>{row.units}</td>
257+
<td>
258+
{getUnit(row)}
259+
{getValid(row)}
260+
</td>
227261
<td>
228262
<ul className="resolution-list">
229263
{getResolution(row)}

assets/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ td :last-child {
144144
}
145145
td > ul {
146146
padding-left: 1.2rem;
147+
margin-bottom: 0.5rem;
147148
}
148149
td > ul > li {
149150
margin-bottom: 0.5rem;
@@ -401,6 +402,12 @@ td.nowrap > div {
401402
margin-bottom: 0;
402403
}
403404

405+
div.separator {
406+
border-top: 1px solid #dee2e6;
407+
margin-top: 0.75rem;
408+
padding-top: 0.75rem;
409+
}
410+
404411
@media print {
405412
body {
406413
/* fix colors in printing */

definitions/variable/hydrological.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,8 @@
376376
- peat
377377
- permafrost
378378
- water_global
379-
valid_max:
380-
other: 1000.0
381-
lakes_local: 5.0
382-
lakes_global: 5.0
383-
valid_min:
384-
other: 0.0
385-
lakes_local: 0.0
386-
lakes_global: 0.0
379+
valid_max: 1000.0
380+
valid_min: 0.0
387381

388382
- specifier: snm
389383
long_name: Snow Melt

0 commit comments

Comments
 (0)