diff --git a/frontend/src/framework/DeltaEnsemble.ts b/frontend/src/framework/DeltaEnsemble.ts index bb0782260..5a76261bd 100644 --- a/frontend/src/framework/DeltaEnsemble.ts +++ b/frontend/src/framework/DeltaEnsemble.ts @@ -87,6 +87,14 @@ export class DeltaEnsemble implements EnsembleInterface { return this._customName; } + getParameters(): EnsembleParameters { + return this._parameters; + } + + getSensitivities(): EnsembleSensitivities | null { + return this._sensitivities; + } + // *** Custom methods *** getEnsembleIdentByElement(element: DeltaEnsembleElement): EnsembleIdent { diff --git a/frontend/src/framework/EnsembleInterface.ts b/frontend/src/framework/EnsembleInterface.ts index 4968cb6f2..e76d18426 100644 --- a/frontend/src/framework/EnsembleInterface.ts +++ b/frontend/src/framework/EnsembleInterface.ts @@ -1,4 +1,6 @@ import { EnsembleIdentInterface } from "./EnsembleIdentInterface"; +import { EnsembleParameters } from "./EnsembleParameters"; +import { EnsembleSensitivities } from "./EnsembleSensitivities"; export interface EnsembleInterface { getIdent(): EnsembleIdentInterface; @@ -7,8 +9,8 @@ export interface EnsembleInterface { getRealizations(): readonly number[]; getRealizationCount(): number; getMaxRealizationNumber(): number | undefined; - // getParemters(): EnsembleParameters; - // getSensitivities(): EnsembleSensitivities | null; + getParameters(): EnsembleParameters; + getSensitivities(): EnsembleSensitivities | null; getColor(): string; getCustomName(): string | null; } diff --git a/frontend/src/framework/GlobalAtoms.ts b/frontend/src/framework/GlobalAtoms.ts index 443e02abc..73aecc8b3 100644 --- a/frontend/src/framework/GlobalAtoms.ts +++ b/frontend/src/framework/GlobalAtoms.ts @@ -3,6 +3,7 @@ import { EnsembleSet } from "@framework/EnsembleSet"; import { atom } from "jotai"; import { isEqual } from "lodash"; +import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; import { EnsembleIdent } from "./EnsembleIdent"; import { RealizationFilterSet } from "./RealizationFilterSet"; import { EnsembleRealizationFilterFunction } from "./WorkbenchSession"; @@ -26,7 +27,7 @@ export const EnsembleRealizationFilterFunctionAtom = atom + return (ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) => realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent).getFilteredRealizations(); }); @@ -40,7 +41,7 @@ export const ValidEnsembleRealizationsFunctionAtom = atom((get) => { let validEnsembleRealizationsFunction = get(EnsembleRealizationFilterFunctionAtom); if (validEnsembleRealizationsFunction === null) { - validEnsembleRealizationsFunction = (ensembleIdent: EnsembleIdent) => { + validEnsembleRealizationsFunction = (ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) => { return ensembleSet.findEnsemble(ensembleIdent)?.getRealizations() ?? []; }; } diff --git a/frontend/src/framework/RealizationFilter.ts b/frontend/src/framework/RealizationFilter.ts index 63c29e9a3..3213d333e 100644 --- a/frontend/src/framework/RealizationFilter.ts +++ b/frontend/src/framework/RealizationFilter.ts @@ -1,5 +1,7 @@ import { isEqual } from "lodash"; +import { DeltaEnsemble } from "./DeltaEnsemble"; +import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; import { Ensemble } from "./Ensemble"; import { EnsembleIdent } from "./EnsembleIdent"; import { @@ -37,7 +39,7 @@ import { * such as the ensemble ident and realization numbers. */ export class RealizationFilter { - private _assignedEnsemble: Ensemble; + private _assignedEnsemble: Ensemble | DeltaEnsemble; private _includeExcludeFilter: IncludeExcludeFilter; private _filterType: RealizationFilterType; @@ -52,7 +54,7 @@ export class RealizationFilter { private _filteredRealizations: readonly number[]; constructor( - assignedEnsemble: Ensemble, + assignedEnsemble: Ensemble | DeltaEnsemble, initialIncludeExcludeFilter = IncludeExcludeFilter.INCLUDE_FILTER, initialFilterType = RealizationFilterType.BY_REALIZATION_NUMBER ) { @@ -65,7 +67,7 @@ export class RealizationFilter { this._parameterIdentStringToValueSelectionMap = null; } - getAssignedEnsembleIdent(): EnsembleIdent { + getAssignedEnsembleIdent(): EnsembleIdent | DeltaEnsembleIdent { return this._assignedEnsemble.getIdent(); } diff --git a/frontend/src/framework/RealizationFilterSet.ts b/frontend/src/framework/RealizationFilterSet.ts index bd1f29fb6..2af833c44 100644 --- a/frontend/src/framework/RealizationFilterSet.ts +++ b/frontend/src/framework/RealizationFilterSet.ts @@ -1,8 +1,10 @@ import { isEqual } from "lodash"; +import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; import { EnsembleIdent } from "./EnsembleIdent"; import { EnsembleSet } from "./EnsembleSet"; import { RealizationFilter } from "./RealizationFilter"; +import { EnsembleType } from "./types/ensembleType"; export class RealizationFilterSet { // Map of ensembleIdent string to RealizationFilter @@ -17,14 +19,23 @@ export class RealizationFilterSet { synchronizeWithEnsembleSet(ensembleSet: EnsembleSet): void { // Remove filters for ensembles that are no longer in the ensemble set for (const ensembleIdentString of this._ensembleIdentStringRealizationFilterMap.keys()) { - const ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + let ensembleIdent = null; + if (EnsembleIdent.isValidEnsembleIdentString(ensembleIdentString)) { + ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + } else if (DeltaEnsembleIdent.isValidDeltaEnsembleIdentString(ensembleIdentString)) { + ensembleIdent = DeltaEnsembleIdent.fromString(ensembleIdentString); + } + if (!ensembleIdent) { + throw new Error(`Invalid ensemble ident string: ${ensembleIdentString}`); + } + if (!ensembleSet.hasEnsemble(ensembleIdent)) { this._ensembleIdentStringRealizationFilterMap.delete(ensembleIdentString); } } // Add filters for ensembles that are new to the ensemble set - for (const ensemble of ensembleSet.getEnsembleArr()) { + for (const ensemble of ensembleSet.getEnsembleArr(EnsembleType.ALL)) { const ensembleIdentString = ensemble.getIdent().toString(); const isEnsembleInMap = this._ensembleIdentStringRealizationFilterMap.has(ensembleIdentString); if (!isEnsembleInMap) { @@ -36,7 +47,7 @@ export class RealizationFilterSet { /** * Get filter for ensembleIdent */ - getRealizationFilterForEnsembleIdent(ensembleIdent: EnsembleIdent): RealizationFilter { + getRealizationFilterForEnsembleIdent(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent): RealizationFilter { const filter = this._ensembleIdentStringRealizationFilterMap.get(ensembleIdent.toString()); if (filter === undefined) { throw new Error( diff --git a/frontend/src/framework/WorkbenchSession.ts b/frontend/src/framework/WorkbenchSession.ts index aa9d610c8..3778804a4 100644 --- a/frontend/src/framework/WorkbenchSession.ts +++ b/frontend/src/framework/WorkbenchSession.ts @@ -1,13 +1,16 @@ import React from "react"; import { AtomStoreMaster } from "./AtomStoreMaster"; +import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; import { Ensemble } from "./Ensemble"; import { EnsembleIdent } from "./EnsembleIdent"; import { EnsembleSet } from "./EnsembleSet"; import { RealizationFilterSet } from "./RealizationFilterSet"; import { UserCreatedItems } from "./UserCreatedItems"; -export type EnsembleRealizationFilterFunction = (ensembleIdent: EnsembleIdent) => readonly number[]; +export type EnsembleRealizationFilterFunction = ( + ensembleIdent: EnsembleIdent | DeltaEnsembleIdent +) => readonly number[]; export enum WorkbenchSessionEvent { EnsembleSetChanged = "EnsembleSetChanged", @@ -78,7 +81,9 @@ export class WorkbenchSession { } function createEnsembleRealizationFilterFuncForWorkbenchSession(workbenchSession: WorkbenchSession) { - return function ensembleRealizationFilterFunc(ensembleIdent: EnsembleIdent): readonly number[] { + return function ensembleRealizationFilterFunc( + ensembleIdent: EnsembleIdent | DeltaEnsembleIdent + ): readonly number[] { const realizationFilterSet = workbenchSession.getRealizationFilterSet(); const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); diff --git a/frontend/src/framework/internal/components/RightSettingsPanel/private-components/RealizationFilterSettings/realizationFilterSettings.tsx b/frontend/src/framework/internal/components/RightSettingsPanel/private-components/RealizationFilterSettings/realizationFilterSettings.tsx index 5c2c0cfe1..2254ed26f 100644 --- a/frontend/src/framework/internal/components/RightSettingsPanel/private-components/RealizationFilterSettings/realizationFilterSettings.tsx +++ b/frontend/src/framework/internal/components/RightSettingsPanel/private-components/RealizationFilterSettings/realizationFilterSettings.tsx @@ -1,5 +1,6 @@ import React from "react"; +import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; import { EnsembleIdent } from "@framework/EnsembleIdent"; import { GuiEvent, @@ -16,7 +17,9 @@ import { EnsembleRealizationFilter, EnsembleRealizationFilterSelections, } from "@framework/internal/components/EnsembleRealizationFilter"; +import { EnsembleType } from "@framework/types/ensembleType"; import { UnsavedChangesAction } from "@framework/types/unsavedChangesAction"; +import { getEnsembleIdentFromString } from "@framework/utils/ensembleIdentUtils"; import { countTrueValues } from "@framework/utils/objectUtils"; import { areParameterIdentStringToValueSelectionMapCandidatesEqual } from "@framework/utils/realizationFilterTypesUtils"; import { FilterAlt } from "@mui/icons-material"; @@ -36,7 +39,9 @@ export const RealizationFilterSettings: React.FC GuiState.NumberOfUnsavedRealizationFilters ); - const [activeFilterEnsembleIdent, setActiveFilterEnsembleIdent] = React.useState(null); + const [activeFilterEnsembleIdent, setActiveFilterEnsembleIdent] = React.useState< + EnsembleIdent | DeltaEnsembleIdent | null + >(null); // Maps for keeping track of unsaved changes and filter selections const [ensembleIdentStringHasUnsavedChangesMap, setEnsembleIdentStringHasUnsavedChangesMap] = React.useState<{ @@ -55,7 +60,9 @@ export const RealizationFilterSettings: React.FC } // Create new maps if ensembles are added or removed - const ensembleIdentStrings = ensembleSet.getEnsembleArr().map((ensemble) => ensemble.getIdent().toString()); + const ensembleIdentStrings = ensembleSet + .getEnsembleArr(EnsembleType.ALL) + .map((ensemble) => ensemble.getIdent().toString()); if (!isEqual(ensembleIdentStrings, Object.keys(ensembleIdentStringToRealizationFilterSelectionsMap))) { // Create new maps with the new ensemble ident strings const updatedHasUnsavedChangesMap: { [ensembleIdentString: string]: boolean } = { @@ -79,7 +86,11 @@ export const RealizationFilterSettings: React.FC continue; } - const ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + const ensembleIdent = getEnsembleIdentFromString(ensembleIdentString); + if (!ensembleIdent) { + throw new Error(`Invalid ensemble ident: ${ensembleIdentString}`); + } + const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); updatedHasUnsavedChangesMap[ensembleIdentString] = false; @@ -102,7 +113,11 @@ export const RealizationFilterSettings: React.FC // Apply all the unsaved changes state and reset the unsaved changes state const resetHasUnsavedChangesMap: { [ensembleIdentString: string]: boolean } = {}; for (const ensembleIdentString in ensembleIdentStringToRealizationFilterSelectionsMap) { - const ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + const ensembleIdent = getEnsembleIdentFromString(ensembleIdentString); + if (!ensembleIdent) { + throw new Error(`Invalid ensemble ident: ${ensembleIdentString}`); + } + const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); const selections = ensembleIdentStringToRealizationFilterSelectionsMap[ensembleIdent.toString()]; @@ -123,11 +138,15 @@ export const RealizationFilterSettings: React.FC setEnsembleIdentStringHasUnsavedChangesMap(resetHasUnsavedChangesMap); setNumberOfUnsavedRealizationFilters(0); + + // Notify subscribers of change. + props.workbench.getWorkbenchSession().notifyAboutEnsembleRealizationFilterChange(); }, [ ensembleIdentStringToRealizationFilterSelectionsMap, realizationFilterSet, setNumberOfUnsavedRealizationFilters, + props.workbench, ] ); @@ -137,7 +156,11 @@ export const RealizationFilterSettings: React.FC const resetSelectionsMap: { [ensembleIdentString: string]: EnsembleRealizationFilterSelections } = {}; const resetHasUnsavedChangesMap: { [ensembleIdentString: string]: boolean } = {}; for (const ensembleIdentString in ensembleIdentStringToRealizationFilterSelectionsMap) { - const ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + const ensembleIdent = getEnsembleIdentFromString(ensembleIdentString); + if (!ensembleIdent) { + throw new Error(`Invalid ensemble ident: ${ensembleIdentString}`); + } + const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); resetSelectionsMap[ensembleIdentString] = { @@ -189,7 +212,7 @@ export const RealizationFilterSettings: React.FC props.onClose(); } - function handleApplyClick(ensembleIdent: EnsembleIdent) { + function handleApplyClick(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { const ensembleIdentString = ensembleIdent.toString(); const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); const selections = ensembleIdentStringToRealizationFilterSelectionsMap[ensembleIdentString]; @@ -214,7 +237,7 @@ export const RealizationFilterSettings: React.FC props.workbench.getWorkbenchSession().notifyAboutEnsembleRealizationFilterChange(); } - function handleDiscardClick(ensembleIdent: EnsembleIdent) { + function handleDiscardClick(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { const ensembleIdentString = ensembleIdent.toString(); const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); setEnsembleIdentStringToRealizationFilterSelectionsMap({ @@ -235,7 +258,10 @@ export const RealizationFilterSettings: React.FC setNumberOfUnsavedRealizationFilters(countTrueValues(newHasUnsavedChangesMap)); } - function handleFilterChange(ensembleIdent: EnsembleIdent, selections: EnsembleRealizationFilterSelections) { + function handleFilterChange( + ensembleIdent: EnsembleIdent | DeltaEnsembleIdent, + selections: EnsembleRealizationFilterSelections + ) { const ensembleIdentString = ensembleIdent.toString(); // Register the filter changes in the map @@ -264,11 +290,11 @@ export const RealizationFilterSettings: React.FC setNumberOfUnsavedRealizationFilters(countTrueValues(newHasUnsavedChangesMap)); } - function handleSetActiveEnsembleRealizationFilter(ensembleIdent: EnsembleIdent) { + function handleSetActiveEnsembleRealizationFilter(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { setActiveFilterEnsembleIdent(ensembleIdent); } - function handleOnEnsembleRealizationFilterHeaderClick(ensembleIdent: EnsembleIdent) { + function handleOnEnsembleRealizationFilterHeaderClick(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { if (activeFilterEnsembleIdent?.equals(ensembleIdent)) { setActiveFilterEnsembleIdent(null); } @@ -284,7 +310,7 @@ export const RealizationFilterSettings: React.FC >
- {ensembleSet.getEnsembleArr().map((ensemble) => { + {ensembleSet.getEnsembleArr(EnsembleType.ALL).map((ensemble) => { const ensembleIdent = ensemble.getIdent(); const isActive = activeFilterEnsembleIdent !== null && activeFilterEnsembleIdent.equals(ensembleIdent); diff --git a/frontend/src/framework/utils/ensembleIdentUtils.ts b/frontend/src/framework/utils/ensembleIdentUtils.ts index 207e48268..2317454ab 100644 --- a/frontend/src/framework/utils/ensembleIdentUtils.ts +++ b/frontend/src/framework/utils/ensembleIdentUtils.ts @@ -1,3 +1,5 @@ +import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; +import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleIdentInterface } from "@framework/EnsembleIdentInterface"; /** @@ -47,3 +49,19 @@ export function ensembleIdentRegexStringWithoutAnchors( ): string { return `(?<${caseUuidNamedGroup}>${ensembleIdentUuidRegexString()})::(?<${ensembleNameNamedGroup}>.*)`; } + +/** + * Get ensemble ident from string + * @param ensembleIdentString + * @returns + */ +export function getEnsembleIdentFromString(ensembleIdentString: string): EnsembleIdent | DeltaEnsembleIdent | null { + let ensembleIdent = null; + if (EnsembleIdent.isValidEnsembleIdentString(ensembleIdentString)) { + ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + } else if (DeltaEnsembleIdent.isValidDeltaEnsembleIdentString(ensembleIdentString)) { + ensembleIdent = DeltaEnsembleIdent.fromString(ensembleIdentString); + } + + return ensembleIdent; +} diff --git a/frontend/src/modules/3DViewer/settings/atoms/derivedAtoms.ts b/frontend/src/modules/3DViewer/settings/atoms/derivedAtoms.ts index a646a9785..1ff345465 100644 --- a/frontend/src/modules/3DViewer/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/3DViewer/settings/atoms/derivedAtoms.ts @@ -1,6 +1,6 @@ import { Grid3dDimensions_api } from "@api"; import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleRealizationFilterFunctionAtom, EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { EnsembleSetAtom, ValidEnsembleRealizationsFunctionAtom } from "@framework/GlobalAtoms"; import { IntersectionPolylinesAtom } from "@framework/userCreatedItems/IntersectionPolylines"; import { GridCellIndexRanges } from "@modules/3DViewer/typesAndEnums"; @@ -67,22 +67,14 @@ export const selectedCustomIntersectionPolylineIdAtom = atom((get) => { }); export const availableRealizationsAtom = atom((get) => { - const ensembleSet = get(EnsembleSetAtom); const selectedEnsembleIdent = get(selectedEnsembleIdentAtom); if (selectedEnsembleIdent === null) { return []; } - let ensembleRealizationFilterFunction = get(EnsembleRealizationFilterFunctionAtom); - - if (ensembleRealizationFilterFunction === null) { - ensembleRealizationFilterFunction = (ensembleIdent: EnsembleIdent) => { - return ensembleSet.findEnsemble(ensembleIdent)?.getRealizations() ?? []; - }; - } - - return ensembleRealizationFilterFunction(selectedEnsembleIdent); + const validEnsembleRealizationsFunction = get(ValidEnsembleRealizationsFunctionAtom); + return validEnsembleRealizationsFunction(selectedEnsembleIdent); }); export const selectedRealizationAtom = atom((get) => { diff --git a/frontend/src/modules/Pvt/settings/atoms/derivedAtoms.ts b/frontend/src/modules/Pvt/settings/atoms/derivedAtoms.ts index 9238320d5..833aca7d1 100644 --- a/frontend/src/modules/Pvt/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/Pvt/settings/atoms/derivedAtoms.ts @@ -1,5 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleRealizationFilterFunctionAtom, EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { EnsembleSetAtom, ValidEnsembleRealizationsFunctionAtom } from "@framework/GlobalAtoms"; import { atom } from "jotai"; @@ -22,18 +21,11 @@ export const selectedEnsembleIdentsAtom = atom((get) => { }); export const selectedRealizationsAtom = atom((get) => { - const ensembleSet = get(EnsembleSetAtom); const userSelectedRealizations = get(userSelectedRealizationsAtom); const selectedEnsembleIdents = get(selectedEnsembleIdentsAtom); - let ensembleRealizationFilterFunction = get(EnsembleRealizationFilterFunctionAtom); - - if (ensembleRealizationFilterFunction === null) { - ensembleRealizationFilterFunction = (ensembleIdent: EnsembleIdent) => { - return ensembleSet.findEnsemble(ensembleIdent)?.getRealizations() ?? []; - }; - } - const realizations = computeRealizationsIntersection(selectedEnsembleIdents, ensembleRealizationFilterFunction); + const validEnsembleRealizationsFunction = get(ValidEnsembleRealizationsFunctionAtom); + const realizations = computeRealizationsIntersection(selectedEnsembleIdents, validEnsembleRealizationsFunction); let computedRealizations = userSelectedRealizations.filter((el) => realizations.includes(el)); if (computedRealizations.length === 0 && realizations.length > 0) { diff --git a/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts b/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts index 1f896540a..7f12817fe 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts +++ b/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts @@ -1,7 +1,7 @@ import { Frequency_api, Observations_api } from "@api"; import { apiService } from "@framework/ApiService"; import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleSetAtom, ValidEnsembleRealizationsFunctionAtom } from "@framework/GlobalAtoms"; +import { ValidEnsembleRealizationsFunctionAtom } from "@framework/GlobalAtoms"; import { atomWithQueries } from "@framework/utils/atomUtils"; import { isEnsembleIdentOfType } from "@framework/utils/ensembleIdentUtils"; import { EnsembleVectorObservationDataMap, VisualizationMode } from "@modules/SimulationTimeSeries/typesAndEnums"; @@ -18,7 +18,6 @@ const STALE_TIME = 60 * 1000; const CACHE_TIME = 60 * 1000; export const vectorDataQueriesAtom = atomWithQueries((get) => { - const ensembleSet = get(EnsembleSetAtom); const vectorSpecifications = get(vectorSpecificationsAtom); const resampleFrequency = get(resampleFrequencyAtom); const visualizationMode = get(visualizationModeAtom); @@ -29,6 +28,7 @@ export const vectorDataQueriesAtom = atomWithQueries((get) => { visualizationMode === VisualizationMode.STATISTICS_AND_REALIZATIONS; const queries = vectorSpecifications.map((item) => { + // Regular Ensemble if (isEnsembleIdentOfType(item.ensembleIdent, EnsembleIdent)) { const realizations = [...validEnsembleRealizationsFunction(item.ensembleIdent)]; const vectorSpecification = { @@ -64,12 +64,8 @@ export const vectorDataQueriesAtom = atomWithQueries((get) => { }); } - const deltaEnsemble = ensembleSet.findEnsemble(item.ensembleIdent); - if (!deltaEnsemble) { - throw new Error(`Delta ensemble not found for: ${item.ensembleIdent.toString()}`); - } - - const realizations = [...deltaEnsemble.getRealizations()]; + // Delta Ensemble + const realizations = [...validEnsembleRealizationsFunction(item.ensembleIdent)]; const vectorSpecification = { ...item, ensembleIdent: item.ensembleIdent }; return () => ({ queryKey: [ @@ -112,7 +108,6 @@ export const vectorDataQueriesAtom = atomWithQueries((get) => { }); export const vectorStatisticsQueriesAtom = atomWithQueries((get) => { - const ensembleSet = get(EnsembleSetAtom); const vectorSpecifications = get(vectorSpecificationsAtom); const resampleFrequency = get(resampleFrequencyAtom); const visualizationMode = get(visualizationModeAtom); @@ -124,6 +119,7 @@ export const vectorStatisticsQueriesAtom = atomWithQueries((get) => { visualizationMode === VisualizationMode.STATISTICS_AND_REALIZATIONS; const queries = vectorSpecifications.map((item) => { + // Regular Ensemble if (isEnsembleIdentOfType(item.ensembleIdent, EnsembleIdent)) { const realizations = [...validEnsembleRealizationsFunction(item.ensembleIdent)]; const vectorSpecification = { @@ -159,12 +155,8 @@ export const vectorStatisticsQueriesAtom = atomWithQueries((get) => { }); } - const deltaEnsemble = ensembleSet.findEnsemble(item.ensembleIdent); - if (!deltaEnsemble) { - throw new Error(`Delta ensemble not found for: ${item.ensembleIdent.toString()}`); - } - - const realizations = [...deltaEnsemble.getRealizations()]; + // Delta Ensemble + const realizations = [...validEnsembleRealizationsFunction(item.ensembleIdent)]; const vectorSpecification = { ...item, ensembleIdent: item.ensembleIdent }; return () => ({ queryKey: [ @@ -192,6 +184,7 @@ export const vectorStatisticsQueriesAtom = atomWithQueries((get) => { gcTime: CACHE_TIME, enabled: !!( enabled && + resampleFrequency && vectorSpecification.vectorName && vectorSpecification.ensembleIdent.getFirstEnsembleIdent().getCaseUuid() && vectorSpecification.ensembleIdent.getFirstEnsembleIdent().getEnsembleName() &&