You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If NEW_VECTOR is a string with length larger than 8 characters, e.g. ROPR_FROM_1_TO_23, the new_vector is not created and no error message is shown.
In both cases, it would be nicer to get a informative error message.
How to reproduce:
In the code below, if new_vector_name = f"{VECTOR_NAME}_S{N_REGIONS}_TEST_LONG:1", the vector is not created, no error messages
But if new_vector_name = f"{VECTOR_NAME}_S{N_REGIONS}:1", then it works
if include list_values.append(0), the vector in not created an no error message is shown.
"""
This script connects to a running ResInsight instance, retrieves summary case data,
calculates the sum of RGIP values across multiple regions, and updates the summary case
with the new calculated values.
Usage:
Ensure a ResInsight instance is running and accessible.
Modify the `new_vector_name` and `case_id` as needed.
The script will output a CSV file named "RGIP_Sum_Region.csv" and update the summary case with the new values.
March 2025
"""
import rips
import pandas as pd
N_REGIONS = 2 # number of regions
VECTOR_NAME = "RGIP"
UNIT = "SM3"
# Connect to a running ResInsight instance
resinsight = rips.Instance.find()
if resinsight:
project = resinsight.project
summary_cases = project.summary_cases()
case_id = 2
# Use the correct case_id, 2 is for GFS_BRENT_FATF_SEP24_BLOCKPRESSURE
# for case in summary_cases:
# print(f"Case ID: {case.id}, Case Name: {case.short_name}")
summary_case = project.summary_case(case_id)
if summary_case is None:
print("No summary case found.")
exit()
max_region = N_REGIONS + 1
new_vector_name = f"{VECTOR_NAME}_S{N_REGIONS}_TEST_LONG:1"
df = pd.DataFrame({f"region_{i}": summary_case.summary_vector_values(f"{VECTOR_NAME}:{i}").values for i in range(1, max_region)})
df[new_vector_name] = df.sum(axis=1)
csv_file_name = f"{VECTOR_NAME}_Sum_Region_1to{N_REGIONS}.csv"
df.to_csv(csv_file_name)
list_values = df[new_vector_name].values.tolist()
summary_case.set_summary_values(new_vector_name, UNIT, list_values)
print(f"Done! New summary vector {new_vector_name} created and updated.")
print(f"For quality check purposes, check {csv_file_name}.")
The text was updated successfully, but these errors were encountered:
If the length of value_vector is larger than expected, the new_vector is not created and no error message is shown.
summary_case.set_summary_values(NEW_VECTOR, "SM3/DAY", value_vector)
If NEW_VECTOR is a string with length larger than 8 characters, e.g. ROPR_FROM_1_TO_23, the new_vector is not created and no error message is shown.
In both cases, it would be nicer to get a informative error message.
How to reproduce:
In the code below, if new_vector_name = f"{VECTOR_NAME}_S{N_REGIONS}_TEST_LONG:1", the vector is not created, no error messages
But if new_vector_name = f"{VECTOR_NAME}_S{N_REGIONS}:1", then it works
if include list_values.append(0), the vector in not created an no error message is shown.
The text was updated successfully, but these errors were encountered: