usnistgov / PyHyperScattering

Tools for hyperspectral x-ray and neutron scattering data loading, reduction, slicing, and visualization.
Other
8 stars 10 forks source link

feat: multiple-scan / cross-scan loading in SST1RSoXSDB #38

Open pbeaucage opened 2 years ago

pbeaucage commented 2 years ago

A fairly common complaint about the Databroker loader is that it's difficult to load multiple scans and compare across them. For example, two polarizations on the same sample, or two samples with the same scan type.

There are valid memory-related reasons to not do this. But it is definitely needed.

I'm adding a new method to SST1RSoXSDB,

def loadSeries(self,run_list,meta_dim,loadrun_kwargs={},):
        '''
        Loads a series of runs into a single xarray object, stacking along meta_dim.

        Useful for a set of samples, or a set of polarizations, etc., taken in different scans.

        Args:

            run_list (list): list of scan ids to load

            meta_dim (str): dimension to stack along.  must be a valid attribute/metadata value, such as polarization or sample_name

        Returns:
            raw: xarray.Dataset with all scans stacked

        '''

example usage:

test = load.loadSeries([42598,42595,42654,42652],'sample_name')
test_integ = integ.integrateImageStack(test)
test_integ.unstack('system').mean('chi').sel(energy=284.25).plot(hue='sample_name')
PriyankaKetkarBNL commented 2 months ago

Assigning to myself. Will do so formally when I figure out how to add my NIST email to my account.