예제 #1
0
def runSingleServerInstanceNoNat():
    # Parse arguments
    args = parser.parse_args()
    sys.path.append(os.getcwd())

    # Load config
    conf = args.configFile
    if conf[-3:] == '.py':
        conf = conf[:-3]
    print(conf)

    cfg = importlib.import_module(conf)

    app = MMPRaytracer('localhost')

    # Creates deamon, register the app in it
    daemon = Pyro4.Daemon(host=cfg.server, port=cfg.serverPort)
    uri = daemon.register(app)

    # Get nameserver
    ns = Pyro4.locateNS(host=cfg.nshost, port=cfg.nsport, hmac_key=cfg.hkey)
    # Register app
    ns.register(cfg.appName, uri)

    print(uri)
    # Deamon loops at the end
    daemon.requestLoop()
예제 #2
0
def runSingleServerInstance():
    '''
    Run a single instance of the Tracer server.
    The configuration file given in args must include the following:
    server,
    serverPort,
    serverNathost,
    serverNatport,
    nshost,
    nsport,
    appName,
    hkey
    '''
    # Parse arguments
    args = parser.parse_args()
    sys.path.append(os.getcwd())

    # Load config
    conf = args.configFile
    if conf[-3:] == '.py':
        conf = conf[:-3]
    print(conf)

    cfg = importlib.import_module(conf)

    app = MMPRaytracer('localhost')

    PyroUtil.runAppServer(cfg.server,
                          cfg.serverPort,
                          cfg.serverNathost,
                          cfg.serverNatport,
                          cfg.nshost,
                          cfg.nsport,
                          cfg.appName,
                          cfg.hkey,
                          app=app)
    # that logs at the INFO-level. Use this place to set for debug level.
    logging.config.fileConfig('../../loggingNew.conf')

    logger = logging.getLogger('mmpraytracer')
    print("#######################################")
    print("######### Active Logging info #########")
    logger.debug('messages will be logged')
    logger.info('messages will be logged')
    logger.warn('messages will be logged')
    logger.error('messages will be logged')
    logger.critical('messages will be logged')
    print("#######################################")

    # Initialise apps
    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    # Set default LED json
    tracerApp.setDefaultInputFile('../../DefaultLED.json')

    # Connect functions
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections,
                               0,
                               objectID=objID.OBJ_PARTICLE_TYPE_1)
    pPhase = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist,
                                0,
                                objectID=objID.OBJ_PARTICLE_TYPE_1)

    tracerApp.setProperty(pScat)
    tracerApp.setProperty(pPhase)
예제 #4
0
def xsim(z, *params):

    #create the apps:
    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    # Point data conversion to false. Speeds up testing
    tracerApp._convertPointData = False

    # Set default LED json
    tracerApp.setDefaultInputFile('./DefaultLED.json')

    # Connect functions
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0,
                               objectID=objID.OBJ_PARTICLE_TYPE_1)
    pPhase = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist, 0,
                                objectID=objID.OBJ_PARTICLE_TYPE_1)

    tracerApp.setProperty(pScat)
    tracerApp.setProperty(pPhase)

    # Connect fields
    fTemp = comsolApp.getField(FieldID.FID_Temperature, 0)
    fHeat = comsolApp.getField(FieldID.FID_Thermal_absorption_volume, 0)

    tracerApp.setField(fTemp)
    tracerApp.setField(fHeat)


    #set the constant properties from *params:

    p_max = 35.0
    p_min = 3.0
    p_num = 50

    w_max = 1100.0
    w_min = 100.0
    w_num = 1000

    # Weight fractions
    #weight_frac = np.array([24]) / 100.0 #CHANGING PARAMETER!See below

    # Particle density
    dens_p = 5.0  # g/cm3
    # Silicone density
    dens_host = 1.1  # g/cm3

    # log mean in microns
    mu = 2.4849
    # log standard deviation in microns
    sigma = 0.3878
    # Particles diameters in micrometers
    d = np.linspace(p_min, p_max, p_num)
    pdf = lognorm(sigma, scale=np.exp(mu))

    #set the changing properties from z:
    # Weight fractions
    weight_frac = np.array([z]) / 100.0
    print("z, weight_frac = ", z, weight_frac)

    #run the simulation:
    
    # Number of rays to trace
    pRays = Property.Property(value=100000,
                              propID=PropertyID.PID_NumberOfRays,
                              valueType=ValueType.Scalar,
                              time=0.0,
                              units=None,
                              objectID=objID.OBJ_CONE)
    tracerApp.setProperty(pRays)
    
    # Emission spectrum
    em = Property.Property(value=ex_em_import.getEm(),
                           propID=PropertyID.PID_EmissionSpectrum,
                           valueType=ValueType.Scalar,
                           time=0.0,
                           units=None,
                           objectID=objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(em)

    # Excitation spectrum
    ex = Property.Property(value=ex_em_import.getEx(),
                           propID=PropertyID.PID_ExcitationSpectrum,
                           valueType=ValueType.Scalar,
                           time=0.0,
                           units=None,
                           objectID=objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(ex)

    # Absorption spectrum
    aabs = Property.Property(value=ex_em_import.getAbs(),
                             propID=PropertyID.PID_AsorptionSpectrum,
                             valueType=ValueType.Scalar,
                             time=0.0,
                             units=None,
                             objectID=objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(aabs)

    #logger.info('Properties set!')

    # Solve Mie
    mieApp.solveStep(0)

    for w_frac in weight_frac:
        particles_in_um3 =\
            st.particlesInVolumeLogNormWeightTotal(w_frac, dens_p,
                                                   dens_host, mu, sigma,
                                                   particle_diameters=d)

    # Particle density
    vDens = particles_in_um3
    pDens = Property.Property(value=vDens,
                              propID=PropertyID.PID_ParticleNumberDensity,
                              valueType=ValueType.Scalar,
                              time=0.0,
                              units=None,
                              objectID=objID.OBJ_CONE)
    tracerApp.setProperty(pDens)

    # Solve
    tracerApp.solveStep(0, runInBackground=False)



    #get the simulation result value and return it:
    
    p = tracerApp.getProperty(PropertyID.PID_LEDCCT, 0,
                              objectID=objID.OBJ_LED)
    print('CCT: %f' % p.value)
    p = tracerApp.getProperty(PropertyID.PID_LEDRadiantPower, 0,
                                  objectID=objID.OBJ_LED)
    print('RadiantPower: %f' % p.value)

    p = tracerApp.getProperty(PropertyID.PID_LEDColor_x, 0,
                                  objectID=objID.OBJ_LED)
    print('Color x: %f' % p.value)
    p = tracerApp.getProperty(PropertyID.PID_LEDColor_y, 0,
                                  objectID=objID.OBJ_LED)
    print('Color y: %f' % p.value)
    p = tracerApp.getProperty(PropertyID.PID_LEDSpectrum, 0,
                                  objectID=objID.OBJ_LED)
    print(p.value['wavelengths'][0:10])
    print(p.value['intensities'][0:10])

    #return CCT:
    p = tracerApp.getProperty(PropertyID.PID_LEDCCT, 0,
                              objectID=objID.OBJ_LED)
    return (p.value)
예제 #5
0
    # that logs at the INFO-level. Use this place to set for debug level.
    logging.config.fileConfig('../../loggingNew.conf')

    logger = logging.getLogger('mmpraytracer')
    print("#######################################")
    print("######### Active Logging info #########")
    logger.debug('messages will be logged')
    logger.info('messages will be logged')
    logger.warn('messages will be logged')
    logger.error('messages will be logged')
    logger.critical('messages will be logged')
    print("#######################################")

    # Initialise apps
    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    logger.info('Connecting Mie properties...')
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0,
                               objID.OBJ_PARTICLE_TYPE_1)

    pPhase = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist, 0,
                                objID.OBJ_PARTICLE_TYPE_1)

    logger.info('Props received...')
    tracerApp.setProperty(pScat, objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(pPhase, objID.OBJ_PARTICLE_TYPE_1)
    logger.info('Props connected')

    # Connect fields
    # that logs at the INFO-level. Use this place to set for debug level.
    logging.config.fileConfig('../../loggingNew.conf')

    logger = logging.getLogger('mmpraytracer')
    print("#######################################")
    print("######### Active Logging info #########")
    logger.debug('messages will be logged')
    logger.info('messages will be logged')
    logger.warn('messages will be logged')
    logger.error('messages will be logged')
    logger.critical('messages will be logged')
    print("#######################################")

    # Initialise apps
    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    # Set default LED json
    tracerApp.setDefaultInputFile('../../DefaultLED.json')

    # Connect functions
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0,
                               objectID=objID.OBJ_PARTICLE_TYPE_1)
    pPhase = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist, 0,
                                objectID=objID.OBJ_PARTICLE_TYPE_1)

    tracerApp.setProperty(pScat)
    tracerApp.setProperty(pPhase)

    # Connect fields
예제 #7
0
import logging
import logging.config
import ex_em_import
import numpy as np
from scipy.stats import lognorm
from pyraytracer import scatteringTools as st
import os



print("test script for n particle types")


#create the apps:
mieApp = MMPMie('localhost')
tracerApp = MMPRaytracer('localhost')
comsolApp = MMPComsolDummy('localhost')

# Point data conversion to false. Speeds up testing
tracerApp._convertPointData = False

# Set default LED json
tracerApp.setDefaultInputFile('./DefaultLED3.json')

#Set refractive indexes to mieApp:
pri = Property.Property(1.83,
                        PropertyID.PID_RefractiveIndex,
                        valueType=ValueType.Scalar,
                        time=0.0,
                        units=None,
                        objectID=objID.OBJ_PARTICLE_TYPE_1)
    # that logs at the INFO-level. Use this place to set for debug level.
    logging.config.fileConfig('../../loggingNew.conf')

    logger = logging.getLogger('mmpraytracer')
    print("#######################################")
    print("######### Active Logging info #########")
    logger.debug('messages will be logged')
    logger.info('messages will be logged')
    logger.warn('messages will be logged')
    logger.error('messages will be logged')
    logger.critical('messages will be logged')
    print("#######################################")

    # Initialise apps
    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    # Point data conversion to false. Speeds up testing
    tracerApp._convertPointData = False

    # Set default LED json
    tracerApp.setDefaultInputFile('../DefaultLED.json')

    # Connect functions
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections,
                               0,
                               objectID=objID.OBJ_PARTICLE_TYPE_1)
    pPhase = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist,
                                0,
                                objectID=objID.OBJ_PARTICLE_TYPE_1)
예제 #9
0
    # that logs at the INFO-level. Use this place to set for debug level.
    logging.config.fileConfig('../../loggingNew.conf')

    logger = logging.getLogger('mmpraytracer')
    print("#######################################")
    print("######### Active Logging info #########")
    logger.debug('messages will be logged')
    logger.info('messages will be logged')
    logger.warn('messages will be logged')
    logger.error('messages will be logged')
    logger.critical('messages will be logged')
    print("#######################################")

    # Initialise apps
    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    logger.info('Connecting Mie properties...')
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0,
                               objID.OBJ_PARTICLE_TYPE_1)

    pPhase = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist, 0,
                                objID.OBJ_PARTICLE_TYPE_1)

    logger.info('Props received...')
    tracerApp.setProperty(pScat, objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(pPhase, objID.OBJ_PARTICLE_TYPE_1)
    logger.info('Props connected')

    # Connect fields
예제 #10
0
from mmp_mie_api import MMPMie
from comsol_api import MMPComsolDummy
from mupif import Property, PropertyID, FieldID, ValueType
import logging
import ex_em_import

if __name__ == '__main__':

    logger = logging.getLogger()

    import time as timeTime
    start = timeTime.time()
    logger.info('Timer started')

    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    # Point data conversion to false. Speeds up testing
    tracerApp._convertPointData = False

    logger.info('Applications loaded:')
    print(mieApp)
    print(tracerApp)
    print(comsolApp)

    # Connect functions

    logger.info('Connecting Mie properties...')
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0,
                               objID.OBJ_PARTICLE_TYPE_1)
예제 #11
0
def xsim(z, *params):

    #create the apps:
    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    # Point data conversion to false. Speeds up testing
    tracerApp._convertPointData = False

    # Set default LED json
    tracerApp.setDefaultInputFile('./DefaultLED3.json')

    #Set refractive indexes to mieApp:
    pri = Property.Property(1.83,
                            PropertyID.PID_RefractiveIndex,
                            valueType=ValueType.Scalar,
                            time=0.0,
                            units=None,
                            objectID=objID.OBJ_PARTICLE_TYPE_1)
    mieApp.setProperty(pri)

    # same for particle_type_2
    pri2 = Property.Property(1.84,
                             PropertyID.PID_RefractiveIndex,
                             valueType=ValueType.Scalar,
                             time=0.0,
                             units=None,
                             objectID=objID.OBJ_PARTICLE_TYPE_2)
    mieApp.setProperty(pri2)
    
    hmri = Property.Property(1.55, PropertyID.PID_RefractiveIndex,
                             valueType=ValueType.Scalar,
                             time=0.0,
                             units=None,
                             objectID=objID.OBJ_CONE)
    mieApp.setProperty(hmri)

    #set also another particle type to MieApp:
    pScat2 = Property.Property(0,
                              PropertyID.PID_ScatteringCrossSections,
                              valueType=ValueType.Vector,
                              time=0.0,
                              units=None,
                              objectID=objID.OBJ_PARTICLE_TYPE_2)

    pPhase2 = Property.Property(0,
                            propID=PropertyID.PID_InverseCumulativeDist,
                            valueType=ValueType.Vector,
                            time=0.0,
                            units=None,
                            objectID=objID.OBJ_PARTICLE_TYPE_2)

    mieApp.setProperty(pScat2)
    mieApp.setProperty(pPhase2)

    # Connect fields
    fTemp = comsolApp.getField(FieldID.FID_Temperature, 0)
    fHeat = comsolApp.getField(FieldID.FID_Thermal_absorption_volume, 0)

    tracerApp.setField(fTemp)
    tracerApp.setField(fHeat)


    #set the constant properties from *params:

    p_max = 35.0
    p_min = 1.0
    p_num = 50

    w_max = 1100.0
    w_min = 100.0
    w_num = 1001


    # Particle density
    dens_p = 5.0  # g/cm3
    # Silicone density
    dens_host = 1.1  # g/cm3

    # log mean in microns
    mu1 = 2.4849
    # log standard deviation in microns
    sigma1 = 0.3878

    mu2 = 2.35137
    sigma2 = 0.627218

    mu = [mu1, mu2]
    sigma = [sigma1, sigma2]

    mup = Property.Property(value=mu1, propID=PropertyID.PID_ParticleMu, valueType=ValueType.Scalar, time=0.0, units=None, objectID=objID.OBJ_PARTICLE_TYPE_1)

    sigmap = Property.Property(value=sigma1, propID=PropertyID.PID_ParticleSigma, valueType=ValueType.Scalar, time=0.0, units=None, objectID=objID.OBJ_PARTICLE_TYPE_1)

    mup2 = Property.Property(value=mu2, propID=PropertyID.PID_ParticleMu, valueType=ValueType.Scalar, time=0.0, units=None, objectID=objID.OBJ_PARTICLE_TYPE_2)

    sigmap2 = Property.Property(value=sigma2, propID=PropertyID.PID_ParticleSigma, valueType=ValueType.Scalar, time=0.0, units=None, objectID=objID.OBJ_PARTICLE_TYPE_2)

    mieApp.setProperty(mup)
    mieApp.setProperty(sigmap)
    mieApp.setProperty(mup2)
    mieApp.setProperty(sigmap2)

    
    # Particles diameters in micrometers
    d = np.linspace(p_min, p_max, p_num)
    #pdf = lognorm(sigma, scale=np.exp(mu))

    #set the changing properties from z:
    # Weight fractions
    weight_frac = z / 100.0
    print("z, weight_frac = ", z, weight_frac)

    #run the simulation:
    
    # Number of rays to trace
    pRays = Property.Property(value=1000000,
                              propID=PropertyID.PID_NumberOfRays,
                              valueType=ValueType.Scalar,
                              time=0.0,
                              units=None,
                              objectID=objID.OBJ_CONE)
    tracerApp.setProperty(pRays)
    

    
    n_particles = Property.Property(value=2,
                                    propID=PropertyID.PID_NumberOfFluorescentParticles,
                                    valueType=ValueType.Scalar,
                                    time=0.0,
                                    units=None,
                                    objectID=objID.OBJ_CONE)
    tracerApp.setProperty(n_particles)

    #Phosphor efficiencies:
    p_eff1 = Property.Property(value=0.8, propID=PropertyID.PID_PhosphorEfficiency, valueType=ValueType.Scalar, time=0.0, units=None, objectID=objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(p_eff1)

    p_eff2 = Property.Property(value=0.7, propID=PropertyID.PID_PhosphorEfficiency, valueType=ValueType.Scalar, time=0.0, units=None, objectID=objID.OBJ_PARTICLE_TYPE_2)
    tracerApp.setProperty(p_eff2)

    # Emission spectrum
    em = Property.Property(value=ex_em_import.getEm(),
                           propID=PropertyID.PID_EmissionSpectrum,
                           valueType=ValueType.Scalar,
                           time=0.0,
                           units=None,
                           objectID=objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(em)

    # Excitation spectrum
    ex = Property.Property(value=ex_em_import.getEx(),
                           propID=PropertyID.PID_ExcitationSpectrum,
                           valueType=ValueType.Scalar,
                           time=0.0,
                           units=None,
                           objectID=objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(ex)

    # Absorption spectrum
    aabs = Property.Property(value=ex_em_import.getAbs(),
                             propID=PropertyID.PID_AsorptionSpectrum,
                             valueType=ValueType.Scalar,
                             time=0.0,
                             units=None,
                             objectID=objID.OBJ_PARTICLE_TYPE_1)
    tracerApp.setProperty(aabs)
    
    
    # Emission spectrum 2
    em2 = Property.Property(value=ex_em_import.getEmRed(),
                           propID=PropertyID.PID_EmissionSpectrum,
                           valueType=ValueType.Scalar,
                           time=0.0,
                           units=None,
                           objectID=objID.OBJ_PARTICLE_TYPE_2)
    tracerApp.setProperty(em2)

    # Excitation spectrum 2
    ex2 = Property.Property(value=ex_em_import.getExRed(),
                           propID=PropertyID.PID_ExcitationSpectrum,
                           valueType=ValueType.Scalar,
                           time=0.0,
                           units=None,
                           objectID=objID.OBJ_PARTICLE_TYPE_2)
    tracerApp.setProperty(ex2)

    # Absorption spectrum 2
    aabs2 = Property.Property(value=ex_em_import.getAbsRed(),
                             propID=PropertyID.PID_AsorptionSpectrum,
                             valueType=ValueType.Scalar,
                             time=0.0,
                             units=None,
                             objectID=objID.OBJ_PARTICLE_TYPE_2)
    tracerApp.setProperty(aabs2)


    # Solve Mie
    mieApp.solveStep(0)

    # Connect functions
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0,
                               objectID=objID.OBJ_PARTICLE_TYPE_1)
    pPhase = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist, 0,
                                objectID=objID.OBJ_PARTICLE_TYPE_1)
    
    pS2 = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0.0,
                               objectID=objID.OBJ_PARTICLE_TYPE_2)

    pP2 = mieApp.getProperty(PropertyID.PID_InverseCumulativeDist, 0.0,
                                objectID=objID.OBJ_PARTICLE_TYPE_2)

    tracerApp.setProperty(pScat)
    tracerApp.setProperty(pPhase)
    tracerApp.setProperty(pS2)
    tracerApp.setProperty(pP2)
    

    particles_in_um3 = []
    j=0
    for w_frac in weight_frac:
        particles_in_um3.extend([st.particlesInVolumeLogNormWeightTotal(w_frac, dens_p, dens_host, mu[j], sigma[j], particle_diameters=d)])
        j = j+1


    # Particle density
    #NOTE: If more than 1 particle type, use ValueType.Vector !
    vDens = particles_in_um3
    pDens = Property.Property(value=vDens,
                              propID=PropertyID.PID_ParticleNumberDensity,
                              valueType=ValueType.Vector,
                              time=0.0,
                              units=None,
                              objectID=objID.OBJ_CONE)
    tracerApp.setProperty(pDens)

    # Solve
    tracerApp.solveStep(0, runInBackground=False)



    #get the simulation result value and return it:
    
    p = tracerApp.getProperty(PropertyID.PID_LEDCCT, 0,
                              objectID=objID.OBJ_LED)
    print('CCT: %f' % p.getValue())
    p = tracerApp.getProperty(PropertyID.PID_LEDRadiantPower, 0,
                                  objectID=objID.OBJ_LED)
    print('RadiantPower: %f' % p.getValue())

    p = tracerApp.getProperty(PropertyID.PID_LEDColor_x, 0,
                                  objectID=objID.OBJ_LED)
    print('Color x: %f' % p.getValue())
    p = tracerApp.getProperty(PropertyID.PID_LEDColor_y, 0,
                                  objectID=objID.OBJ_LED)
    print('Color y: %f' % p.getValue())
    p = tracerApp.getProperty(PropertyID.PID_LEDSpectrum, 0,
                                  objectID=objID.OBJ_LED)
    print(p.getValue()['wavelengths'][0:10])
    print(p.getValue()['intensities'][0:10])

    #return CCT:
    p = tracerApp.getProperty(PropertyID.PID_LEDCCT, 0,
                              objectID=objID.OBJ_LED)
    return (p.getValue())
예제 #12
0
def runSingleServerInstanceSSHtunnel():
    # Parse arguments
    args = parser.parse_args()
    sys.path.append(os.getcwd())

    # Load config
    conf = args.configFile
    if conf[-3:] == '.py':
        conf = conf[:-3]
    print(conf)

    cfg = importlib.import_module(conf)

    # Load the App
    app = MMPRaytracer('localhost')

    # Prepare ssh tunnels
    pyroTunnel = SshTunnel(localport=cfg.serverPort,
                           remoteport=cfg.serverPort,
                           remoteuser=cfg.hostUserName,
                           remotehost=cfg.server,
                           reverse=True)
    nsTunnel = SshTunnel(localport=cfg.nsport,
                         remoteport=cfg.nsport,
                         remoteuser=cfg.hostUserName,
                         remotehost=cfg.nshost,
                         reverse=False)

    try:

        # Open tunnels
        pyroTunnel.run()
        nsTunnel.run()
        sleep(1)

        # Creates deamon, register the app in it
        daemon = Pyro4.Daemon(host='localhost', port=cfg.serverPort)
        uri = daemon.register(app)
        print(uri)

        # Get nameserver
        ns = Pyro4.locateNS(host='localhost',
                            port=cfg.nsport,
                            hmac_key=cfg.hkey)
        # Register app
        ns.register(cfg.appName, uri)
        print(uri)

        # Shutdown handler. Remember to close ssh tunnels
        def signal_handler(signal, frame):
            print('Shutting down!')
            pyroTunnel.terminate()
            nsTunnel.terminate()
            sys.exit(0)

        signal.signal(signal.SIGINT, signal_handler)

        # Deamon loops at the end
        daemon.requestLoop()

    except:
        pyroTunnel.terminate()
        nsTunnel.terminate()
        print('terminated')
        raise
예제 #13
0
from mmp_mie_api import MMPMie
from comsol_api import MMPComsolDummy
from mupif import Property, PropertyID, FieldID, ValueType
import logging
import ex_em_import

if __name__ == '__main__':

    logger = logging.getLogger()

    import time as timeTime
    start = timeTime.time()
    logger.info('Timer started')

    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    # Point data conversion to false. Speeds up testing
    tracerApp._convertPointData = False

    logger.info('Applications loaded:')
    print(mieApp)
    print(tracerApp)
    print(comsolApp)

    # Connect functions

    logger.info('Connecting Mie properties...')
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0,
                               objID.OBJ_PARTICLE_TYPE_1)
예제 #14
0
import os

if not os.path.isdir('runFolder'):
    os.mkdir('runFolder')
os.chdir('runFolder')

if __name__ == '__main__':

    logger = logging.getLogger()

    import time as timeTime
    start = timeTime.time()
    logger.info('Timer started')

    mieApp = MMPMie('localhost')
    tracerApp = MMPRaytracer('localhost')
    comsolApp = MMPComsolDummy('localhost')

    # Point data conversion to false. Speeds up testing
    tracerApp._convertPointData = False

    logger.info('Applications loaded:')
    print(mieApp)
    print(tracerApp)
    print(comsolApp)

    # Connect functions

    logger.info('Connecting Mie properties...')
    pScat = mieApp.getProperty(PropertyID.PID_ScatteringCrossSections, 0,
                               objID.OBJ_PARTICLE_TYPE_1)