From e8570c37a74b397fa056bc70d510f9ba7bcf3319 Mon Sep 17 00:00:00 2001 From: jorgenherje Date: Mon, 2 Dec 2024 15:37:46 +0100 Subject: [PATCH] Adjust front-end after discussion with Sigurd - Remove EnsembleInterface and EnsembleIdentInterface - Rename `Ensemble` to `RegularEnsemble`and `EnsembleIdent` to `RegularEnsembleIdent` --- frontend/src/framework/DeltaEnsemble.ts | 23 ++- frontend/src/framework/DeltaEnsembleIdent.ts | 30 ++-- .../src/framework/EnsembleIdentInterface.ts | 5 - frontend/src/framework/EnsembleInterface.ts | 16 --- frontend/src/framework/EnsembleSet.ts | 77 +++++----- frontend/src/framework/EnsembleTypeSet.ts | 26 ---- frontend/src/framework/GlobalAtoms.ts | 6 +- frontend/src/framework/RealizationFilter.ts | 16 +-- .../src/framework/RealizationFilterSet.ts | 10 +- .../{Ensemble.ts => RegularEnsemble.ts} | 11 +- ...sembleIdent.ts => RegularEnsembleIdent.ts} | 28 ++-- frontend/src/framework/Workbench.ts | 14 +- frontend/src/framework/WorkbenchServices.ts | 4 +- frontend/src/framework/WorkbenchSession.ts | 6 +- .../EnsembleDropdown/ensembleDropdown.tsx | 12 +- .../EnsembleSelect/ensembleSelect.tsx | 22 +-- .../FieldDropdown/fieldDropdown.tsx | 2 +- .../framework/internal/EnsembleSetLoader.ts | 16 +-- .../internal/components/NavBar/leftNavBar.tsx | 10 +- .../realizationFilterSettings.tsx | 30 ++-- .../types/inplaceVolumetricsFilter.ts | 4 +- .../src/framework/utils/ensembleIdentUtils.ts | 11 +- .../src/framework/utils/ensembleUiHelpers.ts | 48 +++---- frontend/src/modules/3DViewer/interfaces.ts | 4 +- .../3DViewer/settings/atoms/baseAtoms.ts | 4 +- .../3DViewer/settings/atoms/derivedAtoms.ts | 6 +- .../modules/3DViewer/settings/settings.tsx | 6 +- .../modules/3DViewer/view/atoms/baseAtoms.ts | 4 +- .../view/queries/polylineIntersection.ts | 4 +- .../DbgWorkbenchSpy/implementation.tsx | 2 +- .../FlowNetwork/settings/atoms/baseAtoms.ts | 6 +- .../settings/atoms/derivedAtoms.ts | 4 +- .../modules/FlowNetwork/settings/settings.tsx | 4 +- .../settings/atoms/baseAtoms.ts | 4 +- .../settings/atoms/derivedAtoms.ts | 4 +- .../settings/atoms/queryAtoms.ts | 4 +- .../view/hooks/usePublishToDataChannels.ts | 11 +- .../view/utils/plotComponentUtils.ts | 13 +- .../settings/atoms/baseAtoms.ts | 4 +- .../settings/atoms/derivedAtoms.ts | 4 +- .../settings/atoms/queryAtoms.ts | 4 +- .../hooks/useMakeViewStatusWriterMessages.ts | 2 +- .../view/utils/tableComponentUtils.ts | 10 +- .../src/modules/Intersection/interfaces.ts | 4 +- .../Intersection/settings/atoms/baseAtoms.ts | 4 +- .../settings/atoms/derivedAtoms.ts | 12 +- .../components/layerSettings/gridLayer.tsx | 8 +- .../components/layerSettings/seismicLayer.tsx | 8 +- .../components/layerSettings/surfaceLayer.tsx | 6 +- .../surfacesUncertaintyLayer.tsx | 6 +- .../Intersection/utils/layers/GridLayer.ts | 4 +- .../Intersection/utils/layers/SeismicLayer.ts | 4 +- .../Intersection/utils/layers/SurfaceLayer.ts | 4 +- .../utils/layers/SurfacesUncertaintyLayer.ts | 4 +- .../utils/layers/WellpicksLayer.ts | 4 +- .../src/modules/Map/settings/settings.tsx | 6 +- frontend/src/modules/MyModule2/atoms.ts | 8 +- .../ParameterDistributionMatrix/interfaces.ts | 4 +- .../settings/atoms/baseAtoms.ts | 6 +- .../settings/atoms/derivedAtoms.ts | 4 +- .../settings/settings.tsx | 4 +- .../ParameterDistributionMatrix/view/view.tsx | 4 +- frontend/src/modules/Pvt/interfaces.ts | 4 +- .../modules/Pvt/settings/atoms/baseAtoms.ts | 6 +- .../Pvt/settings/atoms/derivedAtoms.ts | 4 +- .../modules/Pvt/settings/atoms/queryAtoms.ts | 4 +- .../src/modules/Pvt/settings/settings.tsx | 6 +- .../modules/Pvt/settingsToViewInterface.ts | 4 +- frontend/src/modules/Pvt/typesAndEnums.ts | 4 +- .../src/modules/Pvt/utils/PvtPlotBuilder.ts | 11 +- .../Pvt/utils/realizationsIntersection.ts | 4 +- frontend/src/modules/Pvt/view.tsx | 8 +- frontend/src/modules/Rft/settings.tsx | 4 +- .../modules/Rft/settings/atoms/baseAtoms.ts | 6 +- .../Rft/settings/atoms/derivedAtoms.ts | 4 +- .../SimulationTimeSeries/dataGenerators.ts | 6 +- .../SimulationTimeSeries/interfaces.ts | 10 +- .../settings/atoms/baseAtoms.ts | 7 +- .../settings/atoms/derivedAtoms.ts | 14 +- .../settings/atoms/queryAtoms.ts | 4 +- .../useMakeSettingsStatusWriterMessages.ts | 7 +- .../settings/settings.tsx | 4 +- .../SimulationTimeSeries/typesAndEnums.ts | 6 +- .../utils/ensemblesVectorListHelper.ts | 18 +-- .../view/atoms/derivedAtoms.ts | 4 +- .../view/atoms/queryAtoms.ts | 12 +- .../hooks/useMakeEnsembleDisplayNameFunc.ts | 10 +- .../hooks/useMakeViewStatusWriterMessages.ts | 5 +- .../view/hooks/usePublishToDataChannels.ts | 4 +- .../ensemblesContinuousParameterColoring.ts | 18 +-- .../view/utils/subplotBuilder.ts | 12 +- .../SimulationTimeSeries/view/view.tsx | 9 +- .../settings/settings.tsx | 6 +- .../typesAndEnums.ts | 4 +- .../SubsurfaceMap/settings/settings.tsx | 8 +- frontend/src/modules/SubsurfaceMap/view.tsx | 4 +- .../TornadoChart/settings/settings.tsx | 4 +- .../src/modules/TornadoChart/view/view.tsx | 8 +- .../modules/Vfp/settings/atoms/baseAtoms.ts | 6 +- .../Vfp/settings/atoms/derivedAtoms.ts | 34 ++--- .../src/modules/Vfp/settings/settings.tsx | 121 ++++++++-------- .../settings/atoms/baseAtoms.ts | 6 +- .../settings/atoms/derivedAtoms.ts | 6 +- .../WellCompletions/settings/settings.tsx | 6 +- .../_shared/InplaceVolumetrics/Table.ts | 7 +- .../TableDefinitionsAccessor.ts | 10 +- .../_shared/InplaceVolumetrics/queryHooks.ts | 10 +- .../_shared/InplaceVolumetrics/types.ts | 6 +- .../_shared/Surface/SurfaceAddressBuilder.ts | 4 +- .../inplaceVolumetricsFilterComponent.tsx | 12 +- .../src/modules/_shared/ensembleNameUtils.ts | 10 +- .../tests/unit/DeltaEnsembleIdent.test.ts | 96 +++++++++++++ frontend/tests/unit/EnsembleSet.test.ts | 136 +++++++++++++++--- frontend/tests/unit/RealizationFilter.test.ts | 6 +- .../tests/unit/RegularEnsembleIdent.test.ts | 88 ++++++++++++ 115 files changed, 873 insertions(+), 579 deletions(-) delete mode 100644 frontend/src/framework/EnsembleIdentInterface.ts delete mode 100644 frontend/src/framework/EnsembleInterface.ts delete mode 100644 frontend/src/framework/EnsembleTypeSet.ts rename frontend/src/framework/{Ensemble.ts => RegularEnsemble.ts} (89%) rename frontend/src/framework/{EnsembleIdent.ts => RegularEnsembleIdent.ts} (63%) create mode 100644 frontend/tests/unit/DeltaEnsembleIdent.test.ts create mode 100644 frontend/tests/unit/RegularEnsembleIdent.test.ts diff --git a/frontend/src/framework/DeltaEnsemble.ts b/frontend/src/framework/DeltaEnsemble.ts index 5f5b9e5e9..45b98634c 100644 --- a/frontend/src/framework/DeltaEnsemble.ts +++ b/frontend/src/framework/DeltaEnsemble.ts @@ -1,11 +1,10 @@ import { v4 } from "uuid"; import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; -import { Ensemble } from "./Ensemble"; -import { EnsembleIdent } from "./EnsembleIdent"; -import { EnsembleInterface } from "./EnsembleInterface"; import { EnsembleParameters } from "./EnsembleParameters"; import { EnsembleSensitivities } from "./EnsembleSensitivities"; +import { RegularEnsemble } from "./RegularEnsemble"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; /** * Delta ensemble class. @@ -17,10 +16,10 @@ import { EnsembleSensitivities } from "./EnsembleSensitivities"; * DeltaEnsemble = CompareEnsemble - ReferenceEnsemble * */ -export class DeltaEnsemble implements EnsembleInterface { +export class DeltaEnsemble { private _deltaEnsembleIdent: DeltaEnsembleIdent; - private _compareEnsemble: Ensemble; - private _referenceEnsemble: Ensemble; + private _compareEnsemble: RegularEnsemble; + private _referenceEnsemble: RegularEnsemble; private _color: string; private _customName: string | null; @@ -29,8 +28,8 @@ export class DeltaEnsemble implements EnsembleInterface { private _sensitivities: EnsembleSensitivities | null; constructor( - compareEnsemble: Ensemble, - referenceEnsemble: Ensemble, + compareEnsemble: RegularEnsemble, + referenceEnsemble: RegularEnsemble, color: string, customName: string | null = null ) { @@ -59,8 +58,6 @@ export class DeltaEnsemble implements EnsembleInterface { this._sensitivities = null; } - // *** Interface methods *** - getIdent(): DeltaEnsembleIdent { return this._deltaEnsembleIdent; } @@ -105,13 +102,11 @@ export class DeltaEnsemble implements EnsembleInterface { return this._sensitivities; } - // *** Custom methods *** - - getCompareEnsembleIdent(): EnsembleIdent { + getCompareEnsembleIdent(): RegularEnsembleIdent { return this._compareEnsemble.getIdent(); } - getReferenceEnsembleIdent(): EnsembleIdent { + getReferenceEnsembleIdent(): RegularEnsembleIdent { return this._referenceEnsemble.getIdent(); } diff --git a/frontend/src/framework/DeltaEnsembleIdent.ts b/frontend/src/framework/DeltaEnsembleIdent.ts index 96cbba288..afcd7de3c 100644 --- a/frontend/src/framework/DeltaEnsembleIdent.ts +++ b/frontend/src/framework/DeltaEnsembleIdent.ts @@ -1,5 +1,4 @@ -import { EnsembleIdent } from "./EnsembleIdent"; -import { EnsembleIdentInterface } from "./EnsembleIdentInterface"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; import { ensembleIdentRegexStringWithoutAnchors, ensembleIdentUuidRegexString } from "./utils/ensembleIdentUtils"; /** @@ -15,13 +14,22 @@ import { ensembleIdentRegexStringWithoutAnchors, ensembleIdentUuidRegexString } * DeltaEnsemble = CompareEnsemble - ReferenceEnsemble * */ -export class DeltaEnsembleIdent implements EnsembleIdentInterface { +export class DeltaEnsembleIdent { private _uuid: string; private _ensembleName: string; - private _compareEnsembleIdent: EnsembleIdent; - private _referenceEnsembleIdent: EnsembleIdent; + private _compareEnsembleIdent: RegularEnsembleIdent; + private _referenceEnsembleIdent: RegularEnsembleIdent; + + constructor( + uuid: string, + compareEnsembleIdent: RegularEnsembleIdent, + referenceEnsembleIdent: RegularEnsembleIdent + ) { + const uuidRegex = new RegExp(ensembleIdentUuidRegexString()); + if (!uuidRegex.exec(uuid)) { + throw new Error(`Invalid uuid: ${uuid}`); + } - constructor(uuid: string, compareEnsembleIdent: EnsembleIdent, referenceEnsembleIdent: EnsembleIdent) { this._uuid = uuid; this._ensembleName = `(${compareEnsembleIdent.getEnsembleName()}) - (${referenceEnsembleIdent.getEnsembleName()})`; this._compareEnsembleIdent = compareEnsembleIdent; @@ -69,8 +77,8 @@ export class DeltaEnsembleIdent implements EnsembleIdentInterface | null): boolean { + equals(otherIdent: any | null): boolean { if (!otherIdent || !(otherIdent instanceof DeltaEnsembleIdent)) { return false; } diff --git a/frontend/src/framework/EnsembleIdentInterface.ts b/frontend/src/framework/EnsembleIdentInterface.ts deleted file mode 100644 index 3f9c091d9..000000000 --- a/frontend/src/framework/EnsembleIdentInterface.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface EnsembleIdentInterface { - getEnsembleName(): string; - toString(): string; - equals(otherIdent: EnsembleIdentInterface | null): boolean; -} diff --git a/frontend/src/framework/EnsembleInterface.ts b/frontend/src/framework/EnsembleInterface.ts deleted file mode 100644 index e76d18426..000000000 --- a/frontend/src/framework/EnsembleInterface.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { EnsembleIdentInterface } from "./EnsembleIdentInterface"; -import { EnsembleParameters } from "./EnsembleParameters"; -import { EnsembleSensitivities } from "./EnsembleSensitivities"; - -export interface EnsembleInterface { - getIdent(): EnsembleIdentInterface; - getDisplayName(): string; - getEnsembleName(): string; - getRealizations(): readonly number[]; - getRealizationCount(): number; - getMaxRealizationNumber(): number | undefined; - getParameters(): EnsembleParameters; - getSensitivities(): EnsembleSensitivities | null; - getColor(): string; - getCustomName(): string | null; -} diff --git a/frontend/src/framework/EnsembleSet.ts b/frontend/src/framework/EnsembleSet.ts index d3707cb0f..628f23e47 100644 --- a/frontend/src/framework/EnsembleSet.ts +++ b/frontend/src/framework/EnsembleSet.ts @@ -1,24 +1,23 @@ import { DeltaEnsemble } from "./DeltaEnsemble"; import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; -import { Ensemble } from "./Ensemble"; -import { EnsembleIdent } from "./EnsembleIdent"; -import { EnsembleTypeSet } from "./EnsembleTypeSet"; +import { RegularEnsemble } from "./RegularEnsemble"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; export class EnsembleSet { - private _regularEnsembleSet: EnsembleTypeSet; - private _deltaEnsembleSet: EnsembleTypeSet; + private _regularEnsembleArray: RegularEnsemble[]; + private _deltaEnsembleArray: DeltaEnsemble[]; - constructor(ensembles: Ensemble[], deltaEnsembles: DeltaEnsemble[] = []) { - this._regularEnsembleSet = new EnsembleTypeSet(ensembles); - this._deltaEnsembleSet = new EnsembleTypeSet(deltaEnsembles); + constructor(ensembles: RegularEnsemble[], deltaEnsembles: DeltaEnsemble[] = []) { + this._regularEnsembleArray = ensembles; + this._deltaEnsembleArray = deltaEnsembles; } /** * Returns true if there are any regular ensembles in the set. * @returns True if there are any regular ensembles in the set. */ - hasAnyEnsembles(): boolean { - return this._regularEnsembleSet.hasAnyEnsembles(); + hasAnyRegularEnsembles(): boolean { + return this._regularEnsembleArray.length > 0; } /** @@ -26,23 +25,23 @@ export class EnsembleSet { * @returns True if there are any delta ensembles in the set. */ hasAnyDeltaEnsembles(): boolean { - return this._deltaEnsembleSet.hasAnyEnsembles(); + return this._deltaEnsembleArray.length > 0; } /** * Returns true if there are any regular or delta ensembles in the set. * @returns True if there are any regular or delta ensembles in the set. */ - hasAnyEnsemblesOrDeltaEnsembles(): boolean { - return this.hasAnyEnsembles() || this.hasAnyDeltaEnsembles(); + hasAnyEnsembles(): boolean { + return this.hasAnyRegularEnsembles() || this.hasAnyDeltaEnsembles(); } /** * Get an array of all regular ensembles in the set. * @returns An array of all regular ensembles in the set. */ - getEnsembleArray(): readonly Ensemble[] { - return this._regularEnsembleSet.getEnsembleArray(); + getRegularEnsembleArray(): readonly RegularEnsemble[] { + return this._regularEnsembleArray; } /** @@ -50,15 +49,15 @@ export class EnsembleSet { * @returns An array of all delta ensembles in the set. */ getDeltaEnsembleArray(): readonly DeltaEnsemble[] { - return this._deltaEnsembleSet.getEnsembleArray(); + return this._deltaEnsembleArray; } /** * Get an array of all ensembles in the set. * @returns An array of all ensembles in the set. */ - getAllEnsembleTypesArray(): readonly (Ensemble | DeltaEnsemble)[] { - return [...this._regularEnsembleSet.getEnsembleArray(), ...this._deltaEnsembleSet.getEnsembleArray()]; + getEnsembleArray(): readonly (RegularEnsemble | DeltaEnsemble)[] { + return [...this._regularEnsembleArray, ...this._deltaEnsembleArray]; } /** @@ -67,37 +66,49 @@ export class EnsembleSet { * @param ensembleIdent - The ensemble ident to check for, can be either a regular or delta ensemble ident. * @returns True if the ensemble set has the given ensemble ident. */ - hasEnsemble(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent): boolean { - if (ensembleIdent instanceof EnsembleIdent) { - return this._regularEnsembleSet.findEnsemble(ensembleIdent) !== null; + hasEnsemble(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent): boolean { + if (ensembleIdent instanceof RegularEnsembleIdent) { + return this.findEnsemble(ensembleIdent) !== null; } if (ensembleIdent instanceof DeltaEnsembleIdent) { - return this._deltaEnsembleSet.findEnsemble(ensembleIdent) !== null; + return this.findEnsemble(ensembleIdent) !== null; } return false; } - findEnsemble(ensembleIdent: EnsembleIdent): Ensemble | null; + /** + * Find an ensemble in the set by its ensemble ident. + * + * @param ensembleIdent + * @returns The ensemble if found, otherwise null. + */ + findEnsemble(ensembleIdent: RegularEnsembleIdent): RegularEnsemble | null; findEnsemble(ensembleIdent: DeltaEnsembleIdent): DeltaEnsemble | null; - findEnsemble(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent): Ensemble | DeltaEnsemble | null; - findEnsemble(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent): Ensemble | DeltaEnsemble | null { - if (ensembleIdent instanceof EnsembleIdent) { - return this._regularEnsembleSet.findEnsemble(ensembleIdent); + findEnsemble(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent): RegularEnsemble | DeltaEnsemble | null; + findEnsemble(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent): RegularEnsemble | DeltaEnsemble | null { + if (ensembleIdent instanceof RegularEnsembleIdent) { + return this._regularEnsembleArray.find((ens) => ens.getIdent().equals(ensembleIdent)) ?? null; } if (ensembleIdent instanceof DeltaEnsembleIdent) { - return this._deltaEnsembleSet.findEnsemble(ensembleIdent); + return this._deltaEnsembleArray.find((ens) => ens.getIdent().equals(ensembleIdent)) ?? null; } return null; } - findEnsembleByIdentString(ensembleIdentString: string): Ensemble | DeltaEnsemble | null { - if (EnsembleIdent.isValidEnsembleIdentString(ensembleIdentString)) { - const ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); - return this._regularEnsembleSet.findEnsemble(ensembleIdent); + /** + * Find an ensemble in the set by its ensemble ident string. + * + * @param ensembleIdentString - The ensemble ident string to search for. + * @returns The ensemble if found, otherwise null. + */ + findEnsembleByIdentString(ensembleIdentString: string): RegularEnsemble | DeltaEnsemble | null { + if (RegularEnsembleIdent.isValidEnsembleIdentString(ensembleIdentString)) { + const ensembleIdent = RegularEnsembleIdent.fromString(ensembleIdentString); + return this.findEnsemble(ensembleIdent); } if (DeltaEnsembleIdent.isValidDeltaEnsembleIdentString(ensembleIdentString)) { const deltaEnsembleIdent = DeltaEnsembleIdent.fromString(ensembleIdentString); - return this._deltaEnsembleSet.findEnsemble(deltaEnsembleIdent); + return this.findEnsemble(deltaEnsembleIdent); } return null; } diff --git a/frontend/src/framework/EnsembleTypeSet.ts b/frontend/src/framework/EnsembleTypeSet.ts deleted file mode 100644 index 606bdbabd..000000000 --- a/frontend/src/framework/EnsembleTypeSet.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { EnsembleIdentInterface } from "./EnsembleIdentInterface"; -import { EnsembleInterface } from "./EnsembleInterface"; - -export class EnsembleTypeSet, TEnsemble extends EnsembleInterface> { - private _ensembleTypeArray: TEnsemble[]; - - constructor(ensembleArray: TEnsemble[]) { - this._ensembleTypeArray = ensembleArray; - } - - hasAnyEnsembles(): boolean { - return this._ensembleTypeArray.length > 0; - } - - hasEnsemble(ensembleIdent: TEnsembleIdent): boolean { - return this.findEnsemble(ensembleIdent) !== null; - } - - findEnsemble(ensembleIdent: TEnsembleIdent): TEnsemble | null { - return this._ensembleTypeArray.find((ens) => ens.getIdent().equals(ensembleIdent)) ?? null; - } - - getEnsembleArray(): readonly TEnsemble[] { - return this._ensembleTypeArray; - } -} diff --git a/frontend/src/framework/GlobalAtoms.ts b/frontend/src/framework/GlobalAtoms.ts index 73aecc8b3..c0695ca14 100644 --- a/frontend/src/framework/GlobalAtoms.ts +++ b/frontend/src/framework/GlobalAtoms.ts @@ -4,8 +4,8 @@ import { atom } from "jotai"; import { isEqual } from "lodash"; import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; -import { EnsembleIdent } from "./EnsembleIdent"; import { RealizationFilterSet } from "./RealizationFilterSet"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; import { EnsembleRealizationFilterFunction } from "./WorkbenchSession"; import { atomWithCompare } from "./utils/atomUtils"; @@ -27,7 +27,7 @@ export const EnsembleRealizationFilterFunctionAtom = atom + return (ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) => realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent).getFilteredRealizations(); }); @@ -41,7 +41,7 @@ export const ValidEnsembleRealizationsFunctionAtom = atom((get) => { let validEnsembleRealizationsFunction = get(EnsembleRealizationFilterFunctionAtom); if (validEnsembleRealizationsFunction === null) { - validEnsembleRealizationsFunction = (ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) => { + validEnsembleRealizationsFunction = (ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) => { return ensembleSet.findEnsemble(ensembleIdent)?.getRealizations() ?? []; }; } diff --git a/frontend/src/framework/RealizationFilter.ts b/frontend/src/framework/RealizationFilter.ts index 3213d333e..cc66910bd 100644 --- a/frontend/src/framework/RealizationFilter.ts +++ b/frontend/src/framework/RealizationFilter.ts @@ -2,8 +2,6 @@ import { isEqual } from "lodash"; import { DeltaEnsemble } from "./DeltaEnsemble"; import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; -import { Ensemble } from "./Ensemble"; -import { EnsembleIdent } from "./EnsembleIdent"; import { ContinuousParameter, DiscreteParameter, @@ -12,6 +10,8 @@ import { ParameterIdent, ParameterType, } from "./EnsembleParameters"; +import { RegularEnsemble } from "./RegularEnsemble"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; import { DiscreteParameterValueSelection, IncludeExcludeFilter, @@ -30,16 +30,16 @@ import { /** * Class for filtering realizations based on realization number or parameter values. * - * The class is designed to be used in conjunction with the Ensemble class. + * The class is designed to be used in conjunction with the RegularEnsemble or DeltaEnsemble class. * * The class is designed to keep track of the filtering state and provide the filtered realizations * for an ensemble. * - * Should not provide interface to get the Ensemble object itself, but can provide access to information about the ensemble, - * such as the ensemble ident and realization numbers. + * Should not provide interface to get the RegularEnsemble/DeltaEnsemble object itself, but can provide + * access to information about the ensemble - such as the ensemble ident and realization numbers. */ export class RealizationFilter { - private _assignedEnsemble: Ensemble | DeltaEnsemble; + private _assignedEnsemble: RegularEnsemble | DeltaEnsemble; private _includeExcludeFilter: IncludeExcludeFilter; private _filterType: RealizationFilterType; @@ -54,7 +54,7 @@ export class RealizationFilter { private _filteredRealizations: readonly number[]; constructor( - assignedEnsemble: Ensemble | DeltaEnsemble, + assignedEnsemble: RegularEnsemble | DeltaEnsemble, initialIncludeExcludeFilter = IncludeExcludeFilter.INCLUDE_FILTER, initialFilterType = RealizationFilterType.BY_REALIZATION_NUMBER ) { @@ -67,7 +67,7 @@ export class RealizationFilter { this._parameterIdentStringToValueSelectionMap = null; } - getAssignedEnsembleIdent(): EnsembleIdent | DeltaEnsembleIdent { + getAssignedEnsembleIdent(): RegularEnsembleIdent | DeltaEnsembleIdent { return this._assignedEnsemble.getIdent(); } diff --git a/frontend/src/framework/RealizationFilterSet.ts b/frontend/src/framework/RealizationFilterSet.ts index 5d5f280f1..499284d67 100644 --- a/frontend/src/framework/RealizationFilterSet.ts +++ b/frontend/src/framework/RealizationFilterSet.ts @@ -1,9 +1,9 @@ import { isEqual } from "lodash"; import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; -import { EnsembleIdent } from "./EnsembleIdent"; import { EnsembleSet } from "./EnsembleSet"; import { RealizationFilter } from "./RealizationFilter"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; export class RealizationFilterSet { // Map of ensembleIdent string to RealizationFilter @@ -19,8 +19,8 @@ export class RealizationFilterSet { // Remove filters for ensembles that are no longer in the ensemble set for (const ensembleIdentString of this._ensembleIdentStringRealizationFilterMap.keys()) { let ensembleIdent = null; - if (EnsembleIdent.isValidEnsembleIdentString(ensembleIdentString)) { - ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + if (RegularEnsembleIdent.isValidEnsembleIdentString(ensembleIdentString)) { + ensembleIdent = RegularEnsembleIdent.fromString(ensembleIdentString); } else if (DeltaEnsembleIdent.isValidDeltaEnsembleIdentString(ensembleIdentString)) { ensembleIdent = DeltaEnsembleIdent.fromString(ensembleIdentString); } @@ -34,7 +34,7 @@ export class RealizationFilterSet { } // Add filters for ensembles that are new to the ensemble set - for (const ensemble of ensembleSet.getAllEnsembleTypesArray()) { + for (const ensemble of ensembleSet.getEnsembleArray()) { const ensembleIdentString = ensemble.getIdent().toString(); const isEnsembleInMap = this._ensembleIdentStringRealizationFilterMap.has(ensembleIdentString); if (!isEnsembleInMap) { @@ -46,7 +46,7 @@ export class RealizationFilterSet { /** * Get filter for ensembleIdent */ - getRealizationFilterForEnsembleIdent(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent): RealizationFilter { + getRealizationFilterForEnsembleIdent(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent): RealizationFilter { const filter = this._ensembleIdentStringRealizationFilterMap.get(ensembleIdent.toString()); if (filter === undefined) { throw new Error( diff --git a/frontend/src/framework/Ensemble.ts b/frontend/src/framework/RegularEnsemble.ts similarity index 89% rename from frontend/src/framework/Ensemble.ts rename to frontend/src/framework/RegularEnsemble.ts index 4e1feca3f..4217885a1 100644 --- a/frontend/src/framework/Ensemble.ts +++ b/frontend/src/framework/RegularEnsemble.ts @@ -1,10 +1,9 @@ -import { EnsembleIdent } from "./EnsembleIdent"; -import { EnsembleInterface } from "./EnsembleInterface"; import { EnsembleParameters, Parameter } from "./EnsembleParameters"; import { EnsembleSensitivities, Sensitivity } from "./EnsembleSensitivities"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; -export class Ensemble implements EnsembleInterface { - private _ensembleIdent: EnsembleIdent; +export class RegularEnsemble { + private _ensembleIdent: RegularEnsembleIdent; private _fieldIdentifier: string; private _caseName: string; private _realizationsArray: number[]; @@ -24,7 +23,7 @@ export class Ensemble implements EnsembleInterface { color: string, customName: string | null = null ) { - this._ensembleIdent = new EnsembleIdent(caseUuid, ensembleName); + this._ensembleIdent = new RegularEnsembleIdent(caseUuid, ensembleName); this._fieldIdentifier = fieldIdentifier; this._caseName = caseName; this._realizationsArray = Array.from(realizationsArray).sort((a, b) => a - b); @@ -38,7 +37,7 @@ export class Ensemble implements EnsembleInterface { } } - getIdent(): EnsembleIdent { + getIdent(): RegularEnsembleIdent { return this._ensembleIdent; } diff --git a/frontend/src/framework/EnsembleIdent.ts b/frontend/src/framework/RegularEnsembleIdent.ts similarity index 63% rename from frontend/src/framework/EnsembleIdent.ts rename to frontend/src/framework/RegularEnsembleIdent.ts index cfbc6694f..108da3b94 100644 --- a/frontend/src/framework/EnsembleIdent.ts +++ b/frontend/src/framework/RegularEnsembleIdent.ts @@ -1,17 +1,21 @@ -import { EnsembleIdentInterface } from "./EnsembleIdentInterface"; -import { ensembleIdentRegexStringWithoutAnchors } from "./utils/ensembleIdentUtils"; +import { ensembleIdentRegexStringWithoutAnchors, ensembleIdentUuidRegexString } from "./utils/ensembleIdentUtils"; -export class EnsembleIdent implements EnsembleIdentInterface { +export class RegularEnsembleIdent { private _caseUuid: string; private _ensembleName: string; constructor(caseUuid: string, ensembleName: string) { + const uuidRegex = new RegExp(ensembleIdentUuidRegexString()); + if (!uuidRegex.exec(caseUuid)) { + throw new Error(`Invalid caseUuid: ${caseUuid}`); + } + this._caseUuid = caseUuid; this._ensembleName = ensembleName; } - static fromCaseUuidAndEnsembleName(caseUuid: string, ensembleName: string): EnsembleIdent { - return new EnsembleIdent(caseUuid, ensembleName); + static fromCaseUuidAndEnsembleName(caseUuid: string, ensembleName: string): RegularEnsembleIdent { + return new RegularEnsembleIdent(caseUuid, ensembleName); } static caseUuidAndEnsembleNameToString(caseUuid: string, ensembleName: string): string { @@ -19,13 +23,13 @@ export class EnsembleIdent implements EnsembleIdentInterface { } static isValidEnsembleIdentString(ensembleIdentString: string): boolean { - const regex = EnsembleIdent.getEnsembleIdentRegex(); + const regex = RegularEnsembleIdent.getEnsembleIdentRegex(); const result = regex.exec(ensembleIdentString); return !!result && !!result.groups && !!result.groups.caseUuid && !!result.groups.ensembleName; } - static fromString(ensembleIdentString: string): EnsembleIdent { - const regex = EnsembleIdent.getEnsembleIdentRegex(); + static fromString(ensembleIdentString: string): RegularEnsembleIdent { + const regex = RegularEnsembleIdent.getEnsembleIdentRegex(); const result = regex.exec(ensembleIdentString); if (!result || !result.groups || !result.groups.caseUuid || !result.groups.ensembleName) { throw new Error(`Invalid ensemble ident: ${ensembleIdentString}`); @@ -33,7 +37,7 @@ export class EnsembleIdent implements EnsembleIdentInterface { const { caseUuid, ensembleName } = result.groups; - return new EnsembleIdent(caseUuid, ensembleName); + return new RegularEnsembleIdent(caseUuid, ensembleName); } /** @@ -54,11 +58,11 @@ export class EnsembleIdent implements EnsembleIdentInterface { } toString(): string { - return EnsembleIdent.caseUuidAndEnsembleNameToString(this._caseUuid, this._ensembleName); + return RegularEnsembleIdent.caseUuidAndEnsembleNameToString(this._caseUuid, this._ensembleName); } - equals(otherIdent: EnsembleIdentInterface | null): boolean { - if (!otherIdent || !(otherIdent instanceof EnsembleIdent)) { + equals(otherIdent: any | null): boolean { + if (!otherIdent || !(otherIdent instanceof RegularEnsembleIdent)) { return false; } if (otherIdent === this) { diff --git a/frontend/src/framework/Workbench.ts b/frontend/src/framework/Workbench.ts index 9cdcde80b..4fde0f256 100644 --- a/frontend/src/framework/Workbench.ts +++ b/frontend/src/framework/Workbench.ts @@ -1,12 +1,12 @@ import { QueryClient } from "@tanstack/react-query"; import { AtomStoreMaster } from "./AtomStoreMaster"; -import { EnsembleIdent } from "./EnsembleIdent"; import { GuiMessageBroker, GuiState } from "./GuiMessageBroker"; import { InitialSettings } from "./InitialSettings"; import { ImportState } from "./Module"; import { ModuleInstance } from "./ModuleInstance"; import { ModuleRegistry } from "./ModuleRegistry"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; import { Template } from "./TemplateRegistry"; import { WorkbenchServices } from "./WorkbenchServices"; import { loadMetadataFromBackendAndCreateEnsembleSet } from "./internal/EnsembleSetLoader"; @@ -28,14 +28,14 @@ export type LayoutElement = { }; export type UserEnsembleSetting = { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; customName: string | null; color: string; }; export type UserDeltaEnsembleSetting = { - compareEnsembleIdent: EnsembleIdent; - referenceEnsembleIdent: EnsembleIdent; + compareEnsembleIdent: RegularEnsembleIdent; + referenceEnsembleIdent: RegularEnsembleIdent; customName: string | null; color: string; }; @@ -285,7 +285,7 @@ export class Workbench { const ensembleIdents = JSON.parse(ensembleSettingsString) as StoredUserEnsembleSetting[]; const ensembleIdentsParsed: UserEnsembleSetting[] = ensembleIdents.map((el) => ({ ...el, - ensembleIdent: EnsembleIdent.fromString(el.ensembleIdent), + ensembleIdent: RegularEnsembleIdent.fromString(el.ensembleIdent), })); return ensembleIdentsParsed; @@ -298,8 +298,8 @@ export class Workbench { const deltaEnsembleIdents = JSON.parse(deltaEnsembleSettingsString) as StoredUserDeltaEnsembleSetting[]; const deltaEnsembleIdentsParsed: UserDeltaEnsembleSetting[] = deltaEnsembleIdents.map((el) => ({ ...el, - compareEnsembleIdent: EnsembleIdent.fromString(el.compareEnsembleIdent), - referenceEnsembleIdent: EnsembleIdent.fromString(el.referenceEnsembleIdent), + compareEnsembleIdent: RegularEnsembleIdent.fromString(el.compareEnsembleIdent), + referenceEnsembleIdent: RegularEnsembleIdent.fromString(el.referenceEnsembleIdent), })); return deltaEnsembleIdentsParsed; diff --git a/frontend/src/framework/WorkbenchServices.ts b/frontend/src/framework/WorkbenchServices.ts index d8055623b..89f4c9c93 100644 --- a/frontend/src/framework/WorkbenchServices.ts +++ b/frontend/src/framework/WorkbenchServices.ts @@ -2,7 +2,7 @@ import React from "react"; import { isEqual } from "lodash"; -import { EnsembleIdent } from "./EnsembleIdent"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; import { Workbench } from "./Workbench"; import { InplaceVolumetricsFilter } from "./types/inplaceVolumetricsFilter"; import { Intersection } from "./types/intersection"; @@ -22,7 +22,7 @@ export type GlobalTopicDefinitions = { "global.hoverRegion": { regionName: string } | null; "global.hoverFacies": { faciesName: string } | null; - "global.syncValue.ensembles": EnsembleIdent[]; + "global.syncValue.ensembles": RegularEnsembleIdent[]; "global.syncValue.date": { timeOrInterval: string }; "global.syncValue.timeSeries": { vectorName: string }; "global.syncValue.surface": { name: string; attribute: string }; diff --git a/frontend/src/framework/WorkbenchSession.ts b/frontend/src/framework/WorkbenchSession.ts index f886b3bf4..181325c24 100644 --- a/frontend/src/framework/WorkbenchSession.ts +++ b/frontend/src/framework/WorkbenchSession.ts @@ -2,13 +2,13 @@ import React from "react"; import { AtomStoreMaster } from "./AtomStoreMaster"; import { DeltaEnsembleIdent } from "./DeltaEnsembleIdent"; -import { EnsembleIdent } from "./EnsembleIdent"; import { EnsembleSet } from "./EnsembleSet"; import { RealizationFilterSet } from "./RealizationFilterSet"; +import { RegularEnsembleIdent } from "./RegularEnsembleIdent"; import { UserCreatedItems } from "./UserCreatedItems"; export type EnsembleRealizationFilterFunction = ( - ensembleIdent: EnsembleIdent | DeltaEnsembleIdent + ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent ) => readonly number[]; export enum WorkbenchSessionEvent { @@ -81,7 +81,7 @@ export class WorkbenchSession { function createEnsembleRealizationFilterFuncForWorkbenchSession(workbenchSession: WorkbenchSession) { return function ensembleRealizationFilterFunc( - ensembleIdent: EnsembleIdent | DeltaEnsembleIdent + ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent ): readonly number[] { const realizationFilterSet = workbenchSession.getRealizationFilterSet(); const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); diff --git a/frontend/src/framework/components/EnsembleDropdown/ensembleDropdown.tsx b/frontend/src/framework/components/EnsembleDropdown/ensembleDropdown.tsx index 9033077d4..e8cdfa469 100644 --- a/frontend/src/framework/components/EnsembleDropdown/ensembleDropdown.tsx +++ b/frontend/src/framework/components/EnsembleDropdown/ensembleDropdown.tsx @@ -1,7 +1,7 @@ import { DeltaEnsemble } from "@framework/DeltaEnsemble"; import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { ColorTile } from "@lib/components/ColorTile"; import { Dropdown, DropdownOption, DropdownProps } from "@lib/components/Dropdown"; @@ -9,16 +9,16 @@ import { Dropdown, DropdownOption, DropdownProps } from "@lib/components/Dropdow export type EnsembleDropdownWithDeltaEnsemblesProps = { ensembleSet: EnsembleSet; allowDeltaEnsembles: true; - value: EnsembleIdent | DeltaEnsembleIdent | null; - onChange: (ensembleIdent: EnsembleIdent | DeltaEnsembleIdent | null) => void; + value: RegularEnsembleIdent | DeltaEnsembleIdent | null; + onChange: (ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent | null) => void; } & Omit, "options" | "value" | "onChange">; // Overload for EnsembleDropdown without DeltaEnsembleIdent export type EnsembleDropdownWithoutDeltaEnsemblesProps = { ensembleSet: EnsembleSet; allowDeltaEnsembles?: false | undefined; - value: EnsembleIdent | null; - onChange: (ensembleIdent: EnsembleIdent | null) => void; + value: RegularEnsembleIdent | null; + onChange: (ensembleIdent: RegularEnsembleIdent | null) => void; } & Omit, "options" | "value" | "onChange">; export function EnsembleDropdown(props: EnsembleDropdownWithDeltaEnsemblesProps): JSX.Element; @@ -46,7 +46,7 @@ export function EnsembleDropdown( } const optionsArray: DropdownOption[] = []; - const ensembleArray = allowDeltaEnsembles ? ensembleSet.getAllEnsembleTypesArray() : ensembleSet.getEnsembleArray(); + const ensembleArray = allowDeltaEnsembles ? ensembleSet.getEnsembleArray() : ensembleSet.getRegularEnsembleArray(); for (const ens of ensembleArray) { optionsArray.push({ value: ens.getIdent().toString(), diff --git a/frontend/src/framework/components/EnsembleSelect/ensembleSelect.tsx b/frontend/src/framework/components/EnsembleSelect/ensembleSelect.tsx index 3b7ec44aa..aab2e1dc3 100644 --- a/frontend/src/framework/components/EnsembleSelect/ensembleSelect.tsx +++ b/frontend/src/framework/components/EnsembleSelect/ensembleSelect.tsx @@ -1,7 +1,7 @@ import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { Ensemble } from "@framework/Ensemble"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { ColorTile } from "@lib/components/ColorTile"; import { Select, SelectOption, SelectProps } from "@lib/components/Select"; @@ -10,8 +10,8 @@ export type EnsembleSelectWithDeltaEnsemblesProps = { ensembleSet: EnsembleSet; multiple?: boolean; allowDeltaEnsembles: true; - value: (EnsembleIdent | DeltaEnsembleIdent)[]; - onChange: (ensembleIdentArray: (EnsembleIdent | DeltaEnsembleIdent)[]) => void; + value: (RegularEnsembleIdent | DeltaEnsembleIdent)[]; + onChange: (ensembleIdentArray: (RegularEnsembleIdent | DeltaEnsembleIdent)[]) => void; } & Omit, "options" | "value" | "onChange">; // Overload for EnsembleSelect without DeltaEnsembleIdent @@ -19,8 +19,8 @@ export type EnsembleSelectWithoutDeltaEnsemblesProps = { ensembleSet: EnsembleSet; multiple?: boolean; allowDeltaEnsembles?: false | undefined; - value: EnsembleIdent[]; - onChange: (ensembleIdentArray: EnsembleIdent[]) => void; + value: RegularEnsembleIdent[]; + onChange: (ensembleIdentArray: RegularEnsembleIdent[]) => void; } & Omit, "options" | "value" | "onChange">; export function EnsembleSelect(props: EnsembleSelectWithDeltaEnsemblesProps): JSX.Element; @@ -31,17 +31,19 @@ export function EnsembleSelect( const { ensembleSet, value, allowDeltaEnsembles, onChange, multiple, ...rest } = props; function handleSelectionChanged(selectedEnsembleIdentStrArray: string[]) { - const identArray: (EnsembleIdent | DeltaEnsembleIdent)[] = []; + const identArray: (RegularEnsembleIdent | DeltaEnsembleIdent)[] = []; for (const identStr of selectedEnsembleIdentStrArray) { const foundEnsemble = ensembleSet.findEnsembleByIdentString(identStr); - if (foundEnsemble !== null && (allowDeltaEnsembles || foundEnsemble instanceof Ensemble)) { + if (foundEnsemble !== null && (allowDeltaEnsembles || foundEnsemble instanceof RegularEnsemble)) { identArray.push(foundEnsemble.getIdent()); } } // Filter to match the correct return type before calling onChange if (!allowDeltaEnsembles) { - const validIdentArray = identArray.filter((ident) => ident instanceof EnsembleIdent) as EnsembleIdent[]; + const validIdentArray = identArray.filter( + (ident) => ident instanceof RegularEnsembleIdent + ) as RegularEnsembleIdent[]; onChange(validIdentArray); return; } @@ -49,7 +51,7 @@ export function EnsembleSelect( } const optionsArray: SelectOption[] = []; - const ensembleArray = allowDeltaEnsembles ? ensembleSet.getAllEnsembleTypesArray() : ensembleSet.getEnsembleArray(); + const ensembleArray = allowDeltaEnsembles ? ensembleSet.getEnsembleArray() : ensembleSet.getRegularEnsembleArray(); for (const ens of ensembleArray) { optionsArray.push({ value: ens.getIdent().toString(), diff --git a/frontend/src/framework/components/FieldDropdown/fieldDropdown.tsx b/frontend/src/framework/components/FieldDropdown/fieldDropdown.tsx index 1144b1244..aed8241ad 100644 --- a/frontend/src/framework/components/FieldDropdown/fieldDropdown.tsx +++ b/frontend/src/framework/components/FieldDropdown/fieldDropdown.tsx @@ -15,7 +15,7 @@ export function FieldDropdown(props: FieldDropdownProps): JSX.Element { } const optionsArray: DropdownOption[] = []; - for (const ens of ensembleSet.getEnsembleArray()) { + for (const ens of ensembleSet.getRegularEnsembleArray()) { const fieldIdentifier = ens.getFieldIdentifier(); if (optionsArray.some((option) => option.value === fieldIdentifier.toString())) { continue; diff --git a/frontend/src/framework/internal/EnsembleSetLoader.ts b/frontend/src/framework/internal/EnsembleSetLoader.ts index 0c3dee549..355260817 100644 --- a/frontend/src/framework/internal/EnsembleSetLoader.ts +++ b/frontend/src/framework/internal/EnsembleSetLoader.ts @@ -4,11 +4,11 @@ import { DeltaEnsemble } from "@framework/DeltaEnsemble"; import { UserDeltaEnsembleSetting, UserEnsembleSetting } from "@framework/Workbench"; import { QueryClient } from "@tanstack/react-query"; -import { Ensemble } from "../Ensemble"; -import { EnsembleIdent } from "../EnsembleIdent"; import { ContinuousParameter, DiscreteParameter, Parameter, ParameterType } from "../EnsembleParameters"; import { Sensitivity, SensitivityCase } from "../EnsembleSensitivities"; import { EnsembleSet } from "../EnsembleSet"; +import { RegularEnsemble } from "../RegularEnsemble"; +import { RegularEnsembleIdent } from "../RegularEnsembleIdent"; type EnsembleApiData = { ensembleDetails: EnsembleDetails_api; @@ -25,7 +25,7 @@ export async function loadMetadataFromBackendAndCreateEnsembleSet( userDeltaEnsembleSettings: UserDeltaEnsembleSetting[] ): Promise { // Get ensemble idents to load - const ensembleIdentsToLoad: EnsembleIdent[] = userEnsembleSettings.map((setting) => setting.ensembleIdent); + const ensembleIdentsToLoad: RegularEnsembleIdent[] = userEnsembleSettings.map((setting) => setting.ensembleIdent); for (const deltaEnsembleSetting of userDeltaEnsembleSettings) { if (!ensembleIdentsToLoad.includes(deltaEnsembleSetting.compareEnsembleIdent)) { ensembleIdentsToLoad.push(deltaEnsembleSetting.compareEnsembleIdent); @@ -42,7 +42,7 @@ export async function loadMetadataFromBackendAndCreateEnsembleSet( ); // Create regular ensembles - const outEnsembleArray: Ensemble[] = []; + const outEnsembleArray: RegularEnsemble[] = []; for (const ensembleSetting of userEnsembleSettings) { const ensembleIdentString = ensembleSetting.ensembleIdent.toString(); const ensembleApiData = ensembleIdentStringToApiDataMap[ensembleIdentString]; @@ -54,7 +54,7 @@ export async function loadMetadataFromBackendAndCreateEnsembleSet( const parameterArray = buildParameterArrFromApiResponse(ensembleApiData.parameters); const sensitivityArray = buildSensitivityArrFromApiResponse(ensembleApiData.sensitivities); outEnsembleArray.push( - new Ensemble( + new RegularEnsemble( ensembleApiData.ensembleDetails.field_identifier, ensembleApiData.ensembleDetails.case_uuid, ensembleApiData.ensembleDetails.case_name, @@ -95,7 +95,7 @@ export async function loadMetadataFromBackendAndCreateEnsembleSet( userEnsembleSettings.find((elm) => elm.ensembleIdent.toString() === referenceEnsembleIdentString) ?.customName ?? null; - const compareEnsemble = new Ensemble( + const compareEnsemble = new RegularEnsemble( compareEnsembleApiData.ensembleDetails.field_identifier, compareEnsembleApiData.ensembleDetails.case_uuid, compareEnsembleApiData.ensembleDetails.case_name, @@ -107,7 +107,7 @@ export async function loadMetadataFromBackendAndCreateEnsembleSet( compareEnsembleCustomName ); - const referenceEnsemble = new Ensemble( + const referenceEnsemble = new RegularEnsemble( referenceEnsembleApiData.ensembleDetails.field_identifier, referenceEnsembleApiData.ensembleDetails.case_uuid, referenceEnsembleApiData.ensembleDetails.case_name, @@ -134,7 +134,7 @@ export async function loadMetadataFromBackendAndCreateEnsembleSet( async function loadEnsembleIdentStringToApiDataMapFromBackend( queryClient: QueryClient, - ensembleIdents: EnsembleIdent[] + ensembleIdents: RegularEnsembleIdent[] ): Promise { console.debug("loadEnsembleIdentStringToApiDataMapFromBackend", ensembleIdents); diff --git a/frontend/src/framework/internal/components/NavBar/leftNavBar.tsx b/frontend/src/framework/internal/components/NavBar/leftNavBar.tsx index 363181415..3b1e6e4ed 100644 --- a/frontend/src/framework/internal/components/NavBar/leftNavBar.tsx +++ b/frontend/src/framework/internal/components/NavBar/leftNavBar.tsx @@ -1,8 +1,8 @@ import React from "react"; import WebvizLogo from "@assets/webviz.svg"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { GuiState, LeftDrawerContent, useGuiState, useGuiValue } from "@framework/GuiMessageBroker"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { UserDeltaEnsembleSetting, UserEnsembleSetting, Workbench, WorkbenchEvents } from "@framework/Workbench"; import { useEnsembleSet, useIsEnsembleSetLoading } from "@framework/WorkbenchSession"; import { LoginButton } from "@framework/internal/components/LoginButton"; @@ -129,16 +129,16 @@ export const LeftNavBar: React.FC = (props) => { setNewSelectedEnsembles(ensembleItems); setNewCreatedDeltaEnsembles(createdDeltaEnsembles); const ensembleSettings: UserEnsembleSetting[] = ensembleItems.map((ens) => ({ - ensembleIdent: new EnsembleIdent(ens.caseUuid, ens.ensembleName), + ensembleIdent: new RegularEnsembleIdent(ens.caseUuid, ens.ensembleName), customName: ens.customName, color: ens.color, })); const deltaEnsembleSettings: UserDeltaEnsembleSetting[] = createdDeltaEnsembles.map((deltaEns) => ({ - compareEnsembleIdent: new EnsembleIdent( + compareEnsembleIdent: new RegularEnsembleIdent( deltaEns.compareEnsemble.caseUuid, deltaEns.compareEnsemble.ensembleName ), - referenceEnsembleIdent: new EnsembleIdent( + referenceEnsembleIdent: new RegularEnsembleIdent( deltaEns.referenceEnsemble.caseUuid, deltaEns.referenceEnsemble.ensembleName ), @@ -148,7 +148,7 @@ export const LeftNavBar: React.FC = (props) => { return props.workbench.loadAndSetupEnsembleSetInSession(queryClient, ensembleSettings, deltaEnsembleSettings); } - const selectedEnsembles: EnsembleItem[] = ensembleSet.getEnsembleArray().map((ens) => ({ + const selectedEnsembles: EnsembleItem[] = ensembleSet.getRegularEnsembleArray().map((ens) => ({ caseUuid: ens.getCaseUuid(), caseName: ens.getCaseName(), ensembleName: ens.getEnsembleName(), 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 b1be941fd..8c97bcb3d 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,7 +1,6 @@ import React from "react"; import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { GuiEvent, GuiEventPayloads, @@ -10,6 +9,7 @@ import { useGuiState, useGuiValue, } from "@framework/GuiMessageBroker"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { Workbench } from "@framework/Workbench"; import { useEnsembleSet } from "@framework/WorkbenchSession"; import { Drawer } from "@framework/internal/components/Drawer"; @@ -38,7 +38,7 @@ export const RealizationFilterSettings: React.FC ); const [activeFilterEnsembleIdent, setActiveFilterEnsembleIdent] = React.useState< - EnsembleIdent | DeltaEnsembleIdent | null + RegularEnsembleIdent | DeltaEnsembleIdent | null >(null); // Maps for keeping track of unsaved changes and filter selections @@ -58,9 +58,7 @@ export const RealizationFilterSettings: React.FC } // Create new maps if ensembles are added or removed - const ensembleIdentStrings = ensembleSet - .getAllEnsembleTypesArray() - .map((ensemble) => ensemble.getIdent().toString()); + const ensembleIdentStrings = ensembleSet.getEnsembleArray().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 } = { @@ -210,7 +208,7 @@ export const RealizationFilterSettings: React.FC props.onClose(); } - function handleApplyClick(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { + function handleApplyClick(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) { const ensembleIdentString = ensembleIdent.toString(); const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); const selections = ensembleIdentStringToRealizationFilterSelectionsMap[ensembleIdentString]; @@ -235,7 +233,7 @@ export const RealizationFilterSettings: React.FC props.workbench.getWorkbenchSession().notifyAboutEnsembleRealizationFilterChange(); } - function handleDiscardClick(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { + function handleDiscardClick(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) { const ensembleIdentString = ensembleIdent.toString(); const realizationFilter = realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent); setEnsembleIdentStringToRealizationFilterSelectionsMap({ @@ -257,7 +255,7 @@ export const RealizationFilterSettings: React.FC } function handleFilterChange( - ensembleIdent: EnsembleIdent | DeltaEnsembleIdent, + ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent, selections: EnsembleRealizationFilterSelections ) { const ensembleIdentString = ensembleIdent.toString(); @@ -288,11 +286,11 @@ export const RealizationFilterSettings: React.FC setNumberOfUnsavedRealizationFilters(countTrueValues(newHasUnsavedChangesMap)); } - function handleSetActiveEnsembleRealizationFilter(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { + function handleSetActiveEnsembleRealizationFilter(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) { setActiveFilterEnsembleIdent(ensembleIdent); } - function handleOnEnsembleRealizationFilterHeaderClick(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { + function handleOnEnsembleRealizationFilterHeaderClick(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) { if (activeFilterEnsembleIdent?.equals(ensembleIdent)) { setActiveFilterEnsembleIdent(null); } @@ -308,7 +306,7 @@ export const RealizationFilterSettings: React.FC >
- {ensembleSet.getAllEnsembleTypesArray().map((ensemble) => { + {ensembleSet.getEnsembleArray().map((ensemble) => { const ensembleIdent = ensemble.getIdent(); const isActive = activeFilterEnsembleIdent !== null && activeFilterEnsembleIdent.equals(ensembleIdent); @@ -350,12 +348,14 @@ export const RealizationFilterSettings: React.FC /** * Get ensemble ident from string * @param ensembleIdentString - * @returns EnsembleIdent | DeltaEnsembleIdent | null + * @returns RegularEnsembleIdent | DeltaEnsembleIdent | null */ -export function getEnsembleIdentFromString(ensembleIdentString: string): EnsembleIdent | DeltaEnsembleIdent | null { +export function getEnsembleIdentFromString( + ensembleIdentString: string +): RegularEnsembleIdent | DeltaEnsembleIdent | null { let ensembleIdent = null; - if (EnsembleIdent.isValidEnsembleIdentString(ensembleIdentString)) { - ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + if (RegularEnsembleIdent.isValidEnsembleIdentString(ensembleIdentString)) { + ensembleIdent = RegularEnsembleIdent.fromString(ensembleIdentString); } else if (DeltaEnsembleIdent.isValidDeltaEnsembleIdentString(ensembleIdentString)) { ensembleIdent = DeltaEnsembleIdent.fromString(ensembleIdentString); } diff --git a/frontend/src/framework/types/inplaceVolumetricsFilter.ts b/frontend/src/framework/types/inplaceVolumetricsFilter.ts index bcb18b1f7..7a5c462c8 100644 --- a/frontend/src/framework/types/inplaceVolumetricsFilter.ts +++ b/frontend/src/framework/types/inplaceVolumetricsFilter.ts @@ -1,8 +1,8 @@ import { FluidZone_api, InplaceVolumetricsIdentifierWithValues_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; export type InplaceVolumetricsFilter = { - ensembleIdents: EnsembleIdent[]; + ensembleIdents: RegularEnsembleIdent[]; tableNames: string[]; fluidZones: FluidZone_api[]; identifiersValues: InplaceVolumetricsIdentifierWithValues_api[]; diff --git a/frontend/src/framework/utils/ensembleIdentUtils.ts b/frontend/src/framework/utils/ensembleIdentUtils.ts index 4dc3972a1..25bd7bfc5 100644 --- a/frontend/src/framework/utils/ensembleIdentUtils.ts +++ b/frontend/src/framework/utils/ensembleIdentUtils.ts @@ -1,10 +1,11 @@ -import { EnsembleIdentInterface } from "@framework/EnsembleIdentInterface"; +import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; /** * Check if provided EnsembleIdentInterface implementation is of specified type */ -export function isEnsembleIdentOfType>( - ensembleIdent: EnsembleIdentInterface, +export function isEnsembleIdentOfType( + ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent, type: new (...args: any[]) => T ): ensembleIdent is T { return ensembleIdent instanceof type; @@ -19,8 +20,8 @@ export function isEnsembleIdentOfType>( * @param type - The type of the ensemble idents to filter * @returns A new array of ensemble idents that are of the specified type */ -export function filterEnsembleIdentsByType>( - ensembleIdents: EnsembleIdentInterface[], +export function filterEnsembleIdentsByType( + ensembleIdents: (RegularEnsembleIdent | DeltaEnsembleIdent)[], type: new (...args: any[]) => T ): T[] { return ensembleIdents.filter((ensembleIdent) => isEnsembleIdentOfType(ensembleIdent, type)) as T[]; diff --git a/frontend/src/framework/utils/ensembleUiHelpers.ts b/frontend/src/framework/utils/ensembleUiHelpers.ts index 5c7797dbf..be17482fd 100644 --- a/frontend/src/framework/utils/ensembleUiHelpers.ts +++ b/frontend/src/framework/utils/ensembleUiHelpers.ts @@ -1,11 +1,11 @@ import { DeltaEnsembleIdent } from "../DeltaEnsembleIdent"; -import { EnsembleIdent } from "../EnsembleIdent"; import { EnsembleSet } from "../EnsembleSet"; +import { RegularEnsembleIdent } from "../RegularEnsembleIdent"; export function maybeAssignFirstSyncedEnsemble( - currIdent: EnsembleIdent | null, - syncedEnsembleValues: EnsembleIdent[] | null -): EnsembleIdent | null { + currIdent: RegularEnsembleIdent | null, + syncedEnsembleValues: RegularEnsembleIdent[] | null +): RegularEnsembleIdent | null { if (!syncedEnsembleValues || syncedEnsembleValues.length < 1) { return currIdent; } @@ -19,32 +19,32 @@ export function maybeAssignFirstSyncedEnsemble( } /** - * Validates the the EnsembleIdent or DeltaEnsembleIdent specified in currIdent against the + * Validates the the RegularEnsembleIdent or DeltaEnsembleIdent specified in currIdent against the * contents of the EnsembleSet and fixes the value if it isn't valid. * * Returns null if an empty EnsembleSet is specified. * - * Note that if the specified EnsembleIdents and DeltaEnsembleIdents are valid, this function + * Note that if the specified RegularEnsembleIdents and DeltaEnsembleIdents are valid, this function * will always return a reference to the exact same object that was passed in currIdent. This * means that you can compare the references (fixedIdent !== currIdent) to detect any changes. */ export function fixupEnsembleIdent( - currIdent: EnsembleIdent | null, + currIdent: RegularEnsembleIdent | null, ensembleSet: EnsembleSet | null -): EnsembleIdent | null; +): RegularEnsembleIdent | null; export function fixupEnsembleIdent( currIdent: DeltaEnsembleIdent | null, ensembleSet: EnsembleSet | null ): DeltaEnsembleIdent | null; export function fixupEnsembleIdent( - currIdent: EnsembleIdent | DeltaEnsembleIdent | null, + currIdent: RegularEnsembleIdent | DeltaEnsembleIdent | null, ensembleSet: EnsembleSet | null -): (EnsembleIdent | DeltaEnsembleIdent) | null; +): (RegularEnsembleIdent | DeltaEnsembleIdent) | null; export function fixupEnsembleIdent( - currIdent: EnsembleIdent | DeltaEnsembleIdent | null, + currIdent: RegularEnsembleIdent | DeltaEnsembleIdent | null, ensembleSet: EnsembleSet | null -): (EnsembleIdent | DeltaEnsembleIdent) | null { - if (!ensembleSet?.hasAnyEnsemblesOrDeltaEnsembles()) { +): (RegularEnsembleIdent | DeltaEnsembleIdent) | null { + if (!ensembleSet?.hasAnyEnsembles()) { return null; } @@ -53,11 +53,11 @@ export function fixupEnsembleIdent( } // If requesting delta ensemble, or no regular ensembles are available - if (currIdent instanceof DeltaEnsembleIdent || !ensembleSet.hasAnyEnsembles()) { + if (currIdent instanceof DeltaEnsembleIdent || !ensembleSet.hasAnyRegularEnsembles()) { return ensembleSet.getDeltaEnsembleArray()[0].getIdent(); } - return ensembleSet.getEnsembleArray()[0].getIdent(); + return ensembleSet.getRegularEnsembleArray()[0].getIdent(); } /** @@ -71,29 +71,29 @@ export function fixupEnsembleIdent( * means that you can compare the references (fixedIdent !== currIdent) to detect any changes. */ export function fixupEnsembleIdents( - currIdents: EnsembleIdent[] | null, + currIdents: RegularEnsembleIdent[] | null, ensembleSet: EnsembleSet | null -): EnsembleIdent[] | null; +): RegularEnsembleIdent[] | null; export function fixupEnsembleIdents( currIdents: DeltaEnsembleIdent[] | null, ensembleSet: EnsembleSet | null ): DeltaEnsembleIdent[] | null; export function fixupEnsembleIdents( - currIdents: (EnsembleIdent | DeltaEnsembleIdent)[] | null, + currIdents: (RegularEnsembleIdent | DeltaEnsembleIdent)[] | null, ensembleSet: EnsembleSet | null -): (EnsembleIdent | DeltaEnsembleIdent)[] | null; +): (RegularEnsembleIdent | DeltaEnsembleIdent)[] | null; export function fixupEnsembleIdents( - currIdents: (EnsembleIdent | DeltaEnsembleIdent)[] | null, + currIdents: (RegularEnsembleIdent | DeltaEnsembleIdent)[] | null, ensembleSet: EnsembleSet | null -): (EnsembleIdent | DeltaEnsembleIdent)[] | null { - if (!ensembleSet?.hasAnyEnsemblesOrDeltaEnsembles()) { +): (RegularEnsembleIdent | DeltaEnsembleIdent)[] | null { + if (!ensembleSet?.hasAnyEnsembles()) { return null; } if (currIdents === null || currIdents.length === 0) { // Provide first regular ensemble ident by default - if (ensembleSet.hasAnyEnsembles()) { - return [ensembleSet.getEnsembleArray()[0].getIdent()]; + if (ensembleSet.hasAnyRegularEnsembles()) { + return [ensembleSet.getRegularEnsembleArray()[0].getIdent()]; } return [ensembleSet.getDeltaEnsembleArray()[0].getIdent()]; } diff --git a/frontend/src/modules/3DViewer/interfaces.ts b/frontend/src/modules/3DViewer/interfaces.ts index b74c6fb9f..b4b3352ea 100644 --- a/frontend/src/modules/3DViewer/interfaces.ts +++ b/frontend/src/modules/3DViewer/interfaces.ts @@ -1,5 +1,5 @@ import { BoundingBox3d_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; import { IntersectionType } from "@framework/types/intersection"; import { ColorScale } from "@lib/utils/ColorScale"; @@ -34,7 +34,7 @@ import { } from "./view/atoms/baseAtoms"; export type SettingsToViewInterface = { - ensembleIdent: EnsembleIdent | null; + ensembleIdent: RegularEnsembleIdent | null; highlightedWellboreUuid: string | null; customIntersectionPolylineId: string | null; intersectionType: IntersectionType; diff --git a/frontend/src/modules/3DViewer/settings/atoms/baseAtoms.ts b/frontend/src/modules/3DViewer/settings/atoms/baseAtoms.ts index 72c62537b..d64800670 100644 --- a/frontend/src/modules/3DViewer/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/3DViewer/settings/atoms/baseAtoms.ts @@ -1,4 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { IntersectionType } from "@framework/types/intersection"; import { ColorScale } from "@lib/utils/ColorScale"; import { GridCellIndexRanges } from "@modules/3DViewer/typesAndEnums"; @@ -16,7 +16,7 @@ export const addCustomIntersectionPolylineEditModeActiveAtom = atom(fal export const editCustomIntersectionPolylineEditModeActiveAtom = atom(false); export const currentCustomIntersectionPolylineAtom = atom([]); -export const userSelectedEnsembleIdentAtom = atom(null); +export const userSelectedEnsembleIdentAtom = atom(null); export const userSelectedRealizationAtom = atom(null); export const userSelectedGridModelNameAtom = atom(null); export const userSelectedGridModelParameterNameAtom = atom(null); diff --git a/frontend/src/modules/3DViewer/settings/atoms/derivedAtoms.ts b/frontend/src/modules/3DViewer/settings/atoms/derivedAtoms.ts index 626ed788d..d7a221cd1 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 { EnsembleSetAtom, ValidEnsembleRealizationsFunctionAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { IntersectionPolylinesAtom } from "@framework/userCreatedItems/IntersectionPolylines"; import { GridCellIndexRanges } from "@modules/3DViewer/typesAndEnums"; @@ -19,12 +19,12 @@ import { } from "./baseAtoms"; import { drilledWellboreHeadersQueryAtom, gridModelInfosQueryAtom } from "./queryAtoms"; -export const selectedEnsembleIdentAtom = atom((get) => { +export const selectedEnsembleIdentAtom = atom((get) => { const ensembleSet = get(EnsembleSetAtom); const userSelectedEnsembleIdent = get(userSelectedEnsembleIdentAtom); if (userSelectedEnsembleIdent === null || !ensembleSet.hasEnsemble(userSelectedEnsembleIdent)) { - return ensembleSet.getEnsembleArray()[0]?.getIdent() || null; + return ensembleSet.getRegularEnsembleArray()[0]?.getIdent() || null; } return userSelectedEnsembleIdent; diff --git a/frontend/src/modules/3DViewer/settings/settings.tsx b/frontend/src/modules/3DViewer/settings/settings.tsx index f02cdb7d1..d16dbbd64 100644 --- a/frontend/src/modules/3DViewer/settings/settings.tsx +++ b/frontend/src/modules/3DViewer/settings/settings.tsx @@ -1,8 +1,8 @@ import React from "react"; import { Grid3dInfo_api, WellboreHeader_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useSettingsStatusWriter } from "@framework/StatusWriter"; import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings"; import { useIntersectionPolylines } from "@framework/UserCreatedItems"; @@ -77,7 +77,7 @@ export function Settings(props: ModuleSettingsProps): JSX.Element { const setPolylineEditModeActive = useSetAtom(editCustomIntersectionPolylineEditModeActiveAtom); const [prevSyncedIntersection, setPrevSyncedIntersection] = React.useState(null); - const [prevSyncedEnsembles, setPrevSyncedEnsembles] = React.useState(null); + const [prevSyncedEnsembles, setPrevSyncedEnsembles] = React.useState(null); const [pickSingleGridCellIndexI, setPickSingleGridCellIndexI] = React.useState(false); const [pickSingleGridCellIndexJ, setPickSingleGridCellIndexJ] = React.useState(false); const [pickSingleGridCellIndexK, setPickSingleGridCellIndexK] = React.useState(false); @@ -153,7 +153,7 @@ export function Settings(props: ModuleSettingsProps): JSX.Element { const gridModelErrorMessage = usePropagateApiErrorToStatusWriter(gridModelInfos, statusWriter) ?? ""; const wellHeadersErrorMessage = usePropagateApiErrorToStatusWriter(wellHeaders, statusWriter) ?? ""; - function handleEnsembleSelectionChange(ensembleIdent: EnsembleIdent | null) { + function handleEnsembleSelectionChange(ensembleIdent: RegularEnsembleIdent | null) { setSelectedEnsembleIdent(ensembleIdent); syncHelper.publishValue( SyncSettingKey.ENSEMBLE, diff --git a/frontend/src/modules/3DViewer/view/atoms/baseAtoms.ts b/frontend/src/modules/3DViewer/view/atoms/baseAtoms.ts index 938939ea9..833ece047 100644 --- a/frontend/src/modules/3DViewer/view/atoms/baseAtoms.ts +++ b/frontend/src/modules/3DViewer/view/atoms/baseAtoms.ts @@ -1,4 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { IntersectionType } from "@framework/types/intersection"; import { atom } from "jotai"; @@ -6,6 +6,6 @@ import { atom } from "jotai"; export const intersectionTypeAtom = atom(IntersectionType.WELLBORE); export const editCustomIntersectionPolylineEditModeActiveAtom = atom(false); -export const ensembleIdentAtom = atom(null); +export const ensembleIdentAtom = atom(null); export const highlightedWellboreUuidAtom = atom(null); export const customIntersectionPolylineIdAtom = atom(null); diff --git a/frontend/src/modules/3DViewer/view/queries/polylineIntersection.ts b/frontend/src/modules/3DViewer/view/queries/polylineIntersection.ts index 2e82d8608..c4cd1de0c 100644 --- a/frontend/src/modules/3DViewer/view/queries/polylineIntersection.ts +++ b/frontend/src/modules/3DViewer/view/queries/polylineIntersection.ts @@ -1,5 +1,5 @@ import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { PolylineIntersection_trans, transformPolylineIntersection, @@ -7,7 +7,7 @@ import { import { UseQueryResult, useQuery } from "@tanstack/react-query"; export function useGridPolylineIntersection( - ensembleIdent: EnsembleIdent | null, + ensembleIdent: RegularEnsembleIdent | null, gridModelName: string | null, gridModelParameterName: string | null, gridModelDateOrInterval: string | null, diff --git a/frontend/src/modules/DbgWorkbenchSpy/implementation.tsx b/frontend/src/modules/DbgWorkbenchSpy/implementation.tsx index e3a76351e..51de61992 100644 --- a/frontend/src/modules/DbgWorkbenchSpy/implementation.tsx +++ b/frontend/src/modules/DbgWorkbenchSpy/implementation.tsx @@ -80,7 +80,7 @@ function makeTableRow(label: string, value: any, updatedTS?: string) { } function makeEnsembleSetTable(ensembleSet: EnsembleSet) { - const ensembleArr = ensembleSet.getEnsembleArray(); + const ensembleArr = ensembleSet.getRegularEnsembleArray(); return ( diff --git a/frontend/src/modules/FlowNetwork/settings/atoms/baseAtoms.ts b/frontend/src/modules/FlowNetwork/settings/atoms/baseAtoms.ts index aca1a3da5..e019c8672 100644 --- a/frontend/src/modules/FlowNetwork/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/FlowNetwork/settings/atoms/baseAtoms.ts @@ -1,10 +1,10 @@ import { Frequency_api, NodeType_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithCompare } from "@framework/utils/atomUtils"; import { atom } from "jotai"; -function areEnsembleIdentsEqual(a: EnsembleIdent | null, b: EnsembleIdent | null) { +function areEnsembleIdentsEqual(a: RegularEnsembleIdent | null, b: RegularEnsembleIdent | null) { if (a === null) { return b === null; } @@ -23,7 +23,7 @@ export const userSelectedRealizationNumberAtom = atom(null); export const validRealizationNumbersAtom = atom(null); -export const userSelectedEnsembleIdentAtom = atomWithCompare(null, areEnsembleIdentsEqual); +export const userSelectedEnsembleIdentAtom = atomWithCompare(null, areEnsembleIdentsEqual); export const userSelectedEdgeKeyAtom = atom(null); diff --git a/frontend/src/modules/FlowNetwork/settings/atoms/derivedAtoms.ts b/frontend/src/modules/FlowNetwork/settings/atoms/derivedAtoms.ts index 166298583..46d2e59c6 100644 --- a/frontend/src/modules/FlowNetwork/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/FlowNetwork/settings/atoms/derivedAtoms.ts @@ -1,5 +1,5 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { fixupEnsembleIdent } from "@framework/utils/ensembleUiHelpers"; import { DatedTree, EdgeMetadata, NodeMetadata } from "@webviz/group-tree-plot"; @@ -21,7 +21,7 @@ export const groupTreeQueryResultAtom = atom((get) => { return get(realizationGroupTreeQueryAtom); }); -export const selectedEnsembleIdentAtom = atom((get) => { +export const selectedEnsembleIdentAtom = atom((get) => { const ensembleSet = get(EnsembleSetAtom); const userSelectedEnsembleIdent = get(userSelectedEnsembleIdentAtom); diff --git a/frontend/src/modules/FlowNetwork/settings/settings.tsx b/frontend/src/modules/FlowNetwork/settings/settings.tsx index 056f2c959..fe849286d 100644 --- a/frontend/src/modules/FlowNetwork/settings/settings.tsx +++ b/frontend/src/modules/FlowNetwork/settings/settings.tsx @@ -1,8 +1,8 @@ import React from "react"; import { Frequency_api, NodeType_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useSettingsStatusWriter } from "@framework/StatusWriter"; import { useEnsembleRealizationFilterFunc, useEnsembleSet } from "@framework/WorkbenchSession"; import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; @@ -94,7 +94,7 @@ export function Settings({ workbenchSession, settingsContext }: ModuleSettingsPr setUserSelectedEdgeKey(value); } - function handleEnsembleSelectionChange(ensembleIdent: EnsembleIdent | null) { + function handleEnsembleSelectionChange(ensembleIdent: RegularEnsembleIdent | null) { setUserSelectedEnsembleIdent(ensembleIdent); } diff --git a/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/baseAtoms.ts b/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/baseAtoms.ts index 03ef88853..dab411a31 100644 --- a/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/baseAtoms.ts @@ -1,5 +1,5 @@ import { FluidZone_api, InplaceVolumetricResultName_api, InplaceVolumetricsIdentifierWithValues_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { PlotType } from "@modules/InplaceVolumetricsPlot/typesAndEnums"; import { SelectorColumn, @@ -9,7 +9,7 @@ import { import { atom } from "jotai"; -export const userSelectedEnsembleIdentsAtom = atom(null); +export const userSelectedEnsembleIdentsAtom = atom(null); export const userSelectedTableNamesAtom = atom(null); export const userSelectedFluidZonesAtom = atom(null); export const userSelectedIdentifiersValuesAtom = atom(null); diff --git a/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/derivedAtoms.ts b/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/derivedAtoms.ts index 6c289d0bf..fd9eb2457 100644 --- a/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/derivedAtoms.ts @@ -31,10 +31,10 @@ export const selectedEnsembleIdentsAtom = atom((get) => { const userSelectedEnsembleIdents = get(userSelectedEnsembleIdentsAtom); if (!userSelectedEnsembleIdents) { - if (ensembleSet.getEnsembleArray().length === 0) { + if (ensembleSet.getRegularEnsembleArray().length === 0) { return []; } - return [ensembleSet.getEnsembleArray()[0].getIdent()]; + return [ensembleSet.getRegularEnsembleArray()[0].getIdent()]; } const newSelectedEnsembleIdents = userSelectedEnsembleIdents.filter((ensemble) => diff --git a/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/queryAtoms.ts b/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/queryAtoms.ts index ada10a2c7..a8a485010 100644 --- a/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/queryAtoms.ts +++ b/frontend/src/modules/InplaceVolumetricsPlot/settings/atoms/queryAtoms.ts @@ -1,6 +1,6 @@ import { InplaceVolumetricsTableDefinition_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithQueries } from "@framework/utils/atomUtils"; import { QueryObserverResult } from "@tanstack/query-core"; @@ -11,7 +11,7 @@ const CACHE_TIME = 60 * 1000; export type TableDefinitionsQueryResult = { data: { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; tableDefinitions: InplaceVolumetricsTableDefinition_api[]; }[]; isLoading: boolean; diff --git a/frontend/src/modules/InplaceVolumetricsPlot/view/hooks/usePublishToDataChannels.ts b/frontend/src/modules/InplaceVolumetricsPlot/view/hooks/usePublishToDataChannels.ts index 7f8c021e6..e2dc92579 100644 --- a/frontend/src/modules/InplaceVolumetricsPlot/view/hooks/usePublishToDataChannels.ts +++ b/frontend/src/modules/InplaceVolumetricsPlot/view/hooks/usePublishToDataChannels.ts @@ -1,8 +1,8 @@ import { InplaceVolumetricResultName_api } from "@api"; import { ChannelContentDefinition, ChannelContentMetaData, DataGenerator } from "@framework/DataChannelTypes"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; import { ViewContext } from "@framework/ModuleContext"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { ChannelIds } from "@modules/InplaceVolumetricsPlot/channelDefs"; import { Interfaces } from "@modules/InplaceVolumetricsPlot/interfaces"; import { Table } from "@modules/_shared/InplaceVolumetrics/Table"; @@ -11,7 +11,7 @@ import { makeDistinguishableEnsembleDisplayName } from "@modules/_shared/ensembl function makeDataGeneratorFunc( ensembleName: string, - ensembleIdent: EnsembleIdent, + ensembleIdent: RegularEnsembleIdent, tableName: string, fluidZone: string, table: Table, @@ -56,8 +56,11 @@ export function usePublishToDataChannels( if (table && resultName) { const ensembleCollection = table.splitByColumn(SourceIdentifier.ENSEMBLE); for (const [ensembleIdentStr, ensembleTable] of ensembleCollection.getCollectionMap()) { - const ensembleIdent = EnsembleIdent.fromString(ensembleIdentStr.toString()); - const ensembleName = makeDistinguishableEnsembleDisplayName(ensembleIdent, ensembleSet.getEnsembleArray()); + const ensembleIdent = RegularEnsembleIdent.fromString(ensembleIdentStr.toString()); + const ensembleName = makeDistinguishableEnsembleDisplayName( + ensembleIdent, + ensembleSet.getRegularEnsembleArray() + ); const tableCollection = ensembleTable.splitByColumn(SourceIdentifier.TABLE_NAME); for (const [tableName, table] of tableCollection.getCollectionMap()) { diff --git a/frontend/src/modules/InplaceVolumetricsPlot/view/utils/plotComponentUtils.ts b/frontend/src/modules/InplaceVolumetricsPlot/view/utils/plotComponentUtils.ts index fb6f33241..14cb21edc 100644 --- a/frontend/src/modules/InplaceVolumetricsPlot/view/utils/plotComponentUtils.ts +++ b/frontend/src/modules/InplaceVolumetricsPlot/view/utils/plotComponentUtils.ts @@ -1,5 +1,5 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { ColorSet } from "@lib/utils/ColorSet"; import { PlotType } from "@modules/InplaceVolumetricsPlot/typesAndEnums"; import { Table } from "@modules/_shared/InplaceVolumetrics/Table"; @@ -21,10 +21,10 @@ export function makeFormatLabelFunction( ): (columnName: string, value: string | number) => string { return function formatLabel(columnName: string, value: string | number): string { if (columnName === SourceIdentifier.ENSEMBLE) { - const ensembleIdent = EnsembleIdent.fromString(value.toString()); + const ensembleIdent = RegularEnsembleIdent.fromString(value.toString()); const ensemble = ensembleSet.findEnsemble(ensembleIdent); if (ensemble) { - return makeDistinguishableEnsembleDisplayName(ensembleIdent, ensembleSet.getEnsembleArray()); + return makeDistinguishableEnsembleDisplayName(ensembleIdent, ensembleSet.getRegularEnsembleArray()); } } return value.toString(); @@ -81,11 +81,14 @@ export function makePlotData( for (const [key, table] of collection.getCollectionMap()) { let title = key.toString(); if (colorBy === SourceIdentifier.ENSEMBLE) { - const ensembleIdent = EnsembleIdent.fromString(key.toString()); + const ensembleIdent = RegularEnsembleIdent.fromString(key.toString()); const ensemble = ensembleSet.findEnsemble(ensembleIdent); if (ensemble) { color = ensemble.getColor(); - title = makeDistinguishableEnsembleDisplayName(ensembleIdent, ensembleSet.getEnsembleArray()); + title = makeDistinguishableEnsembleDisplayName( + ensembleIdent, + ensembleSet.getRegularEnsembleArray() + ); } } diff --git a/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/baseAtoms.ts b/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/baseAtoms.ts index 325198b30..9079460cb 100644 --- a/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/baseAtoms.ts @@ -4,12 +4,12 @@ import { InplaceVolumetricStatistic_api, InplaceVolumetricsIdentifierWithValues_api, } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { SourceAndTableIdentifierUnion, SourceIdentifier, TableType } from "@modules/_shared/InplaceVolumetrics/types"; import { atom } from "jotai"; -export const userSelectedEnsembleIdentsAtom = atom(null); +export const userSelectedEnsembleIdentsAtom = atom(null); export const userSelectedTableNamesAtom = atom(null); export const userSelectedFluidZonesAtom = atom(null); export const userSelectedIdentifiersValuesAtom = atom(null); diff --git a/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/derivedAtoms.ts b/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/derivedAtoms.ts index cb08812de..aa262e145 100644 --- a/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/derivedAtoms.ts @@ -26,10 +26,10 @@ export const selectedEnsembleIdentsAtom = atom((get) => { const userSelectedEnsembleIdents = get(userSelectedEnsembleIdentsAtom); if (!userSelectedEnsembleIdents) { - if (ensembleSet.getEnsembleArray().length === 0) { + if (ensembleSet.getRegularEnsembleArray().length === 0) { return []; } - return [ensembleSet.getEnsembleArray()[0].getIdent()]; + return [ensembleSet.getRegularEnsembleArray()[0].getIdent()]; } const newSelectedEnsembleIdents = userSelectedEnsembleIdents.filter((ensemble) => diff --git a/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/queryAtoms.ts b/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/queryAtoms.ts index ada10a2c7..a8a485010 100644 --- a/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/queryAtoms.ts +++ b/frontend/src/modules/InplaceVolumetricsTable/settings/atoms/queryAtoms.ts @@ -1,6 +1,6 @@ import { InplaceVolumetricsTableDefinition_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithQueries } from "@framework/utils/atomUtils"; import { QueryObserverResult } from "@tanstack/query-core"; @@ -11,7 +11,7 @@ const CACHE_TIME = 60 * 1000; export type TableDefinitionsQueryResult = { data: { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; tableDefinitions: InplaceVolumetricsTableDefinition_api[]; }[]; isLoading: boolean; diff --git a/frontend/src/modules/InplaceVolumetricsTable/view/hooks/useMakeViewStatusWriterMessages.ts b/frontend/src/modules/InplaceVolumetricsTable/view/hooks/useMakeViewStatusWriterMessages.ts index fd9438c5c..296496c27 100644 --- a/frontend/src/modules/InplaceVolumetricsTable/view/hooks/useMakeViewStatusWriterMessages.ts +++ b/frontend/src/modules/InplaceVolumetricsTable/view/hooks/useMakeViewStatusWriterMessages.ts @@ -44,7 +44,7 @@ export function useMakeViewStatusWriterMessages(statusWriter: ViewStatusWriter) // Due to no throw in back-end for missing/non-existing result for specific tables, we should compare // the retrieved result columns with the requested columns for (const tableData of activeQueriesResult.tablesData) { - // Per unique volumetric table (EnsembleIdent, tableName) we have a query result + // Per unique volumetric table (RegularEnsembleIdent, tableName) we have a query result const queryData = tableData.data; // Result columns across all fluid selections diff --git a/frontend/src/modules/InplaceVolumetricsTable/view/utils/tableComponentUtils.ts b/frontend/src/modules/InplaceVolumetricsTable/view/utils/tableComponentUtils.ts index 3b0dcf263..90a26d57c 100644 --- a/frontend/src/modules/InplaceVolumetricsTable/view/utils/tableComponentUtils.ts +++ b/frontend/src/modules/InplaceVolumetricsTable/view/utils/tableComponentUtils.ts @@ -1,7 +1,7 @@ import { FluidZone_api, InplaceVolumetricStatistic_api } from "@api"; -import { Ensemble } from "@framework/Ensemble"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { TableHeading, TableRow } from "@lib/components/Table/table"; import { Column, ColumnType, Row, Table } from "@modules/_shared/InplaceVolumetrics/Table"; import { sortResultNameStrings } from "@modules/_shared/InplaceVolumetrics/sortResultNames"; @@ -191,10 +191,10 @@ function formatEnsembleIdent(value: string | number | null, ensembleSet: Ensembl return "-"; } const ensemble = ensembleSet.findEnsembleByIdentString(value.toString()); - if (ensemble && ensemble instanceof Ensemble) { + if (ensemble && ensemble instanceof RegularEnsemble) { return makeDistinguishableEnsembleDisplayName( - EnsembleIdent.fromString(value.toString()), - ensembleSet.getEnsembleArray() + RegularEnsembleIdent.fromString(value.toString()), + ensembleSet.getRegularEnsembleArray() ); } return value.toString(); diff --git a/frontend/src/modules/Intersection/interfaces.ts b/frontend/src/modules/Intersection/interfaces.ts index ccac90da8..51964c855 100644 --- a/frontend/src/modules/Intersection/interfaces.ts +++ b/frontend/src/modules/Intersection/interfaces.ts @@ -1,4 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; import { IntersectionType } from "@framework/types/intersection"; import { ColorScale } from "@lib/utils/ColorScale"; @@ -29,7 +29,7 @@ export type SettingsToViewInterface = { intersectionType: IntersectionType; seismicColorScale: ColorScale | null; showSeismic: boolean; - ensembleIdent: EnsembleIdent | null; + ensembleIdent: RegularEnsembleIdent | null; selectedCustomIntersectionPolylineId: string | null; layerManager: LayerManager; wellboreHeader: WellboreHeader | null; diff --git a/frontend/src/modules/Intersection/settings/atoms/baseAtoms.ts b/frontend/src/modules/Intersection/settings/atoms/baseAtoms.ts index 8a8ebb463..4570b6e78 100644 --- a/frontend/src/modules/Intersection/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/Intersection/settings/atoms/baseAtoms.ts @@ -1,4 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { IntersectionType } from "@framework/types/intersection"; import { ColorScale } from "@lib/utils/ColorScale"; @@ -18,6 +18,6 @@ export const seismicColorScaleAtom = atom(null); export const showSeismicAtom = atom(false); export const userSelectedFieldIdentifierAtom = atom(null); -export const userSelectedEnsembleIdentAtom = atom(null); +export const userSelectedEnsembleIdentAtom = atom(null); export const userSelectedWellboreUuidAtom = atom(null); export const userSelectedCustomIntersectionPolylineIdAtom = atom(null); diff --git a/frontend/src/modules/Intersection/settings/atoms/derivedAtoms.ts b/frontend/src/modules/Intersection/settings/atoms/derivedAtoms.ts index b252c313b..b265b7e0b 100644 --- a/frontend/src/modules/Intersection/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/Intersection/settings/atoms/derivedAtoms.ts @@ -1,6 +1,6 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { IntersectionPolylinesAtom } from "@framework/userCreatedItems/IntersectionPolylines"; import { LayerManager } from "@modules/Intersection/utils/layers/LayerManager"; @@ -23,7 +23,9 @@ export const filteredEnsembleSetAtom = atom((get) => { return ensembleSet; } - return new EnsembleSet(ensembleSet.getEnsembleArray().filter((el) => el.getFieldIdentifier() === fieldIdentifier)); + return new EnsembleSet( + ensembleSet.getRegularEnsembleArray().filter((el) => el.getFieldIdentifier() === fieldIdentifier) + ); }); export const selectedFieldIdentifierAtom = atom((get) => { @@ -31,7 +33,7 @@ export const selectedFieldIdentifierAtom = atom((get) => { const selectedFieldIdentifier = get(userSelectedFieldIdentifierAtom); if (selectedFieldIdentifier === null) { - return ensembleSet.getEnsembleArray()[0]?.getFieldIdentifier() || null; + return ensembleSet.getRegularEnsembleArray()[0]?.getFieldIdentifier() || null; } return selectedFieldIdentifier; @@ -60,12 +62,12 @@ export const selectedCustomIntersectionPolylineIdAtom = atom((get) => { return userSelectedCustomIntersectionPolylineId; }); -export const selectedEnsembleIdentAtom = atom((get) => { +export const selectedEnsembleIdentAtom = atom((get) => { const ensembleSet = get(EnsembleSetAtom); const userSelectedEnsembleIdent = get(userSelectedEnsembleIdentAtom); if (userSelectedEnsembleIdent === null || !ensembleSet.hasEnsemble(userSelectedEnsembleIdent)) { - return ensembleSet.getEnsembleArray()[0]?.getIdent() || null; + return ensembleSet.getRegularEnsembleArray()[0]?.getIdent() || null; } return userSelectedEnsembleIdent; diff --git a/frontend/src/modules/Intersection/settings/components/layerSettings/gridLayer.tsx b/frontend/src/modules/Intersection/settings/components/layerSettings/gridLayer.tsx index c555ca69a..76dfe6468 100644 --- a/frontend/src/modules/Intersection/settings/components/layerSettings/gridLayer.tsx +++ b/frontend/src/modules/Intersection/settings/components/layerSettings/gridLayer.tsx @@ -2,8 +2,8 @@ import React from "react"; import { Grid3dInfo_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { WorkbenchSession, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; import { WorkbenchSettings } from "@framework/WorkbenchSettings"; import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; @@ -45,7 +45,7 @@ export function GridLayerSettingsComponent(props: GridLayerSettingsComponentProp const fixupEnsembleIdent = fixupSetting( "ensembleIdent", - props.ensembleSet.getEnsembleArray().map((el) => el.getIdent()), + props.ensembleSet.getRegularEnsembleArray().map((el) => el.getIdent()), newSettings ); if (!isEqual(fixupEnsembleIdent, newSettings.ensembleIdent)) { @@ -115,7 +115,7 @@ export function GridLayerSettingsComponent(props: GridLayerSettingsComponentProp [gridModelInfosQuery.isFetching, props.layer, newSettings] ); - function handleEnsembleChange(ensembleIdent: EnsembleIdent | null) { + function handleEnsembleChange(ensembleIdent: RegularEnsembleIdent | null) { setNewSettings((prev) => ({ ...prev, ensembleIdent })); } @@ -307,7 +307,7 @@ function makeGridParameterDateOrIntervalOptions(datesOrIntervals: (string | null const STALE_TIME = 60 * 1000; const CACHE_TIME = 60 * 1000; -function useGridModelInfosQuery(ensembleIdent: EnsembleIdent | null, realizationNum: number | null) { +function useGridModelInfosQuery(ensembleIdent: RegularEnsembleIdent | null, realizationNum: number | null) { return useQuery({ queryKey: ["getGridModelInfos", ensembleIdent?.getCaseUuid(), ensembleIdent?.getEnsembleName(), realizationNum], queryFn: () => diff --git a/frontend/src/modules/Intersection/settings/components/layerSettings/seismicLayer.tsx b/frontend/src/modules/Intersection/settings/components/layerSettings/seismicLayer.tsx index f676834bd..5bda7415e 100644 --- a/frontend/src/modules/Intersection/settings/components/layerSettings/seismicLayer.tsx +++ b/frontend/src/modules/Intersection/settings/components/layerSettings/seismicLayer.tsx @@ -1,8 +1,8 @@ import React from "react"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { WorkbenchSession, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; import { WorkbenchSettings } from "@framework/WorkbenchSettings"; import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; @@ -61,7 +61,7 @@ export function SeismicLayerSettingsComponent(props: SeismicLayerSettingsProps): const fixupEnsembleIdent = fixupSetting( "ensembleIdent", - props.ensembleSet.getEnsembleArray().map((el) => el.getIdent()), + props.ensembleSet.getRegularEnsembleArray().map((el) => el.getIdent()), newSettings ); if (!isEqual(fixupEnsembleIdent, newSettings.ensembleIdent)) { @@ -158,7 +158,7 @@ export function SeismicLayerSettingsComponent(props: SeismicLayerSettingsProps): [seismicCubeMetaListQuery.isFetching, props.layer, newSettings] ); - function handleEnsembleChange(ensembleIdent: EnsembleIdent | null) { + function handleEnsembleChange(ensembleIdent: RegularEnsembleIdent | null) { setNewSettings((prev) => ({ ...prev, ensembleIdent })); } @@ -341,7 +341,7 @@ function makeDateOrIntervalStringOptions(availableSeismicDateOrIntervalStrings: const STALE_TIME = 60 * 1000; const CACHE_TIME = 60 * 1000; -function useSeismicCubeMetaListQuery(ensembleIdent: EnsembleIdent | null) { +function useSeismicCubeMetaListQuery(ensembleIdent: RegularEnsembleIdent | null) { return useQuery({ queryKey: ["getSeismicCubeMetaList", ensembleIdent?.getCaseUuid(), ensembleIdent?.getEnsembleName()], queryFn: () => diff --git a/frontend/src/modules/Intersection/settings/components/layerSettings/surfaceLayer.tsx b/frontend/src/modules/Intersection/settings/components/layerSettings/surfaceLayer.tsx index a990b9880..b0586e0ec 100644 --- a/frontend/src/modules/Intersection/settings/components/layerSettings/surfaceLayer.tsx +++ b/frontend/src/modules/Intersection/settings/components/layerSettings/surfaceLayer.tsx @@ -2,8 +2,8 @@ import React from "react"; import { SurfaceAttributeType_api, SurfaceMetaSet_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { WorkbenchSession, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; import { WorkbenchSettings } from "@framework/WorkbenchSettings"; import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; @@ -49,7 +49,7 @@ export function SurfaceLayerSettingsComponent(props: SurfaceLayerSettingsCompone const fixupEnsembleIdent = fixupSetting( "ensembleIdent", - props.ensembleSet.getEnsembleArray().map((el) => el.getIdent()), + props.ensembleSet.getRegularEnsembleArray().map((el) => el.getIdent()), newSettings ); if (!isEqual(fixupEnsembleIdent, newSettings.ensembleIdent)) { @@ -119,7 +119,7 @@ export function SurfaceLayerSettingsComponent(props: SurfaceLayerSettingsCompone [surfaceDirectoryQuery.isFetching, props.layer, newSettings] ); - function handleEnsembleChange(ensembleIdent: EnsembleIdent | null) { + function handleEnsembleChange(ensembleIdent: RegularEnsembleIdent | null) { setNewSettings((prev) => ({ ...prev, ensembleIdent })); } diff --git a/frontend/src/modules/Intersection/settings/components/layerSettings/surfacesUncertaintyLayer.tsx b/frontend/src/modules/Intersection/settings/components/layerSettings/surfacesUncertaintyLayer.tsx index 4efe9114b..3ad52cd41 100644 --- a/frontend/src/modules/Intersection/settings/components/layerSettings/surfacesUncertaintyLayer.tsx +++ b/frontend/src/modules/Intersection/settings/components/layerSettings/surfacesUncertaintyLayer.tsx @@ -2,8 +2,8 @@ import React from "react"; import { SurfaceAttributeType_api, SurfaceMetaSet_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { WorkbenchSession, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; import { WorkbenchSettings } from "@framework/WorkbenchSettings"; import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; @@ -55,7 +55,7 @@ export function SurfacesUncertaintyLayerSettingsComponent( const fixupEnsembleIdent = fixupSetting( "ensembleIdent", - props.ensembleSet.getEnsembleArray().map((el) => el.getIdent()), + props.ensembleSet.getRegularEnsembleArray().map((el) => el.getIdent()), newSettings ); if (!isEqual(fixupEnsembleIdent, newSettings.ensembleIdent)) { @@ -120,7 +120,7 @@ export function SurfacesUncertaintyLayerSettingsComponent( [surfaceDirectoryQuery.isFetching, props.layer, newSettings] ); - function handleEnsembleChange(ensembleIdent: EnsembleIdent | null) { + function handleEnsembleChange(ensembleIdent: RegularEnsembleIdent | null) { setNewSettings((prev) => ({ ...prev, ensembleIdent })); } diff --git a/frontend/src/modules/Intersection/utils/layers/GridLayer.ts b/frontend/src/modules/Intersection/utils/layers/GridLayer.ts index ec65f0b58..a4c446b27 100644 --- a/frontend/src/modules/Intersection/utils/layers/GridLayer.ts +++ b/frontend/src/modules/Intersection/utils/layers/GridLayer.ts @@ -1,5 +1,5 @@ import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { defaultContinuousSequentialColorPalettes } from "@framework/utils/colorPalettes"; import { ColorScale, ColorScaleGradientType, ColorScaleType } from "@lib/utils/ColorScale"; import { ColorScaleWithName } from "@modules/_shared/utils/ColorScaleWithName"; @@ -18,7 +18,7 @@ const STALE_TIME = 60 * 1000; const CACHE_TIME = 60 * 1000; export type GridLayerSettings = { - ensembleIdent: EnsembleIdent | null; + ensembleIdent: RegularEnsembleIdent | null; gridModelName: string | null; parameterName: string | null; parameterDateOrInterval: string | null; diff --git a/frontend/src/modules/Intersection/utils/layers/SeismicLayer.ts b/frontend/src/modules/Intersection/utils/layers/SeismicLayer.ts index 590bcbabb..d0d3eabf2 100644 --- a/frontend/src/modules/Intersection/utils/layers/SeismicLayer.ts +++ b/frontend/src/modules/Intersection/utils/layers/SeismicLayer.ts @@ -1,7 +1,7 @@ import { SeismicFenceData_api } from "@api"; import { SeismicInfo, findIndexOfSample, getSeismicInfo } from "@equinor/esv-intersection"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { defaultContinuousDivergingColorPalettes } from "@framework/utils/colorPalettes"; import { ColorScale, ColorScaleGradientType, ColorScaleType } from "@lib/utils/ColorScale"; import { Vec2, normalizeVec2, point2Distance } from "@lib/utils/vec2"; @@ -51,7 +51,7 @@ const STALE_TIME = 60 * 1000; const CACHE_TIME = 60 * 1000; export type SeismicLayerSettings = { - ensembleIdent: EnsembleIdent | null; + ensembleIdent: RegularEnsembleIdent | null; realizationNum: number | null; polyline: { polylineUtmXy: number[]; diff --git a/frontend/src/modules/Intersection/utils/layers/SurfaceLayer.ts b/frontend/src/modules/Intersection/utils/layers/SurfaceLayer.ts index b2a618356..042c965e2 100644 --- a/frontend/src/modules/Intersection/utils/layers/SurfaceLayer.ts +++ b/frontend/src/modules/Intersection/utils/layers/SurfaceLayer.ts @@ -1,6 +1,6 @@ import { SurfaceIntersectionData_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { defaultColorPalettes } from "@framework/utils/colorPalettes"; import { ColorSet } from "@lib/utils/ColorSet"; import { Vec2, normalizeVec2, point2Distance } from "@lib/utils/vec2"; @@ -14,7 +14,7 @@ const STALE_TIME = 60 * 1000; const CACHE_TIME = 60 * 1000; export type SurfaceLayerSettings = { - ensembleIdent: EnsembleIdent | null; + ensembleIdent: RegularEnsembleIdent | null; realizationNum: number | null; polyline: { polylineUtmXy: number[]; diff --git a/frontend/src/modules/Intersection/utils/layers/SurfacesUncertaintyLayer.ts b/frontend/src/modules/Intersection/utils/layers/SurfacesUncertaintyLayer.ts index ffeef655d..51590ed07 100644 --- a/frontend/src/modules/Intersection/utils/layers/SurfacesUncertaintyLayer.ts +++ b/frontend/src/modules/Intersection/utils/layers/SurfacesUncertaintyLayer.ts @@ -1,6 +1,6 @@ import { SurfaceRealizationSampleValues_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { defaultColorPalettes } from "@framework/utils/colorPalettes"; import { ColorSet } from "@lib/utils/ColorSet"; import { Vec2, normalizeVec2, point2Distance } from "@lib/utils/vec2"; @@ -14,7 +14,7 @@ const STALE_TIME = 60 * 1000; const CACHE_TIME = 60 * 1000; export type SurfacesUncertaintyLayerSettings = { - ensembleIdent: EnsembleIdent | null; + ensembleIdent: RegularEnsembleIdent | null; realizationNums: number[]; polyline: { polylineUtmXy: number[]; diff --git a/frontend/src/modules/Intersection/utils/layers/WellpicksLayer.ts b/frontend/src/modules/Intersection/utils/layers/WellpicksLayer.ts index 3da88f844..3acff64fb 100644 --- a/frontend/src/modules/Intersection/utils/layers/WellpicksLayer.ts +++ b/frontend/src/modules/Intersection/utils/layers/WellpicksLayer.ts @@ -1,6 +1,6 @@ import { transformFormationData } from "@equinor/esv-intersection"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { QueryClient } from "@tanstack/query-core"; import { isEqual } from "lodash"; @@ -12,7 +12,7 @@ const CACHE_TIME = 60 * 1000; export type WellpicksLayerSettings = { wellboreUuid: string | null; - ensembleIdent: EnsembleIdent | null; + ensembleIdent: RegularEnsembleIdent | null; filterPicks: boolean; selectedUnitPicks: string[]; selectedNonUnitPicks: string[]; diff --git a/frontend/src/modules/Map/settings/settings.tsx b/frontend/src/modules/Map/settings/settings.tsx index 3008e7e61..b304cfb51 100644 --- a/frontend/src/modules/Map/settings/settings.tsx +++ b/frontend/src/modules/Map/settings/settings.tsx @@ -1,8 +1,8 @@ import React from "react"; import { SurfaceStatisticFunction_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useSettingsStatusWriter } from "@framework/StatusWriter"; import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings"; import { useEnsembleSet } from "@framework/WorkbenchSession"; @@ -34,7 +34,7 @@ const SurfaceTimeTypeEnumToStringMapping = { //----------------------------------------------------------------------------------------------------------- export function MapSettings(props: ModuleSettingsProps) { const ensembleSet = useEnsembleSet(props.workbenchSession); - const [selectedEnsembleIdent, setSelectedEnsembleIdent] = React.useState(null); + const [selectedEnsembleIdent, setSelectedEnsembleIdent] = React.useState(null); const [timeType, setTimeType] = React.useState(SurfaceTimeType.None); const statusWriter = useSettingsStatusWriter(props.settingsContext); @@ -128,7 +128,7 @@ export function MapSettings(props: ModuleSettingsProps) { setSurfaceAddress(surfaceAddress); }); - function handleEnsembleSelectionChange(newEnsembleIdent: EnsembleIdent | null) { + function handleEnsembleSelectionChange(newEnsembleIdent: RegularEnsembleIdent | null) { console.debug("handleEnsembleSelectionChange()"); setSelectedEnsembleIdent(newEnsembleIdent); if (newEnsembleIdent) { diff --git a/frontend/src/modules/MyModule2/atoms.ts b/frontend/src/modules/MyModule2/atoms.ts index edaac8bb6..2eeddbab5 100644 --- a/frontend/src/modules/MyModule2/atoms.ts +++ b/frontend/src/modules/MyModule2/atoms.ts @@ -1,12 +1,12 @@ import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atom } from "jotai"; import { atomWithQuery } from "jotai-tanstack-query"; export const textAtom = atom("I am an atom with text!"); -export const selectedEnsembleAtom = atom(null); +export const selectedEnsembleAtom = atom(null); export const vectorsAtom = atomWithQuery((get) => ({ queryKey: ["ensembles", get(selectedEnsembleAtom)?.toString()], queryFn: () => @@ -30,8 +30,8 @@ export const selectedVectorAtom = atom((get) => { return vectors.data?.at(0)?.name ?? null; }); -export const ensembleSetDependentAtom = atom((get) => { +export const ensembleSetDependentAtom = atom((get) => { const ensembleSet = get(EnsembleSetAtom); - const firstEnsemble = ensembleSet.getEnsembleArray()[0]; + const firstEnsemble = ensembleSet.getRegularEnsembleArray()[0]; return firstEnsemble?.getIdent() ?? null; }); diff --git a/frontend/src/modules/ParameterDistributionMatrix/interfaces.ts b/frontend/src/modules/ParameterDistributionMatrix/interfaces.ts index f6d9b3f63..14382b094 100644 --- a/frontend/src/modules/ParameterDistributionMatrix/interfaces.ts +++ b/frontend/src/modules/ParameterDistributionMatrix/interfaces.ts @@ -1,5 +1,5 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ParameterIdent } from "@framework/EnsembleParameters"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; import { @@ -14,7 +14,7 @@ type SettingsToViewInterface = { selectedVisualizationType: ParameterDistributionPlotType; showIndividualRealizationValues: boolean; showPercentilesAndMeanLines: boolean; - selectedEnsembleIdents: EnsembleIdent[]; + selectedEnsembleIdents: RegularEnsembleIdent[]; selectedParameterIdents: ParameterIdent[]; }; diff --git a/frontend/src/modules/ParameterDistributionMatrix/settings/atoms/baseAtoms.ts b/frontend/src/modules/ParameterDistributionMatrix/settings/atoms/baseAtoms.ts index f82dc9dcc..65739f173 100644 --- a/frontend/src/modules/ParameterDistributionMatrix/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/ParameterDistributionMatrix/settings/atoms/baseAtoms.ts @@ -1,11 +1,11 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ParameterIdent } from "@framework/EnsembleParameters"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithCompare } from "@framework/utils/atomUtils"; import { ParameterDistributionPlotType } from "@modules/ParameterDistributionMatrix/typesAndEnums"; import { atom } from "jotai"; -function areEnsembleIdentListsEqual(a: EnsembleIdent[], b: EnsembleIdent[]) { +function areEnsembleIdentListsEqual(a: RegularEnsembleIdent[], b: RegularEnsembleIdent[]) { if (a.length !== b.length) { return false; } @@ -23,6 +23,6 @@ export const selectedVisualizationTypeAtom = atom export const showIndividualRealizationValuesAtom = atom(false); export const showPercentilesAndMeanLinesAtom = atom(false); -export const userSelectedEnsembleIdentsAtom = atomWithCompare([], areEnsembleIdentListsEqual); +export const userSelectedEnsembleIdentsAtom = atomWithCompare([], areEnsembleIdentListsEqual); export const userSelectedParameterIdentsAtom = atom([]); export const showConstantParametersAtom = atom(false); diff --git a/frontend/src/modules/ParameterDistributionMatrix/settings/atoms/derivedAtoms.ts b/frontend/src/modules/ParameterDistributionMatrix/settings/atoms/derivedAtoms.ts index a8a94116a..212c9eb62 100644 --- a/frontend/src/modules/ParameterDistributionMatrix/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/ParameterDistributionMatrix/settings/atoms/derivedAtoms.ts @@ -15,8 +15,8 @@ export const selectedEnsembleIdentsAtom = atom((get) => { const userSelectedEnsembleIdents = get(userSelectedEnsembleIdentsAtom); let computedEnsembleIdents = userSelectedEnsembleIdents.filter((el) => ensembleSet.hasEnsemble(el)); - if (computedEnsembleIdents.length === 0 && ensembleSet.getEnsembleArray().length > 0) { - computedEnsembleIdents = [ensembleSet.getEnsembleArray()[0].getIdent()]; + if (computedEnsembleIdents.length === 0 && ensembleSet.getRegularEnsembleArray().length > 0) { + computedEnsembleIdents = [ensembleSet.getRegularEnsembleArray()[0].getIdent()]; } return computedEnsembleIdents; diff --git a/frontend/src/modules/ParameterDistributionMatrix/settings/settings.tsx b/frontend/src/modules/ParameterDistributionMatrix/settings/settings.tsx index 417d4b8cf..ead01361c 100644 --- a/frontend/src/modules/ParameterDistributionMatrix/settings/settings.tsx +++ b/frontend/src/modules/ParameterDistributionMatrix/settings/settings.tsx @@ -1,6 +1,6 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ParameterIdent } from "@framework/EnsembleParameters"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useEnsembleSet } from "@framework/WorkbenchSession"; import { EnsembleSelect } from "@framework/components/EnsembleSelect"; import { Checkbox } from "@lib/components/Checkbox"; @@ -47,7 +47,7 @@ export function Settings({ workbenchSession }: ModuleSettingsProps) ); const [showPercentilesAndMeanLines, setShowPercentilesAndMeanLines] = useAtom(showPercentilesAndMeanLinesAtom); - function handleEnsembleSelectionChange(ensembleIdents: EnsembleIdent[]) { + function handleEnsembleSelectionChange(ensembleIdents: RegularEnsembleIdent[]) { setSelectedEnsembleIdents(ensembleIdents); } diff --git a/frontend/src/modules/ParameterDistributionMatrix/view/view.tsx b/frontend/src/modules/ParameterDistributionMatrix/view/view.tsx index 7b717a11d..b047099b3 100644 --- a/frontend/src/modules/ParameterDistributionMatrix/view/view.tsx +++ b/frontend/src/modules/ParameterDistributionMatrix/view/view.tsx @@ -1,9 +1,9 @@ import React from "react"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ParameterIdent, ParameterType } from "@framework/EnsembleParameters"; import { EnsembleSet } from "@framework/EnsembleSet"; import { ModuleViewProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { EnsembleRealizationFilterFunction, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; import { useElementSize } from "@lib/hooks/useElementSize"; @@ -51,7 +51,7 @@ export function View(props: ModuleViewProps) { function makeParameterDataArr( ensembleSet: EnsembleSet, - ensembleIdents: EnsembleIdent[], + ensembleIdents: RegularEnsembleIdent[], parameterIdents: ParameterIdent[], filterEnsembleRealizations: EnsembleRealizationFilterFunction ): ParameterDataArr[] { diff --git a/frontend/src/modules/Pvt/interfaces.ts b/frontend/src/modules/Pvt/interfaces.ts index 4e0020e56..9c248dbfd 100644 --- a/frontend/src/modules/Pvt/interfaces.ts +++ b/frontend/src/modules/Pvt/interfaces.ts @@ -1,4 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; import { selectedColorByAtom, selectedDependentVariablesAtom, selectedPhaseAtom } from "./settings/atoms/baseAtoms"; @@ -10,7 +10,7 @@ type SettingsToViewInterface = { selectedPhase: PhaseType; selectedColorBy: ColorBy; selectedDependentVariables: PressureDependentVariable[]; - selectedEnsembleIdents: EnsembleIdent[]; + selectedEnsembleIdents: RegularEnsembleIdent[]; selectedPvtNums: number[]; pvtDataQueries: CombinedPvtDataResult; }; diff --git a/frontend/src/modules/Pvt/settings/atoms/baseAtoms.ts b/frontend/src/modules/Pvt/settings/atoms/baseAtoms.ts index 5f7c9cb10..1c9467ea3 100644 --- a/frontend/src/modules/Pvt/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/Pvt/settings/atoms/baseAtoms.ts @@ -1,11 +1,11 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithCompare } from "@framework/utils/atomUtils"; import { ColorBy, PhaseType, PressureDependentVariable } from "@modules/Pvt/typesAndEnums"; import { atom } from "jotai"; import { isEqual } from "lodash"; -function areEnsembleIdentListsEqual(a: EnsembleIdent[], b: EnsembleIdent[]) { +function areEnsembleIdentListsEqual(a: RegularEnsembleIdent[], b: RegularEnsembleIdent[]) { if (a.length !== b.length) { return false; } @@ -26,6 +26,6 @@ export const selectedDependentVariablesAtom = atom( PressureDependentVariable.FLUID_RATIO, ]); -export const userSelectedEnsembleIdentsAtom = atomWithCompare([], areEnsembleIdentListsEqual); +export const userSelectedEnsembleIdentsAtom = atomWithCompare([], areEnsembleIdentListsEqual); export const userSelectedRealizationsAtom = atomWithCompare([], isEqual); export const userSelectedPvtNumsAtom = atomWithCompare([], isEqual); diff --git a/frontend/src/modules/Pvt/settings/atoms/derivedAtoms.ts b/frontend/src/modules/Pvt/settings/atoms/derivedAtoms.ts index 9c5525279..0bdcd8964 100644 --- a/frontend/src/modules/Pvt/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/Pvt/settings/atoms/derivedAtoms.ts @@ -13,8 +13,8 @@ export const selectedEnsembleIdentsAtom = atom((get) => { const userSelectedEnsembleIdents = get(userSelectedEnsembleIdentsAtom); let computedEnsembleIdents = userSelectedEnsembleIdents.filter((el) => ensembleSet.hasEnsemble(el)); - if (computedEnsembleIdents.length === 0 && ensembleSet.getEnsembleArray().length > 0) { - computedEnsembleIdents = [ensembleSet.getEnsembleArray()[0].getIdent()]; + if (computedEnsembleIdents.length === 0 && ensembleSet.getRegularEnsembleArray().length > 0) { + computedEnsembleIdents = [ensembleSet.getRegularEnsembleArray()[0].getIdent()]; } return computedEnsembleIdents; diff --git a/frontend/src/modules/Pvt/settings/atoms/queryAtoms.ts b/frontend/src/modules/Pvt/settings/atoms/queryAtoms.ts index e07665f4c..cd2192d59 100644 --- a/frontend/src/modules/Pvt/settings/atoms/queryAtoms.ts +++ b/frontend/src/modules/Pvt/settings/atoms/queryAtoms.ts @@ -1,6 +1,6 @@ import { ApiError, PvtData_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithQueries } from "@framework/utils/atomUtils"; import { UseQueryResult } from "@tanstack/react-query"; @@ -15,7 +15,7 @@ export const pvtDataQueriesAtom = atomWithQueries((get) => { const selectedEnsembleIdents = get(selectedEnsembleIdentsAtom); const selectedRealizations = get(selectedRealizationsAtom); - const ensembleIdentsAndRealizations: { ensembleIdent: EnsembleIdent; realization: number }[] = []; + const ensembleIdentsAndRealizations: { ensembleIdent: RegularEnsembleIdent; realization: number }[] = []; for (const ensembleIdent of selectedEnsembleIdents) { for (const realization of selectedRealizations) { ensembleIdentsAndRealizations.push({ ensembleIdent, realization }); diff --git a/frontend/src/modules/Pvt/settings/settings.tsx b/frontend/src/modules/Pvt/settings/settings.tsx index d36e9ffd4..eebda91b8 100644 --- a/frontend/src/modules/Pvt/settings/settings.tsx +++ b/frontend/src/modules/Pvt/settings/settings.tsx @@ -1,7 +1,7 @@ import React from "react"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useEnsembleRealizationFilterFunc, useEnsembleSet } from "@framework/WorkbenchSession"; import { EnsembleSelect } from "@framework/components/EnsembleSelect"; import { CollapsibleGroup } from "@lib/components/CollapsibleGroup"; @@ -57,11 +57,11 @@ export function Settings({ workbenchSession }: ModuleSettingsProps) const [selectedDependentVariables, setSelectedPlots] = useAtom(selectedDependentVariablesAtom); const [selectedMultiEnsembleIdents, setSelectedMultiEnsembleIdents] = - React.useState(selectedEnsembleIdents); + React.useState(selectedEnsembleIdents); const [selectedMultiRealizations, setSelectedMultiRealizations] = React.useState(selectedRealizations); const [selectedMultiPvtNums, setSelectedMultiPvtNums] = React.useState(selectedPvtNums); - function handleEnsembleSelectionChange(ensembleIdents: EnsembleIdent[]) { + function handleEnsembleSelectionChange(ensembleIdents: RegularEnsembleIdent[]) { setSelectedEnsembleIdents(ensembleIdents); setSelectedMultiEnsembleIdents(ensembleIdents); } diff --git a/frontend/src/modules/Pvt/settingsToViewInterface.ts b/frontend/src/modules/Pvt/settingsToViewInterface.ts index 96631ddf1..bf6d41d69 100644 --- a/frontend/src/modules/Pvt/settingsToViewInterface.ts +++ b/frontend/src/modules/Pvt/settingsToViewInterface.ts @@ -1,4 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; import { selectedColorByAtom, selectedDependentVariablesAtom, selectedPhaseAtom } from "./settings/atoms/baseAtoms"; @@ -12,7 +12,7 @@ export type SettingsToViewInterface = { selectedPhase: PhaseType; selectedColorBy: ColorBy; selectedDependentVariables: PressureDependentVariable[]; - selectedEnsembleIdents: EnsembleIdent[]; + selectedEnsembleIdents: RegularEnsembleIdent[]; selectedPvtNums: number[]; pvtDataQueries: CombinedPvtDataResult; }; diff --git a/frontend/src/modules/Pvt/typesAndEnums.ts b/frontend/src/modules/Pvt/typesAndEnums.ts index 8e30ec40b..04c89eb43 100644 --- a/frontend/src/modules/Pvt/typesAndEnums.ts +++ b/frontend/src/modules/Pvt/typesAndEnums.ts @@ -1,5 +1,5 @@ import { ApiError, PvtData_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; export enum ColorBy { ENSEMBLE = "ensemble", @@ -38,7 +38,7 @@ export type Phase = { }; export type PvtTableCollection = { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; realization: number; tables: PvtData_api[]; }; diff --git a/frontend/src/modules/Pvt/utils/PvtPlotBuilder.ts b/frontend/src/modules/Pvt/utils/PvtPlotBuilder.ts index 231adeb95..9a63f9ca0 100644 --- a/frontend/src/modules/Pvt/utils/PvtPlotBuilder.ts +++ b/frontend/src/modules/Pvt/utils/PvtPlotBuilder.ts @@ -1,5 +1,5 @@ import { PvtData_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { ColorSet } from "@lib/utils/ColorSet"; import { Size2D } from "@lib/utils/geometry"; import { Figure, makeSubplots } from "@modules/_shared/Figure"; @@ -25,9 +25,12 @@ export class PvtPlotBuilder { private readonly _pvtDataAccessor: PvtDataAccessor; private _figure: Figure | null = null; private _numPlots = 0; - private readonly _makeEnsembleDisplayNameFunc: (ensemble: EnsembleIdent) => string; + private readonly _makeEnsembleDisplayNameFunc: (ensemble: RegularEnsembleIdent) => string; - constructor(pvtDataAccessor: PvtDataAccessor, makeEnsembleDisplayNameFunc: (ensemble: EnsembleIdent) => string) { + constructor( + pvtDataAccessor: PvtDataAccessor, + makeEnsembleDisplayNameFunc: (ensemble: RegularEnsembleIdent) => string + ) { this._pvtDataAccessor = pvtDataAccessor; this._makeEnsembleDisplayNameFunc = makeEnsembleDisplayNameFunc; } @@ -290,7 +293,7 @@ export class PvtPlotBuilder { ratios: readonly number[], pvtNum: number, phase: PhaseType, - ensembleIdent: EnsembleIdent, + ensembleIdent: RegularEnsembleIdent, realization: number ): string[] { const nameY = PRESSURE_DEPENDENT_VARIABLE_TO_DISPLAY_NAME[dependentVariable]; diff --git a/frontend/src/modules/Pvt/utils/realizationsIntersection.ts b/frontend/src/modules/Pvt/utils/realizationsIntersection.ts index 4d8009cc6..2295946ac 100644 --- a/frontend/src/modules/Pvt/utils/realizationsIntersection.ts +++ b/frontend/src/modules/Pvt/utils/realizationsIntersection.ts @@ -1,8 +1,8 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { EnsembleRealizationFilterFunction } from "@framework/WorkbenchSession"; export function computeRealizationsIntersection( - ensembleIdents: EnsembleIdent[], + ensembleIdents: RegularEnsembleIdent[], filterEnsembleRealizations: EnsembleRealizationFilterFunction ) { let realizationsIntersection: number[] = []; diff --git a/frontend/src/modules/Pvt/view.tsx b/frontend/src/modules/Pvt/view.tsx index f76bc234c..90a00def2 100644 --- a/frontend/src/modules/Pvt/view.tsx +++ b/frontend/src/modules/Pvt/view.tsx @@ -1,8 +1,8 @@ import React from "react"; -import { Ensemble } from "@framework/Ensemble"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleViewProps } from "@framework/Module"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useViewStatusWriter } from "@framework/StatusWriter"; import { useEnsembleSet } from "@framework/WorkbenchSession"; import { ApiErrorHelper } from "@framework/utils/ApiErrorHelper"; @@ -69,7 +69,7 @@ export function View({ viewContext, workbenchSettings, workbenchSession }: Modul return No plots selected.; } - const selectedEnsembles: Ensemble[] = []; + const selectedEnsembles: RegularEnsemble[] = []; for (const ensembleIdent of selectedEnsembleIdents) { const ensemble = ensembleSet.findEnsemble(ensembleIdent); if (ensemble) { @@ -77,7 +77,7 @@ export function View({ viewContext, workbenchSettings, workbenchSession }: Modul } } - function makeEnsembleDisplayName(ensembleIdent: EnsembleIdent): string { + function makeEnsembleDisplayName(ensembleIdent: RegularEnsembleIdent): string { return makeDistinguishableEnsembleDisplayName(ensembleIdent, selectedEnsembles); } diff --git a/frontend/src/modules/Rft/settings.tsx b/frontend/src/modules/Rft/settings.tsx index be04a0c2a..e10f33201 100644 --- a/frontend/src/modules/Rft/settings.tsx +++ b/frontend/src/modules/Rft/settings.tsx @@ -1,7 +1,7 @@ import React from "react"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useSettingsStatusWriter } from "@framework/StatusWriter"; import { useEnsembleRealizationFilterFunc, useEnsembleSet } from "@framework/WorkbenchSession"; import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; @@ -71,7 +71,7 @@ export function Settings({ settingsContext, workbenchSession }: ModuleSettingsPr const rftTableDefErrorMessage = usePropagateApiErrorToStatusWriter(rftTableDefinition, statusWriter) ?? ""; - function handleEnsembleSelectionChange(ensembleIdent: EnsembleIdent | null) { + function handleEnsembleSelectionChange(ensembleIdent: RegularEnsembleIdent | null) { setUserSelectedEnsembleIdent(ensembleIdent); } function handleResponseNameChange(responseNames: string[]) { diff --git a/frontend/src/modules/Rft/settings/atoms/baseAtoms.ts b/frontend/src/modules/Rft/settings/atoms/baseAtoms.ts index 204f10cc6..32e94e4bc 100644 --- a/frontend/src/modules/Rft/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/Rft/settings/atoms/baseAtoms.ts @@ -1,16 +1,16 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithCompare } from "@framework/utils/atomUtils"; import { atom } from "jotai"; -function areEnsembleIdentsEqual(a: EnsembleIdent | null, b: EnsembleIdent | null) { +function areEnsembleIdentsEqual(a: RegularEnsembleIdent | null, b: RegularEnsembleIdent | null) { if (a === null) { return b === null; } return a.equals(b); } -export const userSelectedEnsembleIdentAtom = atomWithCompare(null, areEnsembleIdentsEqual); +export const userSelectedEnsembleIdentAtom = atomWithCompare(null, areEnsembleIdentsEqual); export const validRealizationNumbersAtom = atom(null); export const userSelectedResponseNameAtom = atom(null); export const userSelectedWellNameAtom = atom(null); diff --git a/frontend/src/modules/Rft/settings/atoms/derivedAtoms.ts b/frontend/src/modules/Rft/settings/atoms/derivedAtoms.ts index e43207228..ebc3672b3 100644 --- a/frontend/src/modules/Rft/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/Rft/settings/atoms/derivedAtoms.ts @@ -1,5 +1,5 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { fixupEnsembleIdent } from "@framework/utils/ensembleUiHelpers"; import { atom } from "jotai"; @@ -26,7 +26,7 @@ function fixupSelectedOrFirstValue(selectedValue: T | return null; } -export const selectedEnsembleIdentAtom = atom((get) => { +export const selectedEnsembleIdentAtom = atom((get) => { const ensembleSet = get(EnsembleSetAtom); const userSelectedEnsembleIdent = get(userSelectedEnsembleIdentAtom); diff --git a/frontend/src/modules/SimulationTimeSeries/dataGenerators.ts b/frontend/src/modules/SimulationTimeSeries/dataGenerators.ts index c55845a42..b8d2775b2 100644 --- a/frontend/src/modules/SimulationTimeSeries/dataGenerators.ts +++ b/frontend/src/modules/SimulationTimeSeries/dataGenerators.ts @@ -1,13 +1,13 @@ import { VectorRealizationData_api } from "@api"; import { ChannelContentMetaData, DataGenerator } from "@framework/DataChannelTypes"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { simulationUnitReformat, simulationVectorDescription } from "@modules/_shared/reservoirSimulationStringUtils"; import { VectorSpec } from "./typesAndEnums"; // As of now, the publish to data channels only supports regular ensembles export interface RegularEnsembleVectorSpec extends VectorSpec { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; } export function makeVectorGroupDataGenerator( @@ -17,7 +17,7 @@ export function makeVectorGroupDataGenerator( data: VectorRealizationData_api[]; }[], activeTimestampUtcMs: number, - makeEnsembleDisplayName: (ensembleIdent: EnsembleIdent) => string + makeEnsembleDisplayName: (ensembleIdent: RegularEnsembleIdent) => string ): DataGenerator { return () => { const data: { key: number; value: number }[] = []; diff --git a/frontend/src/modules/SimulationTimeSeries/interfaces.ts b/frontend/src/modules/SimulationTimeSeries/interfaces.ts index c0dbefd53..c1e0fbf81 100644 --- a/frontend/src/modules/SimulationTimeSeries/interfaces.ts +++ b/frontend/src/modules/SimulationTimeSeries/interfaces.ts @@ -1,7 +1,7 @@ import { Frequency_api } from "@api"; import { DeltaEnsemble } from "@framework/DeltaEnsemble"; -import { Ensemble } from "@framework/Ensemble"; import { ParameterIdent } from "@framework/EnsembleParameters"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; import { @@ -16,7 +16,7 @@ import { import { parameterIdentAtom, selectedDeltaEnsemblesAtom, - selectedEnsemblesAtom, + selectedRegularEnsemblesAtom, vectorSpecificationsAtom, } from "./settings/atoms/derivedAtoms"; import { GroupBy, StatisticsSelection, VectorSpec, VisualizationMode } from "./typesAndEnums"; @@ -30,7 +30,7 @@ export type SettingsToViewInterface = { statisticsSelection: StatisticsSelection; colorByParameter: boolean; parameterIdent: ParameterIdent | null; - selectedEnsembles: Ensemble[]; + selectedRegularEnsembles: RegularEnsemble[]; selectedDeltaEnsembles: DeltaEnsemble[]; resampleFrequency: Frequency_api | null; }; @@ -64,8 +64,8 @@ export const settingsToViewInterfaceInitialization: InterfaceInitialization { return get(parameterIdentAtom); }, - selectedEnsembles: (get) => { - return get(selectedEnsemblesAtom); + selectedRegularEnsembles: (get) => { + return get(selectedRegularEnsemblesAtom); }, selectedDeltaEnsembles: (get) => { return get(selectedDeltaEnsemblesAtom); diff --git a/frontend/src/modules/SimulationTimeSeries/settings/atoms/baseAtoms.ts b/frontend/src/modules/SimulationTimeSeries/settings/atoms/baseAtoms.ts index 6fc77473d..859de48eb 100644 --- a/frontend/src/modules/SimulationTimeSeries/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/SimulationTimeSeries/settings/atoms/baseAtoms.ts @@ -1,7 +1,7 @@ import { Frequency_api, StatisticFunction_api } from "@api"; import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ParameterIdent } from "@framework/EnsembleParameters"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithCompare } from "@framework/utils/atomUtils"; import { atom } from "jotai"; @@ -26,7 +26,10 @@ export const statisticsSelectionAtom = atom({ FanchartStatisticsSelection: Object.values(FanchartStatisticOption), }); -export const userSelectedEnsembleIdentsAtom = atomWithCompare<(EnsembleIdent | DeltaEnsembleIdent)[]>([], isEqual); +export const userSelectedEnsembleIdentsAtom = atomWithCompare<(RegularEnsembleIdent | DeltaEnsembleIdent)[]>( + [], + isEqual +); export const selectedVectorNamesAtom = atomWithCompare([], isEqual); diff --git a/frontend/src/modules/SimulationTimeSeries/settings/atoms/derivedAtoms.ts b/frontend/src/modules/SimulationTimeSeries/settings/atoms/derivedAtoms.ts index 98f3ffb2e..aa2103ca6 100644 --- a/frontend/src/modules/SimulationTimeSeries/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/SimulationTimeSeries/settings/atoms/derivedAtoms.ts @@ -1,9 +1,9 @@ import { DeltaEnsemble } from "@framework/DeltaEnsemble"; import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { Ensemble } from "@framework/Ensemble"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { Parameter, ParameterIdent, ParameterType } from "@framework/EnsembleParameters"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { filterEnsembleIdentsByType } from "@framework/utils/ensembleIdentUtils"; import { fixupEnsembleIdents } from "@framework/utils/ensembleUiHelpers"; import { createVectorSelectorDataFromVectors } from "@modules/_shared/components/VectorSelector"; @@ -32,7 +32,7 @@ export const statisticsTypeAtom = atom((get) => { return StatisticsType.INDIVIDUAL; }); -export const selectedEnsembleIdentsAtom = atom<(EnsembleIdent | DeltaEnsembleIdent)[]>((get) => { +export const selectedEnsembleIdentsAtom = atom<(RegularEnsembleIdent | DeltaEnsembleIdent)[]>((get) => { const ensembleSet = get(EnsembleSetAtom); const selectedEnsembleIdents = get(userSelectedEnsembleIdentsAtom); @@ -42,14 +42,14 @@ export const selectedEnsembleIdentsAtom = atom<(EnsembleIdent | DeltaEnsembleIde return validatedEnsembleIdents ?? []; }); -export const selectedEnsemblesAtom = atom((get) => { +export const selectedRegularEnsemblesAtom = atom((get) => { // NOTE: Used for view and color by parameter, i.e. not for delta ensembles yet! const ensembleSet = get(EnsembleSetAtom); const allSelectedEnsembleIdents = get(selectedEnsembleIdentsAtom); - const selectedEnsembleIdents = filterEnsembleIdentsByType(allSelectedEnsembleIdents, EnsembleIdent); + const selectedEnsembleIdents = filterEnsembleIdentsByType(allSelectedEnsembleIdents, RegularEnsembleIdent); - const selectedEnsembles: Ensemble[] = []; + const selectedEnsembles: RegularEnsemble[] = []; for (const ensembleIdent of selectedEnsembleIdents) { const ensemble = ensembleSet.findEnsemble(ensembleIdent); if (ensemble) { @@ -87,7 +87,7 @@ export const continuousAndNonConstantParametersUnionAtom = atom((ge } const continuousAndNonConstantParametersUnion: Parameter[] = []; - const regularEnsembleIdents = filterEnsembleIdentsByType(selectedEnsembleIdents, EnsembleIdent); + const regularEnsembleIdents = filterEnsembleIdentsByType(selectedEnsembleIdents, RegularEnsembleIdent); for (const ensembleIdent of regularEnsembleIdents) { const ensemble = ensembleSet.findEnsemble(ensembleIdent); if (!ensemble) { diff --git a/frontend/src/modules/SimulationTimeSeries/settings/atoms/queryAtoms.ts b/frontend/src/modules/SimulationTimeSeries/settings/atoms/queryAtoms.ts index f25e4b8f1..c52e3546f 100644 --- a/frontend/src/modules/SimulationTimeSeries/settings/atoms/queryAtoms.ts +++ b/frontend/src/modules/SimulationTimeSeries/settings/atoms/queryAtoms.ts @@ -1,6 +1,6 @@ import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithQueries } from "@framework/utils/atomUtils"; import { isEnsembleIdentOfType } from "@framework/utils/ensembleIdentUtils"; @@ -15,7 +15,7 @@ export const vectorListQueriesAtom = atomWithQueries((get) => { const queries = selectedEnsembleIdents.map((ensembleIdent) => { // Regular Ensemble - if (isEnsembleIdentOfType(ensembleIdent, EnsembleIdent)) { + if (isEnsembleIdentOfType(ensembleIdent, RegularEnsembleIdent)) { return () => ({ queryKey: ["getVectorList", ensembleIdent.toString()], queryFn: () => diff --git a/frontend/src/modules/SimulationTimeSeries/settings/hooks/useMakeSettingsStatusWriterMessages.ts b/frontend/src/modules/SimulationTimeSeries/settings/hooks/useMakeSettingsStatusWriterMessages.ts index 9314a6f33..c2aec5538 100644 --- a/frontend/src/modules/SimulationTimeSeries/settings/hooks/useMakeSettingsStatusWriterMessages.ts +++ b/frontend/src/modules/SimulationTimeSeries/settings/hooks/useMakeSettingsStatusWriterMessages.ts @@ -1,6 +1,6 @@ import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { SettingsStatusWriter } from "@framework/StatusWriter"; import { joinStringArrayToHumanReadableString } from "@modules/SimulationTimeSeries/utils/stringUtils"; @@ -30,7 +30,10 @@ export function useMakeSettingsStatusWriterMessages(statusWriter: SettingsStatus } // Set warning for vector names not existing in a selected ensemble - function validateVectorNamesInEnsemble(vectorNames: string[], ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) { + function validateVectorNamesInEnsemble( + vectorNames: string[], + ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent + ) { if (ensembleIdent instanceof DeltaEnsembleIdent) { return; } diff --git a/frontend/src/modules/SimulationTimeSeries/settings/settings.tsx b/frontend/src/modules/SimulationTimeSeries/settings/settings.tsx index 6089f7000..23a6eb9a3 100644 --- a/frontend/src/modules/SimulationTimeSeries/settings/settings.tsx +++ b/frontend/src/modules/SimulationTimeSeries/settings/settings.tsx @@ -2,9 +2,9 @@ import React from "react"; import { Frequency_api, StatisticFunction_api } from "@api"; import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { Parameter, ParameterIdent } from "@framework/EnsembleParameters"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useSettingsStatusWriter } from "@framework/StatusWriter"; import { useEnsembleSet } from "@framework/WorkbenchSession"; import { EnsembleSelect } from "@framework/components/EnsembleSelect"; @@ -105,7 +105,7 @@ export function Settings({ settingsContext, workbenchSession }: ModuleSettingsPr setUserSelectedParameterIdentStr(null); } - function handleEnsembleSelectChange(ensembleIdentArray: (EnsembleIdent | DeltaEnsembleIdent)[]) { + function handleEnsembleSelectChange(ensembleIdentArray: (RegularEnsembleIdent | DeltaEnsembleIdent)[]) { setUserSelectedEnsembleIdents(ensembleIdentArray); } diff --git a/frontend/src/modules/SimulationTimeSeries/typesAndEnums.ts b/frontend/src/modules/SimulationTimeSeries/typesAndEnums.ts index 2f09a9f84..2ee155d88 100644 --- a/frontend/src/modules/SimulationTimeSeries/typesAndEnums.ts +++ b/frontend/src/modules/SimulationTimeSeries/typesAndEnums.ts @@ -1,6 +1,6 @@ import { Frequency_api, StatisticFunction_api, SummaryVectorObservations_api } from "@api"; import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; /** * Definition of ensemble vector observation data @@ -16,7 +16,7 @@ export type EnsembleVectorObservationData = { /** * Definition of map of ensemble ident and ensemble vector observation data */ -export type EnsembleVectorObservationDataMap = Map; +export type EnsembleVectorObservationDataMap = Map; /** * Definition of vector observations queries result for combined queries @@ -28,7 +28,7 @@ export type VectorObservationsQueriesResult = { }; export interface VectorSpec { - ensembleIdent: EnsembleIdent | DeltaEnsembleIdent; + ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent; color: string | null; vectorName: string; hasHistoricalVector: boolean; diff --git a/frontend/src/modules/SimulationTimeSeries/utils/ensemblesVectorListHelper.ts b/frontend/src/modules/SimulationTimeSeries/utils/ensemblesVectorListHelper.ts index 7118a9e24..350e8f406 100644 --- a/frontend/src/modules/SimulationTimeSeries/utils/ensemblesVectorListHelper.ts +++ b/frontend/src/modules/SimulationTimeSeries/utils/ensemblesVectorListHelper.ts @@ -1,6 +1,6 @@ import { VectorDescription_api } from "@api"; import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { UseQueryResult } from "@tanstack/react-query"; /** @@ -9,11 +9,11 @@ import { UseQueryResult } from "@tanstack/react-query"; * Assuming that the order of ensembles and queries is the same */ export class EnsembleVectorListsHelper { - private _ensembleIdents: (EnsembleIdent | DeltaEnsembleIdent)[]; + private _ensembleIdents: (RegularEnsembleIdent | DeltaEnsembleIdent)[]; private _queries: UseQueryResult[]; constructor( - ensembleIdents: (EnsembleIdent | DeltaEnsembleIdent)[], + ensembleIdents: (RegularEnsembleIdent | DeltaEnsembleIdent)[], vectorListQueryResults: UseQueryResult[] ) { if (ensembleIdents.length !== vectorListQueryResults.length) { @@ -54,11 +54,11 @@ export class EnsembleVectorListsHelper { /** * Check if vector is in the requested ensembles * - * @param ensembleIdent - EnsembleIdent to check + * @param ensembleIdent - RegularEnsembleIdent or DeltaEnsembleIdent to check * @param vector - Vector name to look for * @returns True if vector is in the ensemble query data, false otherwise */ - isVectorInEnsemble(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent, vector: string): boolean { + isVectorInEnsemble(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent, vector: string): boolean { const index = this.findIndexOfEnsembleIdent(ensembleIdent); if (index === -1 || !this._queries[index].data) return false; @@ -69,11 +69,11 @@ export class EnsembleVectorListsHelper { /** * Check if vector has historical vector in the ensemble * - * @param ensembleIdent - EnsembleIdent to check + * @param ensembleIdent - RegularEnsembleIdent or DeltaEnsembleIdent to check * @param vector - Vector name to look for * @returns True if vector has historical vector in the ensemble query data, false otherwise */ - hasHistoricalVector(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent, vector: string): boolean { + hasHistoricalVector(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent, vector: string): boolean { if (!this.isVectorInEnsemble(ensembleIdent, vector)) return false; const index = this.findIndexOfEnsembleIdent(ensembleIdent); @@ -96,10 +96,10 @@ export class EnsembleVectorListsHelper { /** * Find index of the provided ensemble ident in the list of ensembles - * @param ensembleIdent - EnsembleIdent or DeltaEnsembleIdent to find + * @param ensembleIdent - RegularEnsembleIdent or DeltaEnsembleIdent to find * @returns Index of the ensemble ident in the list, or -1 if not found */ - private findIndexOfEnsembleIdent(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent): number { + private findIndexOfEnsembleIdent(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent): number { return this._ensembleIdents.findIndex((ident) => { return ident.equals(ensembleIdent); }); diff --git a/frontend/src/modules/SimulationTimeSeries/view/atoms/derivedAtoms.ts b/frontend/src/modules/SimulationTimeSeries/view/atoms/derivedAtoms.ts index 4c639c3ac..f0449d017 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/atoms/derivedAtoms.ts +++ b/frontend/src/modules/SimulationTimeSeries/view/atoms/derivedAtoms.ts @@ -1,4 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { isEnsembleIdentOfType } from "@framework/utils/ensembleIdentUtils"; import { atom } from "jotai"; @@ -36,7 +36,7 @@ export const queryIsFetchingAtom = atom((get) => { export const regularEnsembleVectorSpecificationsAtom = atom((get) => { const vectorSpecifications = get(vectorSpecificationsAtom); - return vectorSpecifications.filter((elm) => isEnsembleIdentOfType(elm.ensembleIdent, EnsembleIdent)); + return vectorSpecifications.filter((elm) => isEnsembleIdentOfType(elm.ensembleIdent, RegularEnsembleIdent)); }); export const realizationsQueryHasErrorAtom = atom((get) => { diff --git a/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts b/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts index f287da05f..3c33666b3 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 { ValidEnsembleRealizationsFunctionAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithQueries } from "@framework/utils/atomUtils"; import { isEnsembleIdentOfType } from "@framework/utils/ensembleIdentUtils"; import { EnsembleVectorObservationDataMap, VisualizationMode } from "@modules/SimulationTimeSeries/typesAndEnums"; @@ -30,7 +30,7 @@ export const vectorDataQueriesAtom = atomWithQueries((get) => { const queries = vectorSpecifications.map((item) => { // Regular Ensemble - if (isEnsembleIdentOfType(item.ensembleIdent, EnsembleIdent)) { + if (isEnsembleIdentOfType(item.ensembleIdent, RegularEnsembleIdent)) { const realizations = [...validEnsembleRealizationsFunction(item.ensembleIdent)]; const vectorSpecification = { ...item, @@ -121,7 +121,7 @@ export const vectorStatisticsQueriesAtom = atomWithQueries((get) => { const queries = vectorSpecifications.map((item) => { // Regular Ensemble - if (isEnsembleIdentOfType(item.ensembleIdent, EnsembleIdent)) { + if (isEnsembleIdentOfType(item.ensembleIdent, RegularEnsembleIdent)) { const realizations = [...validEnsembleRealizationsFunction(item.ensembleIdent)]; const vectorSpecification = { ...item, @@ -209,7 +209,7 @@ export const regularEnsembleHistoricalVectorDataQueriesAtom = atomWithQueries((g const queries = regularEnsembleVectorSpecifications.map((item) => { const vectorSpecification = { ...item, - ensembleIdent: item.ensembleIdent as EnsembleIdent, + ensembleIdent: item.ensembleIdent as RegularEnsembleIdent, }; return () => ({ @@ -250,8 +250,8 @@ export const vectorObservationsQueriesAtom = atomWithQueries((get) => { const uniqueEnsembleIdents = [ ...new Set( vectorSpecifications - ?.filter((item) => item.ensembleIdent instanceof EnsembleIdent) - .map((item) => item.ensembleIdent as EnsembleIdent) ?? [] + ?.filter((item) => item.ensembleIdent instanceof RegularEnsembleIdent) + .map((item) => item.ensembleIdent as RegularEnsembleIdent) ?? [] ), ]; diff --git a/frontend/src/modules/SimulationTimeSeries/view/hooks/useMakeEnsembleDisplayNameFunc.ts b/frontend/src/modules/SimulationTimeSeries/view/hooks/useMakeEnsembleDisplayNameFunc.ts index 2f125cff9..45b76bc28 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/hooks/useMakeEnsembleDisplayNameFunc.ts +++ b/frontend/src/modules/SimulationTimeSeries/view/hooks/useMakeEnsembleDisplayNameFunc.ts @@ -1,17 +1,17 @@ import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ViewContext } from "@framework/ModuleContext"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { Interfaces } from "@modules/SimulationTimeSeries/interfaces"; import { makeDistinguishableEnsembleDisplayName } from "@modules/_shared/ensembleNameUtils"; export function useMakeEnsembleDisplayNameFunc( viewContext: ViewContext -): (ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) => string { - const selectedEnsembles = viewContext.useSettingsToViewInterfaceValue("selectedEnsembles"); +): (ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) => string { + const selectedRegularEnsembles = viewContext.useSettingsToViewInterfaceValue("selectedRegularEnsembles"); const selectedDeltaEnsembles = viewContext.useSettingsToViewInterfaceValue("selectedDeltaEnsembles"); - const allSelectedEnsembles = [...selectedEnsembles, ...selectedDeltaEnsembles]; + const allSelectedEnsembles = [...selectedRegularEnsembles, ...selectedDeltaEnsembles]; - return function makeEnsembleDisplayName(ensembleIdent: EnsembleIdent | DeltaEnsembleIdent): string { + return function makeEnsembleDisplayName(ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent): string { return makeDistinguishableEnsembleDisplayName(ensembleIdent, allSelectedEnsembles); }; } diff --git a/frontend/src/modules/SimulationTimeSeries/view/hooks/useMakeViewStatusWriterMessages.ts b/frontend/src/modules/SimulationTimeSeries/view/hooks/useMakeViewStatusWriterMessages.ts index a00568236..b4ee58745 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/hooks/useMakeViewStatusWriterMessages.ts +++ b/frontend/src/modules/SimulationTimeSeries/view/hooks/useMakeViewStatusWriterMessages.ts @@ -1,6 +1,7 @@ -import { Ensemble } from "@framework/Ensemble"; +import { DeltaEnsemble } from "@framework/DeltaEnsemble"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; import { ViewContext } from "@framework/ModuleContext"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; import { ViewStatusWriter } from "@framework/StatusWriter"; import { Interfaces } from "@modules/SimulationTimeSeries/interfaces"; @@ -18,7 +19,7 @@ export function useMakeViewStatusWriterMessages( viewContext: ViewContext, statusWriter: ViewStatusWriter, parameterDisplayName: string | null, - ensemblesWithoutParameter: Ensemble[] + ensemblesWithoutParameter: (RegularEnsemble | DeltaEnsemble)[] ) { const ensembleSet = useAtomValue(EnsembleSetAtom); const showObservations = viewContext.useSettingsToViewInterfaceValue("showObservations"); diff --git a/frontend/src/modules/SimulationTimeSeries/view/hooks/usePublishToDataChannels.ts b/frontend/src/modules/SimulationTimeSeries/view/hooks/usePublishToDataChannels.ts index a62061433..bb761cfdd 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/hooks/usePublishToDataChannels.ts +++ b/frontend/src/modules/SimulationTimeSeries/view/hooks/usePublishToDataChannels.ts @@ -1,7 +1,7 @@ import { VectorRealizationData_api } from "@api"; import { ChannelContentDefinition } from "@framework/DataChannelTypes"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ViewContext } from "@framework/ModuleContext"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { isEnsembleIdentOfType } from "@framework/utils/ensembleIdentUtils"; import { Interfaces } from "@modules/SimulationTimeSeries/interfaces"; @@ -30,7 +30,7 @@ export function usePublishToDataChannels(viewContext: ViewContext) { data: VectorRealizationData_api[]; }[] = []; for (const elm of loadedVectorSpecificationsAndRealizationData) { - if (!isEnsembleIdentOfType(elm.vectorSpecification.ensembleIdent, EnsembleIdent)) { + if (!isEnsembleIdentOfType(elm.vectorSpecification.ensembleIdent, RegularEnsembleIdent)) { continue; } diff --git a/frontend/src/modules/SimulationTimeSeries/view/utils/ensemblesContinuousParameterColoring.ts b/frontend/src/modules/SimulationTimeSeries/view/utils/ensemblesContinuousParameterColoring.ts index f0d5aafa9..651a49055 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/utils/ensemblesContinuousParameterColoring.ts +++ b/frontend/src/modules/SimulationTimeSeries/view/utils/ensemblesContinuousParameterColoring.ts @@ -1,6 +1,6 @@ -import { Ensemble } from "@framework/Ensemble"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ContinuousParameter, ParameterIdent, ParameterType } from "@framework/EnsembleParameters"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { ColorScale } from "@lib/utils/ColorScale"; import { MinMax } from "@lib/utils/MinMax"; @@ -13,14 +13,14 @@ export class EnsemblesContinuousParameterColoring { */ private _parameterIdent: ParameterIdent; - private _ensembleContinuousParameterMap: Map; + private _ensembleContinuousParameterMap: Map; private _colorScale: ColorScale; - constructor(selectedEnsembles: Ensemble[], parameterIdent: ParameterIdent, colorScale: ColorScale) { + constructor(selectedRegularEnsembles: RegularEnsemble[], parameterIdent: ParameterIdent, colorScale: ColorScale) { this._parameterIdent = parameterIdent; - this._ensembleContinuousParameterMap = new Map(); + this._ensembleContinuousParameterMap = new Map(); let minMax = MinMax.createInvalid(); - for (const ensemble of selectedEnsembles) { + for (const ensemble of selectedRegularEnsembles) { const ensembleParameters = ensemble.getParameters(); const parameter = ensembleParameters.findParameter(parameterIdent); if (!parameter || parameter.type !== ParameterType.CONTINUOUS) continue; @@ -45,18 +45,18 @@ export class EnsemblesContinuousParameterColoring { return this._colorScale; } - hasParameterForEnsemble(ensembleIdent: EnsembleIdent): boolean { + hasParameterForEnsemble(ensembleIdent: RegularEnsembleIdent): boolean { return this._ensembleContinuousParameterMap.has(ensembleIdent); } - hasParameterRealizationValue(ensembleIdent: EnsembleIdent, realization: number): boolean { + hasParameterRealizationValue(ensembleIdent: RegularEnsembleIdent, realization: number): boolean { const parameter = this._ensembleContinuousParameterMap.get(ensembleIdent); if (parameter === undefined) return false; return parameter.realizations.indexOf(realization) !== -1; } - getParameterRealizationValue(ensembleIdent: EnsembleIdent, realization: number): number { + getParameterRealizationValue(ensembleIdent: RegularEnsembleIdent, realization: number): number { if (!this.hasParameterRealizationValue(ensembleIdent, realization)) { throw new Error( `Parameter ${this.getParameterDisplayName()} has no numerical value for realization ${realization} in ensemble ${ensembleIdent.toString()}` diff --git a/frontend/src/modules/SimulationTimeSeries/view/utils/subplotBuilder.ts b/frontend/src/modules/SimulationTimeSeries/view/utils/subplotBuilder.ts index d53bcbef9..f0694c382 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/utils/subplotBuilder.ts +++ b/frontend/src/modules/SimulationTimeSeries/view/utils/subplotBuilder.ts @@ -5,7 +5,7 @@ import { VectorStatisticData_api, } from "@api"; import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { isEnsembleIdentOfType } from "@framework/utils/ensembleIdentUtils"; import { timestampUtcMsToCompactIsoString } from "@framework/utils/timestampUtils"; import { ColorSet } from "@lib/utils/ColorSet"; @@ -47,14 +47,14 @@ export class SubplotBuilder { private _subplotOwner: SubplotOwner; private _addedVectorsLegendTracker: string[] = []; - private _addedEnsemblesLegendTracker: (EnsembleIdent | DeltaEnsembleIdent)[] = []; + private _addedEnsemblesLegendTracker: (RegularEnsembleIdent | DeltaEnsembleIdent)[] = []; - private _uniqueEnsembleIdents: (EnsembleIdent | DeltaEnsembleIdent)[] = []; + private _uniqueEnsembleIdents: (RegularEnsembleIdent | DeltaEnsembleIdent)[] = []; private _uniqueVectorNames: string[] = []; private _vectorHexColors: HexColorMap = {}; - private _makeEnsembleDisplayName: (ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) => string; + private _makeEnsembleDisplayName: (ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) => string; private _hasRealizationsTracesColoredByParameter = false; private _hasHistoryTraces = false; @@ -81,7 +81,7 @@ export class SubplotBuilder { constructor( subplotOwner: SubplotOwner, selectedVectorSpecifications: VectorSpec[], - makeEnsembleDisplayName: (ensembleIdent: EnsembleIdent | DeltaEnsembleIdent) => string, + makeEnsembleDisplayName: (ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent) => string, colorSet: ColorSet, width: number, height: number, @@ -290,7 +290,7 @@ export class SubplotBuilder { if (subplotIndex === -1) continue; const ensembleIdent = elm.vectorSpecification.ensembleIdent; - if (!isEnsembleIdentOfType(ensembleIdent, EnsembleIdent)) continue; + if (!isEnsembleIdentOfType(ensembleIdent, RegularEnsembleIdent)) continue; const hasParameterForEnsemble = this._ensemblesParameterColoring.hasParameterForEnsemble(ensembleIdent); diff --git a/frontend/src/modules/SimulationTimeSeries/view/view.tsx b/frontend/src/modules/SimulationTimeSeries/view/view.tsx index 8db2987de..ff5a45955 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/view.tsx +++ b/frontend/src/modules/SimulationTimeSeries/view/view.tsx @@ -1,8 +1,9 @@ import React from "react"; import Plot from "react-plotly.js"; -import { Ensemble } from "@framework/Ensemble"; +import { DeltaEnsemble } from "@framework/DeltaEnsemble"; import { ModuleViewProps } from "@framework/Module"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; import { useViewStatusWriter } from "@framework/StatusWriter"; import { useElementSize } from "@lib/hooks/useElementSize"; import { ColorScaleGradientType } from "@lib/utils/ColorScale"; @@ -28,7 +29,8 @@ export const View = ({ viewContext, workbenchSettings }: ModuleViewProps) { const ensembleSet = useEnsembleSet(workbenchSession); - const [selectedEnsembleIdent, setSelectedEnsembleIdent] = React.useState(null); + const [selectedEnsembleIdent, setSelectedEnsembleIdent] = React.useState(null); const [selectedVectorName, setSelectedVectorName] = React.useState(null); const [selectedVectorTag, setSelectedVectorTag] = React.useState(null); const [vectorSelectorData, setVectorSelectorData] = React.useState([]); @@ -132,7 +132,7 @@ export function Settings({ settingsContext, workbenchSession, workbenchServices [computedEnsembleIdent, computedVectorName, hasComputedVectorName, hasHistoricalVector, setVectorSpec] ); - function handleEnsembleSelectionChange(newEnsembleIdent: EnsembleIdent | null) { + function handleEnsembleSelectionChange(newEnsembleIdent: RegularEnsembleIdent | null) { setSelectedEnsembleIdent(newEnsembleIdent); if (newEnsembleIdent) { syncHelper.publishValue(SyncSettingKey.ENSEMBLE, "global.syncValue.ensembles", [newEnsembleIdent]); diff --git a/frontend/src/modules/SimulationTimeSeriesSensitivity/typesAndEnums.ts b/frontend/src/modules/SimulationTimeSeriesSensitivity/typesAndEnums.ts index cdfe45b02..088a4cbbb 100644 --- a/frontend/src/modules/SimulationTimeSeriesSensitivity/typesAndEnums.ts +++ b/frontend/src/modules/SimulationTimeSeriesSensitivity/typesAndEnums.ts @@ -1,7 +1,7 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; export interface VectorSpec { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; vectorName: string; hasHistorical: boolean; } diff --git a/frontend/src/modules/SubsurfaceMap/settings/settings.tsx b/frontend/src/modules/SubsurfaceMap/settings/settings.tsx index fbeb5d329..bb412f934 100644 --- a/frontend/src/modules/SubsurfaceMap/settings/settings.tsx +++ b/frontend/src/modules/SubsurfaceMap/settings/settings.tsx @@ -1,8 +1,8 @@ import React from "react"; import { SurfaceAttributeType_api, SurfaceStatisticFunction_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings"; import { useEnsembleSet } from "@framework/WorkbenchSession"; import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; @@ -65,7 +65,7 @@ export function Settings({ settingsContext, workbenchSession, workbenchServices console.debug(`${myInstanceIdStr} -- render TopographicMap settings`); const ensembleSet = useEnsembleSet(workbenchSession); - const [selectedEnsembleIdent, setSelectedEnsembleIdent] = React.useState(null); + const [selectedEnsembleIdent, setSelectedEnsembleIdent] = React.useState(null); const [selectedMeshSurfaceName, setSelectedMeshSurfaceName] = React.useState(null); const [selectedMeshSurfaceAttribute, setSelectedMeshSurfaceAttribute] = React.useState(null); const [usePropertySurface, setUsePropertySurface] = React.useState(false); @@ -379,7 +379,7 @@ export function Settings({ settingsContext, workbenchSession, workbenchServices let fieldIdentifier: null | string = null; if (computedEnsembleIdent) { - const ensembleIdent = new EnsembleIdent( + const ensembleIdent = new RegularEnsembleIdent( computedEnsembleIdent.getCaseUuid(), computedEnsembleIdent.getEnsembleName() ); @@ -409,7 +409,7 @@ export function Settings({ settingsContext, workbenchSession, workbenchServices function hideAllWells() { setSelectedWellUuids([]); } - function handleEnsembleSelectionChange(newEnsembleIdent: EnsembleIdent | null) { + function handleEnsembleSelectionChange(newEnsembleIdent: RegularEnsembleIdent | null) { setSelectedEnsembleIdent(newEnsembleIdent); if (newEnsembleIdent) { syncHelper.publishValue(SyncSettingKey.ENSEMBLE, "global.syncValue.ensembles", [newEnsembleIdent]); diff --git a/frontend/src/modules/SubsurfaceMap/view.tsx b/frontend/src/modules/SubsurfaceMap/view.tsx index 8e88671cc..dbac5bba6 100644 --- a/frontend/src/modules/SubsurfaceMap/view.tsx +++ b/frontend/src/modules/SubsurfaceMap/view.tsx @@ -2,8 +2,8 @@ import React from "react"; import { BoundingBox2d_api, PolygonData_api, SurfaceDef_api, WellboreTrajectory_api } from "@api"; import { ContinuousLegend } from "@emerson-eps/color-tables"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleViewProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings"; import { useEnsembleSet } from "@framework/WorkbenchSession"; import { Wellbore } from "@framework/types/wellbore"; @@ -103,7 +103,7 @@ export function View({ let fieldIdentifier: null | string = null; if (meshSurfAddr) { - const ensembleIdent = new EnsembleIdent(meshSurfAddr.caseUuid, meshSurfAddr.ensemble); + const ensembleIdent = new RegularEnsembleIdent(meshSurfAddr.caseUuid, meshSurfAddr.ensemble); fieldIdentifier = ensembleSet.findEnsemble(ensembleIdent)?.getFieldIdentifier() ?? null; } const wellTrajectoriesQuery = useFieldWellboreTrajectoriesQuery(fieldIdentifier ?? undefined); diff --git a/frontend/src/modules/TornadoChart/settings/settings.tsx b/frontend/src/modules/TornadoChart/settings/settings.tsx index 30e247034..c05db040c 100644 --- a/frontend/src/modules/TornadoChart/settings/settings.tsx +++ b/frontend/src/modules/TornadoChart/settings/settings.tsx @@ -1,8 +1,8 @@ import React from "react"; import { KeyKind } from "@framework/DataChannelTypes"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { Checkbox } from "@lib/components/Checkbox"; import { CollapsibleGroup } from "@lib/components/CollapsibleGroup"; import { Dropdown } from "@lib/components/Dropdown"; @@ -53,7 +53,7 @@ export function Settings({ settingsContext, workbenchSession }: ModuleSettingsPr const ensembleIdentString = responseReceiver.channel.contents[0].metaData.ensembleIdentString; if (typeof ensembleIdentString === "string") { try { - const ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + const ensembleIdent = RegularEnsembleIdent.fromString(ensembleIdentString); const ensemble = ensembleSet.findEnsemble(ensembleIdent); if (ensemble) { sensitivityNames.push( diff --git a/frontend/src/modules/TornadoChart/view/view.tsx b/frontend/src/modules/TornadoChart/view/view.tsx index e09a1449f..2a6369b09 100644 --- a/frontend/src/modules/TornadoChart/view/view.tsx +++ b/frontend/src/modules/TornadoChart/view/view.tsx @@ -1,9 +1,9 @@ import React from "react"; import { KeyKind } from "@framework/DataChannelTypes"; -import { Ensemble } from "@framework/Ensemble"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleViewProps } from "@framework/Module"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useEnsembleSet } from "@framework/WorkbenchSession"; import { Tag } from "@lib/components/Tag"; import { useElementSize } from "@lib/hooks/useElementSize"; @@ -39,7 +39,7 @@ export const View = ({ viewContext, workbenchSession, workbenchSettings }: Modul const realizations: number[] = []; const values: number[] = []; - let channelEnsemble: Ensemble | null = null; + let channelEnsemble: RegularEnsemble | null = null; if (responseReceiver.channel && responseReceiver.channel.contents.length > 0) { const data = responseReceiver.channel.contents[0].dataArray; if (data) { @@ -51,7 +51,7 @@ export const View = ({ viewContext, workbenchSession, workbenchSettings }: Modul if (responseReceiver.channel.contents[0].metaData.ensembleIdentString) { const ensembleIdentString = responseReceiver.channel.contents[0].metaData.ensembleIdentString; if (typeof ensembleIdentString === "string") { - const ensembleIdent = EnsembleIdent.fromString(ensembleIdentString); + const ensembleIdent = RegularEnsembleIdent.fromString(ensembleIdentString); channelEnsemble = ensembleSet.findEnsemble(ensembleIdent); } } diff --git a/frontend/src/modules/Vfp/settings/atoms/baseAtoms.ts b/frontend/src/modules/Vfp/settings/atoms/baseAtoms.ts index 143ea37d3..191aa530b 100644 --- a/frontend/src/modules/Vfp/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/Vfp/settings/atoms/baseAtoms.ts @@ -1,10 +1,10 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { atomWithCompare } from "@framework/utils/atomUtils"; import { PressureOption, VfpParam } from "@modules/Vfp/types"; import { atom } from "jotai"; -function areEnsembleIdentsEqual(a: EnsembleIdent | null, b: EnsembleIdent | null) { +function areEnsembleIdentsEqual(a: RegularEnsembleIdent | null, b: RegularEnsembleIdent | null) { if (a === null) { return b === null; } @@ -15,7 +15,7 @@ export const userSelectedRealizationNumberAtom = atom(null); export const validRealizationNumbersAtom = atom(null); -export const userSelectedEnsembleIdentAtom = atomWithCompare(null, areEnsembleIdentsEqual); +export const userSelectedEnsembleIdentAtom = atomWithCompare(null, areEnsembleIdentsEqual); export const userSelectedVfpTableNameAtom = atom(null); diff --git a/frontend/src/modules/Vfp/settings/atoms/derivedAtoms.ts b/frontend/src/modules/Vfp/settings/atoms/derivedAtoms.ts index dec737d7b..ca7eefd2b 100644 --- a/frontend/src/modules/Vfp/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/Vfp/settings/atoms/derivedAtoms.ts @@ -1,6 +1,7 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { fixupEnsembleIdent } from "@framework/utils/ensembleUiHelpers"; +import { isProdTable } from "@modules/Vfp/utils/vfpTableClassifier"; import { atom } from "jotai"; @@ -19,7 +20,6 @@ import { import { vfpTableNamesQueryAtom, vfpTableQueryAtom } from "./queryAtoms"; import { PressureOption, VfpParam } from "../../types"; -import { isProdTable } from "@modules/Vfp/utils/vfpTableClassifier"; export const vfpTableNamesQueryResultAtom = atom((get) => { return get(vfpTableNamesQueryAtom); @@ -30,7 +30,7 @@ export const availableVfpTableNamesAtom = atom((get) => { return vfpTableNamesQueryResult.data?.map((item) => item) ?? []; }); -export const selectedEnsembleIdentAtom = atom((get) => { +export const selectedEnsembleIdentAtom = atom((get) => { const ensembleSet = get(EnsembleSetAtom); const userSelectedEnsembleIdent = get(userSelectedEnsembleIdentAtom); @@ -93,10 +93,10 @@ export const selectedWfrIndicesAtom = atom((get) => { const vfpTable = get(vfpTableQueryAtom).data; const userSelectedWfrIndicies = get(userSelectedWfrIndicesAtom); if (vfpTable === undefined) { - return null + return null; } - if (!(isProdTable(vfpTable))) { - return null + if (!isProdTable(vfpTable)) { + return null; } const wfr_values = vfpTable.wfrValues ?? []; if (wfr_values.length === 0) { @@ -104,7 +104,7 @@ export const selectedWfrIndicesAtom = atom((get) => { } if (!userSelectedWfrIndicies) { return [0]; - } + } return userSelectedWfrIndicies; }); @@ -112,10 +112,10 @@ export const selectedGfrIndicesAtom = atom((get) => { const vfpTable = get(vfpTableQueryAtom).data; const userSelectedGfrIndicies = get(userSelectedGfrIndicesAtom); if (vfpTable === undefined) { - return null + return null; } - if (!(isProdTable(vfpTable))) { - return null + if (!isProdTable(vfpTable)) { + return null; } const gfr_values = vfpTable.gfrValues ?? []; if (gfr_values.length === 0) { @@ -131,10 +131,10 @@ export const selectedAlqIndicesAtom = atom((get) => { const vfpTable = get(vfpTableQueryAtom).data; const userSelectedAlqIndicies = get(userSelectedAlqIndicesAtom); if (vfpTable === undefined) { - return null + return null; } - if (!(isProdTable(vfpTable))) { - return null + if (!isProdTable(vfpTable)) { + return null; } const alq_values = vfpTable.alqValues ?? []; if (alq_values.length === 0) { @@ -159,13 +159,13 @@ export const selectedColorByAtom = atom((get) => { const vfpTable = get(vfpTableQueryAtom).data; const userSelectedColorBy = get(userSelectedColorByAtom); if (vfpTable === undefined) { - return VfpParam.THP + return VfpParam.THP; } if (userSelectedColorBy === null) { - return VfpParam.THP + return VfpParam.THP; } if (!isProdTable(vfpTable) && ["WFR", "GFR", "ALQ"].includes(userSelectedColorBy)) { - return VfpParam.THP + return VfpParam.THP; } - return userSelectedColorBy + return userSelectedColorBy; }); diff --git a/frontend/src/modules/Vfp/settings/settings.tsx b/frontend/src/modules/Vfp/settings/settings.tsx index 7fa0d1944..021528946 100644 --- a/frontend/src/modules/Vfp/settings/settings.tsx +++ b/frontend/src/modules/Vfp/settings/settings.tsx @@ -1,5 +1,5 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useSettingsStatusWriter } from "@framework/StatusWriter"; import { useEnsembleRealizationFilterFunc, useEnsembleSet } from "@framework/WorkbenchSession"; import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; @@ -80,11 +80,11 @@ export function Settings({ workbenchSession, settingsContext }: ModuleSettingsPr const setUserSelectedPressureOption = useSetAtom(userSelectedPressureOptionAtom); const selectedColorBy = useAtomValue(selectedColorByAtom); - const setUserSelectedColorBy = useSetAtom(userSelectedColorByAtom) + const setUserSelectedColorBy = useSetAtom(userSelectedColorByAtom); usePropagateApiErrorToStatusWriter(vfpTableQuery, statusWriter); - function handleEnsembleSelectionChange(ensembleIdent: EnsembleIdent | null) { + function handleEnsembleSelectionChange(ensembleIdent: RegularEnsembleIdent | null) { setUserSelectedEnsembleIdent(ensembleIdent); } @@ -131,17 +131,17 @@ export function Settings({ workbenchSession, settingsContext }: ModuleSettingsPr let gfrLabel = "GFR"; let alqLabel = "ALQ"; const vfpTableData = vfpTableQuery?.data; - let vfpDataAccessor: VfpDataAccessor | null = null - let vfpType: VfpType | null = null + let vfpDataAccessor: VfpDataAccessor | null = null; + let vfpType: VfpType | null = null; if (vfpTableData) { - vfpDataAccessor = new VfpDataAccessor(vfpTableData) - thpLabel = vfpDataAccessor.getVfpParamLabel(VfpParam.THP, true) - vfpType = vfpDataAccessor.getVfpType() - + vfpDataAccessor = new VfpDataAccessor(vfpTableData); + thpLabel = vfpDataAccessor.getVfpParamLabel(VfpParam.THP, true); + vfpType = vfpDataAccessor.getVfpType(); + if (vfpDataAccessor.isProdTable()) { - wfrLabel = vfpDataAccessor.getVfpParamLabel(VfpParam.WFR, true) - gfrLabel = vfpDataAccessor.getVfpParamLabel(VfpParam.GFR, true) - alqLabel = vfpDataAccessor.getVfpParamLabel(VfpParam.ALQ, true) + wfrLabel = vfpDataAccessor.getVfpParamLabel(VfpParam.WFR, true); + gfrLabel = vfpDataAccessor.getVfpParamLabel(VfpParam.GFR, true); + alqLabel = vfpDataAccessor.getVfpParamLabel(VfpParam.ALQ, true); } } @@ -177,44 +177,48 @@ export function Settings({ workbenchSession, settingsContext }: ModuleSettingsPr /> -
- -
} - +
+ + +
+ )} +
@@ -243,13 +246,15 @@ function makeFilterOptions(values: number[] | undefined): SelectOption[] { } function makeColorByOptions(vfpType: VfpType | null, vfpDataAccessor: VfpDataAccessor | null): SelectOption[] { - const options = [{ label: vfpDataAccessor?.getVfpParamLabel(VfpParam.THP, false) ?? "THP", value: VfpParam.THP }] + const options = [{ label: vfpDataAccessor?.getVfpParamLabel(VfpParam.THP, false) ?? "THP", value: VfpParam.THP }]; if (vfpType === VfpType.VFPPROD) { - options.push(...[ - { label: vfpDataAccessor?.getVfpParamLabel(VfpParam.WFR, false) ?? "WFR", value: VfpParam.WFR }, - { label: vfpDataAccessor?.getVfpParamLabel(VfpParam.GFR, false) ?? "GFR", value: VfpParam.GFR }, - { label: vfpDataAccessor?.getVfpParamLabel(VfpParam.ALQ, false) ?? "ALQ", value: VfpParam.ALQ }, - ]) + options.push( + ...[ + { label: vfpDataAccessor?.getVfpParamLabel(VfpParam.WFR, false) ?? "WFR", value: VfpParam.WFR }, + { label: vfpDataAccessor?.getVfpParamLabel(VfpParam.GFR, false) ?? "GFR", value: VfpParam.GFR }, + { label: vfpDataAccessor?.getVfpParamLabel(VfpParam.ALQ, false) ?? "ALQ", value: VfpParam.ALQ }, + ] + ); } - return options + return options; } diff --git a/frontend/src/modules/WellCompletions/settings/atoms/baseAtoms.ts b/frontend/src/modules/WellCompletions/settings/atoms/baseAtoms.ts index 612161372..5b9dbe7f8 100644 --- a/frontend/src/modules/WellCompletions/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/WellCompletions/settings/atoms/baseAtoms.ts @@ -1,11 +1,11 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { ColorSet } from "@lib/utils/ColorSet"; import { RealizationSelection, TimeAggregationSelection } from "@modules/WellCompletions/typesAndEnums"; import { SortDirection, SortWellsBy } from "@webviz/well-completions-plot"; import { atom } from "jotai"; -export const syncedEnsembleIdentsAtom = atom(null); +export const syncedEnsembleIdentsAtom = atom(null); export const selectedStratigraphyColorSetAtom = atom(null); export const userExcludeWellTextAtom = atom(""); export const userSearchWellTextAtom = atom(""); @@ -13,7 +13,7 @@ export const userSelectedCompletionDateIndexAtom = atom(0); export const userSelectedCompletionDateIndexRangeAtom = atom<[number, number]>([0, 0]); export const userSelectedTimeAggregationAtom = atom(TimeAggregationSelection.NONE); export const userSelectedHideZeroCompletionsAtom = atom(false); -export const userSelectedEnsembleIdentAtom = atom(null); +export const userSelectedEnsembleIdentAtom = atom(null); export const userSelectedRealizationNumberAtom = atom(null); export const userSelectedRealizationSelectionAtom = atom(RealizationSelection.AGGREGATED); export const userSelectedSortWellsByAtom = atom(SortWellsBy.WELL_NAME); diff --git a/frontend/src/modules/WellCompletions/settings/atoms/derivedAtoms.ts b/frontend/src/modules/WellCompletions/settings/atoms/derivedAtoms.ts index 6f29bdd60..6d5554870 100644 --- a/frontend/src/modules/WellCompletions/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/WellCompletions/settings/atoms/derivedAtoms.ts @@ -1,5 +1,5 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSetAtom, ValidEnsembleRealizationsFunctionAtom } from "@framework/GlobalAtoms"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { DataLoadingStatus, TimeAggregationSelection } from "@modules/WellCompletions/typesAndEnums"; import { WellCompletionsDataAccessor } from "@modules/WellCompletions/utils/wellCompletionsDataAccessor"; import { PlotData } from "@webviz/well-completions-plot"; @@ -22,7 +22,7 @@ import { } from "./baseAtoms"; import { wellCompletionsQueryAtom } from "./queryAtoms"; -export const selectedEnsembleIdentAtom = atom((get) => { +export const selectedEnsembleIdentAtom = atom((get) => { const syncedEnsembleIdents = get(syncedEnsembleIdentsAtom); const userSelectedEnsembleIdent = get(userSelectedEnsembleIdentAtom); const ensembleSet = get(EnsembleSetAtom); @@ -31,7 +31,7 @@ export const selectedEnsembleIdentAtom = atom((get) => { return syncedEnsembleIdents[0]; } if (userSelectedEnsembleIdent === null || !ensembleSet.hasEnsemble(userSelectedEnsembleIdent)) { - return ensembleSet.getEnsembleArray()[0]?.getIdent() || null; + return ensembleSet.getRegularEnsembleArray()[0]?.getIdent() || null; } return userSelectedEnsembleIdent; }); diff --git a/frontend/src/modules/WellCompletions/settings/settings.tsx b/frontend/src/modules/WellCompletions/settings/settings.tsx index 181a2dde9..d07bcdac9 100644 --- a/frontend/src/modules/WellCompletions/settings/settings.tsx +++ b/frontend/src/modules/WellCompletions/settings/settings.tsx @@ -1,7 +1,7 @@ import React from "react"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { ModuleSettingsProps } from "@framework/Module"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { useSettingsStatusWriter } from "@framework/StatusWriter"; import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings"; import { useEnsembleSet } from "@framework/WorkbenchSession"; @@ -96,7 +96,7 @@ export const Settings = ({ userSelectedSortWellsDirectionAtom ); - const [prevSyncedEnsembleIdents, setPrevSyncedEnsembleIdents] = React.useState(null); + const [prevSyncedEnsembleIdents, setPrevSyncedEnsembleIdents] = React.useState(null); const [prevStratigraphyColorSet, setPrevStratigraphyColorSet] = React.useState(null); const syncedSettingKeys = settingsContext.useSyncedSettingKeys(); @@ -118,7 +118,7 @@ export const Settings = ({ useMakeSettingsStatusWriterMessages(statusWriter); - function handleEnsembleSelectionChange(newEnsembleIdent: EnsembleIdent | null) { + function handleEnsembleSelectionChange(newEnsembleIdent: RegularEnsembleIdent | null) { setUserSelectedEnsembleIdent(newEnsembleIdent); if (newEnsembleIdent) { syncHelper.publishValue(SyncSettingKey.ENSEMBLE, "global.syncValue.ensembles", [newEnsembleIdent]); diff --git a/frontend/src/modules/_shared/InplaceVolumetrics/Table.ts b/frontend/src/modules/_shared/InplaceVolumetrics/Table.ts index 59fb53489..9a451ee9d 100644 --- a/frontend/src/modules/_shared/InplaceVolumetrics/Table.ts +++ b/frontend/src/modules/_shared/InplaceVolumetrics/Table.ts @@ -1,4 +1,4 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { TableCollection } from "./TableCollection"; @@ -148,7 +148,10 @@ export class Table { return row; } - filterRowsByColumn(columnName: string, predicate: (value: string | number | EnsembleIdent) => boolean): Row[] { + filterRowsByColumn( + columnName: string, + predicate: (value: string | number | RegularEnsembleIdent) => boolean + ): Row[] { const columnIndex = this._columns.findIndex((column) => column.getName() === columnName); if (columnIndex === -1) { diff --git a/frontend/src/modules/_shared/InplaceVolumetrics/TableDefinitionsAccessor.ts b/frontend/src/modules/_shared/InplaceVolumetrics/TableDefinitionsAccessor.ts index b5c9ee994..c9265f20f 100644 --- a/frontend/src/modules/_shared/InplaceVolumetrics/TableDefinitionsAccessor.ts +++ b/frontend/src/modules/_shared/InplaceVolumetrics/TableDefinitionsAccessor.ts @@ -4,12 +4,12 @@ import { InplaceVolumetricsIdentifierWithValues_api, InplaceVolumetricsTableDefinition_api, } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { sortResultNames } from "./sortResultNames"; type TableDefinitionsForEnsembleIdent = { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; tableDefinitions: InplaceVolumetricsTableDefinition_api[]; }; @@ -48,7 +48,7 @@ export function makeUniqueTableNamesIntersection( export class TableDefinitionsAccessor { private _tableDefinitions: InplaceVolumetricsTableDefinition_api[]; private _tableNamesFilter: string[]; - private _uniqueEnsembleIdents: EnsembleIdent[]; + private _uniqueEnsembleIdents: RegularEnsembleIdent[]; private _tableNamesIntersection: string[]; private _fluidZonesIntersection: FluidZone_api[] = []; private _resultNamesIntersection: InplaceVolumetricResultName_api[] = []; @@ -135,7 +135,7 @@ export class TableDefinitionsAccessor { this._identifiersWithIntersectionValues = identifiersWithValuesIntersection.sort(); } - getUniqueEnsembleIdents(): EnsembleIdent[] { + getUniqueEnsembleIdents(): RegularEnsembleIdent[] { return this._uniqueEnsembleIdents; } @@ -159,7 +159,7 @@ export class TableDefinitionsAccessor { return !this._tablesNotComparable; } - hasEnsembleIdents(ensembleIdents: EnsembleIdent[]): boolean { + hasEnsembleIdents(ensembleIdents: RegularEnsembleIdent[]): boolean { for (const ensembleIdent of ensembleIdents) { if (!this._uniqueEnsembleIdents.includes(ensembleIdent)) { return false; diff --git a/frontend/src/modules/_shared/InplaceVolumetrics/queryHooks.ts b/frontend/src/modules/_shared/InplaceVolumetrics/queryHooks.ts index 31d9e1340..39452799d 100644 --- a/frontend/src/modules/_shared/InplaceVolumetrics/queryHooks.ts +++ b/frontend/src/modules/_shared/InplaceVolumetrics/queryHooks.ts @@ -7,7 +7,7 @@ import { InplaceVolumetricsIdentifier_api, } from "@api"; import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { InplaceVolumetricsStatisticalTableData, InplaceVolumetricsTableData, @@ -15,7 +15,7 @@ import { import { UseQueryResult } from "@tanstack/react-query"; export type EnsembleIdentWithRealizations = { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; realizations: readonly number[]; }; @@ -48,7 +48,8 @@ export function useGetAggregatedStatisticalTableDataQueries( identifiersWithValues: InplaceVolumetricsIdentifierWithValues_api[], allowEnable: boolean ) { - const uniqueSources: { ensembleIdent: EnsembleIdent; realizations: readonly number[]; tableName: string }[] = []; + const uniqueSources: { ensembleIdent: RegularEnsembleIdent; realizations: readonly number[]; tableName: string }[] = + []; for (const el of ensembleIdentsWithRealizations) { for (const tableName of tableNames) { uniqueSources.push({ ensembleIdent: el.ensembleIdent, realizations: el.realizations, tableName }); @@ -144,7 +145,8 @@ export function useGetAggregatedPerRealizationTableDataQueries( identifiersWithValues: InplaceVolumetricsIdentifierWithValues_api[], allowEnable: boolean ) { - const uniqueSources: { ensembleIdent: EnsembleIdent; realizations: readonly number[]; tableName: string }[] = []; + const uniqueSources: { ensembleIdent: RegularEnsembleIdent; realizations: readonly number[]; tableName: string }[] = + []; for (const el of ensembleIdentsWithRealizations) { for (const tableName of tableNames) { uniqueSources.push({ ensembleIdent: el.ensembleIdent, realizations: el.realizations, tableName }); diff --git a/frontend/src/modules/_shared/InplaceVolumetrics/types.ts b/frontend/src/modules/_shared/InplaceVolumetrics/types.ts index 880f3bc9d..848d92f19 100644 --- a/frontend/src/modules/_shared/InplaceVolumetrics/types.ts +++ b/frontend/src/modules/_shared/InplaceVolumetrics/types.ts @@ -4,18 +4,18 @@ import { InplaceVolumetricTableDataPerFluidSelection_api, InplaceVolumetricsIdentifier_api, } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { Column } from "./Table"; export type InplaceVolumetricsTableData = { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; tableName: string; data: InplaceVolumetricTableDataPerFluidSelection_api; }; export type InplaceVolumetricsStatisticalTableData = { - ensembleIdent: EnsembleIdent; + ensembleIdent: RegularEnsembleIdent; tableName: string; data: InplaceStatisticalVolumetricTableDataPerFluidSelection_api; }; diff --git a/frontend/src/modules/_shared/Surface/SurfaceAddressBuilder.ts b/frontend/src/modules/_shared/Surface/SurfaceAddressBuilder.ts index 34ba220a6..cc1a7ef8d 100644 --- a/frontend/src/modules/_shared/Surface/SurfaceAddressBuilder.ts +++ b/frontend/src/modules/_shared/Surface/SurfaceAddressBuilder.ts @@ -1,5 +1,5 @@ import { SurfaceStatisticFunction_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { SurfaceAddressType } from "./surfaceAddress"; import { ObservedSurfaceAddress, RealizationSurfaceAddress, StatisticalSurfaceAddress } from "./surfaceAddress"; @@ -22,7 +22,7 @@ export class SurfaceAddressBuilder { return this; } - withEnsembleIdent(ensembleIdent: EnsembleIdent): this { + withEnsembleIdent(ensembleIdent: RegularEnsembleIdent): this { this._caseUuid = ensembleIdent.getCaseUuid(); this._ensemble = ensembleIdent.getEnsembleName(); return this; diff --git a/frontend/src/modules/_shared/components/InplaceVolumetricsFilterComponent/inplaceVolumetricsFilterComponent.tsx b/frontend/src/modules/_shared/components/InplaceVolumetricsFilterComponent/inplaceVolumetricsFilterComponent.tsx index 6846512c3..d11be42d2 100644 --- a/frontend/src/modules/_shared/components/InplaceVolumetricsFilterComponent/inplaceVolumetricsFilterComponent.tsx +++ b/frontend/src/modules/_shared/components/InplaceVolumetricsFilterComponent/inplaceVolumetricsFilterComponent.tsx @@ -1,9 +1,9 @@ import React from "react"; import { FluidZone_api, InplaceVolumetricsIdentifierWithValues_api, InplaceVolumetricsIdentifier_api } from "@api"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; import { EnsembleSet } from "@framework/EnsembleSet"; import { SettingsContext } from "@framework/ModuleContext"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings"; import { WorkbenchServices } from "@framework/WorkbenchServices"; import { EnsembleSelect } from "@framework/components/EnsembleSelect"; @@ -21,7 +21,7 @@ export type InplaceVolumetricsFilterComponentProps = { availableTableNames: string[]; availableFluidZones: FluidZone_api[]; availableIdentifiersWithValues: InplaceVolumetricsIdentifierWithValues_api[]; - selectedEnsembleIdents: EnsembleIdent[]; + selectedEnsembleIdents: RegularEnsembleIdent[]; selectedTableNames: string[]; selectedFluidZones: FluidZone_api[]; selectedIdentifiersValues: InplaceVolumetricsIdentifierWithValues_api[]; @@ -34,14 +34,16 @@ export type InplaceVolumetricsFilterComponentProps = { }; export function InplaceVolumetricsFilterComponent(props: InplaceVolumetricsFilterComponentProps): React.ReactNode { - const [ensembleIdents, setEnsembleIdents] = React.useState(props.selectedEnsembleIdents); + const [ensembleIdents, setEnsembleIdents] = React.useState(props.selectedEnsembleIdents); const [tableNames, setTableNames] = React.useState(props.selectedTableNames); const [fluidZones, setFluidZones] = React.useState(props.selectedFluidZones); const [identifiersValues, setIdentifiersValues] = React.useState( props.selectedIdentifiersValues ); - const [prevEnsembleIdents, setPrevEnsembleIdents] = React.useState(props.selectedEnsembleIdents); + const [prevEnsembleIdents, setPrevEnsembleIdents] = React.useState( + props.selectedEnsembleIdents + ); const [prevTableNames, setPrevTableNames] = React.useState(props.selectedTableNames); const [prevFluidZones, setPrevFluidZones] = React.useState(props.selectedFluidZones); const [prevIdentifiersValues, setPrevIdentifiersValues] = React.useState< @@ -169,7 +171,7 @@ export function InplaceVolumetricsFilterComponent(props: InplaceVolumetricsFilte }, props.debounceMs); } - function handleEnsembleIdentsChange(newEnsembleIdents: EnsembleIdent[], publish = true): void { + function handleEnsembleIdentsChange(newEnsembleIdents: RegularEnsembleIdent[], publish = true): void { setEnsembleIdents(newEnsembleIdents); const filter = { ensembleIdents: newEnsembleIdents, diff --git a/frontend/src/modules/_shared/ensembleNameUtils.ts b/frontend/src/modules/_shared/ensembleNameUtils.ts index 5f05bfcb8..3d3b78d8e 100644 --- a/frontend/src/modules/_shared/ensembleNameUtils.ts +++ b/frontend/src/modules/_shared/ensembleNameUtils.ts @@ -1,9 +1,11 @@ -import { EnsembleIdentInterface } from "@framework/EnsembleIdentInterface"; -import { EnsembleInterface } from "@framework/EnsembleInterface"; +import { DeltaEnsemble } from "@framework/DeltaEnsemble"; +import { DeltaEnsembleIdent } from "@framework/DeltaEnsembleIdent"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; export function makeDistinguishableEnsembleDisplayName( - ensembleIdent: EnsembleIdentInterface, - allEnsembles: readonly EnsembleInterface[] + ensembleIdent: RegularEnsembleIdent | DeltaEnsembleIdent, + allEnsembles: readonly (RegularEnsemble | DeltaEnsemble)[] ): string { const ensemble = allEnsembles.find((ensemble) => ensemble.getIdent().equals(ensembleIdent)); diff --git a/frontend/tests/unit/DeltaEnsembleIdent.test.ts b/frontend/tests/unit/DeltaEnsembleIdent.test.ts new file mode 100644 index 000000000..3f4b21f8a --- /dev/null +++ b/frontend/tests/unit/DeltaEnsembleIdent.test.ts @@ -0,0 +1,96 @@ +import { describe, expect, test } from "vitest"; + +import { DeltaEnsembleIdent } from "../../src/framework/DeltaEnsembleIdent"; +import { RegularEnsembleIdent } from "../../src/framework/RegularEnsembleIdent"; + +describe("DeltaEnsembleIdent", () => { + const validUuid = "123e4567-e89b-12d3-a456-426614174000"; + const compareEnsembleIdent = new RegularEnsembleIdent( + "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", + "compare-ensemble-name" + ); + const referenceEnsembleIdent = new RegularEnsembleIdent( + "22222222-aaaa-4444-aaaa-aaaaaaaaaaaa", + "reference-ensemble-name" + ); + + test("should create a valid DeltaEnsembleIdent instance", () => { + const deltaEnsembleIdent = new DeltaEnsembleIdent(validUuid, compareEnsembleIdent, referenceEnsembleIdent); + expect(deltaEnsembleIdent.getUuid()).toBe(validUuid); + expect(deltaEnsembleIdent.getCompareEnsembleIdent()).toBe(compareEnsembleIdent); + expect(deltaEnsembleIdent.getReferenceEnsembleIdent()).toBe(referenceEnsembleIdent); + expect(deltaEnsembleIdent.getEnsembleName()).toBe("(compare-ensemble-name) - (reference-ensemble-name)"); + }); + test("should convert uuid and ensemble ident strings to a single string", () => { + const compareEnsembleIdentString = compareEnsembleIdent.toString(); + const referenceEnsembleIdentString = referenceEnsembleIdent.toString(); + const result = DeltaEnsembleIdent.uuidAndEnsembleIdentStringsToString( + validUuid, + compareEnsembleIdentString, + referenceEnsembleIdentString + ); + expect(result).toBe(`${validUuid}~@@~${compareEnsembleIdentString}~@@~${referenceEnsembleIdentString}`); + }); + + test("should get ensemble ident string matching uuid and ensembles string with separator", () => { + const compareEnsembleIdentString = compareEnsembleIdent.toString(); + const referenceEnsembleIdentString = referenceEnsembleIdent.toString(); + const deltaEnsemble = new DeltaEnsembleIdent(validUuid, compareEnsembleIdent, referenceEnsembleIdent); + const result = deltaEnsemble.toString(); + expect(result).toBe(`${validUuid}~@@~${compareEnsembleIdentString}~@@~${referenceEnsembleIdentString}`); + }); + + test("should create DeltaEnsembleIdent instance from string", () => { + const deltaEnsembleIdentString = `${validUuid}~@@~${compareEnsembleIdent.toString()}~@@~${referenceEnsembleIdent.toString()}`; + const deltaEnsembleIdent = DeltaEnsembleIdent.fromString(deltaEnsembleIdentString); + expect(deltaEnsembleIdent.getUuid()).toBe(validUuid); + expect(deltaEnsembleIdent.getCompareEnsembleIdent().equals(compareEnsembleIdent)).toBe(true); + expect(deltaEnsembleIdent.getReferenceEnsembleIdent().equals(referenceEnsembleIdent)).toBe(true); + }); + + test("should throw an error for invalid UUID", () => { + expect(() => new DeltaEnsembleIdent("invalid-uuid", compareEnsembleIdent, referenceEnsembleIdent)).toThrow(); + }); + + test("should convert to string and back correctly", () => { + const deltaEnsembleIdent = new DeltaEnsembleIdent(validUuid, compareEnsembleIdent, referenceEnsembleIdent); + const deltaEnsembleIdentString = deltaEnsembleIdent.toString(); + const parsedDeltaEnsembleIdent = DeltaEnsembleIdent.fromString(deltaEnsembleIdentString); + expect(parsedDeltaEnsembleIdent.equals(deltaEnsembleIdent)).toBe(true); + }); + + test("should validate a correct DeltaEnsembleIdent string", () => { + const deltaEnsembleIdent = new DeltaEnsembleIdent(validUuid, compareEnsembleIdent, referenceEnsembleIdent); + const deltaEnsembleIdentString = deltaEnsembleIdent.toString(); + expect(DeltaEnsembleIdent.isValidDeltaEnsembleIdentString(deltaEnsembleIdentString)).toBe(true); + }); + + test("should invalidate an incorrect DeltaEnsembleIdent string", () => { + const invalidString = "invalid-string"; + const regularEnsembleString = compareEnsembleIdent.toString(); + expect(DeltaEnsembleIdent.isValidDeltaEnsembleIdentString(invalidString)).toBe(false); + expect(DeltaEnsembleIdent.isValidDeltaEnsembleIdentString(regularEnsembleString)).toBe(false); + }); + + test("should correctly compare two DeltaEnsembleIdent instances", () => { + const deltaEnsembleIdent1 = new DeltaEnsembleIdent(validUuid, compareEnsembleIdent, referenceEnsembleIdent); + const deltaEnsembleIdent2 = new DeltaEnsembleIdent(validUuid, compareEnsembleIdent, referenceEnsembleIdent); + expect(deltaEnsembleIdent1.equals(deltaEnsembleIdent2)).toBe(true); + }); + + test("should correctly identify non-equal DeltaEnsembleIdent instances", () => { + const deltaEnsembleIdent1 = new DeltaEnsembleIdent(validUuid, compareEnsembleIdent, referenceEnsembleIdent); + const deltaEnsembleIdent2 = new DeltaEnsembleIdent( + "33333333-aaaa-4444-aaaa-aaaaaaaaaaaa", + compareEnsembleIdent, + referenceEnsembleIdent + ); + expect(deltaEnsembleIdent1.equals(deltaEnsembleIdent2)).toBe(false); + }); + + test("should return false when comparing with a different type", () => { + const deltaEnsembleIdent = new DeltaEnsembleIdent(validUuid, compareEnsembleIdent, referenceEnsembleIdent); + const regularEnsembleIdent = new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1"); + expect(deltaEnsembleIdent.equals(regularEnsembleIdent)).toBe(false); + }); +}); diff --git a/frontend/tests/unit/EnsembleSet.test.ts b/frontend/tests/unit/EnsembleSet.test.ts index 03ac1d304..34af8c603 100644 --- a/frontend/tests/unit/EnsembleSet.test.ts +++ b/frontend/tests/unit/EnsembleSet.test.ts @@ -1,49 +1,151 @@ -import { Ensemble } from "@framework/Ensemble"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { DeltaEnsemble } from "@framework/DeltaEnsemble"; import { EnsembleSet } from "@framework/EnsembleSet"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; +import { RegularEnsembleIdent } from "@framework/RegularEnsembleIdent"; import { describe, expect, test } from "vitest"; const ensembleArray = [ - new Ensemble("DROGON", "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "case1", "ens1", [], [], null, ""), - new Ensemble("DROGON", "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "case1", "ens2", [], [], null, ""), - new Ensemble("DROGON", "22222222-aaaa-4444-aaaa-aaaaaaaaaaaa", "case2", "ens1", [], [], null, ""), + new RegularEnsemble("DROGON", "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "case1", "ens1", [], [], null, ""), + new RegularEnsemble("DROGON", "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "case1", "ens2", [], [], null, ""), + new RegularEnsemble("DROGON", "22222222-aaaa-4444-aaaa-aaaaaaaaaaaa", "case2", "ens1", [], [], null, ""), +]; + +const deltaEnsembleArray = [ + new DeltaEnsemble(ensembleArray[0], ensembleArray[1], "", null), + new DeltaEnsemble(ensembleArray[0], ensembleArray[2], "", null), ]; describe("EnsembleSet tests", () => { test("access empty EnsembleSet", () => { const ensSet = new EnsembleSet([]); + expect(ensSet.hasAnyRegularEnsembles()).toBe(false); + expect(ensSet.hasAnyDeltaEnsembles()).toBe(false); expect(ensSet.hasAnyEnsembles()).toBe(false); + expect(ensSet.getRegularEnsembleArray().length).toBe(0); + expect(ensSet.getDeltaEnsembleArray().length).toBe(0); expect(ensSet.getEnsembleArray().length).toBe(0); - expect(ensSet.findEnsemble(new EnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1"))).toBeNull(); + expect( + ensSet.findEnsemble(new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1")) + ).toBeNull(); }); - test("has by EnsembleIdent", () => { + test("has any regular ensembles", () => { const ensSet = new EnsembleSet(ensembleArray); + expect(ensSet.hasAnyRegularEnsembles()).toBe(true); + expect(ensSet.hasAnyDeltaEnsembles()).toBe(false); + expect(ensSet.hasAnyEnsembles()).toBe(true); + }); + + test("has any delta ensembles", () => { + const ensSet = new EnsembleSet([], deltaEnsembleArray); + expect(ensSet.hasAnyRegularEnsembles()).toBe(false); + expect(ensSet.hasAnyDeltaEnsembles()).toBe(true); + expect(ensSet.hasAnyEnsembles()).toBe(true); + }); + + test("has any regular ensembles or delta ensembles", () => { + const ensSet = new EnsembleSet(ensembleArray, deltaEnsembleArray); + expect(ensSet.hasAnyRegularEnsembles()).toBe(true); + expect(ensSet.hasAnyDeltaEnsembles()).toBe(true); expect(ensSet.hasAnyEnsembles()).toBe(true); - expect(ensSet.hasEnsemble(new EnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1"))).toBe(true); - expect(ensSet.hasEnsemble(new EnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens99"))).toBe(false); - expect(ensSet.hasEnsemble(new EnsembleIdent("99999999-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1"))).toBe(false); }); - test("find by EnsembleIdent", () => { + test("get regular ensembles", () => { + const ensSet = new EnsembleSet(ensembleArray); + expect(ensSet.getRegularEnsembleArray()).toEqual(ensembleArray); + expect(ensSet.getDeltaEnsembleArray().length).toBe(0); + expect(ensSet.getEnsembleArray()).toEqual(ensembleArray); + }); + + test("get delta ensembles", () => { + const ensSet = new EnsembleSet([], deltaEnsembleArray); + expect(ensSet.getRegularEnsembleArray().length).toBe(0); + expect(ensSet.getDeltaEnsembleArray()).toEqual(deltaEnsembleArray); + expect(ensSet.getEnsembleArray()).toEqual(deltaEnsembleArray); + }); + + test("get regular ensembles and delta ensembles", () => { + const ensSet = new EnsembleSet(ensembleArray, deltaEnsembleArray); + expect(ensSet.getRegularEnsembleArray()).toEqual(ensembleArray); + expect(ensSet.getDeltaEnsembleArray()).toEqual(deltaEnsembleArray); + expect(ensSet.getEnsembleArray()).toEqual([...ensembleArray, ...deltaEnsembleArray]); + }); + + test("has by RegularEnsembleIdent", () => { const ensSet = new EnsembleSet(ensembleArray); + expect(ensSet.hasAnyRegularEnsembles()).toBe(true); + expect(ensSet.hasAnyDeltaEnsembles()).toBe(false); expect(ensSet.hasAnyEnsembles()).toBe(true); - expect(ensSet.findEnsemble(new EnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1"))).toBeInstanceOf( - Ensemble + expect(ensSet.hasEnsemble(new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1"))).toBe(true); + expect(ensSet.hasEnsemble(new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens99"))).toBe( + false ); - expect(ensSet.findEnsemble(new EnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens99"))).toBeNull(); - expect(ensSet.findEnsemble(new EnsembleIdent("99999999-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1"))).toBeNull(); + expect(ensSet.hasEnsemble(new RegularEnsembleIdent("99999999-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1"))).toBe( + false + ); + }); + + test("has by DeltaEnsembleIdent", () => { + const ensSet = new EnsembleSet(ensembleArray, deltaEnsembleArray); + expect(ensSet.hasAnyRegularEnsembles()).toBe(true); + expect(ensSet.hasAnyDeltaEnsembles()).toBe(true); + expect(ensSet.hasAnyEnsembles()).toBe(true); + expect(ensSet.hasEnsemble(deltaEnsembleArray[0].getIdent())).toBe(true); + expect(ensSet.hasEnsemble(deltaEnsembleArray[1].getIdent())).toBe(true); + + const nonExistingDeltaEnsemble = new DeltaEnsemble(ensembleArray[0], ensembleArray[2], "", null); + const ident = nonExistingDeltaEnsemble.getIdent(); + expect(ensSet.hasEnsemble(ident)).toBe(false); + }); + + test("find by RegularEnsembleIdent", () => { + const ensSet = new EnsembleSet(ensembleArray); + expect(ensSet.hasAnyRegularEnsembles()).toBe(true); + expect( + ensSet.findEnsemble(new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1")) + ).toBeInstanceOf(RegularEnsemble); + expect( + ensSet.findEnsemble(new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens99")) + ).toBeNull(); + expect( + ensSet.findEnsemble(new RegularEnsembleIdent("99999999-aaaa-4444-aaaa-aaaaaaaaaaaa", "ens1")) + ).toBeNull(); }); test("find by EnsembleIdentString", () => { const ensSet = new EnsembleSet(ensembleArray); - expect(ensSet.hasAnyEnsembles()).toBe(true); - expect(ensSet.findEnsembleByIdentString("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa::ens1")).toBeInstanceOf(Ensemble); + expect(ensSet.hasAnyRegularEnsembles()).toBe(true); + expect(ensSet.findEnsembleByIdentString("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa::ens1")).toBeInstanceOf( + RegularEnsemble + ); expect(ensSet.findEnsembleByIdentString("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa::ens99")).toBeNull(); expect(ensSet.findEnsembleByIdentString("99999999-aaaa-4444-aaaa-aaaaaaaaaaaa::ens1")).toBeNull(); }); + test("find by DeltaEnsembleIdent", () => { + const ensSet = new EnsembleSet(ensembleArray, deltaEnsembleArray); + expect(ensSet.hasAnyRegularEnsembles()).toBe(true); + expect(ensSet.findEnsemble(deltaEnsembleArray[0].getIdent())).toBeInstanceOf(DeltaEnsemble); + expect(ensSet.findEnsemble(deltaEnsembleArray[1].getIdent())).toBeInstanceOf(DeltaEnsemble); + expect( + ensSet.findEnsemble(new DeltaEnsemble(ensembleArray[0], ensembleArray[2], "", null).getIdent()) + ).toBeNull(); + }); + + test("find by DeltaEnsembleIdentString", () => { + const ensSet = new EnsembleSet([], deltaEnsembleArray); + expect(ensSet.hasAnyDeltaEnsembles()).toBe(true); + const firstString = deltaEnsembleArray[0].getIdent().toString(); + const secondString = deltaEnsembleArray[1].getIdent().toString(); + const invalidDeltaEnsembleIdentString = new DeltaEnsemble(ensembleArray[0], ensembleArray[2], "", null) + .getIdent() + .toString(); + expect(ensSet.findEnsembleByIdentString(firstString)).toBeInstanceOf(DeltaEnsemble); + expect(ensSet.findEnsembleByIdentString(secondString)).toBeInstanceOf(DeltaEnsemble); + expect(ensSet.findEnsembleByIdentString(invalidDeltaEnsembleIdentString)).toBeNull(); + }); + test("find by EnsembleIdentString containing invalid UUID", () => { const ensSet = new EnsembleSet(ensembleArray); expect(ensSet.findEnsembleByIdentString("")).toBeNull(); diff --git a/frontend/tests/unit/RealizationFilter.test.ts b/frontend/tests/unit/RealizationFilter.test.ts index 6a07eadcf..64b891be2 100644 --- a/frontend/tests/unit/RealizationFilter.test.ts +++ b/frontend/tests/unit/RealizationFilter.test.ts @@ -1,4 +1,3 @@ -import { Ensemble } from "@framework/Ensemble"; import { ContinuousParameter, DiscreteParameter, @@ -8,6 +7,7 @@ import { ParameterType, } from "@framework/EnsembleParameters"; import { RealizationFilter } from "@framework/RealizationFilter"; +import { RegularEnsemble } from "@framework/RegularEnsemble"; import { IncludeExcludeFilter, NumberRange, @@ -41,9 +41,9 @@ const SECOND_PARAMETER: Parameter = { values: [10, 10, 20, 25, 20, 30, 30, 30, 30, 40, 40], }; -const FIRST_ENSEMBLE = new Ensemble( +const FIRST_ENSEMBLE = new RegularEnsemble( "DROGON", - "First ensemble UUID", + "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "First case", "First ensemble", FIRST_ENSEMBLE_REALIZATIONS, diff --git a/frontend/tests/unit/RegularEnsembleIdent.test.ts b/frontend/tests/unit/RegularEnsembleIdent.test.ts new file mode 100644 index 000000000..e851d3f64 --- /dev/null +++ b/frontend/tests/unit/RegularEnsembleIdent.test.ts @@ -0,0 +1,88 @@ +import { describe, expect, test } from "vitest"; + +import { RegularEnsembleIdent } from "../../src/framework/RegularEnsembleIdent"; + +describe("RegularEnsembleIdent", () => { + test("should create an instance from caseUuid and ensembleName", () => { + const caseUuid = "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa"; + const ensembleName = "testEnsemble"; + const ensembleIdent = new RegularEnsembleIdent(caseUuid, ensembleName); + expect(ensembleIdent.getCaseUuid()).toBe(caseUuid); + expect(ensembleIdent.getEnsembleName()).toBe(ensembleName); + }); + + test("from case uuid and ensemble name should return a new instance", () => { + const caseUuid = "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa"; + const ensembleName = "testEnsemble"; + const ensembleIdent = RegularEnsembleIdent.fromCaseUuidAndEnsembleName(caseUuid, ensembleName); + expect(ensembleIdent.getCaseUuid()).toBe(caseUuid); + expect(ensembleIdent.getEnsembleName()).toBe(ensembleName); + }); + + test("should create an instance from a string", () => { + const caseUuid = "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa"; + const ensembleName = "testEnsemble"; + const ensembleIdentString = `${caseUuid}::${ensembleName}`; + const ensembleIdent = RegularEnsembleIdent.fromString(ensembleIdentString); + expect(ensembleIdent.getCaseUuid()).toBe(caseUuid); + expect(ensembleIdent.getEnsembleName()).toBe(ensembleName); + }); + + test("should convert caseUuid and ensembleName to string", () => { + const caseUuid = "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa"; + const ensembleName = "testEnsemble"; + const ensembleIdentString = RegularEnsembleIdent.caseUuidAndEnsembleNameToString(caseUuid, ensembleName); + expect(ensembleIdentString).toBe(`${caseUuid}::${ensembleName}`); + }); + + test("should validate a correct ensemble ident string", () => { + const ensembleIdentString = "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa::testEnsemble"; + const isValid = RegularEnsembleIdent.isValidEnsembleIdentString(ensembleIdentString); + expect(isValid).toBe(true); + }); + + test("should invalidate an incorrect ensemble ident string", () => { + const ensembleIdentString = "invalidString"; + const isValid = RegularEnsembleIdent.isValidEnsembleIdentString(ensembleIdentString); + expect(isValid).toBe(false); + }); + + test("should throw an error for an invalid ensemble ident string", () => { + const ensembleIdentString = "invalidString"; + expect(() => RegularEnsembleIdent.fromString(ensembleIdentString)).toThrowError( + `Invalid ensemble ident: ${ensembleIdentString}` + ); + }); + + test("should return the correct string representation", () => { + const caseUuid = "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa"; + const ensembleName = "testEnsemble"; + const ensembleIdent = new RegularEnsembleIdent(caseUuid, ensembleName); + expect(ensembleIdent.toString()).toBe(`${caseUuid}::${ensembleName}`); + }); + + test("should correctly compare two equal EnsembleIdent instances", () => { + const caseUuid = "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa"; + const ensembleName = "testEnsemble"; + const ensembleIdent1 = new RegularEnsembleIdent(caseUuid, ensembleName); + const ensembleIdent2 = new RegularEnsembleIdent(caseUuid, ensembleName); + expect(ensembleIdent1.equals(ensembleIdent2)).toBe(true); + }); + + test("should correctly compare two different EnsembleIdent instances", () => { + const ensembleIdent1 = new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "testEnsemble1"); + const ensembleIdent2 = new RegularEnsembleIdent("22222222-aaaa-4444-aaaa-aaaaaaaaaaaa", "testEnsemble2"); + expect(ensembleIdent1.equals(ensembleIdent2)).toBe(false); + }); + + test("should return false when comparing with null", () => { + const ensembleIdent = new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "testEnsemble"); + expect(ensembleIdent.equals(null)).toBe(false); + }); + + test("should return false when comparing with a different type", () => { + const ensembleIdent = new RegularEnsembleIdent("11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", "testEnsemble"); + const differentType = { _caseUuid: "11111111-aaaa-4444-aaaa-aaaaaaaaaaaa", _ensembleName: "testEnsemble" }; + expect(ensembleIdent.equals(differentType as any)).toBe(false); + }); +});