NZUS93 KOAX 130926 LLLOAX IAZ043-055-056-069-079-080-090-091-NEZ011-012-015>018-030>034-042>045-050>053- 065>068-078-088>093-132126- Public Information Statement National Weather Service Omaha/Valley NE 426 AM CDT Fri Sep 13 2024 import re # Function to find zone lines and VTEC lines in the text def extractVTEC(text): zone_pattern = r\b[A-Z]{2}[ZC]\d{3}.*?\d{6}- vtec_pattern = r/(?:[OTEX]\.(?:CON|NEW|EXT|EXA|EXB|UPG|CAN|EXP|COR|ROU)\.[A-Z]{4}\.[A-Z]{2}\.[A-Z]+\.\d{4}\.\d{6}T\d{4}Z-\d{6}T\d{4}Z/) zone_lines = re.findall(zone_pattern, text, re.DOTALL) vtec_lines = re.findall(vtec_pattern, text) return zone_lines, vtec_lines def read_rfw_from_file(file_path): Read the Red Flag Warning text from a file. try: with open(file_path, r) as file: return file.read() except FileNotFoundError: print(fError: The file at {file_path} was not found.) return except IOError as e: print(fError: An I/O error occurred. Details: {e}) return def match_zones_with_vtec(zone_lines, vtec_lines): matched_dict = {} vtec_index = 0 num_vtec_lines = len(vtec_lines) for zone in zone_lines: if vtec_index >= num_vtec_lines: break # Initialize the list for the current zone line matched_dict[zone] = [] # Process the current VTEC line current_vtec = vtec_lines[vtec_index] matched_dict[zone].append(current_vtec) # If UPG is found, pair with the next VTEC line too if UPG in current_vtec: if vtec_index + 1 < num_vtec_lines: next_vtec = vtec_lines[vtec_index + 1] matched_dict[zone].append(next_vtec) vtec_index += 1 # Skip the next VTEC line as its already matched vtec_index += 1 return matched_dict # Path to the Red Flag Warning file file_path = rH:/Python/rfwChecker/rfw.txt # Read the RFW text from the file warning_text = read_rfw_from_file(file_path) # Extract VTEC lines zone_lines, vtec_lines = extractVTEC(warning_text) # Match zones with VTEC lines matches = match_zones_with_vtec(zone_lines, vtec_lines) # Make a banner if Nebraska zones included AND its a NEW, UPG, EXA, or EXB. vtecActions = [NEW, UPG, EXA, EXB] for zone, vtecs in matches.items(): if NEZ in zone: # Check if NEZ is in the zone string if any(vtecAction in vtec for vtec in vtecs for vtecAction in vtecActions): # Check if any vtecAction is in any of the vtecs print(A Nebraska county with a matching VTEC action is included)