Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fitting: xarray now provides a curvefit wrapper #28

Open
pbeaucage opened this issue May 4, 2022 · 1 comment
Open

fitting: xarray now provides a curvefit wrapper #28

pbeaucage opened this issue May 4, 2022 · 1 comment

Comments

@pbeaucage
Copy link
Collaborator

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.

@EliotGann
Copy link
Collaborator

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 anp.exp(-(x-x0)**2/(2sigma**2))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants