X-Ray Imaging at CMS

At the CMS beam line at NSLS II gpCAM is used as the software version. For this, all that has to be done is to fill out the configuration file and to define a function that tells gpCAM where to send data and how to receive data. This can, for instance, be accomplished via zmq:

####this is version 5 of gpCAM

import numpy as np

import os

import random

import time

from scipy.interpolate import griddata

import sys

from shutil import copyfile

import zmq

from zmq import ssh

import pickle

import zlib


port = "5555"

context = zmq.Context()

socket = context.socket(zmq.PAIR)

socket.bind("tcp://*:%s" % port)


def send_zipped_pickle(obj, socket, flags=0, protocol=-1):

"""pack and compress an object with pickle and zlib."""

pobj = pickle.dumps(obj, protocol)

zobj = zlib.compress(pobj)

print('zipped pickle is %i bytes' % len(zobj))

return socket.send(zobj,flags=flags)


def recv_zipped_pickle(socket,flags = 0):

"""reconstruct a Python object sent with zipped_pickle"""

zobj = socket.recv(flags)

pobj = zlib.decompress(zobj)

return pickle.loads(pobj)


####the client has to send a starting message here

#msg = recv_zipped_pickle(socket)

#print(msg)


def comm_via_zmq(data):

send_zipped_pickle(data,socket)

print("gpCAM has sent data of length: ", len(data))

#print(data)

print("=================================")

data = recv_zipped_pickle(socket)

print("gpCAM has received data of length: ", len(data))

#print(data)

#input()

return data

This function can then be given as a pointer to gpCAM in the Config.py.

import numpy as np

import dask.distributed


parameters = {

"x1": {

"element interval": [-1.2,2.5], ####either an interval, several intervals or discrete points

},

"x2": {

"element interval": [-1.2,4.5],

},

}


from data_acquisition_functions import comm_via_zmqs

gaussian_processes = {

"model_1": {

"kernel function": None,

"hyperparameters": [1.0,1.0,1.0],

"hyperparameter bounds": [[1.0,100.0],[0.10,100.0],[0.10,100.0]],

"number of returns": 1,

"dimensionality of return": 1,

"objective function optimization tolerance": 0.001,

"adjust optimization threshold": [True,0.1],

"run function in every iteration": None,

"data acquisition function": synthetic_function,

"objective function": "shannon_ig",

"mean function": None,

"cost function": None,

"cost update function": None,

"cost function parameters": {"offset": 10,"slope":[2.0,2.0]},

"cost function optimization bounds": [[0.0,10.0],[0.0,10.0],[0.0,10.0]],

"cost optimization chance" : 0.1,

"plot function": plot_function

}

}


breaking_error = 1e-50

automatic_signal_variance_range_determination = True

########################################

###Variance Optimization################

########################################

objective_function_optimization_method = "global"

chance_for_local_objective_function_optimization = 0.5

objective_function_optimization_population_size = 10

objective_function_optimization_max_iter = 20

number_of_suggested_measurements = 1


initial_likelihood_optimization_method = "global"

global_likelihood_optimization_at = [200]

local_likelihood_optimization_at = [100,400,1000]

hgdl_likelihood_optimization_at = []

likelihood_optimization_population_size = 20

likelihood_optimization_tolerance = 0.001

likelihood_optimization_max_iter = 120

########################################

###Computation Parameters###############

########################################

compute_device = "cpu"

sparse = False

compute_inverse = False

training_dask_client = False #dask.distributed.Client() #None/False/client

prediction_dask_client = False #None/False/client

###############################

###DATA ACQUISITION############

###############################

initial_data_set_size = 4

max_number_of_measurements = 100000