Giter VIP home page Giter VIP logo

Comments (5)

pauliacomi avatar pauliacomi commented on September 26, 2024

Weird behaviour...

Under the hood, the IsothermInterpolator is a thin wrapper around scipy.interpolate.interp1d that adds caching for convenience. If interp_fill is anything besides None, its value is passed directly to the parameter fill_value of interp1d, which expects an array.

But then I tried going through interp1d with the raw data and it worked just fine.

I eventually found out that the error in precision is introduced in the on-the-fly conversion. As the isotherm is in an absolute pressure mode, and it is being asked to predict loading from a relative pressure, it performs a pressure conversion in the loading_at function. This seems to lower data precision for some reason.

Can you try?

isotherm.convert(pressure_mode='relative')
loading = isotherm.loading_at(
            pressure=self.pressure,
            branch='ads',
            pressure_mode='relative',
            loading_unit='mol',
            loading_basis='molar',
            material_unit='g',
            material_basis='mass',
)

Does it work?

from pygaps.

sblanky avatar sblanky commented on September 26, 2024

Yup, that works perfectly! Thanks Paul.

from pygaps.

pauliacomi avatar pauliacomi commented on September 26, 2024

I have been trying to get this working for a while, and it turns the code into a complicated hack.

  • The loss of precision is inherent to floating point. Not much can be done here.
  • Failing gracefully on the interpolator requires a lot of data introspection to get it right. The value to interpolate can be either a number or a list, with different behaviours needed for each: searching if the data point is close to the function edges for a single number, or searching the same thing for each array member for an array.

It might be too much for an edge case. I suggest it is left as-is for now.

from pygaps.

sblanky avatar sblanky commented on September 26, 2024

That makes sense. Any idea why the on-the-fly conversion does this and isotherm.conver() doesn't?

from pygaps.

pauliacomi avatar pauliacomi commented on September 26, 2024

In the first case there is a double convert: absolute to relative when generating pressure = isotherm.pressure(branch='ads', pressure_mode='relative'), then relative to absolute in isotherm.loading_at().

When isotherm.convert() is used, the interpolator is re-generated with the new values.

I will close this.

from pygaps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.