Commit 81989358 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

accept directory with run files

parent 9f6b5fd9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ after_script:
build-image:
  stage: build
  variables:
    TAG: "0.1"
    TAG: "0.2"
    FORCE_TAGS: "false"
  when: manual
  script:
+62 −39
Original line number Diff line number Diff line
@@ -13,12 +13,15 @@
# individual run numbers, or ranges specified with a colon separator.
#
# shlex splits line space while ignoring spaces within quotes. May 2018
import os
import shlex


def LoadDictionary(filename):
    params_dictionary = {}
    run_nums = []
    file = open(filename)
    add_all_runs_from_data_directory = False
    for line in file:
        line = line.strip();
        line = line.rstrip();
@@ -32,22 +35,43 @@ def LoadDictionary( filename ):
                elif words[1] == "False":
                    params_dictionary[words[0]] = False
                elif words[0] == "run_nums":
                    if words[1] == "data_directory":
                        add_all_runs_from_data_directory = True
                    else:
                        run_list = ParseRunList(words[1])
          for i in range(0,len(run_list)):
            run_nums.append(run_list[i])
                        run_nums = run_nums + run_list
                else:
                    params_dictionary[words[0]] = words[1]
            else:
                print(("Syntax Error On Line: " + line))

    if add_all_runs_from_data_directory:
        if len(run_nums) > 0:
            raise Exception("cannot mix run_nums as range and data_directory")
        if params_dictionary["data_directory"]:
            run_nums = ParseRunListFromFolder(params_dictionary["data_directory"])
        else:
            raise Exception("data_directory must be set when using run_nums from data_directory")

    params_dictionary["run_nums"] = run_nums
  return params_dictionary;
    return params_dictionary


#
# Return a list of run numbers from a string containing a comma separated
# list of individual run numbers, and/or ranges of run numbers specified 
# with a colon separator.
#

def ParseRunListFromFolder(folder):
    files = []
    for f in os.listdir(folder):
        full_path = os.path.join(folder, f)
        if os.path.isfile(full_path):
            files.append(full_path)
    return files


def ParseRunList(run_string):
    run_list = []
    groups = run_string.split(",")
@@ -62,4 +86,3 @@ def ParseRunList( run_string ):
                run_list.append(str(run))

    return run_list
+5 −6
Original line number Diff line number Diff line
@@ -175,7 +175,6 @@ cylinder_length = params_dictionary[ "cylinder_length" ]
read_UB                   = params_dictionary[ "read_UB" ]
UB_filename               = params_dictionary[ "UB_filename" ]

shared_folder = os.environ.get("SNS_TOPAZ_SHARED_FOLDER", "/SNS/TOPAZ/shared")
shared_folder = os.environ.get("SNS_TOPAZ_SHARED_FOLDER", "/SNS/TOPAZ/shared")
fname = shared_folder+'/ProfileFitting/franz_coefficients_2017.dat'

@@ -278,9 +277,9 @@ run_niggli_fit_profile_file = output_directory + "/" + str(run)+ "_Niggli_profil

#
#ipts_folder_name = GetIPTS(INSTRUMENT='TOPAZ', RunNumber=run)
location = full_name.find("IPTS")
location = full_name.find("/", location)
ipts_folder_name = full_name[0: location + 1]
#location = full_name.find("IPTS")
#location = full_name.find("/", location)
#ipts_folder_name = full_name[0: location + 1]
#
# Load the run data and find the total monitor counts

@@ -292,11 +291,11 @@ if subtract_bkg is not True:
  event_ws = FilterBadPulses(InputWorkspace=event_ws, LowerCutoff = 95)
  proton_charge = event_ws.getRun().getProtonCharge() * 1000.0  # get proton charge

  print("\n", run, " has integrated proton charge x 1000 of", proton_charge, "\n")
  print("\n", run, " has integrted proton charge x 1000 of", proton_charge, "\n")

else:
  # Subtract no-sample background
  bkg_subtracted_event_fname =  ipts_folder_name + "shared/bkg_data/" + short_filename + "_event_bkg.nxs"
  bkg_subtracted_event_fname =  shared_folder + "/bkg_data/" + short_filename + "_event_bkg.nxs"
  if os.path.exists(bkg_subtracted_event_fname):
    print("\nProcessing File: " + bkg_subtracted_event_fname + " ......\n")
    event_ws=Load(Filename=bkg_subtracted_event_fname, LoadHistory=False)
+2 −2
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ list=[]
index = 0
for r_num in run_nums:
  list.append( ProcessThread() )
  cmd = 'mantidpython ' + reduce_one_run_script + ' ' + config_file_name + ' ' + str(r_num)
  cmd = 'mantidpython -u ' + reduce_one_run_script + ' ' + config_file_name + ' ' + str(r_num)
  if slurm_queue_name is not None:
    console_file = output_directory + "/" + str(r_num) + "_output.txt"
    cmd =  'srun -p ' + slurm_queue_name + \
@@ -352,4 +352,4 @@ print("\n***********************************************************************
print("****************************** All DONE **********************************************")
print("**************************************************************************************\n")

print('Connfig file: ' + config_file_name) 
print('Config file: ' + config_file_name)