@@ -86,19 +86,21 @@ def read_ert_summary_obs_file(filename: str) -> list[dict]:
8686 raise ValueError (
8787 f"Format error in file: { filename } for line number: { line_number } \n "
8888 )
89- obs_attribute_key = attribute_item [0 ].strip ()
89+ obs_attribute_key = attribute_item [0 ].strip (). lower ()
9090 obs_attribute_value = attribute_item [1 ].strip ()
9191 obs_dict [obs_attribute_key ] = obs_attribute_value
9292
9393 # Get obs_type and wellname
94- ecl_key = obs_dict ["KEY " ]
95- obs_type , well_name = ecl_key .split (":" )
94+ summary_vector = obs_dict ["key " ]
95+ obs_type , well_name = summary_vector .split (":" )
9696
9797 # Add additional info to obs
9898 obs_dict ["ert_id" ] = ert_id .strip ()
9999 obs_dict ["wellname" ] = well_name .strip ()
100100 obs_dict ["obs_type" ] = obs_type .strip ()
101+ obs_dict ["summary_vector" ] = obs_dict ["key" ]
101102 obs_list .append (obs_dict )
103+ # print(f"{obs_dict=}")
102104 if len (obs_list ) == 0 :
103105 raise ValueError (f"No summary observations found in file: { filename } " )
104106 return obs_list
@@ -577,8 +579,7 @@ def write_result_summary_obs(
577579) -> None :
578580 """
579581 Write csv file with following columns:
580- - wellname
581- - obs_type(vector)
582+ - summary_vector
582583 - date
583584 - obs_value
584585 - obs_error
@@ -593,35 +594,28 @@ def write_result_summary_obs(
593594 )
594595 print (f"Write file: { filename } " )
595596
596- rms_well_name_header = "RMS_WELLNAME"
597- obs_type_header = "OBS_TYPE"
597+ summary_vector_header = "SUMMARY_KEY"
598598 date_header = "DATE"
599599 value_header = "VALUE"
600600 error_header = "ERROR"
601601 min_error_header = "MIN_ERROR"
602602 max_error_header = "MAX_ERROR"
603603
604- max_obs_type_length = 8
605- max_well_name_length = 12
604+ max_summary_vector_length = 12
606605 for key , obs_dict in all_obs_dict .items ():
607606 (zone_name , ert_id ) = key
608- obs_type = obs_dict ["obs_type" ]
609- wellname = obs_dict ["wellname" ]
610- if max_obs_type_length < len (obs_type ):
611- max_obs_type_length = len (obs_type )
612- if max_well_name_length < len (wellname ):
613- max_well_name_length = len (wellname )
607+ summary_vector = obs_dict ["summary_vector" ]
608+ if max_summary_vector_length < len (summary_vector ):
609+ max_summary_vector_length = len (summary_vector )
614610
615- max_well_name_length += 2
616- max_obs_type_length += 2
611+ max_summary_vector_length += 2
617612
618613 max_dates_length = 12
619614 max_value_length = 12
620615 with open (filename , "w" ) as file :
621616 # Heading
622617 content = ""
623- content += f"{ rms_well_name_header :<{max_well_name_length }} "
624- content += f"{ obs_type_header :<{max_obs_type_length }} "
618+ content += f"{ summary_vector_header :<{max_summary_vector_length }} "
625619 content += f"{ date_header :<{max_dates_length }} "
626620 content += f"{ value_header :>{max_value_length }} "
627621 content += f"{ error_header :>{max_value_length }} "
@@ -632,16 +626,19 @@ def write_result_summary_obs(
632626
633627 for key , obs_dict in all_obs_dict .items ():
634628 (zone_name , ert_id ) = key
635- obs_type = obs_dict ["obs_type" ]
636- wellname = obs_dict ["wellname" ]
637- value = float (obs_dict ["VALUE" ])
638- error = float (obs_dict ["ERROR" ])
639- date = obs_dict ["DATE" ]
629+ # print(f"obs_dict: {obs_dict=}")
630+ # obs_type = obs_dict["obs_type"]
631+ # wellname = obs_dict["wellname"]
632+ summary_vector = obs_dict ["summary_vector" ]
633+ value = float (obs_dict ["value" ])
634+ error = float (obs_dict ["error" ])
635+ date = obs_dict ["date" ]
640636 min_error = 0.5 * error
641637 max_error = 1.5 * error
642638 content = ""
643- content += f"{ wellname :<{max_well_name_length }} "
644- content += f"{ obs_type :<{max_obs_type_length }} "
639+ # content += f"{wellname:<{max_well_name_length}}"
640+ # content += f"{obs_type:<{max_obs_type_length}}"
641+ content += f"{ summary_vector :<{max_summary_vector_length }} "
645642 content += f"{ date :<{max_dates_length }} "
646643 content += f"{ value :{max_value_length }.2f} "
647644 content += f"{ error :{max_value_length }.2f} "
@@ -656,8 +653,7 @@ def write_localisation_obs_attributes(
656653) -> None :
657654 """
658655 Write csv file with following columns:
659- - wellname
660- - obs_type(vector)
656+ - summary_vector
661657 - xpos
662658 - ypos
663659 - range1
@@ -674,40 +670,45 @@ def write_localisation_obs_attributes(
674670 )
675671 print (f"Write file: { filename } " )
676672
677- rms_well_name_header = "RMS_WELLNAME"
678- obs_type_header = "OBS_TYPE"
673+ #rms_well_name_header = "RMS_WELLNAME"
674+ #obs_type_header = "OBS_TYPE"
675+ summary_vector_header = "SUMMARY_KEY"
679676 zone_name_header = "ZONE"
680677 xpos_header = "XPOS"
681678 ypos_header = "YPOS"
682679 main_range_header = "MAIN_RANGE"
683680 perp_range_header = "PERP_RANGE"
684681 rotation_angle_header = "AZIMUTH"
685682
686- max_obs_type_length = 8
687- max_well_name_length = 12
683+ # max_obs_type_length = 8
684+ # max_well_name_length = 12
685+ max_summary_vector_length = 12
688686 max_zone_name_length = 12
689687 max_range_length = 12
690688 max_angle_length = 12
691689 for key , obs_dict in all_obs_dict .items ():
692690 (zone_name , ert_id ) = key
693- obs_type = obs_dict ["obs_type" ]
694- wellname = obs_dict ["wellname" ]
691+ # obs_type = obs_dict["obs_type"]
692+ # wellname = obs_dict["wellname"]
693+ summary_vector_header = obs_dict ["summary_vector" ]
695694 if max_zone_name_length < len (zone_name ):
696695 max_zone_name_length = len (zone_name )
697- if max_obs_type_length < len (obs_type ):
698- max_obs_type_length = len (obs_type )
699- if max_well_name_length < len (wellname ):
700- max_well_name_length = len (wellname )
701-
702- max_well_name_length += 2
703- max_obs_type_length += 2
696+ # if max_obs_type_length < len(obs_type):
697+ # max_obs_type_length = len(obs_type)
698+ # if max_well_name_length < len(wellname):
699+ # max_well_name_length = len(wellname)
700+
701+ # max_well_name_length += 2
702+ # max_obs_type_length += 2
703+ max_summary_vector_length += 2
704704 max_zone_name_length += 2
705705 max_value_length = 12
706706 with open (filename , "w" ) as file :
707707 # Heading
708708 content = ""
709- content += f"{ rms_well_name_header :<{max_well_name_length }} "
710- content += f"{ obs_type_header :<{max_obs_type_length }} "
709+ # content += f"{rms_well_name_header:<{max_well_name_length}}"
710+ # content += f"{obs_type_header:<{max_obs_type_length}}"
711+ content += f"{ summary_vector_header :<{max_summary_vector_length }} "
711712 content += f"{ xpos_header :>{max_value_length }} "
712713 content += f"{ ypos_header :>{max_value_length }} "
713714 content += f"{ main_range_header :>{max_range_length }} "
@@ -720,10 +721,10 @@ def write_localisation_obs_attributes(
720721 localisation_param_written = {}
721722 for key , obs_dict in all_obs_dict .items ():
722723 (zone_name , ert_id ) = key
723- obs_type = obs_dict ["obs_type" ]
724- wellname = obs_dict ["wellname" ]
725-
726- key_written = (zone_name , wellname , obs_type )
724+ # obs_type = obs_dict["obs_type"]
725+ # wellname = obs_dict["wellname"]
726+ summary_vector = obs_dict [ "summary_vector" ]
727+ key_written = (zone_name , summary_vector )
727728 if key_written in localisation_param_written :
728729 continue
729730
@@ -733,8 +734,9 @@ def write_localisation_obs_attributes(
733734 perp_range = float (obs_dict ["perp_range" ])
734735 rotation_angle = float (obs_dict ["anisotropy_angle" ])
735736 content = ""
736- content += f"{ wellname :<{max_well_name_length }} "
737- content += f"{ obs_type :<{max_obs_type_length }} "
737+ # content += f"{wellname:<{max_well_name_length}}"
738+ # content += f"{obs_type:<{max_obs_type_length}}"
739+ content += f"{ summary_vector :<{max_summary_vector_length }} "
738740 content += f"{ xpos :{max_value_length }.1f} "
739741 content += f"{ ypos :{max_value_length }.1f} "
740742 content += f"{ main_range :{max_range_length }.1f} "
@@ -821,7 +823,7 @@ def create_obs_local(project, config_file):
821823 obs_localisation_dict ["main_range" ] = default_ranges [0 ]
822824 obs_localisation_dict ["perp_range" ] = default_ranges [1 ]
823825 obs_localisation_dict ["anisotropy_angle" ] = default_ranges [2 ]
824- obs_localisation_dict ["summary_key " ] = obs_dict ["KEY " ]
826+ obs_localisation_dict ["summary_vector " ] = obs_dict ["summary_vector " ]
825827 if obs_localisation_dict ["hlength" ] > min_range_hwell :
826828 well_path_angle = obs_localisation_dict ["well_path_angle" ]
827829 obs_localisation_dict ["anisotropy_angle" ] = well_path_angle
@@ -889,7 +891,6 @@ def create_obs_local(project, config_file):
889891 )
890892
891893 for zone_name in zone_names :
892- # print(f"Field name: {field_name}")
893894 for obs_dict in new_obs_dict_list :
894895 if (
895896 obs_dict ["obs_type" ] in obs_types
@@ -904,7 +905,7 @@ def create_obs_local(project, config_file):
904905 obs_localisation_dict ["main_range" ] = ranges [0 ]
905906 obs_localisation_dict ["perp_range" ] = ranges [1 ]
906907 obs_localisation_dict ["anisotropy_angle" ] = ranges [2 ]
907- obs_localisation_dict ["summary_key " ] = obs_dict ["KEY " ]
908+ obs_localisation_dict ["summary_vector " ] = obs_dict ["summary_vector " ]
908909 output_dict [result_id ] = obs_localisation_dict
909910
910911 # All observations not specified under field_settings is
@@ -918,3 +919,10 @@ def create_obs_local(project, config_file):
918919 write_localisation_obs_attributes (
919920 result_localisation_obs_file , output_dict , allow_overwrite = True
920921 )
922+
923+ if __name__ == "__main__" :
924+ config_file = (
925+ "/private/olia/fmu-tools-olia/tests/rms/localisation/input_files/example_config.yml"
926+ )
927+ create_obs_local (project , config_file )
928+ print ("Finished" )
0 commit comments