Patent Publication Number: US-6707556-B2

Title: Apparatus and method for analyzing fluids

Description:
This application is a divisional of Ser. No. 09/453,003 filed Dec. 2, 1999, now U.S. Pat. No. 6,507,401. the entirety of which is incorporated herein by reference. 
    
    
     FIELD OF THE INVENTION 
     The current invention is directed to the analysis of fluids. More specifically, the current invention is directed to the compositional analysis of fluids, such as fluids produced by oil wells, that contain constituents that fluoresce and/or absorb radiation, such as near-infrared radiation. 
     BACKGROUND OF THE INVENTION 
     Monitoring of the fluids produced by an oil well, such as compositional analysis, provides valuable information that allows production to be optimized. In the past, such monitoring was performed by analyzing fluid samples brought to the surface, typically using techniques such as ultraviolet-visible (UV-Vis) absorbance spectroscopy, infrared (IR) absorbance spectroscopy, UV fluorescence spectroscopy, nuclear magnetic resonance spectroscopy, mass spectrometry, and gas chromatography. 
     Unfortunately, these traditional surface fluid analysis techniques are of limited value in many wells created using modern drilling and production methods. This is so because modern methods often result in the creation of complex and/or difficult to monitor wells, such as multizone, horizontal, or multilateral wells. In such wells, fluid produced from different zones of the well may be combined downhole so that the fluid discharged at the surface is a mixture. Analysis of this mixture provides little information concerning the component of the fluid production associated with any of the individual zones of the well, which is necessary to maximize the overall production of oil while minimizing the production of water. For example, if one zone were producing fluid with a high water content, a control device could be operated to limit or cease production from that zone. Subsurface monitoring at the source is also advantageous where accurate knowledge of various field&#39;s production rates are required. For example, in subsea applications, fluid from different reservoirs may be combined at a subsea manifold. Production monitoring at this point is desirable to allow the operator to make control decisions regarding individual wells. 
     Another disadvantage of surface techniques is that they analyze the fluid after it has flowed through a long production tubing, which can alter the phase properties of the fluid (e.g., induce slugging). By contrast, downhole analysis provides real time data on conditions occurring at the point of production in the well. 
     Consequently, it would be desirable to provide a system and method for analyzing fluid produced in each individual zone of the well prior to intermixing—that is, in a downhole environment. 
     The ability to remotely sense the presence of certain fluids, such as oil, in a flowing stream, is also desirable in situations other than in oil wells. For example, it is sometimes desirable to determine when a fluid, such as discharge water, that should not contain oil has become contaminated with oil. Consequently, it would be desirable to provide a system and method for analyzing the presence of certain fluids in a flowing stream. 
     When light strikes a fluid, several phenomena may occur. A portion of the light may be reflected from the surface, while another portion will enter the fluid. The portion of the light entering the fluid may be transmitted through the fluid or subjected to scattering or absorption. Very often, all of these mechanisms occur simultaneously. 
     Light may scatter as a result of several different mechanisms. If more than one phase is present in the fluid, light will be scattered by reflection and refraction at the interfaces between the phases. Scattering will also occur as a result of the Rayleigh mechanism. Light scattered by the Rayleigh mechanism has the same wavelength as that of the incident light. In some substances, such as oil, scattering also occurs by the Raman phenomenon. Raman scattering produces extremely low intensity light (relative to the intensity of the incident light) having wavelengths both above and below that of the incident light, so that even monochromatic light yields scattered light in a range of wavelengths. Thus, when analyzed by a spectrograph, Raman scattering produces lines on both sides of the Rayleigh line that are a characteristic of the substance and upon which the light is incident can be used its composition. 
     Previously, it has been proposed to use Raman scattering to determine the composition of certain types of hydrocarbons in refineries, such as disclosed in U.S. Pat. No. 4,620,284 (Schnell et al.). However, Raman analysis cannot be used to determine the composition of a mixture of crude oil and water, such as that flowing through a well, for two reasons. First, crude oil is highly fluorescent so the fluorescent radiation, which has a longer wavelength than the incident light, would overwhelm the Raman signal even when using a near infrared excitation source. Second, the light emitted as a result of Raman scattering is too low in intensity to be transmitted to the surface for analysis, while the down hole environment is too harsh to permit the use of the sensitive equipment, such as a spectrograph and charged couple device, necessary to conduct a Raman analysis down hole. 
     In addition to scattering, a portion of the light entering the fluid may be absorbed. The amount of light absorbed at a given wavelength is a characteristic of the substance. Therefore, the constituents of a substance can be determined by comparing the spectrum of the light directed into the fluid with that of the light that has been transmitted through it so as to determine the spectrum of the light absorbed by the fluid. This spectrum may be expressed, for example, as −log 10  of the ratio of the light directed to the fluid and the light transmitted through the fluid. Although compositional analyses using absorption have been proposed in the past, they suffer from the fact that the intensity of the light transmitted through the fluid depends on scattering, as well as absorption. Whereas absorption is primarily a function of the constituents of the fluid, scattering also depends on the physical form of those constituents. For example, in an emulsion, such as a mixture of water and oil, the more finely dispersed the oil droplets the greater the scattering. The increase in scatting associated with the reduction in droplet size will reduce the intensity of the transmitted light, despite the fact that the composition of the fluid, in a quantitative sense, has remained unchanged. Scattering can, therefore, lead to significant errors in systems measuring the absorption spectra of the fluid. 
     U.S. Pat. No. 4,994,671 (Safinya et al.) discloses a method for analyzing the composition of fluid in a well by suspending within the well a tool that contains a spectrograph and an incandescent tungsten-halogen lamp. The lamp is characterized as being relatively bright in the 1000 to 2500 nm range and down to about 500 nm and having acceptable emissions from 350 to 500 nm. The lamp directs light onto a sample of fluid that is admitted into the tool. Different sections of a fiber optic bundle receive the light transmitted across the fluid sample, as well as the light back-scattered from the sample. The spectra of both the transmitted light and the back scattered light are measured by a spectrograph and the data are digitized and transmitted electronically to a computer at the surface. Two absorption spectra for the fluid are determined by dividing the transmitted light spectrum and the back scattered light spectrum by the spectrum of the source light. If the fluid is sufficiently transparent to transmit an adequate amount of light through it, Safinya recommends the use of the transmitted light; otherwise the back-scattered light may be used. The computer determines the constituents of the fluid sample by comparing the transmitted or back-scattered absorption spectra to a data base containing reference spectra for water, gas and various types of oils, and using a least squares or principal component analysis method. Since the spectra may vary with the temperature and pressure, Safinya discloses that in order to obtain an accurate analysis, the data base should contain reference spectra for the various constituents at a variety of pressures and temperatures. Unfortunately, Safinya&#39;s method suffers from a variety of drawbacks that have made it unsuitable for use in practical applications. 
     First, as indicated in U.S. Pat. No. 5,266,800 (Mullins), the computations necessary to perform the analysis taught by Safinya are computationally intensive and required an extensive data base of spectra for water, gas and oils. 
     Second, and perhaps more importantly, Safinya does not account for the effect of variations arising from scattering. The flow of a multicomponent fluid (e.g., oil, water and gas) through a production well has very complex multiphase properties. Variations will occur not only in terms of the relative proportion of the constituents but also in multiphase characteristics, such as droplet or bubble size and the composition of the continuous and dispersed phases (e.g., oil and gas bubbles dispersed in water, oil droplets dispersed in gases, etc.). Additionally, there may be particulate matter suspended in the fluid, which can add to the scattering. As discussed above, variations in these physical characteristics of the fluid will cause variations in the intensity of the transmitted or back scattered light that, according to Safinya&#39;s method, will cause an apparent, but erroneous, change in the composition of the fluid. For example, suppose that the spectrum is obtained of a fluid flowing through a well that is initially a 50/50 mixture of oil and water, with the water occurring in relatively large droplets. Further suppose, although this is not by any means to be expected, that comparison to the spectra in the data base using Safinya&#39;s method results in the correct determination of the composition. If the fluid remains a 50/50 mixture but the water and oil become more finely dispersed, the intensity of the transmitted light will decrease at all wave lengths, including the intensity of the light in the wave lengths associated with water, which will be interpreted as a greater absorption in the water-associated wave lengths. This, in turn, will lead to the erroneous conclusion that the concentration of water in the fluid has increased. 
     U.S. Pat. No. 5,166,747 (Schroeder) recognizes that scattering in Safinya&#39;s method can cause the intensity of the transmitted light to undergo swings so wide that they cannot be handled by the spectrograph. Schroeder&#39;s approach to this challenge was, through an opto/mechanical means, to redistribute the composition of the transmitted light reaching the spectral analyzer. Through optical diffusers or misalignment of the input and output fibers, the spectral analyzer received less directly transmitted light and more forward scattered light. The forward scattered light still indicated the absorbance of the sample, but it is of reduced intensity. The weaker signal was an acceptable tradeoff for signal stability. However, this approach is not feasible where the light source and spectral analyzer are at the surface. In such circumstances, the signal intensity is of paramount concern due to the losses that can occur if the sampling portion of the sensor is many kilometers from the surface. Also, the potential for errors due to scatter will still occur and, perhaps, be even greater than those associated with Safinya&#39;s method because the strength of the original signal is reduced. 
     SUMMARY OF THE INVENTION 
     It is an object of the current invention to provide a method for determining the concentration of a constituent, such as oil or gas, in a fluid flowing in a remote location, such as downhole in an oil well. This and other objects is accomplished in a method of determining the concentration of at least one predetermined constituent in a fluid flowing through a downhole portion a well, comprising the steps of (i) generating a beam of light, (ii) directing the beam of light into the fluid flowing through the downhole portion of the well so as to cause light to emerge from the fluid, the emerging light having been scattered by the fluid and comprised of components each of which has a different wavelength, (iii) transmitting at least a portion of the emerging light to a location proximate to the surface of the earth, (iv) measuring the intensity of each of at least a portion of the components of the transmitted light, each of the light components in the portion of light components having a wavelength falling within a predetermined range of wavelengths, the light component intensity measurements being conducted at the location proximate the surface, (v) normalizing at least those of the measured light component intensities having selected wavelengths so as to reduce the effect of the scattering of the light components on the measured intensities, (vii) exponentially raising and then multiplying each of the normalized light component intensities at the selected wavelengths by a predetermined weighting factor based upon its respective wavelength, and (viii) summing the weighted and normalized light component intensities at the selected wavelengths so as to calculate the concentration of the constituent. 
     In one embodiment, the method further comprises the step of determining the weighting factors by (i) directing a calibration beam of light into a plurality of fluid calibration mixtures so as to cause light to emerge from each of the calibration mixtures that is comprised of components each of which has a different wavelength, with each of the calibration mixtures containing predetermined varying concentrations of the constituent, (ii) measuring the intensity of each of the components of the light emerging from the calibration mixtures having a wavelength falling within the predetermined range of wavelengths, (iii) normalizing at least a selected portion of the measured intensities of the light components emerging from the calibration mixtures, and (iv) performing a regression analysis on the normalized intensities of the calibration mixtures so as to determine the weighting factors. 
     The invention also encompasses an apparatus for determining the concentration of a predetermined constituent in a fluid flowing through a downhole portion a well, comprising (i) means for generating a beam of light, (ii) means for directing the beam of light into the fluid flowing through the downhole portion of the well so as to cause light to emerge from the fluid which light is comprised of components each of which having a different wavelength and that has been scattered by the fluid prior to emerging therefrom, (iii) means for transmitting at least a portion of the emerging light to a location remote from the downhole portion of the well, (iv) means for measuring the intensity of each of the components of the transmitted light having a wavelength falling within a predetermined range of wavelengths at the remote location, (v) means for exponentially raising and normalizing at least a selected portion of the measured component intensities so as to minimize the effect of the scattering to the light emerging from the fluid has been subjected on the component intensities, (vi) means for determining the concentration of the constituent based upon the normalized component intensities. 
     In one embodiment, the apparatus further comprises a computer, and the means for means for normalizing the selected portion of the measured component intensities and the means for determining the concentration of the constituents comprises software programmed into the computer. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is schematic diagram of the fluid analysis system according to the current invention installed in a section of pipe. 
     FIG. 2 is a transverse cross-section through the sensor shown in FIG. 1, taken along line II—II. 
     FIG. 2 a  is a detailed view of the sensor shown in FIG.  2 . 
     FIG. 3 is a longitudinal cross-section taken along line III—III shown in FIG.  2 . 
     FIG. 3 a  is a transverse cross-section through the mixer shown in FIG. 3, taken along line IIIa—IIIa. 
     FIG. 4 is schematic diagram of an alternate embodiment of the fluid analysis system according to the current invention installed in a section of pipe. 
     FIG. 5 is schematic diagram of the equipment for performing a calibration according to the current invention. 
     FIG. 6 is a plot of measured light intensity versus wavelength for oil/water mixtures ranging from 0 to 100% oil using the near-IR attenuation method. The X-axis is the light wavelength in nanometers. The Y-axis is the instrument&#39;s response in analog to digital converter counts. 
     FIG. 7 is a plot of normalized light intensity versus wavelength based on the data shown in FIG.  6 . The X-axis is the light wavelength in nanometers. The Y-axis is the instrument&#39;s response in analog to digital converter counts. 
     FIG. 8 is a plot of predicted concentration C p  versus measured concentration C m  for oil using an algorithm according to the current invention based on the data shown in FIG.  6 . 
     FIG. 9 is a plot of measured light intensity versus wavelength for oil/water mixtures ranging from 0 to 100% oil using the near-IR fluorescence method. The X-axis is the wavelength in Pixel number. The Y-axis is the instrument&#39;s response in arbitrary units. 
     FIG. 10 is a plot of normalized light intensity versus wavelength based on the data shown in FIG.  9 . The X-axis is the wavelength in Pixel number. The Y-axis is the response in arbitrary units. 
     FIG. 11 is a plot of predicted concentration C p  versus measured concentration C m  for oil using an algorithm according to the current invention based on the data shown in FIG.  9 . 
     FIG. 12 is a plot of measured light intensity versus wavelength for isooctane/oil/water mixtures ranging from 0-50% isooctane using the near-IR attenuation method. The X-axis is the wavelength in nanometers. The Y-axis is the response in arbitrary units. 
     FIG. 13 is a plot of measured light intensity versus wavelength for isooctane/oil/water mixtures ranging from 0-25% isooctane using the near-IR attenuation method. The X-axis is the wavelength in nanometers. The Y-axis is the instrument&#39;s response in arbitrary units. 
     FIG. 14 is a plot of normalized light intensity versus wavelength based on the data shown in FIG.  13 . The X-axis is the wavelength in nanometers. The Y-axis is the response in arbitrary units. 
     FIG. 15 is a schematic diagram showing the software programed into the computer portion of the fluid analyzer shown in FIG.  1 . 
     FIG. 16 is a schematic diagram of a multilateral well into which downhole fluid analyzers according to the current invention have been incorporated. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     According to the current invention, the concentration of certain constituents in a fluid can be determined by directing light to the fluid, sensing the light emerging from the fluid, measuring the relative intensity of the components of the sensed light at selected wavelengths, and then treating these relative component intensities according to an algorithm, developed for the particular fluid being analyzed, that weights the component intensities using predetermined weighting factors based on the wavelength associated with each component. As such, the method of the current invention realizes four important advantages over prior methods of analysis. First, once the algorithm has been properly generated, only the components of the light intensity at wavelengths within a predetermined range need be analyzed—that is, it is not necessary to analyze the entire spectrum of the light emerging from the fluid being analyzed. Second, it is not necessary to maintain a large data base of spectra of fluids of known compositions. Third, it is not necessary to compare the measured data to a data base of the spectra of fluids of known composition. Fourth, the effects of scattering are eliminated by normalizing the individual intensities of the emerging light at each of the selected wavelengths. 
     According to the current invention, the algorithm to be used in calculating the concentration of a particular constituent can be developed by measuring the intensity of the components of the light emerging from various known mixtures of the fluids to be analyzed over a range of wavelengths. These mixtures are formed by varying the concentration of the particular constituents in the fluid in a known way. After normalizing the component intensities, a regression analysis, such as a partial least squares regression, is used to determine the weighting factors that indicate the weight to be attached to the normalized component intensity at each wavelength. Based on these weighting factors, an algorithm is developed for calculating the concentration of the constituent. 
     As discussed in detail below, in the practice of the current invention, either the phenomenon associated with the attenuation of radiation (e.g., as a result of absorption) or the excitation of fluorescent radiation may be used to determine the concentration of a particular constituent of the fluid. In particular, a beam of light is directed to the fluid. As a result of its passing through the fluid, the emerging light may be attenuated as a result of absorption and/or scattering. In addition, the light may induce fluorescence. Thus, compared to the light directed to the fluid, the light emerging from the fluid will be attenuated and/or comprises fluorescent radiation. The analysis of the emerging light permits the determination of concentration. 
     Whether the attenuation or fluorescence phenomenon is used to determine concentration depends on the constituent whose concentration is to be determined. The concentration of oil, for example, can be determined using either method. The concentrations of water and natural gas, which do not fluoresce, can only be directly determined using the attenuation method. When using the attenuation method, the light directed to the fluid should encompass a broad range of wavelengths. However, when the fluorescence method is used, the wavelength of the light directed to the fluid should lie within a narrow range, and preferably the light should be monochromatic. In some circumstances, such as when remotely determining the concentration of mixtures of oil, water and/or gas using the attenuation method, the light directed to the fluid is preferably in the near infrared (“near-IR”) range—that is, having a wavelength from approximately 800 nm to 3000 nm. 
     In both the attenuation and fluorescence method, analysis of the emerging light is based on measurement of the intensity of its components at various predetermined wavelengths. Importantly, the measured intensities are normalized to minimize the errors resulting from scattering. When the attenuation method is used, each of the measured component intensities is preferably normalized by dividing it by an intensity characteristic associated with all, or at least most, of the components of the emerging light within a predetermined range of wavelength. When the fluorescence method is used, normalization is preferably accomplished by dividing the measured component intensities by an intensity characteristic of the laser light used to induce the fluorescence. 
     I. Analysis Based on Light Attenuation 
     As discussed above, as the light travels through the fluid, a variety of phenomena arise. Some of the components of the light at discrete wavelengths (or wavelength ranges) are absorbed depending to the chemical constitution of the fluid. In addition, some of the light is scattered in all directions due to the physical constitution of the fluid (emulsions, bubbles, binary mixtures, etc.), and some of the light is transmitted. Thus, the light entering the fluid is either absorbed, scattered, or transmitted through it. 
     The amount of light absorbed at a given wavelength is a characteristic of the substance through which the light is travels. While the light that is absorbed cannot be directly measured, the light emerging from the fluid can be measured. As a result of absorption, the intensity of the emerging light will be reduced or “attenuated.” The amount of attenuation of the light for any given composition will varying as a function of its wavelength. Thus, for a given source light spectrum, evaluating the intensity of the components of the emerging light at selected wavelengths provides information about the composition of the fluid. 
     Scattering also causes attenuation of the light intensity. However, whereas attenuation as a result of absorption causes relative changes in the light intensity as a function of wavelength, i.e., there is a change in the shape of the broadband spectrum, attenuation due to the scattering of light is much less dependent on its absolute wavelength; it has a slow, monotonic dependence on wavelength. The scattering of the light, therefore, results in a drop in the light intensity at all wavelengths so that at any given wavelength, the intensity does not change appreciably relative to the intensity at other wavelengths. For fluids which both scatter and absorb light, the net result is that even though the absolute magnitude of the collected light as a function of wavelength it is not uniquely related to chemical composition, the relative light intensity as a function of wavelength is related to the chemical composition. 
     Therefore, according to the current invention, the effects of scattering can be effectively eliminated by normalizing the intensity of the collected light components at each wavelength utilized in the algorithm to the intensity over a broad band of wavelengths. Thus, an analysis of the relative attenuated components of the light emerging from the fluid can be used to accurately determine the concentration of its constituents, despite the simultaneous presence of scattering. 
     When the attenuation method of analysis is used, the light directed to the fluid preferably encompasses a broad band of wavelengths that, most preferably, is sufficiently broad to encompass all, or at least most, of the major absorption peaks associated with the constituents whose concentration is to be determined. For example, oil and natural gas have absorption peaks at 1200 nm and 1400 nm. Water has absorption peaks at 1150 nm and 1450 nm. Thus, the light should have wavelengths that at least encompass the 300 nm range as associated with these peaks (i.e., from 1150 nm to 1450 nm). Thus, in the case of mixtures of oil, water, and gas, the light directed to the fluid preferably has wavelengths in the near-IR range—that is, having a wavelength from approximately 800 nm to 3000 nm. More preferably, the light is in the range of about 900 nm to 2000 nm, more preferably still in the range of about 1100 nm to 1800 nm, and most preferably in the range of about 1100 nm to 1550 nm. 
     II. Analysis Based on Fluorescence 
     Depending upon on the material, the absorption of light may not only result in attenuation of the light intensity at certain wavelengths but may also result in generation of radiation at other wavelengths, specifically, due to fluorescence. Fluorescence is a type of luminescence—that is, light emitted by a process other than combustion or incandescence. When a flourescent substance is illuminated with light of the appropriate wavelength it absorbs energy which, in turn, excites the absorbing species to a higher energy electronic state. When the absorbing species returns to its electronic ground state, a photon of light is emitted. If the excited state from which the absorbing species decays has the same multiplicity as the ground state, the time between absorption and emission is relatively short and the process is called fluorescence. If the excited state from which the absorbing species decays has a different multiplicity from that of the ground state, the time interval is relatively long, and the process is referred to as phosphorescence. The light generated by fluorescence is always of longer wavelength than the incident light. Thus, in fluorescence, the absorption of light of one wavelength results in the emission of light of longer wavelengths. 
     Certain molecular arrangements within fluorescent substances, called chromophores, are the centers of fluorescent activity. Not all chromophores respond to light in the same way. In general, compounds with fused aromatic rings or compounds with a greater number of conjugated multiple bonds, such as crude oil, can fluoresce when subjected to light at longer wavelengths, specifically, in the visible to near-IR range. Less complex, low molecular weight compounds, such as the simple hydrocarbons found in natural gas, either do not fluoresce or fluoresce only at shorter wavelengths (in the ultra violet range) but not in the near-IR range. Water does not fluoresce. Other substances that do not fluoresce when excited by light in the near-IR range are sand and silt. 
     In general, using excitation light having shorter wavelengths will result in fluorescent radiation of greater intensity, making analysis easier. However, according to the current invention, the excitation light from the light source is generated at one location, preferably the surface, and transmitted through fiber optic cables over long distances to fluid at a remote location, such as downhole in an oil well. Light having short wavelengths, such as ultraviolet radiation, is difficult to transmit over such long distances and can result in excessive Raman scattering. By contrast, light in the near-IR range can be readily transmitted over long distances. In addition, shorter wavelength light may induce fluorescence in too many substances, making analysis of a particular constituent more difficult. In any event, near-IR excitation light causes oil, but not natural gas or water, to emit relatively intense fluorescent radiation. Consequently, according to the current invention, the concentration of oil is preferably determined using excitation light having a wavelength within or somewhat below the near-IR range. 
     When the fluorescence method is used, laser light having a relatively narrow wavelength band, and preferably 2 nm FWHM (i.e., full width at half maximum) or less, is directed to the fluid. Preferably, the source should emit light having wavelengths from somewhat below the near-IR range to about the mid near-IR range—that is, from about 500 nm to 1700 nm range. More preferably, the excitation light should be in the range of about the 600 nm to 1000 nm, more preferably still in the range of about the 780 nm to 900 nm, such as laser light having a wavelength of about 780 nm, 808 nm, or 852 nm. 
     As the laser light passes through the fluid, some of the light is absorbed by and re-emitted as fluorescent light at longer wavelengths than the absorbed light. Some of this fluorescent light is collected, along with some of the laser light that was transmitted through the fluid. For fluids that are highly scattering, the collected laser light intensity will be lower than for fluids that are not highly scattering since in the latter case a greater percentage of the laser light will be collected. Consequently, the laser light scattered by the fluid can be used as a means for monitoring its scattering characteristics. 
     The collected fluorescence light will be dependent on both the concentration of fluorescent species present in the fluid and the scattering properties of the fluid. As the concentration of fluorescent species increases, the collected fluorescent light will increase. As the scattering characteristics of the fluid increase, the collected fluorescent light will decrease. Thus, the influence of the scattering properties of the fluid can be corrected for by normalizing the collected fluorescent intensity to the collected laser intensity. (In some circumstances, it may also be desirable to normalize the collected laser intensity itself by the laser intensity at the surface, in order to correct for optical power fluctuations in the laser.) In any event, in the fluorescence method of analysis, evaluation of the normalized intensity of the fluorescent light emitted by the fluid can be used to accurately determine the concentration of its constituents, despite the presence of scattering. 
     III. Apparatus 
     A. Hardware 
     One embodiment of an apparatus according to the current invention is shown in FIG. 1 applied to an instrumented section of pipe  10 , which in some applications may be incorporated into production piping  7  disposed in a well bore  5 , through which the fluid  3  to be analyzed flows. Depending on the detailed components selected, each of which is discussed further below, the apparatus shown in FIG. 1 can be optimized for use with either the attenuation or fluorescence methods of analysis. 
     1. Sensor 
     As shown in FIG. 1, the instrumented pipe section  10  comprises a sensor  12  that has been incorporated into the pipe. Although only one sensor  12  is shown in FIG. 1, it may be desirable to incorporate a number of sensors into the instrumented section  10 , for example, by spacing two or more sensors circumferentially around the pipe at the same axial location and/or spacing two or more sensors axially along the pipe. The use of multiple sensors  12  will reduce errors associated with the fact that the fluid flowing through the instrumented section  10  may not be uniform across its cross-section or along the length of the section. 
     A diagram of one sensor  12  suitable for use in the current invention is shown in FIGS. 2 and 3 and comprises a notch  19  formed in the inner wall of the pipe section  10 . Optically transparent windows  30  are formed on opposing walls of the notch  19 . A focusing lens  32 , to which fiber optics  14  are coupled, is located behind each window  30 . The light  26  from the source  16  exits the first fiber optic  14 ′, passes through the first lens  32 , and then the first window  30 . The light subsequently passes into and interacts with the fluid stream  3 . As shown in FIG. 3, the light emerging from the fluid stream passes through the second window  30  and is focused by the second lens  32  so that it is collected by the second fiber optic  14 ″. 
     As shown in FIG. 1, in some applications, it may be desirable to incorporate a mixing device  60  upstream of the instrumented section  10  so as to ensure adequate mixing of the fluid  3  to be measured. As shown in FIGS. 3 and 3 a , the mixer  60  may comprise a section of piping  61  incorporated into the production piping  7  and into which helically extending mixing vanes  66  have been installed to swirl the fluid, thereby ensuring adequate mixing of the constituents before they reach the instrumented section  10 . 
     As also shown in FIG. 1, it may also be desirable in some applications to incorporate a diverter section  62  upstream of the instrumented section  10  to ensure the proper flow of fluid  3  into the notch  19 . As shown in FIG. 3, the diverter  62  may comprise a section of piping  63  incorporated into the production piping  7  and into which a baffle  64  has been installed. The baffle  64  is preferably angled toward the notch  19  of the sensor  12 , most preferably at an angle with respect to the axis of the piping that is equal to or greater than the angle of the sloping side wall  19  of the notch, so as to deflect at least a portion, preferably a major portion, of the fluid  3  so that it is directed into the notch  19 . This not only ensures that the fluid flowing through the notch  19  is representative of the fluid  3  flowing through the production piping  7  but also ensures that the fluid in the notch is not stagnant so as to flush the notch and prevent the buildup of deposits or debris that could interfere with the operation of the sensor  10 . 
     The sections of piping forming the mixer  60 , diverter  62  and instrumented section  10  could be jointed to each other, and to the production piping  7 , by threaded or welded connections. Alternatively, these components could be incorporated into a single section of piping that was joined to the production piping  7  or they could be inserted directly into inside diameter of the production piping  7  itself. 
     When laser light is used, a filter, such as a dielectric filter (not shown), may be incorporated at the probe to filter out emission lines around the laser wavelength so as to eliminate the effect of glass Raman scattering. 
     2. Fiber Optic Cables 
     Each sensor  12  is optically connected to a light source  16  and a remote fluid analyzer  6  by a fiber optic cable  13  containing a pair of optical fibers  14 ′ and  14 ″. Preferably, the optical fibers, which may comprise a bundle of optical fibers, are of the multimode type. The first optical fiber  14 ′ is coupled to a light source  16 , which is preferably located at a remote location, such as the surface. The second optical fiber  14 ″ is coupled to a fluid analyzer  6 , which is also preferably located a remote location, such at the surface. Thus, the fiber optic cable  13  transmits light from the light source  16  to the sensor  12  and transmits light from the sensor to the fluid analyzer  6 . 
     3. Light Source 
     When used in connection with the attenuation method, a broadband light source  16  should be used, such as a quartz tungsten halogen lamp. Preferably, the light source  16  emits light having wavelengths sufficiently broad to encompass the major absorption peaks of the constituents whose concentration is to be determined, as previously discussed. In the case of mixtures of oil, water and/or natural gas, the wavelength of the light should encompass the ranges previously discussed in section I. 
     When used in connection with the fluorescence method, the light source  16  should be an extremely narrow band source, and preferably be a monochromatic light source, such as a diode laser or a diode-pumped solid state (DPSS) laser. When used in circumstances requiring transmission of light over long distances, the light source  16  emits light having a wavelength in the ranges previously discussed in section II. 
     4. Fluid Analyzer 
     As shown in FIG. 1, the fluid analyzer  6  comprises a spectrographic detector  18 , a computer  20 , and an indicator  22 . The spectrographic detector  18  includes a spectrograph for dispersing the light from the collection fiber into its component wavelengths and a detector for sensing the intensity at each of these wavelengths. 
     Depending on the analysis technique to be utilized, the detector may comprise an InGaAs diode array to detect the intensity at each of the dispersed wavelengths. Such an array typically has a spectral sensitivity from 900 nm to 1700 nm. The primary advantage of using an array for detection is its ability to detect the light intensity simultaneously at every detected wavelength. For scanning systems, whether of interferometric or grating type, each wavelength&#39;s intensity is detected at a different discrete time. Since downhole scattering is a temporal phenomenon, this would make the measured effect of the scattering appear to be wavelength dependent. With the use of a diode array, the simultaneous detection of intensity at all detected wavelengths ensures that the effects of scattering are common to all wavelengths and facilitates the use of a normalization method to correct for scattering. 
     Alternatively, in connection with fluorescence analysis methods, a charge coupled device silicon array may be used for the detector. As a further alternative when using the fluorescence method, a filter or beam splitter can be used to direct the collected laser signal to one detector while the fluorescent signal is directed to a second detector. In this case, the detectors can be single element detectors that effectively integrate the signal intensities for all of the impinging wavelengths. The output of the detector for the laser signal is proportional to the integrated laser intensity and the output of the detector for the fluorescent signal is proportional to the integrated fluorescence signal. Normalization can be performed by taking the ratio of the two detector outputs in either analog or digital form. 
     Regardless of the type of detector used, the computer  20  is programmed with software that allows it to read the array of intensities from the spectrographic detector  18 . 
     Regardless of whether the attenuation or the fluorescence analysis technique is used, in operation, the output of the light source  16  is directed into the proximal end of the first fiber optic  14 ′ located at the surface, as shown in FIG.  1 . The fiber optic  14 ′ permits the transmission of the light downhole to the remote sensor  12 . The sampling portion of the remote sensor  12  is in contact with the downhole fluid stream  3  that is to be analyzed. After exiting the fiber optic  14 ′, the source light interacts with the fluid  3 , as shown in FIG. 3, causing the fluid to absorb, scatter, transmit and/or fluoresce light. Subsequently, the second fiber optic  14 ″ collects a portion of the light which is emerging from the fluid stream  3  (which may include scattered light from the source, transmitted light, and fluorescent radiation) and transmits this light to the surface, where its intensity is detected as a function of wavelength using the spectrographic detector  18 . The data from the spectrographic detector  18  is then input into the computer  20 . 
     The computer  20  is programmed with software containing an algorithm that determines the composition of the fluid  3 —that is, the concentrations of predetermined constituents, for example, the percentages of oil and water—based on the intensity of the light emerging from the fluid at one or more selected discrete wavelength or range of wavelengths, as determined by the spectrographic detector  18 . These concentrations are indicated on the indicator  22 , which may be a digital readout device. 
     An apparatus for simultaneously employing both the fluorescence and attenuation methods of analysis is shown in FIG.  4 . In this case, two separate light sources  16 ′ and  16 ″ and two separate spectrographic detectors  18 ′ and  18 ″ are utilized. The first light source  16 ′ is used for the fluorescence portion of the analysis and, as discussed above, preferably generates monochromatic light. The second light source  16 ″ is used for the attenuation portion of the analysis and, as discussed above, preferably generates broad band light. The first spectrographic detector  18 ′ is used for the fluorescence analysis and, as discussed above, preferably comprises a diode array. The second spectrographic detector  18 ″ is used for fluorescence analysis and, as discussed above, preferably comprises a charged couple device. 
     Light from the two sources  16 ′ and  16 ″ may be directed by optic fibers  15 ′ and  15 ″ into a common optic fiber  14 ′ by using a beam combining device  40 . The beam combining device  40  may consist of a dichromatic beam splitter, a fiber optic coupler, a fiber optic multiplexer, or a similar type of device. Light from both light sources  16 ′ and  16 ″ is carried downhole by the common fiber optic  14 ′ to a common sensor  12 , such as that previously discussed. After interaction of light from both sources  16 ′ and  16 ″ with the fluid stream  3 , light from the fluid stream is collected and returned to the surface by a common carrier fiber optic  14 ″. Light exiting from the fiber  14 ″ is split into two signals of having light in two different wavelength ranges by a splitter device  42 , which may be a filter, a filter set, a beam splitter, a fiber optic splitter, a fiber optic demultiplexer, a grating, or a similar device. 
     One signal comprises light in the wavelength range that incorporates the wavelengths of the first, monochromatic light source  16 ′ and the wavelengths of the fluorescence that was generated downhole by the interaction of light from the monochromatic source and the fluid stream  3 . This signal is directed to the first spectrographic detector  18 ′ by means of fiber optic  17 ′. The second signal comprises the wavelength range that incorporates the wavelengths of the second, broadband source light source  16 ″. This signal is directed to the second spectrographic detector  18 ″ by means of fiber optic  17 ″. The processing of these independent signals is performed by the computer  20  using the software and algorithms of the current invention, as discussed further below—specifically, a first algorithm developed from an attenuation-based, calibration would be used to determine concentration based on the attenuation analysis and a second algorithm developed from a fluorescence-based calibration would be used to determine concentration based on the fluorescence analysis. The concentration resulting from the two methods of analysis could then be compared for verification. 
     B. Algorithms/Software 
     Using techniques well known in the art, the computer  20  is programed with software, shown schematically in FIG. 15, for determining the concentration based on the light components measured by the spectrographic detector  18 . As shown in FIG. 15, in operation, in the first step  100 , the computer  20  first directs the light source  16  to transmit a beam of light to the sensor  12 , which directs the light emerging from the fluid to the spectrographic detector  18 . In the second step  110 , the computer directs the spectrographic detector  18  to determine the intensity of the components of the emerging light at wavelengths within a predetermined range. In step  120 , the normalization factor f n  is calculated from the measured intensities, for example using the equation indicated. In step  130 , the measured intensities at selected wavelengths, preprogramed into the computer, are normalized using the normalization factor determined in step  120 . In step  140 , the normalized intensities are applied to one or more algorithms preprogramed into the computer so as to calculate the concentration of the constituents of interest. In step  150 , the calculated concentration, for example 90% oil, is displayed on the indicator  22 . The normalization techniques applied in steps  120  and  130  and the algorithm applied in step  140  are discussed in detail below. 
     As previously discussed, according to an important aspect of the current invention, the measured intensities of the light emerging from the fluid are normalized to eliminate the effect of scattering on the analysis. When a light attenuation method is used, normalization is preferably performed using a characteristic of the intensity of the light emerging from the fluid over a range of wavelengths. Preferably, the vector length of the emerging light spectrum is used. Mathematically, the vector length is represented as:                f   n     =         ∑     i   =   1     m          I   in   2                 [   1   ]                         
     where: 
     n=a number representing the particular mixture being analyzed, 
     i=represents discrete wavelengths or wavelength ranges, 
     I in =the measured intensity of the component of the emerging light for mixture n existing at wavelength i, 
     f n =the vector length for mixture n, 
     m=the total number of component intensities used in the normalization (e.g., the total number of component intensities measured over a predetermined wavelength range). 
     Note that for purposes of the current invention, preferably, the measured intensity I in  at any given wavelength is determined by integrating the intensity over at least a small wavelength band about the given wavelength in order to minimize errors due to slight deviations in wavelength detection. Thus, for example, the measured intensity at a wavelength of 1100 nm, I 1100 , is determined by integrating the intensity over a wavelength band from 1095 nm to 1105 nm. Alternatively, the integrated intensity over a relatively large band of wavelengths (e.g., 950 to 1000 nm) could be used if such a band contained valuable information on the concentration of a particular constituent. 
     Normalization is performed by dividing the measured intensity I in  at each wavelength in the n th  spectrum by the vector length f n  so that 
     
       
           IN   in   =I   in   /f   n   [2] 
       
     
     Where IN in =the normalized intensity of mixture n at wavelength i. 
     Although vector normalization is a preferred method, those knowledgeable in the art will recognize that other normalization routines may be used. For example the spectral data can be normalized to the area of the spectrum:                f   n     =       ∑     i   =   1     m               I   in                    [   3   ]                         
     or to the intensity at a specific wavelength, or to the integrated intensity across one or more spectral regions. 
     Note that, according to the current invention, when using the attenuation method, it is not necessary (although it is not prohibited) to normalize the measured intensities to the spectrum of the light from the light source  16  that is directed to the fluid. This is due to the fact that changes in light source intensity at the surface are expected to be relatively wavelength independent and thus will not effect the analysis according to the current invention, in which only the relative intensities, not the absolute magnitudes, are used. 
     When using the fluorescence method, normalization is performed by reference to the intensity of the portion of the collected light that represents the scattered laser light, determined by detecting the intensity of the collected light in a small band of wavelengths around the wavelength of the laser. For example, the measured intensities can be normalized by dividing the intensity of the fluorescent radiation at each wavelength I i  by the intensity of the transmitted laser light IL (e.g., determined by measuring the intensity of the transmitted light component at the wavelength of the laser light) so that: 
     
       
           IN   in   =I   in   /IL   [4] 
       
     
     Other laser light intensity related values could also be used for the normalization, such as the area under the transmitted laser light spectrum. 
     Regardless of whether the attenuation or fluorescence methods of analysis are used and regardless of which normalization technique is used, the concentration of each constituent of interest is preferably determined from an equation of the type:                C   kn     =         ∑     i   =   1     m            β   ki          IN   in     α   ki           +     b   k               [   5   ]                         
     where: 
     k=A number representing the particular constituent of interest (for example, 1=oil, 2=water, and 3=gas) 
     C kn =The concentration of constituent k for mixture n (for example, C 12  is the percentage of oil for mixture 2). 
     n=A number representing the particular fluid that is the subject of the analysis (for example, n=1 represents a fluid flowing in an oil well that consists of a mixture of 10% water and 90% oil, n=2 represents the well fluid at a later point in time, when its relative constituents may have changed). 
     i=A number representing the selected key wavelengths (for example, 1=1000 nm (or 950 to 1050 nm), 2=1110 nm (or 950 to 1050 nm), etc.). 
     m=The total number of light components whose intensities are used in the algorithm, which may, but need not be, the same as the number of light component intensities used in calculating the vector length or other normalization factor. 
     β ki =The weighting factor for constituent k at each of the selected wavelengths or wavelength ranges i, discussed further below. 
     IN in =The normalized intensity of the component of the light at wavelength i for fluid mixture n determined as discussed above. 
     α ki =Exponents for constituent k at each of the selected wavelengths or wavelength ranges i. Preferably, α is 1 so that the algorithm will be linear. However, in some circumstances, linearity may not yield sufficient accuracy, in which cases a may have values other than 1. Moreover, all of the α i  values may not be the same. For example, α 1 =2, α 2 =½, etc. 
     b k =A constant. 
     Essentially, the weighting factor β ki  for each constituent shows the relative weight to be given the intensity at each of the selected wavelengths in determining the concentration of that constituent—that is, the extent to which the intensity of the light component at a given wavelength is a predictor of the concentration of the constituent of interest. The larger the variation in the intensity of the component of the emerging light at a given wavelength as the concentration of a particular constituent varies, relative to the intensity variation at that wavelength as the concentration of other constituents varies, the larger the weighting factor β ki  for that particular constituent at that wavelength. The weighting factors may be positive or negative. If all of the wavelengths are used, rather than only the most significant, then some of the weighting factors may be zero. 
     In any event, the normalized intensity of the light component at each wavelength to be used in the algorithm is multiplied by a weighting factor the value of which is dependent upon the wavelength. The normalized and weighted intensities are then summed to arrive at the concentration of the constituent for which the algorithm was developed. 
     For the sake of illustration, consider a highly-simplified example of fluid flowing downhole in a well in which the concentration of three constituents—oil, water, and gas—are to be determined using linear algorithms based on the normalized light component intensities at five selected wavelengths (m=5) from a set of five wavelengths—1100, 1200, 1300, 1400, and 1500 nm. Further suppose that, as a result of the application of a regression technique to a set of calibration data, discussed further below, values for the weighting factors β at each wavelength were determined for the three constituents as follows: 
     
       
         
           
               
               
            
               
                   
                   
               
               
                   
                 Weighting Factors (β) 
               
            
           
           
               
               
               
               
               
            
               
                   
                 Wavelength (i) 
                 Oil 
                 Water 
                 Gas 
               
               
                   
                   
               
            
           
           
               
               
               
               
               
            
               
                   
                 1100 
                 100 
                 400 
                 200 
               
               
                   
                 1200 
                 250 
                 400 
                 0 
               
               
                   
                 1300 
                 130 
                 100 
                 80 
               
               
                   
                 1400 
                 0 
                 225 
                 30 
               
               
                   
                 1500 
                 150 
                 0 
                 20 
               
               
                   
                   
               
            
           
         
       
     
     Equation 5 would then result in the following algorithms for concentrations of oil, water, and gas: 
     
       
           C   oil =100  IN   1100 +250  IN   1200 +130  IN   1300 +0  IN   1400 +150  IN   1500   [5a] 
       
     
     
       
           C   water =400  IN   1100 +400  IN   1200 +100  IN   1300 +225  IN   1400 +0  IN   1500   [5b] 
       
     
     
       
           C   gas =200  IN   1100 +0  IN   1200 +80  IN   1300 +30  IN   1400 +20  IN   1500   [5c] 
       
     
     For the sake of simplicity, all of the wavelengths used for the three equations above were drawn from the same five wavelength set. However, in actual practice, the selected wavelengths for each constituent might come from completely different sets of wavelengths. However, generally, all of the wavelengths used in each of the algorithms would fall within the same range of wavelengths. For example, when using a method based on the attenuation of near-IR light or the inducement of fluorescence caused by near-IR light, the wavelengths used in the algorithm would all fall somewhere within the near-IR range (e.g., in the range from 800 nm to 1600 nm). 
     Although only five wavelengths were used in the algorithms in the example above, in practice, a greater number of wavelengths may often be used. For example, the algorithm might contain each wavelength in the 1100 to 1500 nm range—that is, four hundred wavelengths (m=400)—so that there were four hundred weighting factors, each of which is applied to the component of the normalized intensity at the respective wavelength. Alternatively, in the limit, an algorithm utilizing only a single wavelength could also be used—example, C oil =200 IN 1300 +12—provided that it yielded sufficient accuracy for the particular application. 
     In any event, during operation, the intensity of the light components at the prescribed wavelengths of the light emerging from the fluid flowing in the well is measured using either an attenuation or fluorescence technique. These measured component intensities are then normalized, as discussed above. For example, if vector length normalization were used, the vector length of the spectrum over a range of wavelengths (for example, all of the wavelengths in the 1100 to 1500 nm range) would be calculated from the measured intensities and the measured intensity at each of the wavelengths used in the algorithm would then be divided by the vector length so as to arrive at normalized intensities for those wavelengths. For example, a set of normalized intensities might be: 
     
       
         
           
               
               
               
             
               
                   
                   
               
               
                   
                 Wavelength (i) 
                 Normalized Intensity (IN) 
               
               
                   
                   
               
             
            
               
                   
                 1100 
                 .06 
               
               
                   
                 1200 
                 .04 
               
               
                   
                 1300 
                 .05 
               
               
                   
                 1400 
                 .03 
               
               
                   
                 1500 
                 .02 
               
               
                   
                   
               
            
           
         
       
     
     Substituting these normalized intensities into equations 5a, 5b and 5c would yield concentrations of 52% oil, 26% water, and 17% gas. 
     In some applications, the algorithm might involve two or more equations for each constituent, each covering a different concentration range—for example, one equation for oil concentrations between 0% and 50% and another equation, with different weighting factors and/or selected wavelengths, for oil concentrations between 50% and 100%, etc. 
     When using several algorithms covering different ranges for the same constituent, it is desirable to identify into which subset range of concentrations a particular mixture being measured belongs before choosing the algorithm to determine the concentration. Thus, an algorithm generated for concentrations over the entire 0 to 100% concentration range could be used to preliminarily screen the data and, based on the concentration calculated using that algorithm, a more accurate, narrower range algorithm could be used for the final calculation. Alternatively, a Soft Independent Modeling by Class Analogy (SIMCA) could be used. In this method, a classification model is generated based on the light intensities of mixtures that fall into the different concentration ranges selected. The model is then used to predict into which concentration range an unknown mixture falls. Once a mixture has been assigned to a certain subset range of concentrations, a calibration algorithm optimized for that range can be used to more accurately determine the concentration of the constituents of interest. One knowledgeable in the art will realize that classification models other than SIMCA can be used to achieve the same goal, such as K-nearest neighbors, discriminate analysis, principal component analysis, and neural nets. 
     In addition to the software for calculating concentrations, the computer  20  may also be programmed with software for performing the calculations associated with the development of the specific algorithm from the calibration data—that is, the identification of the weighting factors used to weight the importance of the intensities at various wavelengths in determining concentration, as discussed further below. 
     IV. Development of the Concentration Algorithm 
     A. Equipment 
     The specific form of the algorithm discussed above and shown as equation 5 is developed for each constituent by identifying a range of wavelengths that encompasses those wavelengths whose intensities are likely to provide the maximum information about the concentration of that constituent, determining the weighting factors β ik  associated with each of the wavelengths in the range, and selecting those wavelengths to be used in the algorithm based on the weighting factors. This is done by performing a calibration for the particular type of fluid to be analyzed—for example, the fluid from the well into which the sensor  12  will be installed—and the particular constituents for which concentration is to be determined—for example, the particular type of crude oil being produced by the well. 
     Calibration is performed by obtaining quantities of each constituent and preparing various mixtures of differing concentrations that preferably span the range of concentrations to be encountered in operation. For example, if a mixture of crude oil and water from a producing well is to be analyzed, a quantity of pure crude oil extracted from the fluid produced by the well is obtained. The sensor  12  is then installed onto a container  50 , as shown in FIG. 5. A stirring device, such as a stir plate  52 , is used to mix the oil and water in the container  50 . The sensor  12 ′, which may be similar to the sensor  12  shown in FIGS. 2 and 3, is coupled to the fluid analyzer  6  and light source  16  using a fiber optic cable  13 . The light source  16  and fluid analyzer  6  are as discussed above in connection with FIG.  1 . Preferably, the same type and length of fiber optic cable  13  that will be used in actual service is employed so as to remove the effects of attenuation of the light as it travels through the long fiber optic cable on the calibration results. 
     B. Acquisition and Normalization of Calibration Intensities 
     1. Experiment 1—Oil Concentration Using Attenuation 
     The method for acquiring and normalizing the component light intensities to be used in developing the details of the concentration algorithm will now be discussed by way of example—specifically, an experiment that was conducted using the near-IR attenuation method, portions of the spectra resulting from this method are shown in FIGS. 6 and 7. 
     The equipment set up used is shown in FIG.  5 . Initially, the container 50 was filled with pure crude oil. In actual practice, the crude oil would be extracted from the fluid produced by the well. For purposes of this experiment, light Pennsylvania crude oil was used. The light source  16  used for this experiment was a quartz tungsten halogen lamp, which generated light having wavelengths that encompass the 1100 nm to 1550 nm range. The intensity of the source was set just below saturation of the detector at 0.1 sec integration (˜50,000 counts/sec). This light was directed by the fiber optic  14 ′ to the sensor  12 , which then directed it to the oil in the container  50 . The light emerging from the oil was collected by the sensor  12  and transmitted by fiber optic  14 ″ to the fluid analyzer  6 . 
     The fiber optics  14 ′ and  14 ″ were each approximately nine feet long. The fluid analyzer  6  employed a diode array to measure the intensity of the emerging light versus its wavelength so as to essentially develop the spectrum of light emerging from pure oil of the type produced by the well. This data was then stored in the computer  20 . Since crude oil has absorption peaks at about 1200 nm and 1400 nm, it was determined that the range of wavelengths to be used in the calibration was 1100 nm to 1520 nm. The spectrum of light emerging from pure crude oil in this wavelength range is shown in FIG.  6 . Since the intensity of the light emerging from the fluid is reduced at those wavelengths at which appreciable absorption occurs, the areas of greatest absorption appear as troughs in the spectrum of the emerging light. Thus, the spectra shown in FIG.  6  and utilized according to the current invention are not the spectra of the absorbed light but rather the spectra of the emerging light from the fluid, which contains those portions of the light that are scattered by or transmitted through the fluid (i.e., not absorbed). 
     Next, water was added in carefully titrated increments to the container  52  and additional spectra were obtained and stored in the computer until spectra were acquired over a range of crude oil concentrations down to 50%. This procedure was repeated starting with a container of pure water and adding oil in carefully titrated increments until spectra were acquired over a range of water concentrations down to 50%. In this experiment, spectra where obtained at a total of thirty eight different concentrations spanning 0% to 100% oil concentrations. For simplicity, eleven of these spectra (i.e., in 10% increments) are shown in FIG. 6 over wavelengths in the approximately 1100 nm to 1550 nm range. As discussed below, in actual practice, the number of spectra used for the calibration may depend on the regression technique utilized during the calibration calculations. 
     In this experiment, the stir plate  52  was used to maintain good mixing of the oil and water. In actual practice, the degree of mixing during data acquisition should approximate that of the fluid to be encountered in actual service—for example, the degree of mixing associated with the fluid flowing down hole in the well. 
     At each concentration, a spectrum for the 1100 nm to 1550 nm range was obtained by measuring the intensity of the light component at each wavelength within the range so that intensity was measured at a total of 450 wavelengths. The intensity of the light from the fluid was measured simultaneously at all wavelength over a 0.1 second period. This measurement was repeated one hundred times and the readings averaged to arrive at a final intensity value for each wavelength. Data acquisition was repeated ten times so that ten sets of data was obtained for each mixture. 
     As can be seen in FIG. 6, the absolute intensity of the spectra vary quite dramatically with concentration. Specifically, higher concentrations of oil yield low absolute spectral intensities at the wavelengths for which absorption is high. As previously discussed, this results from two phenomena associated with the presence of oil—increased scattering and increased near-IR absorption. However, as also previously discussed, whereas the amount of absorption is a function of only the concentration of oil, the amount of scattering depends upon both the concentration and various multiphase characteristics, such as droplet size. Therefore, according to an important aspect of the current invention, the effect of scattering is minimized by normalizing the spectra. Thus, using the method previously discussed, the vector length of each of the spectra in FIG. 6 was calculated. Each spectrum was then divided by its own vector length so as to generate the normalized spectra shown in FIG.  7 . As can be seen, the peak intensity trends follow concentration, indicating that the normalized spectra are independent of the scattering properties of the various mixtures. 
     Based upon the normalized spectra shown in FIG. 7, the weighting factors β for each wavelength in the 1100 nm to 1550 nm range were determined (a total of 450 weighting factors) using a partial least squares regression technique, discussed below. Based on these weighting factors, an algorithm was developed in the form of equation 5 (linear, with α=1) for the calculation of the concentration of oil, C oil , in mixture n based on normalized intensity IN a each wavelength in the 1100 nm to 1520 nm range: 
     
       
           C   oil,n =β oil,1100nm   IN   n,1100nm +β oil,1101nm   IN   n,1101nm + . . . +β oil,1520nm   IN   n,1520nm   [6] 
       
     
     A leave one out validation technique was employed to check the accuracy of the algorithm. Specifically, the partial least squares regression was run for each mixture used in the calibration except one and the resulting algorithm was then used to calculate the concentration of oil in the mixture left out and this computed value was compared to the actual value. This procedure was repeated for each mixture used in the calibration and the predicted versus actual values are shown plotted in FIG.  8 . These data revealed a standard error for the algorithm of only 2.9% in the percentage concentration value. 
     2. Experiment 2—Oil Concentration Using Fluorescence 
     The calibration procedure described above, as well as the procedure for determining weighting factors at each wavelength, as discussed below, are essentially the same whether the absorption or fluorescence methods are used to generate the emerging light from the fluid. Thus, a second experiment was conduced using the near-IR fluorescence method. The equipment used in this experiment was the same as that shown in FIG.  5  and discussed above in connection with the near-IR attenuation experiment, except in this case, the light source  16  was DBR laser, which emitted monochromatic light at a wavelength of about 852 nm, and a CCD was used for the spectrograph detector  18 . The same ratios of oil/water concentrations were used to generate the spectra based on near-IR attenuation shown in FIG. 6 were used and the intensities were measured using a similar procedure. Data was acquired for each mixture five times. In this case, the intensity was determined at each pixel in about the 18 to 770 pixel range (corresponding to approximately 850 nm to 1300 nm). The resulting raw spectra ranges are shown in FIG.  9 . The scattered laser light is clearly visible at a pixel number slightly greater than 18. The measured intensity at each wavelength was then normalized by dividing it by the peak amplitude of the scattered laser light so as to obtain the normalized spectra shown in FIG.  10 . 
     Based upon the normalized spectra shown in FIG. 10, the weighting factors β for each pixel in the 18 to 770 pixel range were determined (a total of 752 weighting factors) using a partial least squares regression technique, discussed below. Based on these weighting factors, an algorithm was developed in the form of equation 5 (linear, with α=1) for the calculation of the concentration of oil, C oil , in mixture n based on normalized intensity IN a each wavelength in the 18 to 770 pixel range: 
     
       
           C   oil,n =β oil,18   IN   n,18 +β oil,19   IN   n,19 + . . . +β oil,770   IN   n,770   [7] 
       
     
     A leave one out analysis revealed a standard error for this algorithm of 5.6%. The oil concentrations predicted by the near-IR fluorescence algorithm are shown graphed versus the actual concentration values in FIG.  11 . 
     3. Experiment 3—Gas Concentration Using Attenuation Method 
     The attenuation method of the current invention can also be used to determine the concentration of natural gas in a fluid flow. A simulation of natural gas dissolved in crude oil, or a crude oil/water mixture, was performed using isooctane (2,2,4-trimethylpentane) as a proxy for the natural gas. Natural gas consists mainly of methane (CH 4 ), ethane (C 2 H 6 ) and other small chain hydrocarbons (e.g., propane and butane), which are characterized by the presence of methyl groups (—CH 3 ). Isooctane has a high percentage of methyl groups and its addition to crude oil flow would closely mimic the near-IR absorption behavior of an addition of liquefied or dissolved natural gas. The temperatures and pressures that exist downhole would generally cause natural gas to be in a liquid state. Crude oil consists several different lengths of chain hydrocarbons, which consist of some methyl groups (CH 3 ) but predominantly methylene groups (CH 2 ). Both groups have distinct absorption bands in the near-IR region. Evans et. al, Analytical Chemistry, vol. 23, no. 11 (1951) used the ratio of these two absorption bands to determine the number of methyl and methylene groups per molecule in paraffins and lubrication oils. FIG. 11 shows near-IR spectra of crude oil with varying amounts of isooctane (0-50%). As the isooctane concentration increases, the methyl spectral band grows in intensity relative to the methylene band, which allows the method described above to distinguish between the two organic fluids. 
     A mixture composed of 67% oil and 33% water was prepared as a starting point. Using the set up shown in FIG. 5, the mixture was analyzed using the near-IR attenuation method. Light from a quartz tungsten halogen lamp  16  having strong emissions in the near-IR range was the directed to the mixture and analyzed by the InGaAs diode array. Additional measurements were taken as isooctane was subsequently added until a concentration of 25% isooctane was achieved. The intensity was measured at each wavelength in the 1100 nm to 1300 nm range (a total of 200 wavelengths). FIG. 13 shows the raw spectra taken from the mixtures of crude oil, water, and isooctane. The measured intensities were normalized using the spectrum vector lengths. The resulting normalized spectra are shown in FIG.  14 . 
     Based upon the normalized spectra shown in FIG. 14, the weighting factors β for each wavelength in the 1100 nm to 1300 nm range were determined (a total of 200 weighting factors) using a partial least squares regression technique, discussed below. Based on these weighting factors, an algorithm was developed in the form of equation 5 (linear, with α=1) for the calculation of the concentration of “gas” (i.e., isooctane), C gas , in mixture n based on normalized intensity IN a each wavelength in the 1100 nm to 1300 nm range: 
     
       
           C   gas,n =β gas,1100nm   IN   n,1100nm +β gas,1101nm   IN   n,1101nm + . . . +β gas,1520nm   IN   n,1520nm   [8] 
       
     
     A leave one out analysis revealed a standard error for this algorithm of only 0.55% in the percentage in the percentage concentration value. 
     C. Determination of Weighting Factors 
     Once the spectral data are normalized to remove the effects of scattering, any one of a number of well know regression techniques, some of which are discussed below, can be used to determine the weighting factors β to be used in weighing the values of the normalized component intensities measured in actual service in order to calculate concentration. The preferred regression technique is partial least squares regression. In some cases, two or more techniques may be employed—for example, an initial regression model may be determined based on a partial least squares regression technique and then refined using a multiple least squares regression technique. 
     Univariate regression is by far the most familiar technique for correlating spectral data to concentration. In chemical analysis this amounts to correlating the value of the peak spectral intensity IN n  of spectrum n with the concentration C n  of the constituent k of interest associated with that spectrum. The sequence of observations of IN n  and C n  from mixtures at each of the concentrations to be used in the calibration are used to derive a linear equation: 
     
       
           C   n   =β·IN   n   +b   [9] 
       
     
     where: 
     β=the slope of the linear equation 
     b=the concentration at zero intensity (i.e., the y-axis intercept) 
     This equation is optimized by minimizing the sum of the squares of the differences (residuals) between the predicted and true values; minimizing the residuals being one of the common threads that ties the various forms of regression together. These values of β and b thus developed are used in equation 5 to determine the concentration of constituent k—for example, oil—in actual service. These calculations would be repeated for other constituents for which concentration was to be calculated—for example, gas—so that a equation in the form shown in equation 5 would be derived for each constituent, with each constituent having different values for the weighting factor β and b. 
     Although univariate least squares regression is computationally simple, it will not offer sufficient accuracy in most applications since only the normalized intensities at one wavelength (that at which the intensity is a maximum) are used in the model. Therefore, more sophisticated regression techniques, such as those discussed below are preferred. 
     Multiple least squares (MLS) regression is another well known regression technique. Although the goal of MLS regression is identical to univariate least squares, i.e., to minimize the sum of the squares of the residuals, it allows more than one variable (i.e., normalized intensities at more than one wavelength) to be used in the regression analysis: 
     
       
           C=β   0 +β 1   ·IN   1 +β 2   ·IN   2 + . . . +β m   ·IN   m   +e   [10] 
       
     
     where m refers to the total number of collected wavelengths i and e represents the error of the simple model. The coefficients β are essentially weighting factors that relate how much information each measured intensity, at each individual wavelength, contains concerning the concentration C. The largest values of the weighting factors β are associated with the wavelengths that have the most influence on the determination of concentration. 
     MLS regression is an adequate procedure in some situations. However, it requires independence of the elements in the matrix subject to inversion—an unlikely situation for collinear spectroscopic data. Also, significant amounts of irrelevant information are likely to be incorporated into the model since every variable is included in the model. 
     In recent years, principal component regression (PCR) methods have been used to solve a wide variety of chemical problems which require the use of multivariate analysis. PCR involves decomposition of a row matrix containing the normalized intensity spectra into a loading matrix and a score matrix so that the product of these two matrices yields the original normalized intensity spectra. Each row vector in the loading matrix is referred to as a principal component and consists of a single loading value L for each spectral wavelength. Hence, the first row vector in the loading matrix corresponds to principal component 1 (PC 1 ), the second row to PC 2 , and so on. 
     The magnitude of a particular loading for a given principle component indicates how much-information that wavelength contributes to the principle component. Inspection of the loading matrix may reveal which wavelengths contain the most information about the concentration of the constituent of interest. The scores matrix simply relates the principal components back to the original spectra, i.e., the scores define how much a particular principal component contributes to a spectrum. Thus the first row vector of the scores matrix tells how much PC 1 , PC 2 , etc., contribute to the particular spectrum. The principal components are ranked in order of variance, i.e. PC 1  accounts for the greatest amount of variance in the set of input spectra. For this reason, the vast majority of the spectral information is included in the first few principal components, while the higher principal components are comprised mostly of noise. 
     The reduction of data dimension and the elimination of noise makes PCR the obvious choice over MLS regression. However, PCR suffers from a disadvantage in that the correlation between the property of interest and the spectral intensities is not included in the generation of the principle components. 
     Partial least squares (PLS) regression, also known as Projection to Latent Structures, is described, for example, in Wold, “Partial Least Squares,” in Encyclopedia of Statistic Sciences, Vol. 6, Katz and Johnson, Ed. (Wiley 1985), pp. 581-591 and Manne, “Analysis of Two Partial-Least-Squares Algorithms for Multivariant Calibration,” Chemom. Intell. Lab. Syst. (1987) 2:187-197, each of which is hereby incorporated by reference. PLS regression is a procedure that simultaneously estimates the eigenvectors in both the spectral data and the sample property data. Although PLS regression is fundamentally similar to PCR, it has the additional advantage of ordering its factors by considering both the variance of the spectral data and its correlation to the property of interest. Generally, this results in an equivalent or slightly more reliable model than PCR generates. An additional advantage of PLS regression involves a much faster computation time (when using a bidiagonalization procedure) compared to PCR. PLS regression shares many PCR characteristics—for example, PLS regression finds factors analogous to PCR&#39;s principal components. However, because these factors contain information about the correlations, they often yield more parsimonious and, in some situations, more reliable models than PCR. 
     Although PLS regression is preferred, other regression techniques could also be utilized, such as classical least squares, or inverse least squares in addition to any of the other techniques discussed above. For example, neural net regression techniques could also be used, especially if the regression model were nonlinear. A number of regression techniques suitable for use in practicing the current invention are described more fully in R. Kramer, “Chemometric Techniques For Quantitative Analysis,” ISB 0-824-0198-4, Marcel Dekker (1998), incorporated by reference herein. 
     Regardless of the regression technique utilized, a separate regression is performed for each constituent so that a weighting factors β i  is obtained for each of the selected wavelengths to be used in the algorithm for each constituent. 
     D. Determination of the Wavelengths to be Used in the Algorithm 
     As previously discussed, in performing the calibration and constructing the algorithm, component intensities are preferably measured at each wavelength within a preselected range of wavelengths—for example, in the experiments discussed above, algorithms were constructed using the normalized intensity for each wavelength within the 1100 to 1520 nm range for oil using the near-IR absorption method, within the 18 to 770 pixels range for oil using the fluorescence method, and within the 1100 to 1300 nm range for gas using the near-IR absorption method. The weighting factor associated with many of these wavelengths (i.e., those whose intensities can not be readily relied upon to determine concentration of the constituent of interest), however, will be very close to zero. Therefore, if desired in order to simply the computations, the algorithm can be constructed by selecting only key wavelengths within the range—specifically, those wavelengths whose intensities contain the maximum amount of information concerning the concentration of the constituents of interest. 
     According to the current invention, a variety of methods may be used to select the key wavelengths to be included in the algorithm, such as by inspection of the weighting factors in the algorithm. As previously discussed, the larger the variation in the intensity of the component of the emerging light at a given wavelength as the concentration of a particular constituent varies, relative to the intensity variation at that wavelength as the concentration of other constituents varies, the larger the weighting factor β ki  for that particular constituent at that wavelength. A large weighting factor means that the value of the intensity of the light at that wavelength will carry significant information about the concentration of interest. 
     Preferably, the wavelengths to be used in the algorithm are determined using a “leave one out” validation technique. This is accomplished by performing the calibration calculations discussed above using all but one of the mixtures for which data is available but so as to develop an algorithm containing only one wavelength—the wavelength having the highest weighting factor β. This algorithm is then used to predict the concentration for the mixture excluded from the calibration and the resulting error determined. The calibration calculations are then re-run but this time including the mixture previously excluded but leaving out a different mixture so as to develop another single-wavelength algorithm. Again the error associated with the predicted concentration for the new excluded mixture is determined. This process is repeated until each of the mixtures in the calibration have been left out. The predicted residual error sum of the squares (PRESS) associated with this one wavelength algorithm is then calculated. 
     The calculations above are then repeated using an algorithm containing the wavelengths having the two highest weighting factors, and the PRESS associated with these algorithms is calculated. The calculations are then repeated adding one additional wavelength to the algorithm each time until an algorithm containing all of the wavelengths has been constructed. The algorithm that results in the lowest value for PRESS contains the optimum number of wavelengths. 
     E. Multiple Algorithms for Different Concentration Ranges 
     Calibration results can be improved if the algorithms are limited to certain concentration ranges. This can be accomplished by performing separate regression analyses for mixtures in concentrations within predetermined ranges—for example, mixtures ranging between 0% to 50% oil are used in one regression to arrive at one algorithm and mixtures ranging between 50% to 100% oil are used in another regression to arrive at another algorithm—rather than using all of the mixtures from 0% to 100% in a single regression. For example, the near-IR calibration data shown in FIGS. 6 and 7 were re-analyzed using the same partial least squares regression technique but, this time, the analysis was performed separately for the 0% to 50% oil concentration range and the 50% to 100% oil concentration range so as to develop two different algorithms, one for each range. This reduced the 2.9% standard error that resulted from the use of a single algorithm, previously discussed, to a 1.6% for the 0% to 50% range and to 1.4% for the 50% to 100% range. Similarly, re-analyzing the near-IR fluorescence calibration data shown in FIGS. 11 and 12 separately for the 0% to 50% and 50% to 100% ranges reduced the standard error from 5.6% to 3.1% for the 0% to 50% range and to 2.1% for the 50% to 100% range. 
     Particularly in the case of oil wells, those skilled in the art will realize that both the near-IR attenuation data and the near-IR fluorescence data may be significantly dependent on the pressure and temperature of the fluid stream being analyzed, which may be at pressures and temperatures as high as 400° F. and 20,000 psig. Thus, in some applications, it may be desirable to compensate for pressure and temperature effects by performing the calibration on mixtures at the pressures and temperatures expected to be encountered in actual service, or on mixtures of varying pressures and temperatures so as to arrive at a set of algorithms, each of which is applicable to a different ranges of pressures and/or temperatures. In this case, classification models can be constructed using mixtures compositions of varying pressure and temperature so that the light component data from the flowing fluid can be assigned to a concentration algorithm that has been optimized for the pressures and temperatures having ranges that encompass those of the flowing fluid. 
     V. Use of Downhole Fluid Analysis in an Oil Well 
     By way of example only, the invention will be described in connection with the analysis of the fluid flowing from a multilateral well into which production strings have been incorporated. It will be understood by those skilled in the art that the invention is equally applicable to other environments in which it is desirable to remotely sense the presence of a substance that fluoresces or absorbs radiation, such as oil, in a flowing fluid. 
     As depicted in FIG. 16, a multilateral well  4  has three zones extending into the formation  2 . A section of a production string  8  is located in each zone so that all three zones produce fluids simultaneously. Each section of the production string  8  includes a valve  70  for regulating the flow of fluid from its zone. The fluid  25  flowing from the well  4  typically may comprise one or more of oil, water, natural gas, and solids, such as sand. As is conventional, the fluid  25 ′,  25 ″ and  25 ′″ from all three zones are combined into a common flow line  25  before reaching the surface. As a result, an analysis of the fluid at the surface according to a conventional approach will not enable the operator to assess the production of the individual zones of the well. 
     A system for analyzing fluid according to the current invention is shown incorporated into each zone of the well  4 . Specifically, an instrumented section  10  of the type shown in FIG. 1 have been incorporated into the branches of the production piping that extend into each zone of the well, along with a mixer  60  and diverter  62 . As shown in FIG. 16, fiber optic cables  14 , which may be several kilometers long, connect each of the instrumented sections  10  to the light source  16  and fluid analyzer  6  at the surface. 
     As previously discussed, the computer  20  of the fluid analyzer  6  is programed with an appropriate algorithm for calculating the concentrations of oil and water, each of which is preferably in the form of equation [5] so that it employs weighting factors for selected wavelengths, which are preferably determined based on a calibration of the oil from the well. 
     As shown in FIGS. 1 and 15, during production, the light source  16  periodically or continuously transmits light to each of the sensors  12  in the instrumented sections  10  via the optical fibers  14 ′. The intensity of the components of the collected light returned from each of the sensors  12  by the optical fibers  14 ″ over a predetermined range of wavelengths is measured using the spectrographic detector  18 . The computer  20  periodically or continuously calculates the concentrations of oil and water flowing through each of the zones of the well, using software that allows it to calculate the normalized intensity of the measured light components, preferably using one of the normalization techniques previously discussed, and then apply those normalized intensities to the aforementioned algorithms. The calculated concentrations of oil and water are then displayed by the indicator  24 . 
     Incorporating instrumented sections  10  in each zone of the well  4  allows the operator to determine the percentage of oil and/or water in the fluid flowing downhole through each zone on a nearly real-time basis. This information can, in turn, be used to regulate the flow from each zone so as to optimize production, for example, by operating the valve  70  to reduce the flow from a zone producing a low percentage of crude oil, or excessive water. 
     Although the present invention has been discussed in connection with the determination of the concentration of crude oil or gas in an oil well producing an oil/water/gas mixture, the invention can be used to determine the concentration, or merely detect the presence, of oil or gas in other applications, such as when contamination of water by oil is suspected. Alternatively, the invention can be used to determine the concentration or detect the presence of other substances that fluoresce or absorb radiation in flowing streams that have scattering characteristics. 
     Moreover, although the mixer and diverter have been discussed in connection with the sensor of a fluid analyzer, these components could also be used in connection with other types of sensors used in the well piping. 
     Accordingly, the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof and, accordingly, reference should be made to the appended claims, rather than to the foregoing specification, as indicating the scope of the invention.