def __init__(self, filename, interpolation_mode='linear', in_memory=True):
        self._molecule_name = sanitize_molecule_string(
            pathlib.Path(filename).stem.split('_')[0])
        super().__init__('HDF5Ktable:{}'.format(self._molecule_name),
                         interpolation_mode=interpolation_mode)
        self._molecule_name = sanitize_molecule_string(
            pathlib.Path(filename).stem.split('_')[0])
        self._filename = filename
        self._spec_dict = None

        self._resolution = None
        self.in_memory = in_memory
        self._load_pickle_file(filename)
    def discover(cls):
        import os
        import glob
        import pathlib
        from taurex.cache import GlobalCache

        path = GlobalCache()['ktable_path']
        if path is None:
            return []
        path = os.path.join(path, '*.hdf5')

        files = glob.glob(path) + \
            glob.glob(os.path.join(GlobalCache()['ktable_path'], '*.h5'))

        discovery = []

        interp = GlobalCache()['xsec_interpolation'] or 'linear'

        for f in files:
            splits = pathlib.Path(f).stem.split('_')
            mol_name = sanitize_molecule_string(splits[0])

            discovery.append((mol_name, [f, interp]))

        return discovery
    def __init__(self, filename, interpolation_mode='linear'):
        super().__init__('NemesisKtable:{}'.format(
            pathlib.Path(filename).stem[0:10]),
                         interpolation_mode=interpolation_mode)

        self._filename = filename
        splits = pathlib.Path(filename).stem.split('_')
        mol_name = sanitize_molecule_string(splits[0])
        self._molecule_name = mol_name
        self._spec_dict = None
        self._resolution = None
        self._decode_ktables(filename)
    def discover(cls):
        import os
        import glob
        import pathlib
        from taurex.cache import GlobalCache
        from taurex.util.util import sanitize_molecule_string

        path = GlobalCache()['xsec_path']
        if path is None:
            return []
        path = os.path.join(path, '*.dat')

        files = glob.glob(path)

        discovery = []

        interp = GlobalCache()['xsec_interpolation'] or 'linear'

        for f in files:
            mol_name = sanitize_molecule_string(pathlib.Path(f).stem[4:])
            discovery.append((mol_name, [f, interp]))

        return discovery
def test_molecule_sanitization_same():
    from taurex.util.util import sanitize_molecule_string
    names = [
            'NH3',
            'AsH3',
            'C6H6',
            'Br2',
            'CS2',
            'CO',
            'CCl4',
            'Cl2',
            'ClO2',
            'C2H4',
            'H2COCH2',
            'HCHO',
            'H2NNH2',
            'H2',
            'HBr',
            'HCl',
            'HCN',
            'H2O2',
            'H2S',
            'CH3SH',
            'CH3NHNH2',
            'NO',
            'NO2',
            'N2O4',
            'O3',
            'CH3COOOH',
            'PH3',
            'CH3CHOCH2',
            'SiH4',
            'SO2',
            'SO2F2'
        ]
    for n in names:
        assert sanitize_molecule_string(n) == n
def test_molecule_sanitization(mol):
    from taurex.util.util import sanitize_molecule_string
    expected, exomol, mass = mol
    assert sanitize_molecule_string(exomol) == expected
 def determine_mass(self):
     self.mass = calculate_weight(sanitize_molecule_string(self.molecule))
     self.info('Auto determined mass as %.3f', self.mass)