Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
pbeaucage authored Sep 11, 2023
2 parents f2fa985 + 886d4cd commit ef97fb4
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/PyHyperScattering/SST1RSoXSLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,19 @@ def loadSingleImage(self,filepath,coords=None, return_q=False,image_slice=None,u

def read_json(self,jsonfile):
json_dict = {}
with open(jsonfile) as f:
data = json.load(f)
meas_time =datetime.datetime.fromtimestamp(data[1]['time'])
json_dict['sample_name'] = data[1]['sample_name']

# Try / except statment to be compatible with local rsoxs data before
# and after SST1 cycle 2 2023
try: # For earlier cyles
with open(jsonfile) as f:
data = json.load(f)
meas_time = datetime.datetime.fromtimestamp(data[1]['time'])
except KeyError: # For later cycles (confirmed working for cycle 2 2023)
with open(jsonfile) as f:
data = [0, json.load(f)] # Quick fix to load the json in a list
meas_time = datetime.datetime.fromtimestamp(data[1]['time'])

json_dict['sample_name'] = data[1]['sample_name']
if data[1]['RSoXS_Main_DET'] == 'SAXS':
json_dict['rsoxs_config'] = 'saxs'
# discrepency between what is in .json and actual
Expand All @@ -150,7 +159,7 @@ def read_json(self,jsonfile):
json_dict['beamcenter_y'] = data[1]['RSoXS_SAXS_BCY']
json_dict['sdd'] = data[1]['RSoXS_SAXS_SDD']

elif data[1]['RSoXS_Main_DET'] == 'WAXS':
elif (data[1]['RSoXS_Main_DET'] == 'WAXS') | (data[1]['RSoXS_Main_DET'] == 'waxs_det'): # additional name for for cycle 2 2023
json_dict['rsoxs_config'] = 'waxs'
if (meas_time > datetime.datetime(2020,11,16)) and (meas_time < datetime.datetime(2021,1,15)):
json_dict['beamcenter_x'] = 400.46
Expand Down Expand Up @@ -247,9 +256,15 @@ def loadMd(self,filepath):
else:
cwd = pathlib.Path(dirPath)

json_fname = list(cwd.glob('*.jsonl'))
json_dict = self.read_json(json_fname[0])

# Another try/except statement to be compatible with local data pre and
# post SST1 cycle 2 2023
try: # For earlier data
json_fname = list(cwd.glob('*.jsonl'))
json_dict = self.read_json(json_fname[0])
except IndexError: # For later data (works for cycle 2 2023)
json_fname = list(cwd.glob('*.json')) # Changed '*.jsonl' to '*.json'
json_dict = self.read_json(json_fname[0])

baseline_fname = list(cwd.glob('*baseline.csv'))
baseline_dict = self.read_baseline(baseline_fname[0])

Expand Down

0 comments on commit ef97fb4

Please sign in to comment.