Abstract:
A method and system for determination of contaminants, such as black powder, in a flowing fluid, such as natural gas, is disclosed. The method comprises transmitting a plurality of light beams over a spectrum of wavelengths through the flowing fluid in a main pipeline and receiving a plurality of measurements relating to transmitted and scattered light beams over the spectrum of wavelengths. The measurements relate to at least one of absorption, reflection or refraction. The received plurality of measurements are compared with a plurality of stored patterns and a result indicative of the determination of the contaminants is output.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    The present application is a continuation-in-part of U.S. Non-provisional patent application Ser. No. 14/639,473 filed by the present inventors on Mar. 5, 2015. 
         [0002]    The aforementioned provisional patent application is hereby incorporated by reference in its entirety. 
     
    
     STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT 
       [0003]    None. 
       BACKGROUND OF THE INVENTION 
       [0004]    1. Field of the Invention 
         [0005]    The present invention relates to a system and method for measuring the amount of black powder in a gas pipeline. 
         [0006]    2. Brief Description Of The Related Art 
         [0007]    Black powder is a general term used for solid contaminants, which can be found in a gas or fluid pipeline. The black powder occurs from various and many unknown reasons. The black powder has numerous forms and may be wet or/and or have a tar-like appearance. It comprises very fine particles (often sub micrometer in size) of iron sulfide, iron oxide, and iron carbonate (see Sherik and Davis “Thermodynamic analysis of formation of black powder in sales gas pipelines, Saudi Aramco J. Technol., Vol. 1, pp 17-23, March 2009). As these fine particles flow in the gas pipeline, the particles of the black power can accumulate around the control valves, compressors, and other equipment, which may create a severe pressure drop and in some cases lead to an entire shutdown of the pipeline and thus of the production. The problems may extend further to the utilities companies connected to the actual network pipeline (e.g. electricity companies) in which their various pieces of equipment are damaged and electricity production declines. 
         [0008]    These issues have led to gas production companies to implement measures for mitigating the propagation of black powder in their gas pipelines, as reported in Trifilieff et al “Black power removal from transmission pipelines: Diagnostics and solution”, presented at the Pipeline Rehabilitation Maintenance Conference, Gulf Int. Convention Center, Manama, Bahrain, January 2009, pp 1-12. Despite all separation techniques applied currently to the gas pipelines to eliminate the black powder (e.g., filtering, cyclones, and pigging), the problem is still current. The difficulties in resolving the issue can be at least partly explained by the fact that the size of black powder particles are in the order of sub micrometers and are thus hard to extract from the flowing gas in the gas pipeline. Consequently, new strategies are being now investigated. 
         [0009]    One approach is to monitor propagation of the black powder at different points of the pipeline network, which helps in taking more effective preventive actions against the buildup of the black powder. Currently, there is no existing system for inline measurement of the black powder, within either natural gas or petroleum continuous phases. 
         [0010]    In other different industrial applications optical-based techniques such as NIR, MIR and Raman spectroscopy have been used for monitoring fluid conditions. These prior art methods usually comprise the scanning of the target fluid over a large range of wavelengths in either the transmission or reflection mode. 
         [0011]    The following patents illustrate the use of such optical-based techniques. 
         [0012]    U.S. Pat. No. 8,379,205 B2 issued February, 2013 suggests an arrangement for determining the concentration of substances in a fluid. The system comprises a light source and a light source splitter (consisting of fiber Bragg grating), which generates a relatively small number of secondary light beams (e.g. around three light beams) at different wavelengths. The secondary light beams impact the fluid in a time-multiplexed manner and a number of photosensitive detectors, corresponding to the number of light beams (e.g. around 3 detectors), generate a plurality of electrical signals that are proportional to the composition and the concentration of the substance in the measured fluid. 
         [0013]    The apparatus of US &#39;205 is not suitable for black powder detection in oil or gas pipelines for several reasons. The analysis of the light intensity of the transmitted light beams through the fluid for a relatively small number of wavelengths (in this case three) will not be effective because of the complex wavelength spectrum that is obtained for various concentrations of black powder, especially when present within different continuous phases. 
         [0014]    U.S. Pat. No. 5,742,064 issued Apr. 21, 1998 suggests a method to determine the amount of dirt and water in oil when a target oil is passing through a given section of the pipeline. The apparatus of US &#39;064 comprises a tunable laser light which emits coherent light towards the target oil. A photomultiplier or a spectrometer are present to sense the received light from the target oil. This received light is proportional to the amount of dirt and water existing in the target oil. The application addressed in this &#39;064 patent is different from the teachings of the current disclosure. The algorithm disclosed in the &#39;064 patent is based around a simple search for the best match of the spectrum of the received light within a database of existing spectra and may not be always effective due to the high complexity and sensitivity of the wavelength spectrum from the target oil. More complex algorithms (e.g. pattern recognition algorithms) are usually required in practice. 
         [0015]    U.S. Pat. No. 5,418,614 issued May 23, 1995 suggests a method for on-line analysis of online fluids streams. The invention uses a general-purpose optical photometer in the ultraviolet, visible and near infrared spectral ranges. The light source generates light signals, which are carried via optical fiber cables between a central photometric console and remote analysis sites in which the captured signals are compared with a reference signal. Although the disclosure in this patent application shares some similarities with the current disclosure by using optical light (NIR), the teachings of US &#39;614 differs from the current disclosure by the use of a photomultiplier in the detection process, instead of photodiodes. Hence, in this earlier disclosure, the detector can not simultaneously explore a range of wavelengths, which constitutes the basic concept of optical spectroscopy. The earlier disclosure focuses on one wavelength (e.g. NIR wavelength) and measures the corresponding intensity of light received, which is said to be function of the fluid composition to be measured. Furthermore, the teachings of this patent were not intended to detect micro-sized particles, as is the case of the current disclosure. 
         [0016]    U.S. Pat. No. 5,140,169 and U.S. Pat. No. 5,170,056 issued Aug. 14, 1992 and Dec. 8, 1992 respectively. The first US &#39;169 patent teaches a flow cell while the second US &#39;056 patent teaches a probe. While both techniques use spectrometry with optical fiber cables, they only handle offline measurements on samples, which are put within a very narrow volume space. Furthermore, the two disclosures do not specify the wavelengths used and consider the light in the transmittance mode only. 
         [0017]    U.S. Pat. No. 5,140,169 A discloses a flow cell for use in highly corrosive environments that is constructed from an extended metal body containing a smooth longitudinal circular center bore of uniform cross-section. 
         [0018]    U.S. Patent Application Publication No. 2013/0031964 A1 discloses a method of monitoring the fluid, which includes containing the fluid within a flow path, the fluid including at least one adulterant present therein, optically interacting at least one integrated computational element with the fluid, thereby generating optically interacted light, receiving with at least one detector the optically interacted light, and generating with the at least one detector an output signal corresponding to a characteristic of the at least one adulterant in the fluid. 
         [0019]    U.S. Pat. No. 8,686,364 B1 discloses methods and systems for real time, in situ monitoring of fluids, and particularly the determination of both the energy content and contaminants in a gas or oil transmission facility. The disclosed system includes two separate scanning sources to scan two different, but overlapping, near infra-red (NIR) ranges, or involves two separate scans from a single scanning spectroscopy source. 
         [0020]    International Patent Application No. WO 2009/002322 A1 discloses a system and method of monitoring contaminant particles in pipelines. The system can include a probe for extending into the pipeline, and sampling fluid in the pipeline to ensure that a representative amount of contaminants within the pipeline can subsequently be measured. An analyzer receives the sampled fluid from the probe, illuminates the sampled fluid with a light source and collects scattered light from any contaminant particles in the illuminated sampled fluid. 
         [0021]    U.S. Patent Application Publication No. 20150021482 A1 relates to a contamination recording apparatus for recording contaminations in a flowing hydraulic fluid to be examined in an aircraft comprising a conveying device for conveying the flowing hydraulic fluid, a light source for exposing the hydraulic fluid flowing in the conveying device to light and a detection device for recording a fraction of the light absorbed by the exposed hydraulic fluid. 
         [0022]    Another drawback of the aforementioned prior art is that the disclosures all assume that the continuous phase (i.e. the background surrounding the particles of interest) is constant over time. This constraint is not realistic in oil and gas fields, since the density of the fluid (oil or gas) and even its type is likely to change. For instance, over a period of time, the produced natural gas can change from methane-dominated gas to ethane-dominated gas. Furthermore, when these apparatuses operate online, the apparatuses only monitor a relatively small portion of the flow in a slip-stream sample line either by using measurement cells (e.g. multi-pass measurement cell, cross flow measurement cell, and/or integrating sphere) or immersion probes. Therefore, such methods do not consider the entire process flow and consequently cannot be applied directly to the gas/oil pipelines (termed “main pipelines”) in order to measure the flow of black powder. 
       SUMMARY OF THE INVENTION 
       [0023]    The present disclosure teaches a non-destructive optical-based device to monitor online and continuously the amount of black powder within a main pipeline passing though the earliest stages of the pipeline network. This device will allow isolating highly contaminated pipelines and thus reduce the risks; which may be caused to the pipelines by contamination through the black powder. In one aspect, the device operates using at least near infra-red radiation (NIR) to analyze at least one of the reflected, transmitted, and refraction light beams, which interact with the target medium. Hence, besides being non-intrusive and non-invasive techniques, the device also employs the property that light in the IR range has a different absorption rate for different constituents of black powder in the target medium. Hence, by knowing the spectrum of each of these different constituents, a proper analysis of the spectrum would lead to a good estimation of the concentration of the different constituents in the target medium. 
         [0024]    In one aspect, the device further transmits further light beams of at least one of middle infra-red (MIR) or Raman spectra. 
         [0025]    Measurements in the main pipeline as taught in this document refer to measurements ‘in-inline’ of a main flow path of the main pipeline in order to avoid for example a bypass to which measurement devices/facilities are allocated (see above—drawbacks of the prior art). The flowing fluid within the main pipeline is the target medium. 
         [0026]    The device uses an algorithm to process the data from the different techniques. In one embodiment two multivariate techniques are used, namely the Principal Component Regression (PCR) and the Partial Least Square Regression (PLSR) techniques. These multivariate techniques are commonly used to group samples with similar characteristics to classify unknown samples (qualitative analysis) or to determine specific properties of unknown samples (quantitative analysis). Other artificial intelligence techniques such as neural network and fuzzy logic techniques can also be applied. 
         [0027]    The description teaches a device to monitor online and continuously the amount of the black powder passing through the earliest stages of the pipeline network. The device allows for reducing of the risks that may be linked to the substantial pressure drops commonly experienced in the downstream pipelines. 
         [0028]    The device comprises a ring of optical sender and receiving sensors evenly distributed across a given section of the pipeline. Extensive offline experiments to quantify the amount of black powder were conducted, and the results of the experiments were recorded to create a database of spectra relating to the different concentrations of the constituents of the black powder. The experiments were conducted by first measuring the samples of black powder by standard analytical procedures and then using the results as reference values for establishing the calibration model based on multivariate calibration using the PCR and the PLSR for NIR, MIR, and Raman spectroscopy. The results obtained from these experiments support the feasibility of using optical-based approach to monitor black powder particles in gas pipelines. 
         [0029]    In an aspect, the present invention is an optical-based system and a method for online measurement of sub-micrometer sized black powder in gas or oil pipelines is disclosed. The system comprises at least one optical light transmitter (also called emitter), which transmits a beam of light towards a target medium within which the black powder concentration is sought to be determined. Depending on the positioning of the transmitters relative to the receivers, the sensing area can be either a two-dimensional (2D) section of the pipeline, or a 3D volume of the target medium. Targeting the 3D volume leads to a better accuracy of measurement at the expense of high computation time and/or hardware complexity. A plurality of optical sensors operating within the senders&#39; wavelengths are positioned at different locations in the pipeline to measure the amount of light absorbed and/or reflected by black powder particles. A dedicated pattern recognition algorithm using statistical and/or artificial intelligence approaches uses this data to estimate the amount of black powder passing through the target area. The optical senders and receivers can be connected to the control room via optical fibers, which allow the apparatus to operate safely in hazardous areas (e.g. Zone 0 areas). 
         [0030]    Still other aspects, features, and advantages of the present invention are readily apparent from the following detailed description, simply by illustrating a preferable embodiments and implementations. The present invention is also capable of other and different embodiments and its several details can be modified in various obvious respects, all without departing from the spirit and scope of the present invention. Accordingly, the drawings and descriptions are to be regarded as illustrative in nature, and not as restrictive. Additional objects and advantages of the invention will be set forth in part in the description, which follows and in part will be obvious from the description, or may be learned by practice of the invention. The above aspects and/or features within the aspects may be freely combined with each other to form embodiments of the present application. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0031]    For a more complete understanding of the present invention and the advantages thereof, reference is now made to the following description and the accompanying drawings, in which: 
           [0032]      FIG. 1  shows a structure of an exemplary aspect of the system as used in the gas industry. 
           [0033]      FIG. 2  shows a first embodiment of the system. 
           [0034]      FIG. 3  shows a second embodiment of the system 
           [0035]      FIG. 4  shows a third embodiment of the system 
           [0036]      FIG. 5  shows a fourth embodiment of the system 
           [0037]      FIG. 6  illustrates a multivariate calibration flow chart 
           [0038]      FIGS. 7A-C  shows the (A) MIR, (B) NIR, and (B) Raman spectra of black powder used. 
           [0039]      FIG. 8  shows an MIR spectrum of black powder mixed with sand, methane, and ethane gas. 
           [0040]      FIG. 9  shows an MIR spectra of black powder mixed with sand after extracting methane and ethane gases. 
           [0041]      FIG. 10  shows a correlation spectrum for black powder. 
           [0042]      FIGS. 11A-C  shows a PRESS-PLS and PCR for the (A) MIR, (B) NIR, and (B) Raman data. 
           [0043]      FIGS. 12A-C  shows MSPE curves for the PLS and PCR for (A) MIR, (B) NIR, and (C) Raman data set. 
           [0044]      FIGS. 13A-C  shows PCR and PLS calibration of the (A) MIR, (B) NIR, and (B) Raman data set 
           [0045]      FIGS. 14A-C  shows PCR and PLSR prediction of three new samples for (A) MIR, (B) NIR, and (C) Raman calibration models 
           [0046]      FIGS. 15A-C  shows computation time for the prediction analysis for (A) MIR, (B) NIR, and (B) Raman models 
           [0047]      FIG. 16  shows Table I, which is a summary of the comparison between PLSR and PCR for NIR, MIR, and Raman spectroscopy 
       
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
       [0048]    The invention will now be described on the basis of the drawings. It will be understood that the embodiments and aspect of the invention described herein are only examples and do not limit the protective scope of the claims in any way. The invention is defined by the claims and their equivalents. It will be understood that feature of one aspect or embodiment of the invention can be combined with a feature of a different aspect or aspects and/or embodiments of the invention. 
         [0049]      FIG. 1  shows a global overview of the system  10  in which the device is incorporated and how the system  10  fits into the gas field  20  with one or more gas wells  30 . This system  10  comprises three areas: 1) Area  1  comprising an upstream gas processing plant  40  and gas reservoir  50  as well as one or more reference probes  110  in a gas pipeline  130 ; 2) Area  2  comprising a control room  60  in which all field data are gathered and compiled; and 3) Area  3 , comprising a device of this disclosure (i.e., observing probe  100 ). Without loss of generalities, Areas  1  and  3  can be adjacent and are classified as hazardous areas. Connecting the reference probes  110  in Area  1  and the observing probe  100  in Area  3  to the control room in Area  2  by using optical fibers  120  makes the system  10  safer. 
         [0050]    Hence, the system  10  is distributed across all the three areas  1 ,  2  and  3 , which are interconnected via the optical fibers  120 . In the control room  60 , a spectrometer  70  emits light toward both the reference probes  110  and the observing probes  100  and the emitted light is projected into the gas stream  140  in the gas pipeline  130 . The control room  60  is also depicted in  FIG. 1  as having a computing device  90 . In practice the computing  90  may be located elsewhere and connected to a terminal in the control room  60 . The computing device will have logic for performing the calculations set out below, as well as for receiving data and outputting a result. 
         [0051]    Only a portion of the emitted light, or photons, will absorbed by the black powder contaminants in the gas stream. The remaining portion of the emitted light is transmitted, reflected, or refracted by the black powder contaminants. The light detector  80  in the control room  60  can analyze the received light from the reference probe  110  and the observing probe  100 . The received light will be proportional to the amount of the black powder passing through the gas pipelines  130  and depends on the constituents (contaminants) of the black powder. 
         [0052]    In  FIG. 1 , the reference probe  110  is expected to handle a less complex fluid since the reference probe  110  is placed very close to the gas processing plant  40 , which removes various types of impurities from the gas stream  140 . Hence, a negligible amount of the black powder is expected to pass through this reference probe  110 , while a larger amount of the black powder is gradually generated at the downstream section of the gas pipeline  130 , i.e. in Area  3 . The role of this reference probe  110  is mainly to identify the type of natural gas passing through the gas pipeline  130 . The natural gas in the gas stream  140  is known to have a complex composition of different gases with different concentrations (e.g., methane CH 4 , ethane C 2 H 6 , propane C 3 H 8 , butane Gam, hydrogen sulfide, carbon dioxide, water vapor, and sometimes other gases, such as helium and nitrogen—see Liang et al “NIR spectrum analysis of natural gas based on hollow-core photonic bandgap fiber”, IEEE Sensors J, vol. 12, no 7, 2362-2367, July 2012). Knowing this complex composition makes the calibration significantly less complex by applying some advanced chemometric techniques that generate a multivariate model, which can distinguish each one of the components in the gas stream  140  and measure its concentration. Hence, by subtracting the wavelength spectrums obtained from the reference probes  110  and the observation probes  110 , one can determine the spectrum that corresponds to the black powder in the gas stream  140  at the observation probes  110 . This is because the absorption spectra is assumed to be additive in case the substances of the mixture do not interact with each other. 
         [0053]      FIG. 2  shows a first embodiment of the overall hardware configuration of both the observation probes  100  and the reference probes  110 . The hardware configuration comprises a multitude of transmitting optical fibers  120   t  and receiving optical fibers  120   r  evenly connected to a same cross section of the gas pipeline  130  via robust transparent adapters (e.g. sapphire windows in the walls of the gas pipeline  130 ) and remotely connected to a spectrum analyzer device  80 . The transmitter probes  160  and the detector probes  170  are connected to the light source  70  through a light multiplexer  180  and a light demultiplexer  190  in order to emit and collect the transmitted, reflected, and refracted light in a time-multiplexed manner. While the light source  70  can emit light, which can be spread over a wide range of wavelengths, the photodetector  80  (also known as light detector) operates within either the NIR or MIR ranges. Hence, the photodetector consists of 2 n  photo detector elements, where the photo-detector elements are sensitive to a very narrow single wavelength source of light. A transparent prism (not shown) is inserted between the receiving optical fiber  120   r  and the array of photodetectors elements in the photodetector  80 . The computing device  90  reads the values stored by these photodetector elements in a fast serial manner, allowing a real-time data acquisition. 
         [0054]    Raman spectroscopy is a technique that is used to monitor the black powder  150  in the gas pipeline  130 . Raman spectroscopy is based on inelastic scattering of monochromatic laser light (from the light source  70 ) by matter. Inelastic scattering is the change of the frequency of photons in the laser light upon interaction with the matter. When the photons of the laser light are absorbed by the matter and then reemitted, the reemitted photons can have a frequency that is shifted up or down when compared with the original laser frequency. This shift is called the Raman effect. This shift offers information about the studied matter by observing the vibrational, rotational, and other low frequency transitions in molecules. A further discussion on the use of the Raman effect to detect solid particles in a fluid is found in Gallego et al, “Rapid measurement of phenolic compounds in red wine using Raman spectroscopy”, IEEE Trans. Instrum. Meas. Vol. 60, No. 2, 507-512, February 2011. 
         [0055]    In  FIG. 2 , the device  10  can operates either in the transmittance mode or in the diffuse-reflectance mode as will now be explained. 
         [0056]    Transmittance Mode 
         [0057]    By illuminating one side of the gas pipeline  130 , and measuring the intensity of the light that exits from the contaminants of the black powder  150  in an opposite side of the gas pipeline  130 , the computing device  90  acting as an analyzer can analyze the relationship between the projected light intensity and the received light intensity to determine the absorption according to Eqn 1: 
         [0000]      A=log 1   I   0   /I   1    (1)
 
         [0058]    where A is the absorbance, I 0  is the emitted light, and I 1  is the detected light. 
         [0059]    While the accuracy of the measurement would increase with the increase of the number of the transmitter probes  160  and the detector probes  170 , having a homogenous distribution of the black powder  150  in the gas pipeline  130  helps to relax this constraint. Hence, a flow homogenization can be easily obtained by properly designing the gas pipeline  130  preceding the transmitter probes  160  and the detector probes  1370  (e.g. by using a T-blender). This approach is commonly considered in flow measurement instrumentation, as noted in Meribout et al “A multisensory intelligent device for real-time multiphase flow metering in oil fields”, IEEE Trans. Instrum. Measur., Vol. 59, No. 6, 1507-1519, January 2010. 
         [0060]    Diffuse-reflectance spectroscopy is a technique for measuring irregular-shaped materials and powders, especially iron oxides and oxyhydroxides (see Liu et al, “Quantification of hematite from the visible diffuse reflectance spectrum: Effects of aluminum substitution and grain morphology”, Clay Minerals, Vol. 46, No. 1, 137-147, 2011. The diffuse-reflectance spectroscopy relies on the principle that when the light beam  165  enters the gas pipeline  130 , some of the energy in the light beam is reflected off the surface of the particles in the black powder  150  while some of its energy is transmitted through the particles. The light energy reflecting off the surface of the particle is usually lost while the light energy that passes through the particle is either reflected off the next one of the particles or transmitted through the next particle. This transmission-reflectance event happens many times in the device, which increases the path length of the reflected beam, as discussed in Giusto et al “Monitoring absorption changes in a layered diffusive medium by white-light time-resolved reflectance spectroscopy”, IEEE Trans. Instrum. Meas., Vol. 59, No. 7, 1925-1932, June 2010. 
         [0061]    When the light beam hits a diffuse surface, the light beam creates a “virtual light source” by reflection. Radiance, which is the flux density per unit solid angle, is used to best describe the light energy stemming from the surface. Radiance is used to indicate the amount of flux that is collected by the detector viewing the illuminated surface. The following equation represents the radiance L of a diffuse surface for an input flux, φ i . 
         [0000]    
       
         
           
             
               
                 
                   L 
                   = 
                   
                     
                       
                         ϕ 
                         i 
                       
                        
                       ρ 
                     
                     
                       Ω 
                        
                       
                           
                       
                        
                       A 
                     
                   
                 
               
               
                 
                   ( 
                   2 
                   ) 
                 
               
             
           
         
       
     
         [0062]    where ρ is the reflectance, A is the illuminated area, and Ω is the total projected solid angle from the surface of the particle. 
         [0063]    To derive the radiance L of an internally illuminated reflective loop, the radiance equation (2) must consider the multiple surface reflections as well as the losses through port openings for the transmitter probes  160  and the detector probes. Consider a reflective loop with a transmitter port area A i  and one detector port area A e . When the first beam hits the first spot in the reflective loop, the input flux is perfectly diffused by the first reflection. The quantity of flux incident on the entire reflective loop surface is 
         [0000]    
       
         
           
             
               
                 
                   
                     ϕ 
                     total 
                   
                   = 
                   
                     
                       ϕ 
                       i 
                     
                      
                     
                       ρ 
                        
                       
                         ( 
                         
                           
                             
                               A 
                               s 
                             
                             - 
                             
                               A 
                               i 
                             
                             - 
                             
                               A 
                               e 
                             
                           
                           
                             A 
                             s 
                           
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   ( 
                   3 
                   ) 
                 
               
             
           
         
       
     
         [0064]    where A s  is the surface area of the entire loop and the quantity in parenthesis represents the fraction of flux received by the loop&#39;s surface that is unconsumed by the two port openings, which can be written as (1−f) where f represents the port fraction (A i +A e )/A s . Consequently, the total flux incident after n reflections over the entire circle surface is 
         [0000]    
       
         
           
             
               
                 
                   
                     ϕ 
                     total 
                   
                   = 
                   
                     
                       
                         
                           ϕ 
                           i 
                         
                          
                         
                           ρ 
                            
                           
                             ( 
                             
                               1 
                               - 
                               f 
                             
                             ) 
                           
                         
                       
                       
                         1 
                         - 
                         
                           ρ 
                            
                           
                             ( 
                             
                               1 
                               - 
                               f 
                             
                             ) 
                           
                         
                       
                     
                     . 
                   
                 
               
               
                 
                   ( 
                   4 
                   ) 
                 
               
             
           
         
       
     
         [0065]    Eqn 4 shows that the total flux incident φ total  on the loop surface is greater than the input flux φ i  because of the multiple reflections within the circle boundaries. Accordingly, the circle surface radiance is 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       
                         
                           
                             ? 
                           
                           = 
                           
                             
                               
                                 ϕ 
                                 i 
                               
                               
                                 Ω 
                                  
                                 
                                     
                                 
                                  
                                 
                                   
                                     A 
                                     s 
                                   
                                    
                                   
                                     ( 
                                     
                                       1 
                                       - 
                                       f 
                                     
                                     ) 
                                   
                                 
                               
                             
                             × 
                             
                               
                                 ρ 
                                  
                                 
                                   ( 
                                   
                                     1 
                                     - 
                                     f 
                                   
                                   ) 
                                 
                               
                               
                                 1 
                                 - 
                                 
                                   ρ 
                                    
                                   
                                     ( 
                                     
                                       1 
                                       - 
                                       f 
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                       
                     
                     
                       
                         
                           = 
                           
                             
                               
                                 ϕ 
                                 i 
                               
                               
                                 Ω 
                                  
                                 
                                     
                                 
                                  
                                 
                                   A 
                                   s 
                                 
                               
                             
                             × 
                             
                               
                                 ρ 
                                 
                                   1 
                                   - 
                                   
                                     ρ 
                                      
                                     
                                       ( 
                                       
                                         1 
                                         - 
                                         f 
                                       
                                       ) 
                                     
                                   
                                 
                               
                               . 
                             
                           
                         
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     
                       ? 
                     
                      
                     
                       indicates text missing or illegible when filed 
                     
                   
                 
               
               
                 
                   ( 
                   5 
                   ) 
                 
               
             
           
         
       
     
         [0066]    Equation (5) represents the detected light, which is used in Equation (1) to deduce the absorbance required for the quantitative analysis of the black powder  150 . The equation (5) is used to predict the loop radiance for a given input flux (pi as a function of circle diameter, reflectance, and port fraction. Maximum radiance is expected to be detected by the detector probe  170  when there is no black powder  150  in the gas pipeline  130 . The radiance fluctuates as the quantity of the black powder  150  fluctuates in the illuminated area A. Accordingly, a quantitative analysis of the black powder  150  can be obtained. 
         [0067]      FIG. 3  illustrates a second embodiment of the overall detection system  10  in which a ring of optical fiber connectors  300  is attached to a plurality of probes with lens and/or sapphire window in the wall of the gas pipeline  130 . It will be appreciated that similar reference numerals are used in  FIGS. 2 to 4  to indicate similar elements. Each of these optical fiber connectors  300  receive an amount of light in either direction (transmittance/reflectance), depending on sequence of program instructions being executed by a controller  310 . The controller  310  is connected to the multiplexer  190  and the de-multiplexer  180 . The transmitting optical fibers  120   t  and the receiving optical fibers  120   r  are connected at a connector  330  to the optical fibers  320  connected to the optical fiber connectors  300 . 
         [0068]      FIG. 4  is a third embodiment of the overall system which is similar to the one shown in  FIG. 3 , except that the receiving light from the receiving optical fibers  120   r  is simultaneously acquired by a data acquisition module to run a detection algorithm in the computing device  90 . This third embodiment enables fast detection throughput, but at the expense of larger amount of hardware. 
         [0069]      FIG. 5  is a fourth embodiment of the overall system, which is similar to the ones shown in  FIGS. 3 and 4  except that no multiplexer or demultiplexer circuits are used. However, two bundles of optical fibers comprising multiple optical fibers lines in transmitting and receiving modes, respectively, are used. These optical fibers are the transmitting optical fibers  120   t  and the receiving optical fibers  120   r    
         [0070]      FIG. 6  shows the flow chart  600  of the approach carried out to conduct a multivariate calibration model. Details on the steps are given below. 
         [0071]    Choosing the Calibration and Validation Samples—step  610 . 
         [0072]    The number of samples  613  for the calibration and validation should be carefully chosen. Yet, more importantly is considering how to choose them. The calibration samples are also called training set and they are used to conduct the calibration and design the model in step  616 . On the other hand, the validation set consists of the validation samples and it is used to validate the model designed and evaluate the calibration performance. 
         [0073]    Design of Samples—step  616   
         [0074]    The quality of the calibration depends mostly on the training set used to generate the calibration. The training set must contain all of the unknowns that the calibration should analyze. Since the model to be designed for the calibration is based on statistical techniques, the training set should be a statistically valid sample of the population including all unknown samples for the application. In order to prevent extrapolation, the concentrations of the particles of black powder  130  in the calibration samples should span the full range of concentrations that will exist in the unknown gas stream  140 . Since only one component is considered in the experiments, the sample design is not complicated and only requires to vary the concentration of the black powder samples stepwise in order to span the full range of the specified concentrations. However, if more than one component exists in the samples, more attention should be paid for the sample design in step  616 . 
         [0075]    Determination of the target parameter in step  620 . 
         [0076]    In order to produce a model that predicts different concentration values of black powder  150  in the gas pipeline  130 , target parameters should be determined and the first step is to create a concentration matrix, which will be used later to predict the concentration values. The data set concentration values are used to form the concentration matrix (C). For m components and n samples, the concentration matrix (C) can be assembled as a (n×m) matrix, where the m components in this context mean sources of variation. For simplicity, the black powder  150  was considered as a single one of the m components in the test and ten samples were taken. Accordingly, the concentration matrix (C) was assembled as a (10×1) matrix. 
         [0077]    Record NIR Spectra of All Samples—Step  630 . 
         [0078]    The absorbance matrix (A) represents the spectral data and each spectrum is represented as a column vector. For P wavelengths and n samples, the absorbance matrix (A) can be assembled as an (n x p) matrix. Consequently, for the application of this disclosure, the absorbance matrix for the NIR spectroscopy was assembled as a (10×1400) matrix since the data were taken over P=1400 wavelengths for the ten different samples. On the other hand, the absorbance matrices (A) for the MIR (P=828) and Raman spectroscopy (P=1850) were assembled as (10×828) and (10 X 1850) matrices, respectively. 
         [0079]    The multicomponent form of the Beer-Lambert law is considered the base of quantitative analysis in spectroscopy 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       A 
                       s 
                     
                      
                     
                       
                         ∑ 
                         
                           
                             ? 
                           
                           , 
                           
                             ? 
                           
                         
                         
                           ? 
                         
                       
                        
                       
                           
                       
                        
                       
                         ( 
                         
                           
                             a 
                             
                               j 
                               , 
                               i 
                             
                           
                            
                           
                             bc 
                             j 
                           
                         
                         ) 
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     
                       ? 
                     
                      
                     
                       indicates text missing or illegible when filed 
                     
                   
                 
               
               
                 
                   ( 
                   6 
                   ) 
                 
               
             
           
         
       
     
         [0000]    where Ai is the measured absorbance at wavelength i, ε j,i  is the sample&#39;s absorptivity of component j at wavelength i, b is the optical path length of the measurement, and c j  is the concentration of component j. 
         [0080]    The summation in equation (6) is taken over the m components of each of the samples. However, the term product ε j,i  can be combined to produce the sensitivity coefficient k j,i , which represents the correlation between the concentration and absorbance. For the m components and the P wavelengths, the sensitivity matrix (K) can be assembled as a (m×P) matrix, which is basically the spectra of each pure component in each raw. After assembling the (A), (C), and (K) matrices, the equation (6) can be defined in matrix notation as. 
         [0000]        A=CK+E    (7)
 
         [0000]    where E represents the error matrix (n×P) which shows that noise, artifact, or other kind of errors cannot be verified by the term C·K and will be presented in the measured absorbance matrix A. 
         [0081]    Pretreatment of the Recorded Spectra—Step  640 . 
         [0082]    Prior to designing a multivariate model for the system  10 , data pretreatment techniques are used in step  640  to reduce, remove, or regulate unwanted effects on the spectra caused by physical properties of the samples or instrumental effects, such as light scattering, path length variations, and random noise. Therefore, different ones of the pretreatment methods were applied to the spectra to choose the right ones. It was found that only normalization (step  646 ) and mean centering (step  643 ) were chosen to apply to the MR spectra while the MIR and Raman spectra required smoothing (step  649 ) in addition to normalization  646  and mean centering  643  as the smoothing  649  helped getting the best results without destroying the information. 
         [0083]    Reduction of Variables by Principal Component Analysis—Step  640   
         [0084]    Principal component analysis (PCA) is a variable-reduction tool that reduces the dimensions of the original data into less uncorrelated variables comprising only significant information from the sample. The PCA in step  655  uses the directions of maximum variability in sample groupings to generate new axes called principal components (PCs). The new variables (PCs) should have the following criteria.
   Comprise of linear combinations of the original variables.   The first new axis is in the direction covering most variation.   Every succeeding new variable is orthogonal to preceding variables.   Every succeeding new variable is in the direction covering most of the remaining variation.   The new variables are uncorrelated.   
 
         [0090]    Mathematically, the new variables (PCs) are produced by finding the eigenvectors of the variance matrix of the original variables (wavelengths). Then, use these found eigenvectors as the weight vectors for constructing the variables. The analogous eigenvalues then indicate the amount of the original variance that has been enclosed by each new variable. 
         [0091]    The PCA is used for qualitative analysis in which spectra are compared with beforehand known spectra then the difference or the resemblance of those spectra discloses information. If we observe A, we can predict C and K in Eqn 7 
         [0000]        A=Ĉ{circumflex over (K)}+{circumflex over (K)}   (8)
 
         [0000]    where the hat notation (̂) used in equation (8) indicates a prediction. 
         [0092]    This calculation is done by first performing PCA, which results in an abstract mathematical transformation of the equation (8) and yields the form: 
         [0000]        A=Ĉ{circumflex over (K)}+Ê={circumflex over (T)}−{circumflex over (P)}   (9)
 
         [0000]    where T contains the scores in which the variables are linear combinations of the original variables in A. P is the loadings matrix, which is estimated by regressing A onto T. The residual matrix E is found by subtracting the estimated {circumflex over (T)}−{circumflex over (P)} from A. 
         [0093]    Construct the Model in step  660 . 
         [0094]    When the different components of the samples are classified, the next step is to quantitatively identify the concentration of each of the different components. The PCR and PLSR methods permit the prediction of the concentrations for the new samples based on their spectra, as is known from Larrain et al, “A multipurpose portable instrument for determining ripeness in wine grapes using NIR spectroscopy”, IEEE Trans. Instrum. Meas., Vol. 57, No. 2, 294-302, February 2008. 
         [0095]    Calibration using PCR or PLS can be very simple if we consider only black powder  150  as a single compound and ignore all identities and concentrations of the other compounds. 
         [0096]    The PCR in step  663  is performed through four main steps.
   Obtain the spectra of the training set to construct the (A) matrix.   Perform PCA on these spectra, and deduce the scores (T) matrix and the loadings (P) matrices.   Determine how many PCs should be retained. For this purpose, leave one out (LOO) cross validation was used.   Perform the regression.
 
The aim of the calibration in step  663  is to find a relationship between the scores and the true concentrations of each compound in the gas stream  40 , which takes the form
   
 
         [0000]        c=T·{circumflex over (r)}   (10)
 
         [0000]    where c is the known concentrations in the mixture spectra in the gas stream  140 , and r is a column vector, which represents the estimated regression coefficient whose length equals the number of PCs. r can be estimated by the known c and (T) (obtained from PCA) as 
         [0000]        {circumflex over (r)}=T   +   ·c.    (11)
 
         [0000]    This allows the PCR approximation of the concentration C(CPR) vector to be computed 
         [0000]        c   (PCR)   =T·T   +   ·c.    (12)
 
         [0101]    T +  is the pseudo inverse of T. If there are numerous compounds of interest, the vector c can be expanded to a matrix (C), in which each column corresponds to a compound 
         [0000]        C=T·R.    (13)
 
         [0000]    In order to estimate the quality of prediction, the equation (12) is applied to the test or validation set before estimating real data of unknowns. 
         [0102]    The PLSR components in step  666  are acquired using both (A) and c data simultaneously, which maximize the covariance between them. The covariance in PLSR is modeled by finding a variable that maximizes the product of the experimental data with the concentrations. Basically, the PLSR assumes that errors exist in both blocks, which are equally important as opposed to PCR which assumes that all the errors are in the measured data. The PLSR is presented by 
         [0000]    
       
      
       A=T·P+E  
      
     
         [0000]        c=T·q+f    (14)
 
         [0000]    where the first equation in (14) appears similar to that of PCA except that the scores matrix (T) models both the concentrations and the spectra. The vector q in equation (14) has some analogy to a loadings vector and it is estimated by regressing c onto T. f is the error vector for the c block and it is calculated by subtracting the estimated T·q from c. After defining the new scores and loadings matrices and vectors the regression is done the same way as PCR. 
         [0103]    Validate the Model Using Cross Validation—Step  670 . 
         [0104]    The optimal number of PCs is determined by cross validation. The LOO cross validation is used in this disclosure. This is done by removing one sample from the calibration set, using the remaining for calculating a new calibration, and using the new calibration to predict the concentrations of the removed sample. Each prediction is then compared with the actual concentration, which is already known, as the removed sample is part of the total calibration set. This procedure is repeated N times (where N is the number of samples in the calibration set), each time leaving out one sample and performing the calibration on it until all samples are tested. This is done in order to determine the best number of PCs (or factors) by trying all numbers of factors. 
         [0105]    Both the PCR and the PLSR models for NIR, MIR, and Raman spectroscopy were evaluated to determine their efficiency. The following criteria were calculated and compared. 
         [0106]    Predicted Residual Sums of Squares 
         [0107]    The size of the errors in the models can determine their quality. Therefore, the sum of squares of E (in PCR and PLS) and f (in PLS) is calculated which measures the accuracy of the prediction by taking the sum over all squared differences between cross validation predicted and true known qualities for all N samples 
         [0000]    
       
         
           
             
               
                 
                   PRESS 
                   = 
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         1 
                       
                       
                         ? 
                       
                     
                      
                     
                         
                     
                      
                     
                       
                         
                           
                             ( 
                             
                               
                                 c 
                                 
                                   predicted 
                                   , 
                                   i 
                                 
                               
                               - 
                               
                                 c 
                                 
                                   known 
                                   , 
                                   i 
                                 
                               
                             
                             ) 
                           
                           2 
                         
                         . 
                         
                           
 
                         
                          
                         
                           ? 
                         
                       
                        
                       
                         indicates text missing or illegible when filed 
                       
                     
                   
                 
               
               
                 
                   ( 
                   15 
                   ) 
                 
               
             
           
         
       
     
         [0108]    Also, the number of significant PLS and PCR components are estimated according to the size of these errors using cross validation, the smaller the error is, the better the model. 
         [0109]    Coefficient of Determination R 2    
         [0110]    The coefficient of determination R 2  provides a measure of how well future outcomes are likely to be predicted by the model. It is represented by the total sum of squares divided by the residual sum of squares all subtracted from 1 
         [0000]    
       
         
           
             
               
                 
                   
                     R 
                     2 
                   
                   = 
                   
                     1 
                     - 
                     
                       
                         SS 
                         
                           
                             ? 
                           
                            
                           err 
                         
                       
                       
                         SS 
                         
                           ? 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   16 
                   ) 
                 
               
             
             
               
                 where 
               
               
                 
                     
                 
               
             
             
               
                 
                   
                     SS 
                     
                       
                         ? 
                       
                        
                       err 
                     
                   
                   = 
                   
                     
                       ∑ 
                       i 
                     
                      
                     
                       
                         ( 
                         
                           
                             y 
                             i 
                           
                           - 
                           
                             f 
                             i 
                           
                         
                         ) 
                       
                       2 
                     
                   
                 
               
               
                 
                   ( 
                   17 
                   ) 
                 
               
             
             
               
                 
                   
                     SS 
                     
                       ? 
                     
                   
                   = 
                   
                     
                       ∑ 
                       i 
                     
                      
                     
                       
                         ( 
                         
                           
                             y 
                             i 
                           
                           - 
                           
                             y 
                             _ 
                           
                         
                         ) 
                       
                       2 
                     
                   
                 
               
               
                 
                   ( 
                   18 
                   ) 
                 
               
             
             
               
                 
                   
                     ? 
                   
                    
                   
                     indicates text missing or illegible when filed 
                   
                 
               
               
                 
                     
                 
               
             
           
         
       
     
         [0000]    y i  is the observed value, f i  is the predicted value, and  y  is the mean of the observed data. 
         [0111]    Ideally, a perfect model has R 2 =1, however, in practice a high value of R 2  almost equal to one is enough to represent a good model. 
         [0112]    For a process device, the computation time is a factor in order to rapidly monitor the continuous process. The less required computation time of the designed model, the faster the analysis is done. The computation time takes into account the preprocessing task, as well as the PCR or PLSR timing requirements. For the offline experiment, the computation time required for running the MATLAB code for the preprocessing task and the PCR/PLSR was calculated using built in special MATLAB codes. 
         [0113]    In the real device, the preprocessing task, such as the smoothing operation (step  649 ), features local computation requirements, which can be effectively implemented on a VLSI device, such as field programmable gate array (FPGA). Hence, a first in first out memory device is fed to the smoothing circuit to provide the input noisy spectrum. In this way, the filtered spectrum is generated on the fly with no delay. The number of logic blocks used within the FPGA device is proportional to the window size of the filter being considered. Hence, for a typical window size of eight (8), seven (7) logic blocks are required. This constitutes a negligible hardware requirement with regard to the capacity of modern FPGA devices, which contain hundreds of thousands of logic blocks. The remaining resources can be used for the post processing tasks. 
         [0114]    The mean squared error of prediction (MSEP) is often used to assess the performance of regressions. Furthermore, the MSEP is used for selecting the optimal number of components in (PCR) and (PLSR). In order to perform the MSPE, the training data set (L={x i ,y i )}) of n L  observations is randomly divided into K segments L k , where k=1 . . . to . . . K, of approximately equal size. The equation (19) represents the MSPE where f k  is the predictor (PLSR and PCR) trained on L/L k , i.e., all observations not in L k . The K-fold cross validation estimate is 
         [0000]    
       
         
           
             
               
                 
                   
                     MSEP 
                     
                       ev 
                       , 
                       K 
                     
                   
                   = 
                   
                     
                       1 
                       
                         n 
                          
                         
                             
                         
                          
                         L 
                       
                     
                      
                     
                       
                         ∑ 
                         
                           k 
                           = 
                           1 
                         
                         K 
                       
                        
                       
                           
                       
                        
                       
                         
                           ∑ 
                           
                             ? 
                           
                         
                          
                         
                             
                         
                          
                         
                           
                             ( 
                             
                               
                                 
                                   f 
                                   k 
                                 
                                  
                                 
                                   ( 
                                   
                                     x 
                                     i 
                                   
                                   ) 
                                 
                               
                               - 
                               
                                 y 
                                 i 
                               
                             
                             ) 
                           
                           . 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   19 
                   ) 
                 
               
             
             
               
                 
                   
                     ? 
                   
                    
                   
                     indicates text missing or illegible when filed 
                   
                 
               
               
                 
                     
                 
               
             
           
         
       
     
         [0000]    where the inner sum is taken over the observations in the kth segment. The LOO cross validation is the K-fold cross validation with K=n L . 
       EXAMPLES 
       [0115]    Materials: The black powder samples were obtained from ASAB field, GASCO, Abu Dhabi, United Arab Emirates. 
         [0116]    Instrumentation. A UV-vis-NIR Carry 5000 spectrophotometer was used for the NIR measurements. The measuring method was transmittance and the NIR spectra were obtained as absorbance in the 800-2200 nm range with a resolution of 1 nm. 
         [0117]    The FT-MIR transmission spectra were recorded on a Vertext-70 from Bruker FT-MIR spectrometer (Appendix E) to obtain the MIR spectra. The spectra were recorded at 4 cm −1  resolution in the 525-3897 cm −1  spectral range. 
         [0118]    Raman spectra were obtained using LabRam HR spectrometer, manufactured by Horiba Scientific. The He—Ne laser operates at 633 nm with a maximum power of 2 W and a focal length of 50 mm. A laser output power of 1.2 W was used, which was low enough to prevent possible laser induced sample damage and a high signal to noise ratio. Data were collected at 1 cm −1  resolution. Spectra were used in the Raman shift range between 150 and 2000 cm −1 . 
         [0119]    All of the black powder samples were stored and their spectra were obtained at 25° C. room temperature. The spectral range specified for each measurement was determined by the spectrometers used. 
         [0120]    Sample Preparation and Recording of Spectra 
         [0121]    For the NIR spectra, ten samples of the black powder  150  ranging from 200 to 2000 ppm were prepared. The black powder  150  was mixed with distilled water in an ultrasonic-based mixer for 30 min to suspend the black powder particles  150  in order to mimic its suspension in the gas process. After mixing, the black powder  150  was quickly transferred to a cuvette to take the measurement while the particles of the black powder  150  are still suspended in the liquid. Another cuvette containing distilled water was used as a reference. 
         [0122]    In another set of experiments, ten spectra were acquired using MIR and Raman spectroscopy directly without any sample preparation. Samples with different dry black powder contents were prepared by varying the depth or thickness of the black powder layer facing the MIR/Raman light source. The depth of powder was 2-10 mm. 
         [0123]    Data Processing 
         [0124]    All data processing was coded in MATLAB programming language, Version 7.0.1 (the Math Works, Natick, Mass., USA). 
         [0125]    Spectral Features 
         [0126]      FIG. 7  shows all the ten (10) MIR ( FIG. 7A ), NIR ( FIG. 7B ), and Raman spectra ( FIG. 7C ) of the black powder samples used in this disclosure. These spectra provide information of all the components of the black powder  150 . The absorption bands in the spectra represent the chemical groups of components present in the samples. Although the NIR spectra ( FIG. 7B ) show clearer and simpler spectral differences among the samples, the MIR and Raman spectra  FIGS. 7A and 7C  have more information and sharper peaks. Overall, the MIR spectra ( FIG. 7B ) offer greater spectral features and resolution, yet the MIR spectra in  FIG. 7B  comprise more spectral noise and baseline variation. Also, it is evident from  FIG. 7A  that the black powder  150  has very low absorption in the MIR range. On the other hand, the band in the NIR ( FIG. 7B ) is wide and less sensitive compared with the MIR spectra in  FIG. 7A  and the Raman spectra in  FIG. 7B . 
         [0127]    PLSR and PCR Calibration Models for NIR, MIR, and Raman Spectroscopy 
         [0128]    In order to simplify the calibration process, the pure natural gas spectrum should be extracted from the acquired online spectrum before analyzing the data. In an attempt to mimic the black powder  150  in real natural gas pipelines  130 , which contain many different contaminants, sand, methane gas, and ethane gas spectra were added to the black powder spectra.  FIG. 8  shows the resultant MIR spectrum of black powder mixed with sand, methane, and ethane gas before extraction.  FIG. 9  shows the MIR spectra of black powder mixed with sand after extracting methane and ethane gases. 
         [0129]    In both the PLSR and PCR calibration models, the spectral range and number of PLSR factors are critical parameters and the calibration performance depends on them. Therefore, only the regions (1300-3000 cm −1 ) of the MIR, (1300-1900 nm) of NIR and (200-1400 cm −1 ) of the Raman spectra were considered as these ranges contain most of the useful information. Decreasing the calibration regions also helped in increasing the speed of the analysis and thus save computational time. This spectral range is further reduced and only critical ranges, which include information about the black powder should be considered to avoid the effect of sand. The chosen spectral range must include information describing the concentration variation of the black powder while excluding regions conquered by noise or other constituents. The proper spectral ranges can be recognized by calculating the correlation spectrum for each constituent of interest ( FIG. 10 ), i.e., different spectral ranges can also be used to identify the quantity of sand. This is done by calculating the correlation of the absorbance at every wavelength in the training set spectra to the concentrations of black powder. Only high correlation regions should be selected and low or no correlation regions should be ignored.  FIG. 10  shows high correlation bands at (1614-1661) and (2099-2145) cm −1  for the black powder  150 . These regions are selected for PLSR and PCR calibrations to determine the concentration of black powder since they are mostly conquered by characteristic absorptions due to the black powder only. 
         [0130]    The optimal number of components for PCR and PLSR is determined before the predictions of new samples; it is a part of the calibration. The optimal number of factors is the number that results in the best prediction; hence, the optimum number of factors was identified as the number of factors that result in minimum predicted residual sums of squares (PRESS). The evaluation of the calibration and prediction performances is estimated by calculating the coefficient of determination R 2  and the MSPE values. Prior to calibration, the NIR, MIR, and Raman spectra were mean centered (step  343 ) and normalized (step  646 ) while only the MIR and Raman spectra were smoothed (step  649 ). 
         [0131]    In order to test PCR and later PLSR, a random selection of three validation samples from the total data set were removed. The remaining seven spectra and their known concentrations serve as the calibration set that is used then to predict the unknown concentrations of the validation set. The predicted concentrations are then compared with their known concentrations. 
         [0132]      FIG. 11  shows a plot of the PRESS function, which performs the systematic cross validation for up to six principal components. The optimum number of principal components (or factors) for the NIR and Raman PCR calibration model is 2, which present a PRESS of 0.005344 and 0.0002402, respectively. The minimum value for the MIR PCR model is clearly associated with three factors with a PRESS value of 0.00202; however, this value does not significantly differ from the two factors (0.002126), which also can be used to obtain good results. On the other hand, the PLSR calibration model in  FIG. 11  shows that the optimum number of components for NIR, MIR, and Raman is 2 with a PRESS value of 0.005467, 0.002099, and 0.0002329, respectively. 
         [0133]    The MSPE for the PLSR is 0.0008731, 0.0001983, and 5.04e-5 for NIR, MIR, and Raman, respectively; while for the PCR it is 0.0009065, 0.0002068, and 5.099e-5, see  FIG. 12 . It is expected that the MSPE decreases sharply with the initial factors and continues to decrease as more related spectral variation is assimilated into the calibration model. As the number of factors increases further, the MSPE begins to increase indicating that the data has been over-fit by including spectral information into the model that is not related to the concentrations property. 
         [0134]      FIG. 13A  shows the PCR and PLSR calibration for the MIR using only two factors for the PLSR model and three factors for the PCR model.  FIGS. 13B and 13C  show the PCR and PLSR calibration for the NIR and Raman models, respectively, in which both PLSR and PCR used two factors. 
         [0135]    Furthermore, in order to validate the model, the prediction of the three validation samples is performed and shown in  FIG. 14 . As it is expected already from the high R 2  ( FIG. 16 ) and the low MSPE values, all three techniques show very high precision and accuracy. 
         [0136]    This disclosure discusses different IR spectroscopic techniques for gas monitoring in the pipelines and the computation time for the prediction analysis is a factor. The computation time for all three techniques as a function of PLSR and PCR factors is shown in  FIG. 15 . Although increasing the number of PLSR and PCR factors result in better prediction (only to a certain number and then the data get over-fitted), it also increases the computation time required. 
         [0137]    Comparing PLSR and PCR Methods 
         [0138]      FIG. 16  summarizes the comparison between PLSR and PCR for all three techniques. Since these models adapt only ten samples, it is expected to have a smaller scale for all statistical results and comparison; hence, it is noticeable that two PLSR and PCR factors is enough to perform an excellent calibration although it is also possible to get good results with one factor. The correlations R 2  between the predicted and actual values for the black powder  150  were very high for both PLSR and PCR methods. The accuracy of the above models was considered sufficient since testing was done with samples that cover a broad range of concentrations. 
         [0139]    In view of the similarity of the PRESS results for PCR and PLSR, it is anticipated that the predicted concentrations are very similar for the three methods. Comparing the R 2  and MSPE values for the PLSR and PCR, it can be concluded that both methods are almost indistinguishable in their outcome. However, PLSR seems to reach optimal prediction with fewer factors than PCR. Also, PLSR seems to be accomplishing the prediction analysis faster than PCR ( FIG. 15 ), which serves as an advantage for online monitoring especially when a plurality of the transmitter probes  160  and the detector probes  170  are used for the monitoring. In addition, in an attempt to check the robustness of both methods, the true concentrations were varied and the prediction capabilities of both methods were observed. As expected, the PLSR method gave a better prediction than PCR since PLSR components are acquired using both the spectra and the concentrations data simultaneously which maximize the covariance between the two data sets, unlike PCR which only considers the spectra data when calculating its factors. Hence, the PLSR is more robust and can compensate for systematic and human errors more than PCR. 
         [0140]    Comparing NIR, MIR, and Raman Techniques 
         [0141]    As shown in  FIG. 16  all three techniques can be used to obtain an excellent calibration model. However, in account of the calibration and prediction performances, the Raman technique shows slightly better results than NIR and MIR techniques considering the R 2  and MSPE values. However, the Raman spectroscopy requires the use of powerful lasers as the sources of light  70  and their optical alignment in order to create an intense and focused path of radiation on the sample, and usually only a professional operator with adequate skills can acquire the proper alignment. Hence, for rapid online monitoring, more experiments should be conducted for Raman spectroscopy before obtaining any conclusive decision on its efficiency. 
         [0142]    On the other hand, the MIR spectra are the richest in information among all three techniques, as evident from  FIG. 7A . Therefore, the use of MIR spectra is good for multicomponent quantitative analysis where several constituents are to be identified and measured. However, the MIR spectroscopy technique does not have an established multiplexing capabilities nor does the MIR spectroscopy technique support long optical fiber cables. These two criteria are crucial for the requirement of this paper and the proposed device in order to be able to monitor black powder in remote hazardous pipeline systems. 
         [0143]    Although NIR is poor with obvious information content, sophisticated chemometric methods, such as PLSR and PCR can be applied to its spectra to extract useful information and perform quantitative analysis. In addition, its ability for online monitoring via optical fibers and its multiplexing capabilities make NIR spectroscopy preferable to MIR spectroscopy despite the slightly better results of MIR shown in  FIG. 16 . Again, these models considered only ten samples, which resulted in a very small scale for all statistical results; hence, if a conclusion can be drawn, it is that the Raman technique with the use of PLSR regression appears to have the potential for calibrating a better system only for the offline experiment conducted for this paper. Yet, MIR and NIR techniques produced good prediction results as well and can be alternatively considered with the expectation of good results. Therefore, since all techniques produced good models, a feasibility study can be conducted in order to determine the best option for real-time remote online monitoring. 
         [0144]    The foregoing description of the preferred embodiment of the invention has been presented for purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise form disclosed, and modifications and variations are possible in light of the above teachings or may be acquired from practice of the invention. The embodiment was chosen and described in order to explain the principles of the invention and its practical application to enable one skilled in the art to utilize the invention in various embodiments as are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the claims appended hereto, and their equivalents. The entirety of each of the aforementioned documents is incorporated by reference herein.