### Install klarfkit using pip Source: https://github.com/michaelhotaling/klarfkit/blob/main/README.md Install the klarfkit library directly from its GitHub repository using pip. This command ensures you get the latest version. ```bash pip install git+https://github.com/MichaelHotaling/klarfkit.git ``` -------------------------------- ### Display Wafer Metadata with WaferMap.describe Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Use the WaferMap.describe() method to print a formatted summary of all wafer metadata and configuration parameters. This is useful for quickly inspecting the contents of a loaded KLARF file. ```python from klarfkit import WaferMap wafer = WaferMap.read_klarf('sample_files/CPS3TwithoutReview.001') # Display all wafer metadata wafer.describe() ``` -------------------------------- ### WaferMap.describe Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Displays a formatted summary of all wafer metadata and configuration parameters. ```APIDOC ## WaferMap.describe ### Description Print a formatted summary of all wafer metadata and configuration parameters. Useful for quickly inspecting the contents of a loaded KLARF file. ``` -------------------------------- ### WaferMap Constructor Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Creates a new WaferMap instance programmatically using custom defect data and configuration parameters. ```APIDOC ## WaferMap Constructor ### Description Create a WaferMap instance programmatically with custom defect data and wafer configuration. This is useful for generating synthetic data or importing defects from other sources. ### Parameters #### Request Body - **defect_record** (DataFrame) - Required - Pandas DataFrame containing columns: DEFECTID, XINDEX, YINDEX, XREL, YREL, XSIZE, YSIZE, CLASSNUMBER. - **sample_size** (float) - Required - Size of the wafer in micrometers. - **sample_center_location** (tuple) - Required - (x, y) coordinates of the wafer center. - **die_pitch** (tuple) - Required - (x, y) dimensions of the dies. - **die_origin** (tuple) - Required - (x, y) origin coordinates. - **lot_id** (string) - Optional - Identifier for the lot. - **wafer_id** (string) - Optional - Identifier for the wafer. - **slot** (int) - Optional - Slot number. - **orientation_marker** (string) - Optional - 'NOTCH' or 'FLAT'. - **orientation** (string) - Optional - 'UP', 'DOWN', 'LEFT', or 'RIGHT'. - **class_lookup** (dict) - Optional - Mapping of class numbers to descriptions. ``` -------------------------------- ### Load KLARF File with WaferMap.read_klarf Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Use WaferMap.read_klarf to load a KLARF file into a WaferMap object. This object contains all defect records, metadata, and wafer configuration. Requires the file path as an argument. ```python from klarfkit import WaferMap # Load a KLARF file from disk wafer = WaferMap.read_klarf('sample_files/CPS3TwithoutReview.001') # The wafer object now contains all parsed data print(f"Wafer ID: {wafer.wafer_id}") print(f"Lot ID: {wafer.lot_id}") print(f"Number of defects: {len(wafer.defect_list)}") print(f"Sample size: {wafer.sample_size} um") print(f"Die pitch: {wafer.die_pitch}") ``` -------------------------------- ### Create Custom WaferMap with DataFrame Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Instantiate a WaferMap object programmatically using a pandas DataFrame for defect data. This method is useful for generating synthetic data or importing defects from other sources. Ensure the DataFrame includes required columns like XINDEX, YINDEX, XREL, YREL, XSIZE, YSIZE, and CLASSNUMBER. ```python import pandas as pd from klarfkit import WaferMap # Create defect data as a DataFrame # Required columns: XINDEX, YINDEX, XREL, YREL (die index and relative position) defects = pd.DataFrame({ 'DEFECTID': [1, 2, 3, 4, 5], 'XINDEX': [0, 1, -1, 2, -2], 'YINDEX': [0, 1, -1, 0, 0], 'XREL': [5000, 3000, 7000, 2000, 8000], 'YREL': [5000, 4000, 6000, 5000, 5000], 'XSIZE': [2.5, 3.0, 1.5, 4.0, 2.0], 'YSIZE': [2.5, 3.0, 1.5, 4.0, 2.0], 'CLASSNUMBER': [82, 81, 84, 82, 81] # Defect class codes }) # Create a custom WaferMap for a 300mm wafer wafer = WaferMap( defect_record=defects, sample_size=300_000, # 300mm wafer in micrometers sample_center_location=(150_000, 150_000), # Center of wafer die_pitch=(10_000, 10_000), # 10mm x 10mm dies die_origin=(0, 0), lot_id='LOT001', wafer_id='W01', slot=1, orientation_marker='NOTCH', # Options: 'NOTCH' or 'FLAT' orientation='DOWN', # Notch position: UP, DOWN, LEFT, RIGHT class_lookup={ 81: 'Big_Particle', 82: 'Small_Particle', 84: 'Scratch' } ) print(f"Created wafer with {len(wafer.defect_list)} defects") ``` -------------------------------- ### Plot Wafer Map with Custom Styling Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Customize the appearance of wafer map plots by adjusting marker size, style, and line transparency. Save the styled map to a file. ```python plt.figure(figsize=(10, 10)) wafer.plot_wafer_map( color='blue', die_line_alpha=0.3, # Transparency of die grid lines die_line_color='gray', # Color of die grid lines s=100, # Marker size marker='x' # Marker style ) plt.title(f'Lot: {wafer.lot_id} | Wafer: {wafer.wafer_id}') plt.savefig('wafer_styled_map.png', dpi=150) plt.show() ``` -------------------------------- ### Access and Analyze Defect Data as DataFrame Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Read a KLARF file and access the raw defect data as a pandas DataFrame. Perform filtering, grouping, and export the data to CSV or Excel. ```python import pandas as pd from klarfkit import WaferMap wafer = WaferMap.read_klarf('sample_files/CPS3TwithoutReview.001') # Access defect data as DataFrame defects = wafer.defect_list # View available columns print("Defect columns:", defects.columns.tolist()) # Output: ['DEFECTID', 'XREL', 'YREL', 'XINDEX', 'YINDEX', 'XSIZE', 'YSIZE', # 'DEFECTAREA', 'DSIZE', 'CLASSNUMBER', 'TEST', 'ROUGHBINNUMBER', # 'IMAGECOUNT', 'IMAGELIST', '_XACTUAL', '_YACTUAL'] # Filter defects by size large_defects = defects[defects['DSIZE'] > 10] print(f"Found {len(large_defects)} large defects (DSIZE > 10)") # Group defects by class class_counts = defects.groupby('CLASSNUMBER').size() print("\nDefects per class:") print(class_counts) # Find defects in a specific die die_defects = defects[(defects['XINDEX'] == 0) & (defects['YINDEX'] == 0)] print(f"\nDefects in die (0,0): {len(die_defects)}") # Export to CSV for external analysis defects.to_csv('defect_export.csv', index=False) # Export to Excel defects.to_excel('defect_export.xlsx', index=False) # Statistical summary print("\nDefect size statistics:") print(defects['DSIZE'].describe()) ``` -------------------------------- ### WaferMap.read_klarf Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Parses a standard KLARF file and initializes a WaferMap object containing defect records and metadata. ```APIDOC ## WaferMap.read_klarf ### Description Parses the standard KLARF format (typically .001 extension) and creates a WaferMap object containing all defect records, metadata, and wafer configuration. ### Parameters #### Path Parameters - **filepath** (string) - Required - The path to the KLARF file on disk. ### Response - **WaferMap** (object) - An instance containing parsed data including wafer_id, lot_id, defect_list, sample_size, and die_pitch. ``` -------------------------------- ### Automatic Wafer Map Visualization Source: https://context7.com/michaelhotaling/klarfkit/llms.txt The WaferMap class automatically generates a visual representation when displayed in interactive environments like Jupyter notebooks. This includes the wafer boundary, die grid, and defect markers. ```python from klarfkit import WaferMap wafer = WaferMap.read_klarf('sample_files/CPS3TwithoutReview.001') # In Jupyter notebook, simply evaluating the wafer displays a plot wafer # Displays wafer map visualization automatically # The __repr__ method creates a 3x3 inch figure showing: # - Circular wafer boundary # - Die grid lines # - Red markers for each defect location ``` -------------------------------- ### Visualize Defect Distribution with plot_wafer_map Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Generate a visual plot of the wafer map showing die grid and defect locations using plot_wafer_map. Supports customization of colors and can color-code defects by any column in the defect DataFrame. Requires matplotlib for plotting. ```python import matplotlib.pyplot as plt from klarfkit import WaferMap wafer = WaferMap.read_klarf('sample_files/CPS3TwithoutReview.001') # Basic wafer map plot with default red defect markers plt.figure(figsize=(8, 8)) wafer.plot_wafer_map(color='red', s=50) # s=marker size plt.title(f'Wafer {wafer.wafer_id} - Defect Map') plt.savefig('wafer_defect_map.png', dpi=150) plt.show() ``` -------------------------------- ### Color Wafer Map Defects by Class Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Visualize defects on a wafer map, coloring them based on a specific data column like 'CLASSNUMBER' and applying a colormap. Includes saving the plot. ```python plt.figure(figsize=(10, 10)) wafer.plot_wafer_map( color='CLASSNUMBER', # Color by this DataFrame column cmap='viridis', # Matplotlib colormap s=80 ) plt.colorbar(label='Defect Class') plt.title('Defects Colored by Classification') plt.savefig('wafer_class_map.png', dpi=150) plt.show() ``` -------------------------------- ### Access Wafer Class Lookup Table Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Retrieve the class lookup dictionary from a WaferMap object to map defect class numbers to human-readable descriptions. This can be used to enrich defect data. ```python from klarfkit import WaferMap wafer = WaferMap.read_klarf('sample_files/CPS3TwithoutReview.001') # Access the class lookup dictionary class_lookup = wafer.class_lookup # Print some class definitions print("Sample class definitions:") for class_num in [0, 81, 82, 84, 174]: if class_num in class_lookup: print(f" Class {class_num}: {class_lookup[class_num]}") # Output: # Class 0: Undefined # Class 81: Big_Particle # Class 82: Small_Particle # Class 84: Scratch # Class 174: MicroScrtch # Add class descriptions to defect data defects = wafer.defect_list.copy() defects['CLASS_NAME'] = defects['CLASSNUMBER'].map(class_lookup) print("\nDefects with class names:") print(defects[['DEFECTID', 'CLASSNUMBER', 'CLASS_NAME', 'DSIZE']].head()) ``` -------------------------------- ### WaferMap.plot_wafer_map Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Generates a visual plot of the wafer map showing the die grid and defect locations. ```APIDOC ## WaferMap.plot_wafer_map ### Description Generate a visual plot of the wafer map showing the die grid and defect locations. Supports customization of colors and can color-code defects by any column in the defect DataFrame. ### Parameters #### Query Parameters - **color** (string) - Optional - Color of the defect markers. - **s** (int) - Optional - Size of the defect markers. ``` -------------------------------- ### Modify Die Pitch and Center Location Source: https://context7.com/michaelhotaling/klarfkit/llms.txt Update the die pitch and center location of a WaferMap object. These changes automatically recalculate relative defect coordinates. ```python from klarfkit import WaferMap wafer = WaferMap.read_klarf('sample_files/CPS3TwithoutReview.001') # View original configuration print(f"Original die pitch: {wafer.die_pitch}") print(f"Original center: {wafer.center_location}") # Update die pitch - relative coordinates recalculated automatically wafer.die_pitch = (3000, 2500) print(f"New die pitch: {wafer.die_pitch}") # Update center location wafer.center_location = (150_000, 150_000) print(f"New center: {wafer.center_location}") # Access other configuration properties print(f"Sample size: {wafer.sample_size}") print(f"Die origin: {wafer.die_origin}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.