home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 770388498

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/pull/4849#issuecomment-770388498 https://api.github.com/repos/pydata/xarray/issues/4849 770388498 MDEyOklzc3VlQ29tbWVudDc3MDM4ODQ5OA== 35968931 2021-01-31T14:12:12Z 2021-01-31T14:12:12Z MEMBER

This is great, thanks for submitting this!

I just had a go with it, and it worked nicely. I have a couple of suggestions for improving it though:

1) Different fit coefficients as differently-named variables in the output, rather than indexed with a coordinate. This would then be consistent with Dataset.polyfit, which returns a set of different variables [var]_polyfit_coefficients. We could also get the names from the names of the keyword args when inspecting the function, and if it fails to get names just call them like param1_fit_coefficients, param2_fit_coefficients etc.

What you have now works nicely though, so perhaps you could just reorganise the result before returning, like `Dataset.polyfit` does?

2) Initial guesses for each fit parameter. At the moment the user has to pass an ordered array of initial guesses through like

```python
da.curvefit(x=da.x, dim='x', func=linear, kwargs={'p0': [m_guess, c_guess]})
```

but it would be nicer to just pass them as a dictionary like

```python
da.curvefit(x=da.x, dim='x', func=linear, initial_guess={'m': m_guess, 'c': c_guess})
```
or even have the guesses read from the function definition maybe? i.e.
```python
def linear(x, m=m_guess, c=c_guess):
    return m*x + c
```

3) (Stretch goal) Ability to fit >1D functions, e.g. fit a 2D gaussian to find a peak in a 2D image. But if we get the API right then this could be left to a later PR.

Also, the whole argument inspection thing probably deserves a few dedicated tests, in addition to testing the fitting functionality.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  797302408
Powered by Datasette · Queries took 0.578ms · About: xarray-datasette