Open pbeaucage opened 2 years ago
example use of this from beamtime today:
data = c[-1]['primary']['data'].read() data = data.assign_coords(coords={'m3pitch':data['SST 1 Mirror 3 fmb_pitch_setpoint'],'energy':data['en_energy_setpoint']}).swap_dims({'time':'system'}).set_index({'system':['m3pitch','energy']}).unstack('system')#.reset_index('time',drop=True).unstack('system') m3peakpos = data['SAXS Beamstop'].curvefit('m3pitch',gauss_function).sel(param='x0').curvefit_coefficients
def gauss_function(x, a, x0, sigma): return a*np.exp(-(x-x0)*2/(2sigma**2))
see https://xarray.pydata.org/en/stable/generated/xarray.DataArray.curvefit.html also https://xarray.pydata.org/en/stable/generated/xarray.DataArray.polyfit.html
@dsunday might be interested in this. I have not looked into it in any depth, but seemed worth noting.