MickaelRigault / skysurvey

Simulate transients within the sky
Apache License 2.0
9 stars 7 forks source link

Update afterglow.py and kilonova.py #16

Closed AkshayPanayada closed 9 months ago

mcoughlin commented 9 months ago

@MickaelRigault Can you take a look and see about merging?

MickaelRigault commented 9 months ago

Hello guys, I updated Kilonova doing PR #20 to account for #19.

mcoughlin commented 9 months ago

Thanks @MickaelRigault ! @AkshayPanayada, I think you can close this one now.

MickaelRigault commented 9 months ago

Is the afterglow from main what you need?

mcoughlin commented 9 months ago

@MickaelRigault The main question is how to allow like E0 and other afterglow parameters vary: https://github.com/MickaelRigault/skysurvey/blob/main/skysurvey/target/afterglow.py#L27

MickaelRigault commented 9 months ago

I will look into that tomorrow.

Should all parameter be allowed to vary? (The variable names are not super explicit...)

mcoughlin commented 9 months ago

@MickaelRigault

 'thetaObs':    0.05,   # Viewing angle in radians
 'E0':          1.0e53, # Isotropic-equivalent energy in erg
 'thetaCore':   0.1,    # Half-opening angle in radians
 'n0':          1.0,    # circumburst density in cm^{-3}
 'p':           2.2,    # electron energy distribution index
 'epsilon_e':   0.1,    # epsilon_e
 'epsilon_B':   0.01,   # epsilon_B
 'xi_N':        1.0,    # Fraction of electrons accelerated
 'd_L':         1.0e28, # Luminosity distance in cm
 'z':           0.55

I.e. everything but spectral type. Sensible ranges are:

https://github.com/nuclear-multimessenger-astronomy/nmma/blob/main/priors/TrPi2018.prior

AkshayPanayada commented 9 months ago

Should we mention about these ranges in the code?

On Tue, 26 Sept 2023, 02:01 Michael Coughlin, @.***> wrote:

@MickaelRigault https://github.com/MickaelRigault

'thetaObs': 0.05, # Viewing angle in radians 'E0': 1.0e53, # Isotropic-equivalent energy in erg 'thetaCore': 0.1, # Half-opening angle in radians 'n0': 1.0, # circumburst density in cm^{-3} 'p': 2.2, # electron energy distribution index 'epsilon_e': 0.1, # epsilon_e 'epsilon_B': 0.01, # epsilon_B 'xi_N': 1.0, # Fraction of electrons accelerated 'd_L': 1.0e28, # Luminosity distance in cm 'z': 0.55

I.e. everything but spectral type. Sensible ranges are:

https://github.com/nuclear-multimessenger-astronomy/nmma/blob/main/priors/TrPi2018.prior

— Reply to this email directly, view it on GitHub https://github.com/MickaelRigault/skysurvey/pull/16#issuecomment-1734420505, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZIAXIEDWEYUTDUKTTKZ5RLX4HS2LANCNFSM6AAAAAA5ANPL3E . You are receiving this because you were mentioned.Message ID: @.***>

mcoughlin commented 9 months ago

@AkshayPanayada I think they should be the default ranges sampled.

MickaelRigault commented 9 months ago

Looked into this.

The issue is that your current implementation, the source is generated from a 2D flux-phase surface given your parameters. So none of them are sncosmo.Source parameter. This could not work.

The best would be to do a sncosmo.Source that depends on them, but redshift and t0 could not be source parameter (I think, to be confirmed) as this is captured by Model (model = sncosmo.Model(source))

something like:

class AfterglowSource(sncosmo.Source):

    _param_names = ['amplitude', 
                    "thetaobs", "e0",
                    "thetacore", "n0",
                    "p","epsilon_e", "epsilon_b",
                    "xi_n"]
    param_names_latex = ['A', 'thetaObs', "E0", 
                        "thetaCore", "n0", "p",
                        "epsilon_e", "epsilon_B",
                        "xi_N"]   # used in plotting display

    def __init__(self, phase, wave, name=None, version=None):

        self.name = name
        self.version = version
        self._phase = phase
        self._wave = wave
        self._parameters = np.array([1., 
                                     0.05, 1.0e53, 0.1,
                                     1.0, 2.2, 0.1, 0.01, 
                                     1.0])  # initial parameters

    def _flux(self, phase, wave):
        # afterglowpy here
AkshayPanayada commented 9 months ago

So to be clear, We should not use the afterglowpy package and instead use a sncosmo source and modify the code accordingly .

I also noted an issue where the model could not be fitted properly while generating a lightcurve. Will this issue be resolved by changing the model to sncosmo one?

On Tue, 26 Sept 2023, 11:14 Mickael Rigault, @.***> wrote:

Looked into this.

The issue is that your current implementation, the source is generated from a 2D flux-phase surface given your parameters. So none of them are sncosmo.Source parameter. This could not work.

The best would be to do a sncosmo.Source that depends on them, but redshift and t0 could not be source parameter (I think, to be confirmed) as this is captured by Model (model = sncosmo.Model(source))

something like:

class AfterglowSource(sncosmo.Source):

_param_names = ['amplitude',
                "thetaobs", "e0",
                "thetacore", "n0",
                "p","epsilon_e", "epsilon_b",
                "xi_n"]
param_names_latex = ['A', 'thetaObs', "E0",
                    "thetaCore", "n0", "p",
                    "epsilon_e", "epsilon_B",
                    "xi_N"]   # used in plotting display

def __init__(self, phase, wave, name=None, version=None):

    self.name = name
    self.version = version
    self._phase = phase
    self._wave = wave
    self._parameters = np.array([1.,
                                 0.05, 1.0e53, 0.1,
                                 1.0, 2.2, 0.1, 0.01,
                                 1.0])  # initial parameters

def _flux(self, phase, wave):
    # afterglowpy here

— Reply to this email directly, view it on GitHub https://github.com/MickaelRigault/skysurvey/pull/16#issuecomment-1734866502, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZIAXIEXQ75NYTVDU65THUTX4JTVNANCNFSM6AAAAAA5ANPL3E . You are receiving this because you were mentioned.Message ID: @.***>