Skip to content

Base line algorithms struggle with xaxis #1

Closed

Description

@mhw-hermes

The algorithms which use van der monde matrices (spc.fit.poly and spc.rubberband) can not handle higher order polinomials if the xaxis does not match the right criteria. The returned error message is Error in qr.solve(vdm[use, ], y[use, i]) : singular matrix 'a' in solve.

The hypothesis for that is that the numerical fitting becomes instable for an axis containing high numbers far away from 0.

The workaround for this problem is to normalise the wavelength axis before doing the fit and recover it afterwards.

Activity

  1. cbeleites commented on Apr 15, 2016

    @cbeleites
    Owner

    Workaround:

    wl.orig <- wl (flu)
    tmp <- flu
    wl (tmp) <- normalize01 (wl.orig)
    bl <- spc.fit.poly(tmp, apply.to = tmp, poly.order = 3)
    wl (bl) <- wl.orig
    plot (flu)
    plot (bl, add = TRUE, col = 2)
    
  2. cbeleites commented on Apr 15, 2016

    @cbeleites
    Owner

    Reproduce issue:

    wl (flu) <- wl (flu) + 1e4
    spc.fit.poly(flu, poly.order = 3)
    spc.fit.poly.below(flu, poly.order = 3)
    
  3. added
    Type: bug 💣
    on Apr 15, 2016
  4. self-assigned this
    on Nov 4, 2016
  5. cbeleites commented on Nov 17, 2016

    @cbeleites
    Owner

    Hi Michael,

    I put the basic x-offset option into hyperSpec's code base (master branch).

    Now, there is the possiblity to ask spc.fit.poly and spc.fit.poly.below to return the polynomial coefficient instead of the evaluated polynomial baseline.
    These need to be backtransformed from a_0 (x - ofs)^0 + a_1 (x - ofs)^1 + ... a_n (x - ofs)^n -> a'_0 x^0 + a'_1 x^1 + ... a'_n x^n.

    Could you provide a function that does this?

    Many thanks,

  6. added 2 commits that reference this issue on Sep 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Note: help wantedType: bug 💣

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions