home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 770395357

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-770395357 https://api.github.com/repos/pydata/xarray/issues/4849 770395357 MDEyOklzc3VlQ29tbWVudDc3MDM5NTM1Nw== 39069044 2021-01-31T14:59:12Z 2021-01-31T14:59:12Z CONTRIBUTOR
  1. Different fit coefficients as differently-named variables in the output, rather than indexed with a coordinate.

I think the way I configured things now does replicate the polyfit results. For example: ```python ds = xr.tutorial.open_dataset('air_temperature') ds['air2'] = ds.air.copy() ds.polyfit(dim='time', deg=2)

<xarray.Dataset> Dimensions: (degree: 3, lat: 25, lon: 53) Coordinates: * degree (degree) int64 2 1 0 * lat (lat) float64 75.0 72.5 70.0 ... 20.0 17.5 15.0 * lon (lon) float64 200.0 202.5 205.0 ... 327.5 330.0 Data variables: air_polyfit_coefficients (degree, lat, lon) float64 -1.162e-32 ... 1.13... air2_polyfit_coefficients (degree, lat, lon) float64 -1.162e-32 ... 1.14... Compared to this:python def square(x, a, b ,c): return anp.power(x, 2) + bx + c

ds.curvefit(x=ds.time, dim='time', func=square)

<xarray.Dataset> Dimensions: (lat: 25, lon: 53, param: 3) Coordinates: * lat (lat) float32 75.0 72.5 70.0 ... 20.0 17.5 15.0 * lon (lon) float32 200.0 202.5 205.0 ... 327.5 330.0 * param (param) <U1 'a' 'b' 'c' Data variables: air_curvefit_coefficients (param, lat, lon) float64 -1.162e-32 ... 1.13... air2_curvefit_coefficients (param, lat, lon) float64 -1.162e-32 ... 1.14... `` In both cases, each variable in the dataset returns a separate coefficients variable, and all fittable coefficients are stacked along a dimension,degreefor the more specific polyfit case and a genericparam` for curvefit.

  1. Initial guesses for each fit parameter.

Yeah this would be good. Should be easy to look for default values in the function itself using inspect.

  1. (Stretch goal) Ability to fit >1D functions

Looks like this could be possible with a call to ravel like this. I'll do some experimenting.

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