-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from pcdshub/60-add-cctbx-class
60 add cctbx class
- Loading branch information
Showing
32 changed files
with
483 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,121 @@ | ||
def xfel_gui(): | ||
import subprocess | ||
import logging | ||
from mfx.macros import get_exp | ||
|
||
logging.info("Checking xfel gui phil File") | ||
cctbx_settings = open("/cds/home/opr/mfxopr/.cctbx.xfel/settings_old.phil", "r", encoding="UTF-8") | ||
setting_lines = cctbx_settings.readlines() | ||
change = False | ||
|
||
if setting_lines[10] != f'name = "{get_exp()}"': | ||
logging.warning(f"Changing experiment to current: {get_exp()}") | ||
setting_lines[10] = f' name = "{get_exp()}"\n' | ||
change = True | ||
|
||
if setting_lines[11] != f'user = "{get_exp()}"': | ||
logging.warning(f"Changing experiment to current: {get_exp()}") | ||
setting_lines[11] = f' user = "{get_exp()}"\n' | ||
change = True | ||
|
||
if change: | ||
cctbx_settings = open("/cds/home/opr/mfxopr/.cctbx.xfel/settings.phil", "w", encoding="UTF-8") | ||
cctbx_settings.writelines(setting_lines) | ||
cctbx_settings.close | ||
cctbx_settings = open("/cds/home/opr/mfxopr/.cctbx.xfel/settings_old.phil", "w", encoding="UTF-8") | ||
cctbx_settings.writelines(setting_lines) | ||
cctbx_settings.close | ||
|
||
subprocess.Popen( | ||
[". /reg/g/cctbx/brewster/working/build/conda_setpaths.sh;cctbx.xfel &"], | ||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
class bs: | ||
def xfel_gui(self): | ||
import subprocess | ||
import logging | ||
from mfx.macros import get_exp | ||
|
||
logging.info("Checking xfel gui phil File") | ||
cctbx_settings = open("/cds/home/opr/mfxopr/.cctbx.xfel/settings_old.phil", "r", encoding="UTF-8") | ||
setting_lines = cctbx_settings.readlines() | ||
change = False | ||
|
||
if setting_lines[10] != f'name = "{get_exp()}"': | ||
logging.warning(f"Changing experiment to current: {get_exp()}") | ||
setting_lines[10] = f' name = "{get_exp()}"\n' | ||
change = True | ||
|
||
if setting_lines[11] != f'user = "{get_exp()}"': | ||
logging.warning(f"Changing experiment to current: {get_exp()}") | ||
setting_lines[11] = f' user = "{get_exp()}"\n' | ||
change = True | ||
|
||
if change: | ||
cctbx_settings = open("/cds/home/opr/mfxopr/.cctbx.xfel/settings.phil", "w", encoding="UTF-8") | ||
cctbx_settings.writelines(setting_lines) | ||
cctbx_settings.close | ||
cctbx_settings = open("/cds/home/opr/mfxopr/.cctbx.xfel/settings_old.phil", "w", encoding="UTF-8") | ||
cctbx_settings.writelines(setting_lines) | ||
cctbx_settings.close | ||
|
||
subprocess.Popen( | ||
[". /reg/g/cctbx/brewster/working/build/conda_setpaths.sh;cctbx.xfel &"], | ||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
|
||
|
||
def takepeds(self): | ||
import os | ||
import logging | ||
logging.info("Taking Pedestals") | ||
os.system(f"/reg/g/pcds/engineering_tools/latest-released/scripts/takepeds") | ||
|
||
|
||
def makepeds(self, username, run_number=None): | ||
import os | ||
import logging | ||
from mfx.db import daq | ||
from mfx.macros import get_exp | ||
logging.info("Making Pedestals") | ||
if run_number is None: | ||
run_number = daq.run_number() | ||
username = str(username) | ||
run_number = str(int(run_number)) | ||
os.system(f"ssh -Y {username}@s3dflogin ssh -Y psana /sdf/group/lcls/ds/tools/engineering_tools/engineering_tools/scripts/makepeds_psana --queue milano --run {run_number} --experiment {get_exp()}") | ||
|
||
|
||
def awr(self, hutch='mfx'): | ||
import os | ||
import logging | ||
logging.info(f"{hutch} Beamline Check") | ||
os.system(f"/cds/home/opr/mfxopr/bin/awr {hutch}") | ||
|
||
|
||
def restartdaq(self): | ||
import subprocess | ||
import logging | ||
logging.info("Restarting the DAQ") | ||
subprocess.Popen( | ||
["/reg/g/pcds/engineering_tools/latest-released/scripts/restartdaq -w"], | ||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
|
||
|
||
def cameras(self, time=12): | ||
import subprocess | ||
import logging | ||
logging.info("Opening Cam Viewer") | ||
subprocess.Popen( | ||
[f"/reg/g/pcds/engineering_tools/latest-released/scripts/camViewer -w {time}"], | ||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
|
||
|
||
def camera_list(self): | ||
import re | ||
import logging | ||
logging.info("Opening Camera List") | ||
camlist = open("/reg/g/pcds/pyps/config/mfx/camviewer.cfg", "r", encoding="UTF-8") | ||
cam_list = camlist.readlines() | ||
avail_cams = [cam for cam in cam_list if cam.startswith('GE')] | ||
self.camera_names = [['camera_name', 'camera_pv']] | ||
print("Available Cameras") | ||
for cam in avail_cams: | ||
cam = re.split(';|,', cam) | ||
self.camera_names.append([cam[4].strip(),cam[2]]) | ||
print(f"Camera {cam[4].strip()} .... {cam[2]}") | ||
|
||
|
||
def focus_scan(self, camera): | ||
import os | ||
import sys | ||
import logging | ||
logging.info( | ||
"Preparing for Focus Scan\n" | ||
"Please check the following\n" | ||
"One of the following cameras is selected\n\n") | ||
self.camera_list() | ||
logging.info( | ||
"\nCamera orientation set to none\n" | ||
"Slits are open\n" | ||
"Blue crosshair in upper left corner\n" | ||
"Red crosshair in bottom right corner\n") | ||
|
||
input("Press Enter to continue...") | ||
|
||
if camera not in [pv[1] for pv in self.camera_names]: | ||
logging.info("Desired Camera not in List. Software will exit.") | ||
sys.exit() | ||
|
||
logging.info("Checking Focus Scan Plot") | ||
os.system(f"/cds/home/opr/mfxopr/bin/focus_scan {camera} -p") | ||
input("Press Enter to continue...") | ||
|
||
def takepeds(): | ||
import os | ||
import logging | ||
logging.info("Taking Pedestals") | ||
os.system(f"/reg/g/pcds/engineering_tools/latest-released/scripts/takepeds") | ||
|
||
|
||
def makepeds(username, run_number=None): | ||
import os | ||
import logging | ||
from mfx.db import daq | ||
from mfx.macros import get_exp | ||
logging.info("Making Pedestals") | ||
if run_number is None: | ||
run_number = daq.run_number() | ||
username = str(username) | ||
run_number = str(int(run_number)) | ||
os.system(f"ssh -Y {username}@s3dflogin ssh -Y psana /sdf/group/lcls/ds/tools/engineering_tools/engineering_tools/scripts/makepeds_psana --queue milano --run {run_number} --experiment {get_exp()}") | ||
|
||
|
||
def awr(hutch='mfx'): | ||
import os | ||
import logging | ||
logging.info(f"{hutch} Beamline Check") | ||
os.system(f"/cds/home/opr/mfxopr/bin/awr {hutch}") | ||
|
||
|
||
def restartdaq(): | ||
import subprocess | ||
import logging | ||
logging.info("Restarting the DAQ") | ||
subprocess.Popen( | ||
["/reg/g/pcds/engineering_tools/latest-released/scripts/restartdaq -w"], | ||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
#os.system("/reg/g/pcds/engineering_tools/latest-released/scripts/restartdaq -w") | ||
|
||
|
||
def cameras(time=12): | ||
import subprocess | ||
import logging | ||
logging.info("Opening Cam Viewer") | ||
subprocess.Popen( | ||
[f"/reg/g/pcds/engineering_tools/latest-released/scripts/camViewer -w {time}"], | ||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
#os.system(f"/reg/g/pcds/engineering_tools/latest-released/scripts/camViewer -w {time}") | ||
logging.info("Running Focus Scan") | ||
os.system(f"/cds/home/opr/mfxopr/bin/focus_scan {camera} -s") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,50 @@ | ||
class cctbx: | ||
def __init__(self): | ||
from mfx.macros import get_exp | ||
self.settings = "~/.cctbx.xfe/settings_old.phil" | ||
self.experiment = str(get_exp()) | ||
|
||
|
||
def check_settings(self, user): | ||
def xfel_gui(self, user): | ||
import logging | ||
import subprocess | ||
exp = self.experiment | ||
logging.info("Checking xfel gui phil File") | ||
cctbx_settings = open("/cds/home/opr/mfxopr/.cctbx.xfel/settings_s3df.phil", "r", encoding="UTF-8") | ||
setting_lines = cctbx_settings.readlines() | ||
change = False | ||
if setting_lines[4] != f'experiment = "{exp}"': | ||
logging.warning(f"Changing experiment to current: {exp}") | ||
change = True | ||
settings = f'''\ | ||
facility {{ | ||
name = *lcls standalone | ||
lcls {{ | ||
experiment = "{exp}" | ||
web {{ | ||
location = "S3DF" | ||
}} | ||
}} | ||
}} | ||
output_folder = "/sdf/data/lcls/ds/mfx/{exp}/results/common/results" | ||
mp {{ | ||
method = local lsf sge pbs *slurm shifter htcondor custom | ||
nnodes_index = 2 | ||
nnodes_scale = 1 | ||
nnodes_merge = 1 | ||
nproc_per_node = 120 | ||
queue = "milano" | ||
extra_options = " --account=lcls:{exp} --reservation=lcls:onshift" | ||
env_script = "/sdf/group/lcls/ds/tools/cctbx/build/conda_setpaths.sh" | ||
phenix_script = "/sdf/group/lcls/ds/tools/cctbx/phenix/phenix-1.20.1-4487/phenix_env.sh" | ||
}} | ||
experiment_tag = "common" | ||
db {{ | ||
host = "172.24.5.182" | ||
name = "{exp}" | ||
user = "{exp}" | ||
}}\ | ||
''' | ||
if change: | ||
cctbx_settings = open("/cds/home/opr/mfxopr/.cctbx.xfel/settings_s3df.phil", "w", encoding="UTF-8") | ||
cctbx_settings.writelines(settings) | ||
cctbx_settings.close | ||
self.settings = f"/sdf/home/{user[0]}/{user}/.cctbx.xfel/settings.phil" | ||
self.cctbx_dir = f"/sdf/home/{user[0]}/{user}" | ||
|
||
subprocess.Popen( | ||
[f"rsync -avze ssh ~/.cctbx.xfel/settings_s3df.phil {user}@s3dflogin:~/.cctbx.xfel/settings_old.phil"], | ||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
proc = [ | ||
f"ssh -YAC {user}@s3dflogin " | ||
f"/sdf/home/d/djr/scripts/cctbx_step1.sh {user} {self.experiment}" | ||
] | ||
|
||
logging.info(proc) | ||
|
||
subprocess.Popen( | ||
proc, shell=True, | ||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
|
||
def xfel_gui(self, user): | ||
|
||
def notch_check(self, user, runs=[]): | ||
import logging | ||
import subprocess | ||
import os | ||
|
||
#cctbx_dir = | ||
if not os.path.exists(out_result): | ||
os.makedirs(out_result) | ||
import sys | ||
if len(runs) > 0: | ||
run_list = [] | ||
for run in runs: | ||
run_list.append(f'{experiment}:{run}') | ||
logging.info(f'Selected runs: {run_list}') | ||
runlist = ' ' | ||
runlist = runlist.join(run_list) | ||
logging.info(f'Selected runs: {runlist}') | ||
else: | ||
logging.warning(f'No selected runs. Program will exit.') | ||
sys.exit() | ||
|
||
proc = [ | ||
f"ssh -YAC mfxopr@daq-mfx-mon0{str(node)} " | ||
f"/cds/group/pcds/pyps/apps/hutch-python/mfx/scripts/" | ||
f"detector_image.sh {experiment} {str(det)} {str(calibdir)} {str(ave)}" | ||
f'ssh -YAC {user}@s3dflogin ' | ||
f'/sdf/home/d/djr/scripts/cctbx_notch_check.sh "{self.runlist}"' | ||
] | ||
|
||
logging.info(proc) | ||
|
||
subprocess.Popen( | ||
proc, shell=True, | ||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) | ||
|
||
subprocess.Popen( | ||
[". /reg/g/cctbx/brewster/working/build/conda_setpaths.sh;cctbx.xfel &"], | ||
shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) |
Oops, something went wrong.