diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts b/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts index e52a58ce2..c4d82f271 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts +++ b/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts @@ -73,6 +73,19 @@ export class StatisticalSurfaceContext implements SettingsContext + pair.sensitivityName === currentSensitivityPair.sensitivityName && + pair.sensitivityCase === currentSensitivityPair.sensitivityCase + ) + ) { + if (availableSensitivityPairs.length > 0) { + settings[SettingType.SENSITIVITY].getDelegate().setValue(availableSensitivityPairs[0]); + } + } const availableAttributes: string[] = []; availableAttributes.push( diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts b/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts index 371700499..653363be0 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts +++ b/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts @@ -49,18 +49,42 @@ export class StatisticalSurfaceLayer fechData(queryClient: QueryClient): Promise { let surfaceAddress: FullSurfaceAddress | null = null; const addrBuilder = new SurfaceAddressBuilder(); - + const workbenchSession = this.getLayerDelegate().getLayerManager().getWorkbenchSession(); const settings = this.getSettingsContext().getDelegate().getSettings(); const ensembleIdent = settings[SettingType.ENSEMBLE].getDelegate().getValue(); const surfaceName = settings[SettingType.SURFACE_NAME].getDelegate().getValue(); const attribute = settings[SettingType.SURFACE_ATTRIBUTE].getDelegate().getValue(); const timeOrInterval = settings[SettingType.TIME_OR_INTERVAL].getDelegate().getValue(); const statisticFunction = settings[SettingType.STATISTIC_FUNCTION].getDelegate().getValue(); + const sensitivityNameCasePair = settings[SettingType.SENSITIVITY].getDelegate().getValue(); + if (ensembleIdent && surfaceName && attribute) { addrBuilder.withEnsembleIdent(ensembleIdent); addrBuilder.withName(surfaceName); addrBuilder.withAttribute(attribute); + // Get filtered realizations from workbench + let filteredRealizations = workbenchSession + .getRealizationFilterSet() + .getRealizationFilterForEnsembleIdent(ensembleIdent) + .getFilteredRealizations(); + + // If sensitivity is set, filter realizations further to only include the realizations that are in the sensitivity + if (sensitivityNameCasePair) { + const currentEnsemble = workbenchSession.getEnsembleSet().findEnsemble(ensembleIdent); + + const sensitivity = currentEnsemble + ?.getSensitivities() + ?.getCaseByName(sensitivityNameCasePair.sensitivityName, sensitivityNameCasePair.sensitivityCase); + + const sensitivityRealizations = sensitivity?.realizations ?? []; + + filteredRealizations = filteredRealizations.filter((realization) => + sensitivityRealizations.includes(realization) + ); + } + addrBuilder.withStatisticRealizations(filteredRealizations.map((realization) => realization)); + if (timeOrInterval !== SurfaceTimeType_api.NO_TIME) { addrBuilder.withTimeOrInterval(timeOrInterval); } diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/Sensitivity.tsx b/frontend/src/modules/LayerSpike/layers/implementations/settings/Sensitivity.tsx index f1b7e726e..cf0aa863d 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/settings/Sensitivity.tsx +++ b/frontend/src/modules/LayerSpike/layers/implementations/settings/Sensitivity.tsx @@ -83,8 +83,11 @@ export class Sensitivity implements Setting { sensitivityCase: selectedValue, }); } + if (!props.value) { + return "No sensitivities available"; + } return ( - <> +
{ value={currentSensitivityCase ?? ""} onChange={handleSensitivityCaseChange} /> - +
); }; }