示例#1
0
def run():
    from spectral.io.spyfile import find_file_path, FileNotFoundError

    tests = [('92AV3C.lan', (99, 99, 99), 2057.0)]
#    tests = [('92AV3C.lan', (99, 99, 99), 2057.0),
#             ('f970619t01p02_r02_sc04.a.rfl', (99, 99, 99), 0.2311),
#             ('cup95eff.int.hdr', (99, 99, 33), 0.1842)]
    for (fname, datum, value) in tests:
        try:
            check = find_file_path(fname)
            suite = SpyFileTestSuite(fname, datum, value,
                                     dtypes=('i2', 'i4', 'f4', 'f8'))
            suite.run()
        except FileNotFoundError:
            print('File "%s" not found. Skipping.' % fname)
    def read_data_from_file(filename):
        path = find_file_path(filename)
        with open(path) as f:
            header_line = f.readline()
            libname, record, measurement, spectrometer_name, description = \
                SpectrometerData.parse_header(header_line.strip())

            data = []
            for line in f:
                try:
                    data.append(float(line.strip()))
                except:
                    pass

            data = np.array(data)

            return libname, record, measurement, spectrometer_name, description, data
def run():
    from spectral.io.spyfile import find_file_path, FileNotFoundError

    tests = [('92AV3C.lan', (99, 99, 99), 2057.0)]
    #    tests = [('92AV3C.lan', (99, 99, 99), 2057.0),
    #             ('f970619t01p02_r02_sc04.a.rfl', (99, 99, 99), 0.2311),
    #             ('cup95eff.int.hdr', (99, 99, 33), 0.1842)]
    for (fname, datum, value) in tests:
        try:
            check = find_file_path(fname)
            suite = SpyFileTestSuite(fname,
                                     datum,
                                     value,
                                     dtypes=('i2', 'i4', 'f4', 'f8'))
            suite.run()
        except FileNotFoundError:
            print('File "%s" not found. Skipping.' % fname)
示例#4
0
    def __init__(self, sqlite_filename=None):
        '''Creates a database object to interface an existing database.

        Arguments:

            `sqlite_filename` (str):

                Name of the database file.  If this argument is not provided,
                an interface to a database file will not be established.

        Returns:

            An :class:`~spectral.AsterDatabase` connected to the database.
        '''
        from spectral.io.spyfile import find_file_path
        if sqlite_filename:
            self._connect(find_file_path(sqlite_filename))
        else:
            self.db = None
            self.cursor = None
示例#5
0
    def __init__(self, sqlite_filename=None):
        '''Creates a database object to interface an existing database.

        Arguments:

            `sqlite_filename` (str):

                Name of the database file.  If this argument is not provided,
                an interface to a database file will not be established.

        Returns:

            An :class:`~spectral.AsterDatabase` connected to the database.
        '''
        from spectral.io.spyfile import find_file_path
        if sqlite_filename:
            self._connect(find_file_path(sqlite_filename))
        else:
            self.db = None
            self.cursor = None
    def read_from_file(filename):
        path = find_file_path(filename)

        with open(path) as f:
            header_line = f.readline()
            libname, record, description, spectrometer, purity, measurment_type = \
                SpectralData.parse_header(header_line.strip())

            spectrum = []
            for line in f:
                try:
                    spectrum.append(float(line.strip()))
                except:
                    pass

            spectrometer_data = SpectrometerData.get_by_name(spectrometer)

            return SpectralData(np.array(spectrum), libname, record,
                                description, spectrometer, purity,
                                measurment_type, spectrometer_data)