Skip to content

Problems with fitMCMC (with proposed fixes) #4

Open
@jfrostburke

Description

@jfrostburke

Hi, I’m a grad student attempting to use snpy to fit some SNe Ia data. Specifically I’m attempting to use the fitMCMC method to enforce priors. I have two corrections which I believe should be made:

  1. In the documentation for fitMCMC (https://users.obs.carnegiescience.edu/cburns/SNooPyDocs/html/fitting_MCMC.html), the first fit is run using
s.fit(Rv=2.0)

This correctly fixes the Rv parameter. However, the MCMC fit is run using

s.fitMCMC(bands=['u','B','V','g','r','i','Y','J','H'], R_V="N,2.3,0.9")

R_V is not a parameter, Rv is. I believe passing this extra argument does nothing (e.g. if I pass foobar=’N,2.3,0.9’ then the fit will run without errors, but obviously that’s not a parameter).

I believe that R_V should be changed to Rv in the MCMCfit documentation.

  1. However, making sure parameter names match introduces an error. Here’s the partial traceback when I try to enforce a prior on EBVhost:
emcee: Exception while calling your likelihood function:
  params: [3.25815455e+01 1.55605255e+00 5.81841998e+04]
  args: ({'varlist': ['DM', 'dm15', 'EBVhost', 'Tmax'], 'fitflux': True, 'free': ['DM', 'dm15', 'Tmax'], 'DM': {'fixed': False, 'index': 0, 'prior_type': 'model'}, 'dm15': {'fixed': False, 'index': 1, 'prior_type': 'model'}, 'EBVhost': {'value': 'U,0,1', 'fixed': True}, . . .
. . .
"/Users/jamisonfrost/miniconda3/envs/earlysne/lib/python3.7/site-packages/snpy/model.py", line 473, in __call__
    temp = temp + self.Robs[band]*self.EBVhost + R*self.parent.EBVgal
TypeError: can't multiply sequence by non-int of type 'numpy.float64'

The parameter is getting fixed as a string, instead of translated into the desired prior. In order for the built-in priors (uniform, exponential, and normal) to be instantiated, I believe this line should be changed:

if type(args[var]) is bytes:

Currently it’s checking for an arg with type bytes, and I think this should be changed to str. Passing the argument as a byte string doesn’t work, I get ValueError: I don't understand the prior code b'U,0,1' (since it checks if st[0] in [‘U’, ‘G’, ‘E’], and b’U,0,1’[0] is apparently 85). I’ve tested it and making the change to str allows priors to be enforced as expected.

For completeness, I’m running this on python 3.7.9, snpy version 2.5.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions