diff --git a/src/wres/pipeline/pooling/EventsGenerator.java b/src/wres/pipeline/pooling/EventsGenerator.java index b2bd3f6ea..83d277760 100644 --- a/src/wres/pipeline/pooling/EventsGenerator.java +++ b/src/wres/pipeline/pooling/EventsGenerator.java @@ -10,6 +10,7 @@ import java.util.TreeSet; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; +import java.util.function.Predicate; import java.util.function.UnaryOperator; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -134,6 +135,10 @@ Set doEventDetection( Project project, TimeScaleOuter covariateTimeScale = this.getAdjustedTimeScale( desiredTimeScale, next.rescaleFunction() ); + String variableName = next.dataset() + .variable() + .name(); + switch ( next.featureNameOrientation() ) { case LEFT -> @@ -144,9 +149,8 @@ Set doEventDetection( Project project, FeatureTuple::getLeft, eventRetriever, detection, - next.dataset() - .variable() - .name(), + variableName, + project.getCovariateFeatures( variableName ), covariateTimeScale, this.covariateUpscaler(), null, @@ -162,9 +166,8 @@ Set doEventDetection( Project project, FeatureTuple::getRight, eventRetriever, detection, - next.dataset() - .variable() - .name(), + variableName, + project.getCovariateFeatures( variableName ), covariateTimeScale, this.covariateUpscaler(), null, @@ -179,9 +182,8 @@ Set doEventDetection( Project project, FeatureTuple::getBaseline, eventRetriever, detection, - next.dataset() - .variable() - .name(), + variableName, + project.getCovariateFeatures( variableName ), covariateTimeScale, this.covariateUpscaler(), null, @@ -207,6 +209,7 @@ Set doEventDetection( Project project, eventRetriever, detection, null, + Set.of(), desiredTimeScale, this.leftUpscaler(), this.measurementUnit(), @@ -225,6 +228,7 @@ Set doEventDetection( Project project, eventRetriever, detection, null, + Set.of(), desiredTimeScale, this.rightUpscaler(), this.measurementUnit(), @@ -243,6 +247,7 @@ Set doEventDetection( Project project, eventRetriever, detection, null, + Set.of(), desiredTimeScale, this.baselineUpscaler(), this.measurementUnit(), @@ -317,6 +322,9 @@ private Set doEventDetection( EventDetectionDetails details ) timeWindow = TimeWindowSlicer.adjustTimeWindowForTimeScale( adjustedOuter, details.desiredTimeScale() ); } + // Get the features for the dataset orientation, which is one of the main datasets (observed, predicted or + // baseline), not a covariate. The covariate features must be further derived by correlating the feature names + // whose features have the same feature authority as the covariate dataset, which is a requirement. See below. Set features = this.getFeatures( featureGroup.getFeatures(), featureGetter ); LOGGER.info( "Getting time-series data to perform event detection for the following features: {}", features ); @@ -373,7 +381,17 @@ private Set doEventDetection( EventDetectionDetails details ) } case COVARIATES -> { - Stream> series = eventRetriever.getCovariateRetriever( features, + // Map the features to covariate features based on name correlation + Predicate contained = feature -> features.stream() + .anyMatch( f -> Objects.equals( f.getName(), + feature.getName() ) ); + + Set innerFeatures = details.covariateFeatures() + .stream() + .filter( contained ) + .collect( Collectors.toUnmodifiableSet() ); + + Stream> series = eventRetriever.getCovariateRetriever( innerFeatures, details.covariateName(), timeWindow ) .get(); @@ -665,6 +683,7 @@ private EventDetectionDetails getAdjustedDetails( EventDetectionDetails details, details.eventRetriever(), details.detection(), details.covariateName(), + details.covariateFeatures(), details.desiredTimeScale(), details.upscaler(), measurementUnit, @@ -696,6 +715,7 @@ private Set getFeatures( Set featureTuples, Function eventRetriever, EventDetection detection, String covariateName, + Set covariateFeatures, TimeScaleOuter desiredTimeScale, TimeSeriesUpscaler upscaler, String measurementUnit, diff --git a/wres-vis/src/wres/vis/charts/ChartFactory.java b/wres-vis/src/wres/vis/charts/ChartFactory.java index c09a0ea44..863a08337 100644 --- a/wres-vis/src/wres/vis/charts/ChartFactory.java +++ b/wres-vis/src/wres/vis/charts/ChartFactory.java @@ -2388,7 +2388,8 @@ private String getPoolingWindowLegendName( MetricConstants metricName, // Reference times when required if ( graphicShape != GraphicShape.ISSUED_DATE_POOLS - && ( !earliestReferenceTime.equals( Instant.MIN ) || !latestReferenceTime.equals( Instant.MAX ) ) ) + && ( !earliestReferenceTime.equals( Instant.MIN ) + || !latestReferenceTime.equals( Instant.MAX ) ) ) { legendTitle = legendTitle + "Issued time window [UTC], "; }