Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate all remaining references to Plates #409

Merged
merged 3 commits into from
Nov 28, 2023
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
90 changes: 33 additions & 57 deletions components/reports/PrecipitationFrequency.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
<div>
<b-field label="Era">
<b-radio v-model="radioEra" name="radioEra" native-value="2020-2049">
2020-2049
2020&ndash;2049
</b-radio>
<b-radio v-model="radioEra" name="radioEra" native-value="2050-2079">
2050-2079
2050&ndash;2079
</b-radio>
<b-radio v-model="radioEra" name="radioEra" native-value="2080-2099">
2080-2099
2080&ndash;2099
</b-radio>
</b-field>
</div>
Expand All @@ -49,14 +49,14 @@
name="radioPrecipFreqModel"
native-value="NCAR-CCSM4"
>
NCAR-CCSM4
NCAR CCSM4
</b-radio>
<b-radio
v-model="radioPrecipFreqModel"
name="radioPrecipFreqModel"
native-value="GFDL-CM3"
>
GFDL-CM3
GFDL CM3
</b-radio>
</b-field>
</div>
Expand All @@ -69,9 +69,7 @@
<thead>
<tr>
<th class="no-border">Duration</th>
<th class="no-border" colspan="9">
Annual exceedance probability
</th>
<th class="no-border" colspan="9">Annual exceedance probability</th>
</tr>
<tr>
<th></th>
Expand Down Expand Up @@ -114,17 +112,17 @@
:key="intIndex"
>
{{
results.precip_frequency[
pf[
`pr_${interval}_${duration}_${radioPrecipFreqModel}_${radioEra}_mean`
]
}}<UnitWidget unitType="mm_in" /><br />
<span class="small-text">
{{
results.precip_frequency[
pf[
`pr_${interval}_${duration}_${radioPrecipFreqModel}_${radioEra}_min`
]
}}&mdash;{{
results.precip_frequency[
pf[
`pr_${interval}_${duration}_${radioPrecipFreqModel}_${radioEra}_max`
]
}}
Expand Down Expand Up @@ -196,59 +194,37 @@ export default {
}
},
computed: {
pf: function () {
let res = {}
for (const return_interval in this.results.precip_frequency) {
const durations = this.results.precip_frequency[return_interval]
for (const duration in durations) {
const models = durations[duration]
for (const model in models) {
const eras = models[model]
for (const era in eras) {
const precips = eras[era]
res[`pr_${return_interval}_${duration}_${model}_${era}_min`] =
precips.pf_lower

res[`pr_${return_interval}_${duration}_${model}_${era}_mean`] =
precips.pf

res[`pr_${return_interval}_${duration}_${model}_${era}_max`] =
precips.pf_upper
}
}
}
}
return res
},
...mapGetters({
results: 'report/results',
placeName: 'report/placeName',
isPlaceDefined: 'report/isPlaceDefined',
units: 'report/units',
isPrecipitationFrequencyPresent: 'report/isPrecipitationFrequencyPresent',
}),
getUnits() {
return this.units === 'imperial' ? 'inches' : 'mm'
},
},
watch: {
isPlaceDefined: function () {
this.$fetch()
},
},
fetch() {
let plateResults = {}
for (const return_interval in this.results.precip_frequency) {
// If the results have already been converted, such as when
// clicking on an anchor link in the TOC, do not try to convert
// the results again.
if (return_interval.includes('pr')) {
plateResults = this.results.precip_frequency
break
}
const durations = this.results.precip_frequency[return_interval]
for (const duration in durations) {
const models = durations[duration]
for (const model in models) {
const eras = models[model]
for (const era in eras) {
const precips = eras[era]
plateResults[
`pr_${return_interval}_${duration}_${model}_${era}_min`
] = precips.pf_lower

plateResults[
`pr_${return_interval}_${duration}_${model}_${era}_mean`
] = precips.pf

plateResults[
`pr_${return_interval}_${duration}_${model}_${era}_max`
] = precips.pf_upper
}
}
}
}

this.$store.commit('report/setPlateResults', {
plateResults: plateResults,
variable: 'precip_frequency',
})
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion store/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default {
},
toggleLayer(state, layerObj) {
// Remove existing layer: right now, we only
// want one layer to be visible on any plate in the Atlas.
// want one layer to be visible on any map in the Atlas.
// Need to test explicitly for the existence of the
// layerObject because this code can get run while
// the full DOM is hydrating, see MapLayer / mounted().
Expand Down
3 changes: 0 additions & 3 deletions store/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,6 @@ export default {
)
})
},
setPlateResults(state, payload) {
state.results[payload.variable] = payload.plateResults
},
setResults(state, results) {
state.results = results
},
Expand Down
Loading