ramancontrol.py 2.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# -*- coding: utf-8 -*-
"""
GEPARD - Gepard-Enabled PARticle Detection
Copyright (C) 2018  Lars Bittrich and Josef Brandt, Leibniz-Institut für 
Polymerforschung Dresden e. V. <bittrich-lars@ipfdd.de>    

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program, see COPYING.  
If not, see <https://www.gnu.org/licenses/>.
"""
import os
22
import configparser
23

24
__all__ = ["RamanControl", "defaultPath", "simulatedRaman"]
25

26 27

defaultPath = os.path.dirname(os.path.split(__file__)[0])
28

29
config = configparser.ConfigParser()
30
config.read(os.path.join(defaultPath, 'gepard.cfg'))
31

32 33
interface = "RENISHAW_CONTROL"

34

35 36 37 38 39 40 41 42 43 44 45
try: 
    defaultPath = config["Defaults"]["file_path"]
except KeyError:
    pass

try:
    interface = config["Interface"]["raman_interface"]
except KeyError:
    pass

if interface == "SIMULATED_RAMAN_CONTROL":
46
    from .simulatedraman import SimulatedRaman
47
    RamanControl = SimulatedRaman
48 49
    print("WARNING: using only simulated raman control!")
    simulatedRaman = True
50
    
Raman's avatar
Raman committed
51
elif interface == "WITEC_CONTROL":
52
    from .WITecCOM import WITecCOM
53
    RamanControl = WITecCOM
54
    RamanControl.magn = int(config["General Microscope Setup"]["magnification"])    # not yet implemented in WITecCOM, but would probably be a good idea...
55
    simulatedRaman = False
56
    
57
elif interface == "RENISHAW_CONTROL":
58
    from .renishawcom import RenishawCOM
59 60 61 62 63 64 65 66 67 68 69 70 71 72
    RamanControl = RenishawCOM
    RamanControl.magn = int(config["General Microscope Setup"]["magnification"])
    try:
        bf_dims = config["Renishaw"]["img_size_BF"].split('*')
        df_dims = config["Renishaw"]["img_size_DF"].split('*')
        RamanControl.cam_bf_dims = [float(bf_dims[0]), float(bf_dims[1])]
        RamanControl.cam_df_dims = [float(df_dims[0]), float(df_dims[1])]
    except:
        print('Invalid image dimensions in config file!')
#    RamanControl.defaultMeasTemplate = config["Renishaw"]["defaultMeasTemplate"]
    RamanControl.measTemplatePath = config["Renishaw"]["measTemplatePath"]
    print(RamanControl.measTemplatePath)
    RamanControl.ramanParameters = RamanControl.updateRamanParameters(RamanControl, RamanControl.measTemplatePath)
            
73
    simulatedRaman = False
74 75