Cannabis contains an highly complex mixture of compounds, and even varieties grown from the same supplier can vary by up to 25%  in their chemical makeup.
With the rise of both medical and recreational cannabis use, uniformity amongst products being released is critical. Nevertheless most products aren’t tested for THC or CBD content until they are finalized. Mid-Infrared Spectroscopy is a process analytical technology (PAT) that can be used to measure cannabinoids concentrations in cannabis inflorescences and derivatives and it is capable of monitoring the product composition throughout the production process ensuring a final result in line with the needs. 
How Cannabinoids are Commonly Measured
Gas chromatography (GC) and high-performance liquid chromatography (HPLC)  are the most common techniques to quantificate phytocannabinoids concentrations. GC permits the separation and identification of compounds vaporizing the analytes in a carrier gas.
The downside is that thermolabile compounds such as cannabinoids can’t be accurately measured by this techniques and for this reason GC is generally used to detect and quantificate volatiles like terpenes. HPLC ensure the analysis and separation of complex mixtures of non-volatiles and thermally labile compounds by dissolving them in a pressurized solvent passing through a packed column filled with absorbent material. Even if this is the mostly used method for cannabinoid analysis, there is large use od solvent to be considered and the sample preparation can be laborious. For this reason other analytical techniques should be used in order to monitor in-process product composition.
Mid-Infrared Spectroscopy As An Alternative Method
Mid-infrared spectroscopy (MIR)  relies on light absorption (around 4,000–400 cm−1 ; 2.5–25 μm) to determine molecular composition through biochemical bond vibration. After assigning the absorprion bands of THC and CBD, the spectral features of decarboxylation in the native flowers can be assigned and the bands for tetrahydrocannabinolic acid (THCA) and cannabidiolic acid (CBDA) can be highlighted. A statistical multivariate model can be constructed for the prediction of the final THC and CBD content in the extract with a low level of deviation and good corrlation coefficients on y axis (R2Y) and root mean square error of prediction (RMSEP) of 0.95 and 3.79% for THC and 0.99 and 1.4% for CBD. Considering the complexity and the variability of the sample and the disomogeneity of the plant material, MIR technique can be combined with traditional analytical methods in order to give labs the best picture of THC/CBD concentrations at all stages of production process.
References: Borroto Fernandez E. et al. Distribution of Chemical Phenotypes (Chemotypes) in European Agricultural Hemp (Cannabis sativa L.) Cultivars. Journal of Forensic Sciences (2019) ; 1556-4029.14242. doi:10.1111/1556-4029.14242 [Journal Impact Factor = 1.832] [Times cited = 14 ]
 Geskovski, N. et al. Mid-infrared spectroscopy as process analytical technology tool for estimation of THC and CBD content in Cannabis flowers and extracts. Spectrochimica Acta Part A: Molecular and Biomolecular Spectroscopy (2021); 251 , 119422. https://doi.org/10.1016/j.saa.2020.119422 [Journal Impact Factor = 4.098] [Times cited = 9 ]
 Burnier, C. et al. Quantification of THC in Cannabis Plants by Fast-HPLC-DAD: a promising method for routine analyses. Talanta, (2018); S0039914018309214–. doi:10.1016/j.talanta.2018.09.012 [Journal Impact Factor = 6.057] [Times cited = 29 ]