Exemple #1
0
                label=['$\\bar{x}$', '$\\bar{y}$', '$\\bar{z}$'],legendAlpha=0.5,maxNX=5);
        cietriplt.saveFig('cieBAR'+figtype)










        ## ----------------------- colour tristimulus ---------------------------------
        # read csv file with wavelength in nm, x, y, z cie tristimulus values (x,y,z).
        # return values are 2-D (N,3) array scaled and interpolated.
        bar = ryfiles.loadColumnTextFile('data/colourcoordinates/ciexyz31_1.txt', abscissaOut=wavelength,
                        loadCol=[1,2,3],  comment='%', delimiter=',', abscissaScale=1e-3)


        ## ------------------------ sources ------------------------------------------
        #build a 2-D array with the source radiance values, where each column
        #represents a different source. Wavelength extends along rows.
        #Spectral interval for all source spectra is the same, which is 'wavelength'
        #Blackbody radiance spectra are calculated at the required wavelength intervals
        #Data read from files are interpolated to the required wavelength intervals
        #Use np.hstack to stack columns horizontally.

        sources = ryfiles.loadColumnTextFile('data/colourcoordinates/fluorescent.txt',
            abscissaOut=wavelength,comment='%', normalize=1).reshape(-1,1)
        sources = np.hstack((sources, ryplanck.planckel(wavelength,5900).reshape(-1,1)))
        sources = np.hstack((sources, ryplanck.planckel(wavelength,2850).reshape(-1,1)))
        sources = np.hstack((sources, ryfiles.loadColumnTextFile(
Exemple #2
0
import pyradi.ryfiles as ryfiles
import pyradi.ryplot as ryplot
import pyradi.ryplanck as ryplanck
import pyradi.ryutils as ryutils

#this example is somewhat contrived, but serves to show toolkit use

#load atmospheric transmittance from file created in Modtran in wavenumbers
# the transmittance is specified in the wavenumber domain with
# 5 cm-1 intervals, but we want to work in wavelength with 2.5 cm-1
waven = numpy.arange(2000.0, 3300.0, 2.5).reshape(-1, 1)
wavel = ryutils.convertSpectralDomain(waven, type='nl')

#remove comment lines, and scale path radiance from W/cm2.sr.cm-1  to W/m2.sr.cm-1
tauA = ryfiles.loadColumnTextFile('../data/path1kmflamesensor.txt', [1],
                                  abscissaOut=waven,
                                  comment='%')
lpathwn = ryfiles.loadColumnTextFile('../data/pathspaceflamesensor.txt', [9],
                                     abscissaOut=waven,
                                     ordinateScale=1.0e4,
                                     comment='%')

#convert path radiance spectral density from 1/cm^-1 to 1/um, at the sample
#wavenumber points
(dum, lpathwl) = ryutils.convertSpectralDensity(waven, lpathwn, type='nl')

#load the detector file in wavelengths, and interpolate on required values
detR = ryfiles.loadColumnTextFile('../data/detectorflamesensor.txt', [1],
                                  abscissaOut=wavel,
                                  comment='%')
Exemple #3
0
    import pyradi.ryplanck as ryplanck
    import pyradi.ryplot as ryplot
    import pyradi.ryfiles as ryfiles

    #figtype = ".png"  # eps, jpg, png
    figtype = ".eps"  # eps, jpg, png

    ## ----------------------- wavelength------------------------------------------
    #create the wavelength scale to be used in all spectral calculations,
    # wavelength is reshaped to a 2-D  (N,1) column vector
    wavelength=np.linspace(0.38, 0.72, 350).reshape(-1, 1)

    ## ----------------------- colour tristimulus ---------------------------------
    # read csv file with wavelength in nm, x, y, z cie tristimulus values (x,y,z).
    # return values are 2-D (N,3) array scaled and interpolated.
    bar = ryfiles.loadColumnTextFile('data/colourcoordinates/ciexyz31_1.txt', abscissaOut=wavelength,
                    loadCol=[1,2,3],  comment='%', delimiter=',', abscissaScale=1e-3)


    ## ------------------------ sources ------------------------------------------
    #build a 2-D array with the source radiance values, where each column
    #represents a different source. Wavelength extends along rows.
    #Spectral interval for all source spectra is the same, which is 'wavelength'
    #Blackbody radiance spectra are calculated at the required wavelength intervals
    #Data read from files are interpolated to the required wavelength intervals
    #Use np.hstack to stack columns horizontally.

    sources = ryfiles.loadColumnTextFile('data/colourcoordinates/fluorescent.txt',
        abscissaOut=wavelength,comment='%', normalize=1).reshape(-1,1)
    sources = np.hstack((sources, ryplanck.planckel(wavelength,5900).reshape(-1,1)))
    sources = np.hstack((sources, ryplanck.planckel(wavelength,2850).reshape(-1,1)))
    sources = np.hstack((sources, ryfiles.loadColumnTextFile(
Exemple #4
0
    def LoadSpectrals(self):
        """Load the five required spectral parameters, interpolate on the
        fly to local spectrals.

        If the spectral parameters are strings, the strings are used as filenames
        and the data loaded from file.  If None, unity values are assumed. If not
        a string or None, the parameters are used as is, and must be numpy arrays
        with shape (N,1) where the N vector exactly matches to spectral samples

        Args:
            |  None.

        Returns:
            |  None. Side-effect of loaded spectrals.


        Raises:
            | No exception is raised.
        """

        #--------------------------
        if self.sourceEmis is not None:
            if type(self.sourceEmis) is not type(np.asarray(['0'])):
                self.specEmis = ryfiles.loadColumnTextFile(self.sourceEmis,
                    loadCol=[1], normalize=0, abscissaOut=self.wl)
            else:
                self.specEmis = self.sourceEmis
        else:
            self.specEmis = np.ones(self.nu.shape)
        self.specEmis = self.specEmis.reshape(-1,1)

        #--------------------------
        if self.atmoTau is not None:
            if type(self.atmoTau) is not type(np.asarray(['0'])):
                self.specAtmo = ryfiles.loadColumnTextFile(self.atmoTau,
                    loadCol=[1], normalize=0, abscissaOut=self.wl)
            else:
                self.specAtmo = self.atmoTau
        else:
            self.specAtmo= np.ones(self.nu.shape)
        self.specAtmo = self.specAtmo.reshape(-1,1)

        #--------------------------
        if self.filterTau is not None:
            if type(self.filterTau) is not type(np.asarray(['0'])):
                self.specFilter = ryfiles.loadColumnTextFile(self.filterTau,
                    loadCol=[1], normalize=0, abscissaOut=self.wl)
            else:
                self.specFilter = self.filterTau
        else:
            self.specFilter= np.ones(self.nu.shape)
        self.specFilter = self.specFilter.reshape(-1,1)

        #--------------------------
        if self.sensorResp is not None:
            if type(self.sensorResp) is not type(np.asarray(['0'])):
                self.specSensor = ryfiles.loadColumnTextFile(self.sensorResp,
                    loadCol=[1], normalize=0, abscissaOut=self.wl)
            else:
                self.specSensor = self.sensorResp
        else:
            self.specSensor= np.ones(self.nu.shape)
        self.specSensor = self.specSensor.reshape(-1,1)

        #--------------------------
        if self.opticsTau is not None:
            if type(self.opticsTau) is not type(np.asarray(['0'])):
                self.specOptics = ryfiles.loadColumnTextFile(self.opticsTau,
                    loadCol=[1], normalize=0, abscissaOut=self.wl)
            else:
                self.specOptics = self.opticsTau
        else:
            self.specOptics= np.ones(self.nu.shape)
        self.specOptics = self.specOptics.reshape(-1,1)

        self.spectralsLoaded = True
Exemple #5
0
import numpy
import pyradi.ryfiles as ryfiles
import pyradi.ryplot as ryplot
import pyradi.ryplanck as ryplanck
import pyradi.ryutils as ryutils

#this example is somewhat contrived, but serves to show toolkit use

#load atmospheric transmittance from file created in Modtran in wavenumbers
# the transmittance is specified in the wavenumber domain with
# 5 cm-1 intervals, but we want to work in wavelength with 2.5 cm-1
waven = numpy.arange(2000.0,  3300.0,  2.5).reshape(-1, 1)
wavel= ryutils.convertSpectralDomain(waven,  type='nl')

#remove comment lines, and scale path radiance from W/cm2.sr.cm-1  to W/m2.sr.cm-1
tauA = ryfiles.loadColumnTextFile('../data/path1kmflamesensor.txt',
    [1],abscissaOut=waven,  comment='%')
lpathwn = ryfiles.loadColumnTextFile('../data/pathspaceflamesensor.txt',
    [9],abscissaOut=waven,  ordinateScale=1.0e4,  comment='%')

#convert path radiance spectral density from 1/cm^-1 to 1/um, at the sample
#wavenumber points
(dum, lpathwl) = ryutils.convertSpectralDensity(waven,  lpathwn, type='nl')

#load the detector file in wavelengths, and interpolate on required values
detR = ryfiles.loadColumnTextFile('../data/detectorflamesensor.txt',
    [1],abscissaOut=wavel,  comment='%')

#construct the flame emissivity from parameters
emis = ryutils.sfilter(wavel,center=4.33, width=0.45, exponent=6, taupass=0.8,
    taustop=0.1 )
Exemple #6
0
    inspectral[55/samplingresolution] = 1
    inspectral[70/samplingresolution] = 1
    inspectral[75/samplingresolution] = 1
    inwinwidth=1
    outwinwidth=5
    outspectral,  windowfn = convolve(inspectral, samplingresolution,  inwinwidth,  outwinwidth)
    convplot = ryplot.Plotter(1, 1, 1)
    convplot.plot(1, wavenum, inspectral, "Convolution Test", r'Wavenumber cm$^{-1}$',\
                r'Signal', ['r-'],label=['Input'],legendAlpha=0.5)
    convplot.plot(1, wavenum, outspectral, "Convolution Test", r'Wavenumber cm$^{-1}$',\
                r'Signal', ['g-'],label=['Output'],legendAlpha=0.5)
    convplot.saveFig('convplot01'+figtype)

    ## ----------------------- spectral convolution practical example ----------
     # loading bunsen spectral radiance file: 4cm-1  spectral resolution, approx 2 cm-1 sampling
    specRad = ryfiles.loadColumnTextFile('data/bunsenspec.txt',  \
                    loadCol=[0,1], comment='%', delimiter=' ')
    # modtran5 transmittance 5m path, 1 cm-1 spectral resolution, sampled 1cm-1
    tauAtmo = ryfiles.loadColumnTextFile('data/atmotrans5m.txt',  \
                    loadCol=[0,1], comment='%', delimiter=' ')
    wavenum =  tauAtmo[:, 0]
    tauA = tauAtmo[:, 1]
    # convolve transmittance from 1cm-1 to 4 cm-1
    tauAtmo4,  windowfn = convolve(tauA, 1,  1,  4)
    #interpolate bunsen spectrum to atmo sampling
    #first construct the interpolating function, using bunsen
    bunInterp1 = interp1d(specRad[:,0], specRad[:,1])
    #then call the function on atmo intervals
    bunsen = bunInterp1(wavenum)

    atmoplot = tauA.copy()
    atmoplot =  np.vstack((atmoplot, tauAtmo4))