Skip to content

Commit

Permalink
wip sensitivities
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Sep 13, 2024
1 parent 892e5a5 commit cc1932a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ export class StatisticalSurfaceContext implements SettingsContext<StatisticalSur
})
);
this._contextDelegate.setAvailableValues(SettingType.SENSITIVITY, availableSensitivityPairs);
const currentSensitivityPair = settings[SettingType.SENSITIVITY].getDelegate().getValue();
if (
!currentSensitivityPair ||
!availableSensitivityPairs.some(
(pair) =>
pair.sensitivityName === currentSensitivityPair.sensitivityName &&
pair.sensitivityCase === currentSensitivityPair.sensitivityCase
)
) {
if (availableSensitivityPairs.length > 0) {
settings[SettingType.SENSITIVITY].getDelegate().setValue(availableSensitivityPairs[0]);
}
}

const availableAttributes: string[] = [];
availableAttributes.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,42 @@ export class StatisticalSurfaceLayer
fechData(queryClient: QueryClient): Promise<SurfaceDataFloat_trans | SurfaceDataPng_api> {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ export class Sensitivity implements Setting<SensitivityNameCasePair | null> {
sensitivityCase: selectedValue,
});
}
if (!props.value) {
return "No sensitivities available";
}
return (
<>
<div className="flex">
<Dropdown
options={sensitivityNameOptions}
value={props.value?.sensitivityName ?? ""}
Expand All @@ -95,7 +98,7 @@ export class Sensitivity implements Setting<SensitivityNameCasePair | null> {
value={currentSensitivityCase ?? ""}
onChange={handleSensitivityCaseChange}
/>
</>
</div>
);
};
}
Expand Down

0 comments on commit cc1932a

Please sign in to comment.