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

Errors in running simulation with some models #71

Open
xinyuewu21 opened this issue Mar 8, 2022 · 1 comment
Open

Errors in running simulation with some models #71

xinyuewu21 opened this issue Mar 8, 2022 · 1 comment

Comments

@xinyuewu21
Copy link

In the simulations of the models: Walk_2018, Walk_2019, and Zha_2021, an error appears as below.

ValueError: `x` must be strictly increasing sequence.

The code and error of each model:

Walk_2018

model = {'name': 'Walk_2018',
         'param':{
             'progenitor_mass': 15 * u.Msun 
            }}

sim = Simulation(model=model,
                 distance=10 * u.kpc, 
                 Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,
                 tmin=0.01*u.s, tmax=0.33*u.s, dt=1*u.ms,
                 mixing_scheme='AdiabaticMSW',
                 hierarchy='normal')
sim.run()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-0c41e268116a> in <module>
      4             }}
      5 
----> 6 sim = Simulation(model=model,
      7                  distance=10 * u.kpc,
      8                  Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,

~/IceCube/ASTERIA/python/asteria/simulation.py in __init__(self, config, model, distance, flavors, hierarchy, interactions, mixing_scheme, mixing_angle, E, Emin, Emax, dE, t, tmin, tmax, dt, geomfile, effvolfile)
     57                 _dt = 1 * u.ms
     58 
---> 59             self.source = Source(model['name'], model['param'])
     60             self.distance = distance
     61             self.energy = E

~/IceCube/ASTERIA/python/asteria/source.py in __init__(self, model, model_params)
    107         for flavor in Flavor:
    108             t = self.model.time
--> 109             self._interp_lum.update({flavor: PchipInterpolator(t, self.model.luminosity[flavor], extrapolate=False)})
    110             self._interp_meanE.update({flavor: PchipInterpolator(t, self.model.meanE[flavor], extrapolate=False)})
    111             self._interp_pinch.update({flavor: PchipInterpolator(t, self.model.pinch[flavor], extrapolate=False)})

/opt/anaconda3/lib/python3.8/site-packages/scipy/interpolate/_cubic.py in __init__(self, x, y, axis, extrapolate)
    228     """
    229     def __init__(self, x, y, axis=0, extrapolate=None):
--> 230         x, _, y, axis, _ = prepare_input(x, y, axis)
    231         xp = x.reshape((x.shape[0],) + (1,)*(y.ndim-1))
    232         dk = self._find_derivatives(xp, y)

/opt/anaconda3/lib/python3.8/site-packages/scipy/interpolate/_cubic.py in prepare_input(x, y, axis, dydx)
     59     dx = np.diff(x)
     60     if np.any(dx <= 0):
---> 61         raise ValueError("`x` must be strictly increasing sequence.")
     62 
     63     y = np.rollaxis(y, axis)

ValueError: `x` must be strictly increasing sequence.

Walk_2019

model = {'name': 'Walk_2019',
         'param':{
             'progenitor_mass': 40 * u.Msun 
            }}

sim = Simulation(model=model,
                 distance=10 * u.kpc, 
                 Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,
                 tmin=0.01*u.s, tmax=0.57*u.s, dt=1*u.ms,
                 mixing_scheme='AdiabaticMSW',
                 hierarchy='normal')
sim.run()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-20-526866286412> in <module>
      4             }}
      5 
----> 6 sim = Simulation(model=model,
      7                  distance=10 * u.kpc,
      8                  Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,

~/IceCube/ASTERIA/python/asteria/simulation.py in __init__(self, config, model, distance, flavors, hierarchy, interactions, mixing_scheme, mixing_angle, E, Emin, Emax, dE, t, tmin, tmax, dt, geomfile, effvolfile)
     57                 _dt = 1 * u.ms
     58 
---> 59             self.source = Source(model['name'], model['param'])
     60             self.distance = distance
     61             self.energy = E

~/IceCube/ASTERIA/python/asteria/source.py in __init__(self, model, model_params)
    107         for flavor in Flavor:
    108             t = self.model.time
--> 109             self._interp_lum.update({flavor: PchipInterpolator(t, self.model.luminosity[flavor], extrapolate=False)})
    110             self._interp_meanE.update({flavor: PchipInterpolator(t, self.model.meanE[flavor], extrapolate=False)})
    111             self._interp_pinch.update({flavor: PchipInterpolator(t, self.model.pinch[flavor], extrapolate=False)})

/opt/anaconda3/lib/python3.8/site-packages/scipy/interpolate/_cubic.py in __init__(self, x, y, axis, extrapolate)
    228     """
    229     def __init__(self, x, y, axis=0, extrapolate=None):
--> 230         x, _, y, axis, _ = prepare_input(x, y, axis)
    231         xp = x.reshape((x.shape[0],) + (1,)*(y.ndim-1))
    232         dk = self._find_derivatives(xp, y)

/opt/anaconda3/lib/python3.8/site-packages/scipy/interpolate/_cubic.py in prepare_input(x, y, axis, dydx)
     59     dx = np.diff(x)
     60     if np.any(dx <= 0):
---> 61         raise ValueError("`x` must be strictly increasing sequence.")
     62 
     63     y = np.rollaxis(y, axis)

ValueError: `x` must be strictly increasing sequence.

Zha_2021

model = {'name': 'Zha_2021',
         'param':{
             'progenitor_mass': 16 * u.Msun 
            }}

sim = Simulation(model=model,
                 distance=10 * u.kpc, 
                 Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,
                 tmin=-0.21*u.s, tmax=2.02*u.s, dt=1*u.ms,
                 mixing_scheme='AdiabaticMSW',
                 hierarchy='normal')
sim.run()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-21-4f03eb4d6e5c> in <module>
      4             }}
      5 
----> 6 sim = Simulation(model=model,
      7                  distance=10 * u.kpc,
      8                  Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,

~/IceCube/ASTERIA/python/asteria/simulation.py in __init__(self, config, model, distance, flavors, hierarchy, interactions, mixing_scheme, mixing_angle, E, Emin, Emax, dE, t, tmin, tmax, dt, geomfile, effvolfile)
     57                 _dt = 1 * u.ms
     58 
---> 59             self.source = Source(model['name'], model['param'])
     60             self.distance = distance
     61             self.energy = E

~/IceCube/ASTERIA/python/asteria/source.py in __init__(self, model, model_params)
    107         for flavor in Flavor:
    108             t = self.model.time
--> 109             self._interp_lum.update({flavor: PchipInterpolator(t, self.model.luminosity[flavor], extrapolate=False)})
    110             self._interp_meanE.update({flavor: PchipInterpolator(t, self.model.meanE[flavor], extrapolate=False)})
    111             self._interp_pinch.update({flavor: PchipInterpolator(t, self.model.pinch[flavor], extrapolate=False)})

/opt/anaconda3/lib/python3.8/site-packages/scipy/interpolate/_cubic.py in __init__(self, x, y, axis, extrapolate)
    228     """
    229     def __init__(self, x, y, axis=0, extrapolate=None):
--> 230         x, _, y, axis, _ = prepare_input(x, y, axis)
    231         xp = x.reshape((x.shape[0],) + (1,)*(y.ndim-1))
    232         dk = self._find_derivatives(xp, y)

/opt/anaconda3/lib/python3.8/site-packages/scipy/interpolate/_cubic.py in prepare_input(x, y, axis, dydx)
     59     dx = np.diff(x)
     60     if np.any(dx <= 0):
---> 61         raise ValueError("`x` must be strictly increasing sequence.")
     62 
     63     y = np.rollaxis(y, axis)

ValueError: `x` must be strictly increasing sequence.

In the simulations of the models Warren_2020 and Fornax_2019, an error appears as below.

OSError: Unable to open file

The code and error of each model:

Warren_2020

model = {'name': 'Warren_2020',
         'param':{
             'turb_mixing': 1.23 ,
             'progenitor_mass': 9.25 * u.Msun 
            }}

sim = Simulation(model=model,
                 distance=10 * u.kpc, 
                 Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,
                 tmin=-0.22*u.s, tmax=4.7*u.s, dt=1*u.ms,
                 mixing_scheme='AdiabaticMSW',
                 hierarchy='normal')
sim.run()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-23-47ddbceda145> in <module>
      5             }}
      6 
----> 7 sim = Simulation(model=model,
      8                  distance=10 * u.kpc,
      9                  Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,

~/IceCube/ASTERIA/python/asteria/simulation.py in __init__(self, config, model, distance, flavors, hierarchy, interactions, mixing_scheme, mixing_angle, E, Emin, Emax, dE, t, tmin, tmax, dt, geomfile, effvolfile)
     57                 _dt = 1 * u.ms
     58 
---> 59             self.source = Source(model['name'], model['param'])
     60             self.distance = distance
     61             self.energy = E

~/IceCube/ASTERIA/python/asteria/source.py in __init__(self, model, model_params)
    100             self.model = init_snewpy_model_from_param(model, **model_params)
    101         else:
--> 102             self.model = init_snewpy_model(model, model_params)
    103         self._interp_lum = {}
    104         self._interp_meanE = {}

~/IceCube/ASTERIA/python/asteria/source.py in init_snewpy_model(model, model_params)
     89         return init_snewpy_model_from_param(model_name=model, base=os.path.join(model_path, f'{model}/'),
     90                                             mass=mass, eos=EOS)
---> 91     return init_snewpy_model_from_param(model_name=model, filename=os.path.join(model_path, model, fname))
     92 
     93 

~/IceCube/snewpy/python/snewpy/models/registry.py in init_model(model_name, download, download_dir, **user_param)
     58 
     59     try:
---> 60         return getattr(module, model_name)(**user_param)
     61     except FileNotFoundError as e:
     62         logger = logging.getLogger()

~/IceCube/snewpy/python/snewpy/models/base.py in _wrapper(self, *arg, **kwargs)
     16     @wraps(init)
     17     def _wrapper(self, *arg, **kwargs):
---> 18         init(self, *arg, **kwargs)
     19         check(self)
     20     return _wrapper

~/IceCube/snewpy/python/snewpy/models/ccsn.py in __init__(self, filename, eos)
    375         """
    376         # Read data from HDF5 files, then store.
--> 377         f = h5py.File(filename, 'r')
    378         simtab = Table()
    379 

/opt/anaconda3/lib/python3.8/site-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)
    404             with phil:
    405                 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0, **kwds)
--> 406                 fid = make_fid(name, mode, userblock_size,
    407                                fapl, fcpl=make_fcpl(track_order=track_order),
    408                                swmr=swmr)

/opt/anaconda3/lib/python3.8/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
    171         if swmr and swmr_support:
    172             flags |= h5f.ACC_SWMR_READ
--> 173         fid = h5f.open(name, flags, fapl=fapl)
    174     elif mode == 'r+':
    175         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5f.pyx in h5py.h5f.open()

OSError: Unable to open file (unable to open file: name = '/Users/wxy/.astropy/cache/snewpy/models/Warren_2020/stir_a1.23/stir_multimessenger_a1.23_m9.25.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

Fornax_2019

model = {'name': 'Fornax_2019',
         'param':{
             'progenitor_mass': 12 * u.Msun 
            }}

sim = Simulation(model=model,
                 distance=10 * u.kpc, 
                 Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,
                 tmin=-0.21*u.s, tmax=4.49*u.s, dt=1*u.ms,
                 mixing_scheme='AdiabaticMSW',
                 hierarchy='normal')
sim.run()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-22-56c9df4900cd> in <module>
      4             }}
      5 
----> 6 sim = Simulation(model=model,
      7                  distance=10 * u.kpc,
      8                  Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,

~/IceCube/ASTERIA/python/asteria/simulation.py in __init__(self, config, model, distance, flavors, hierarchy, interactions, mixing_scheme, mixing_angle, E, Emin, Emax, dE, t, tmin, tmax, dt, geomfile, effvolfile)
     57                 _dt = 1 * u.ms
     58 
---> 59             self.source = Source(model['name'], model['param'])
     60             self.distance = distance
     61             self.energy = E

~/IceCube/ASTERIA/python/asteria/source.py in __init__(self, model, model_params)
    100             self.model = init_snewpy_model_from_param(model, **model_params)
    101         else:
--> 102             self.model = init_snewpy_model(model, model_params)
    103         self._interp_lum = {}
    104         self._interp_meanE = {}

~/IceCube/ASTERIA/python/asteria/source.py in init_snewpy_model(model, model_params)
     89         return init_snewpy_model_from_param(model_name=model, base=os.path.join(model_path, f'{model}/'),
     90                                             mass=mass, eos=EOS)
---> 91     return init_snewpy_model_from_param(model_name=model, filename=os.path.join(model_path, model, fname))
     92 
     93 

~/IceCube/snewpy/python/snewpy/models/registry.py in init_model(model_name, download, download_dir, **user_param)
     58 
     59     try:
---> 60         return getattr(module, model_name)(**user_param)
     61     except FileNotFoundError as e:
     62         logger = logging.getLogger()

~/IceCube/snewpy/python/snewpy/models/base.py in _wrapper(self, *arg, **kwargs)
     16     @wraps(init)
     17     def _wrapper(self, *arg, **kwargs):
---> 18         init(self, *arg, **kwargs)
     19         check(self)
     20     return _wrapper

~/IceCube/snewpy/python/snewpy/models/ccsn.py in __init__(self, filename, cache_flux)
    573 
    574             # Open HDF5 data file.
--> 575             self._h5file = h5py.File(filename, 'r')
    576 
    577             # Get grid of model times in seconds.

/opt/anaconda3/lib/python3.8/site-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)
    404             with phil:
    405                 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0, **kwds)
--> 406                 fid = make_fid(name, mode, userblock_size,
    407                                fapl, fcpl=make_fcpl(track_order=track_order),
    408                                swmr=swmr)

/opt/anaconda3/lib/python3.8/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
    171         if swmr and swmr_support:
    172             flags |= h5f.ACC_SWMR_READ
--> 173         fid = h5f.open(name, flags, fapl=fapl)
    174     elif mode == 'r+':
    175         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5f.pyx in h5py.h5f.open()

OSError: Unable to open file (unable to open file: name = '/Users/wxy/.astropy/cache/snewpy/models/Fornax_2019/lum_spec_12M.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
@sgriswol
Copy link
Collaborator

sgriswol commented Mar 15, 2022

In the case of the Walk models, this issue is due to a subtle version mismatch issue. Release 1.2 of snewpy corrected errors in the walk model files, this code is likely being run against a branch of snewpy that was created from release 1.1, and does not include these changes.

It is possibly to hotfix this locally by modifying snewpy's _version.py, calling _get_model_urls() in a python environment, deleting the existing SN Walk models in the astropy cache, and then re-downloading the models (this is done automatically by ASTERIA when the model is loaded).

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

2 participants