<jupyter_start><jupyter_text>Load PnP file Exported using "centroids-screamingcircuits-smd" ULP in Fusion/Eagle.<jupyter_code>pnp_fusion = pd.read_csv("pcb v55_centroid.csv", skiprows=7)
pnp_fusion = pnp_fusion.query("Layer == 'Top'")

pnp_fusion["LocationX"] = pnp_fusion["LocationX"] * INCH_TO_MM
pnp_fusion["LocationY"] = pnp_fusion["LocationY"] * INCH_TO_MM

pnp_fusion.rename(columns={"RefDes": "Designator", "LocationX": "Mid X", "LocationY": "Mid Y"}, inplace=True)<jupyter_output><empty_output><jupyter_text>Correct LED orientation (opposite of JLCPCB standard)<jupyter_code>led_mask = pnp_fusion["Designator"].str.startswith("D")
flip_rotation = lambda r: (r + 180) % 360
pnp_fusion.loc[led_mask, "Rotation"] = pnp_fusion.loc[led_mask, "Rotation"].map(flip_rotation)<jupyter_output><empty_output><jupyter_text>Load BOM<jupyter_code>bom = pd.read_csv("BOM_cnn_card_2020-11-28_19-21-05.csv", sep="\t")<jupyter_output><empty_output><jupyter_text>Panelize<jupyter_code>pnp_panel, bom_panel = panelize(
    pnp_fusion,
    bom,
    board_width=BOARD_WIDTH,
    board_height=BOARD_HEIGHT,
    n_rows=N_ROWS,
    n_cols=N_COLS,
    spacing=SPACING,
    bottom_margin=EDGE_RAIL_HEIGHT + SPACING
)<jupyter_output><empty_output><jupyter_text>Export image<jupyter_code>marked_img = mark_components(front_img, pnp_panel, pixel_width)
cv2.imwrite("panel_marked.png", marked_img)<jupyter_output><empty_output><jupyter_text>Save<jupyter_code>bom_panel.to_csv("cnn_card_panel_2x2_bom_top.csv", index=None)<jupyter_output><empty_output><jupyter_text>Add "mm" suffix to positions<jupyter_code>pnp_panel["Mid X"] = pnp_panel["Mid X"].map(lambda x: str(x) + "mm")
pnp_panel["Mid Y"] = pnp_panel["Mid Y"].map(lambda x: str(x) + "mm")
pnp_panel.to_csv("cnn_card_panel_2x2_pnp_top.csv", index=None)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup