Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include informative validation error message for summary_case.set_summary_values() #12199

Open
hnformentin opened this issue Mar 3, 2025 · 0 comments
Labels
BugInRelease Bug in an official release

Comments

@hnformentin
Copy link

hnformentin commented Mar 3, 2025

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.

"""
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}.")

@hhgs hhgs added the BugInRelease Bug in an official release label Mar 4, 2025
@hhgs hhgs added this to the Maintenance 2025 - smaller issues milestone Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugInRelease Bug in an official release
Projects
None yet
Development

No branches or pull requests

2 participants