Smart mid-infrared metasurface microspectrometer gas sensing system