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

Add TemperatureResponse class #6

Open
dstansby opened this issue Apr 20, 2020 · 2 comments
Open

Add TemperatureResponse class #6

dstansby opened this issue Apr 20, 2020 · 2 comments

Comments

@dstansby
Copy link
Member

The current implementation I'm using is below. This is useful for being able to sample a temperature response function, and in theory could be an anlytic function, or just interpolating between points.

class TemperatureResponse:
    """
    A discretely sampled temperature response function.

    Parameters
    ----------
    temps : astropy.units.Quantity
        Temperatures.
    responses : astropy.units.Quantity
        Response function.
    """
    # TODO: use astropy quantity input here
    def __init__(self, temps, responses):
        if temps.shape != responses.shape:
            raise ValueError('Shape of temps must be the same as '
                             'shape of responses')
        self.temps = temps
        self.responses = responses

    def __repr__(self):
        return f'TemperatureResponse, T={self.temps}, response={self.responses}'

    # TODO: use astropy quantity input here
    def sample(self, temps):
        """
        Sample the temperature repsonse function at temperatures *temps*.

        Uses linear interpolation.
        """
        resps = np.interp(temps, self.temps, self.responses,
                          left=np.nan, right=np.nan)
        return resps
@Cadair
Copy link
Member

Cadair commented Apr 23, 2020

you might be able to use the Tabular1D model in astropy modelling to do this?

@wtbarnes
Copy link
Member

This is a nice approach. I wonder if this could be the expected type for the temperature response input arguments to Model

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

3 participants