imcgreer / simqso

Module for generating simulated quasar spectra
BSD 3-Clause "New" or "Revised" License
12 stars 11 forks source link

multiple instances of QsoSimGrid results in crashes #14

Open imcgreer opened 6 years ago

imcgreer commented 6 years ago

Something is being held in global memory. This patch results in a crash if multiple sims are executed:

diff --git a/sdss/ebosscore.py b/sdss/ebosscore.py
index 4576766..ffb3d26 100644
--- a/sdss/ebosscore.py
+++ b/sdss/ebosscore.py
@@ -257,10 +257,10 @@ def run_colorz_sim(model,nm=7,nz=500):
    zrange = (0.9,4.0)
    mbins = np.linspace(*tuple(mrange+(nm,)))
    zbins = np.linspace(*tuple(zrange+(nz,)))
-   M,z = np.meshgrid(mbins,zbins,indexing='ij')
-   M = grids.AbsMagVar(grids.FixedSampler(M.flatten()),restWave=1450)
-   z = grids.RedshiftVar(grids.FixedSampler(z.flatten()))
-   qsos = grids.QsoSimPoints([M,z],cosmo=dr9cosmo,units='luminosity')
+   M = grids.AbsMagVar(grids.FixedSampler(mbins),restWave=1450)
+   z = grids.RedshiftVar(grids.FixedSampler(zbins))
+   qsos = grids.QsoSimGrid([M,z],(None,None),1,fixed_vars=['absMag','z'],
+                           cosmo=dr9cosmo,units='luminosity')
    qsos = runsim(model,None,'sdss_forest_grid.fits',qsos,
                  medianforest=True,const=True,nophot=True)
    synmags = np.array(qsos.data['synMag'].reshape(nm,nz,-1))