Assuming we do this using a masterfile full of links we need to patch the import imagefiles command to put in links with respect to frames.file.filename rather than the existing relative links.
Kind of a sad recipe. Otherwise I guess dataset would need to handle multiple masterfiles.
In raw data created a new dataset which has links to the existing one:
f1 = "/data/visitor/ma7058/id11/20260306/RAW_DATA/BFOconeNscope/BFOconeNscope_s3DXRD_z100/BFOconeNscope_s3DXRD_z100.h5"
s1 = list(range(1,203))
f2 = "/data/visitor/ma7058/id11/20260306/RAW_DATA/BFOconeNscope/BFOconeNscope_s3DXRD_z100_0003/BFOconeNscope_s3DXRD_z100_0003.h5"
s2 = list(range(2,101))
with h5py.File('BFOconeNscope_s3DXRD_merge.h5','w', track_order=True) as hout:
for s in s1:
for j in 1,2:
scan = f'{s}.{j}'
print(s,j,scan)
hout[ scan ] = h5py.ExternalLink(f1, scan)
for s in s2:
for j in 1,2:
scan = f'{s}.{j}'
scanout = f'{s + len(s1) -1}.{j}'
print(scan,scanout)
hout[ scanout ] = h5py.ExternalLink(f2, scan)
Then when segmenting proceed as normal to create the dataset. Then patch the imagefiles code:
def import_imagefiles(self):
"""Get the Lima file names from the bliss master file, also scan_npoints"""
# self.import_scans() should always be called before this function, so we know the detector
self.imagefiles = []
self.frames_per_file = []
with h5py.File(self.masterfile, "r") as hin:
bad = []
for i, scan in enumerate(self.scans):
if ("measurement" not in hin[scan]) or (
self.detector not in hin[scan]["measurement"]
):
print("Bad scan", scan)
bad.append(scan)
continue
frames = hin[scan]["measurement"][self.detector]
self.imageshape = frames.shape[1:]
path = os.path.dirname(frames.file.filename)
for vsrc in frames.virtual_sources():
self.imagefiles.append(os.path.join( path, vsrc.file_name))
self.frames_per_file.append(
vsrc.src_space.shape[0]
) # not sure about this
# check limapath
if self.limapath is None:
self.limapath = vsrc.dset_name
assert self.limapath == vsrc.dset_name
self.frames_per_file = np.array(self.frames_per_file, int)
self.sparsefiles = [
os.path.join(
"sparsefiles", f"scan{i+1}_eiger_0000_sparse.h5",
)
for i, name in enumerate(self.imagefiles)
]
I think the patches needed are just this thing for dataset image file import, and maybe something for building master files from bits of scans
Assuming we do this using a masterfile full of links we need to patch the import imagefiles command to put in links with respect to
frames.file.filenamerather than the existing relative links.Kind of a sad recipe. Otherwise I guess dataset would need to handle multiple masterfiles.
In raw data created a new dataset which has links to the existing one:
Then when segmenting proceed as normal to create the dataset. Then patch the imagefiles code:
I think the patches needed are just this thing for dataset image file import, and maybe something for building master files from bits of scans