Federal prosecutors have charged a man with impersonating an ATF agent at the site of the May 2015 derailment of an Amtrak train in the Frankford section of Philadelphia.

Michael Alvaro, 37, is charged with impersonating a federal law enforcement officer, conducting a search while impersonating an officer and possession of an unregistered firearm in a pair of bizarre instances in which he is accused of trying to convince the cops that he was one of them.

At the crash site, where eight people lost their lives after a train derailed after entering a turn at a high speed, investigators say Alvaro called a police dispatcher, identified himself as a sergeant with the agency. He asked where the command post was.

When he showed up on the scene, prosecutors say, Alvaro was decked out in a black vest that said “Police.” He approached two Philly cops, who were investigating a large crater, and told them he was with the ATF.

The cops asked him to guard the hole while they went to interview passengers. When they returned, Alvaro was gone, according to court documents.

In another instance back in 2014, Alvaro allegedly identified himself as a DEA agent to a Pennsylvania State Trooper who had pulled someone over on I-95. Alvaro asked to search the car, claiming expertise in finding “hiding spots.” That search yielded a black tar-like substance that Alvaro claimed was heroin. It turned out to be paint balls.