Skip to content

Commit

Permalink
Latest changes at the end of cycle 19-1
Browse files Browse the repository at this point in the history
  • Loading branch information
lcdesilva committed Apr 8, 2019
1 parent 7647adc commit 3ffc820
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
13 changes: 10 additions & 3 deletions xas/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

from .xas_logger import get_logger

from datetime import datetime

def process_interpolate_bin(doc, db, draw_func_interp = None, draw_func_bin = None):

def process_interpolate_bin(doc, db, draw_func_interp = None, draw_func_binnned = None):

logger = get_logger()
if 'experiment' in db[doc['run_start']].start.keys():
Expand All @@ -33,13 +35,18 @@ def process_interpolate_bin(doc, db, draw_func_interp = None, draw_func_bin = No

try:
if e0 > 0:
print('Inside xas process try draw (e0 > 0) start time: ', datetime.now())
binned_df = bin(interpolated_df, e0)
logger.info(f'Binning successful for {path_to_file}')
save_binned_df_as_file(path_to_file, binned_df, comments)
print('Just before IF')
if draw_func_interp is not None:
print('Made the first IF')
draw_func_interp(interpolated_df)
if draw_func_bin is not None:
draw_func_bin(binned_df)
if draw_func_binned is not None:
print('Made the second IF')
draw_func_binned(binned_df)
print('Inside xas process try draw (e0 > 0) end time: ', datetime.now())
else:
print('Energy E0 is not defined')
except:
Expand Down
32 changes: 32 additions & 0 deletions xas/xas_logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import logging
import logging.handlers


def get_logger():
# Setup beamline specifics:
beamline_gpfs_path = '/nsls2/xf07bm'

logger = logging.getLogger('xas_logger')
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')

# only add handlers if not added before
if not len(logger.handlers):
logger.setLevel(logging.DEBUG)
# Write DEBUG and INFO messages to /var/log/data_processing_worker/debug.log.
debug_file = logging.handlers.RotatingFileHandler(
beamline_gpfs_path + '/log/data_processing_debug.log',
maxBytes=10000000, backupCount=9)
debug_file.setLevel(logging.DEBUG)
debug_file.setFormatter(formatter)
logger.addHandler(debug_file)

# Write INFO messages to /var/log/data_processing_worker/info.log.
info_file = logging.handlers.RotatingFileHandler(
beamline_gpfs_path + '/log/data_processing.log',
maxBytes=10000000, backupCount=9)
info_file.setLevel(logging.INFO)
info_file.setFormatter(formatter)
logger.addHandler(info_file)


return logger

0 comments on commit 3ffc820

Please sign in to comment.