eblur / newdust

Holding place for major rewrite of eblur/dust code
BSD 2-Clause "Simplified" License
6 stars 5 forks source link

Reading in table saved from GrainPop object does not return the same outputs #18

Open eblur opened 6 years ago

eblur commented 6 years ago

Example:

from newdust import make_MRN

ENERGY = np.arange(0.1, 6.1, 0.2) # keV
THETA = np.logspace(np.log10(0.5), 3, 20) # arcsec

mrn = make_MRN(amax=0.5, na=50)
mrn.calculate_ext(ENERGY, unit="kev", theta=THETA)

for name in mrn.keys:
    mrn[name].write_extinction_table("%s_10eV.fits" % (name))

new_silpop = SingleGrainPop(mrn['sil'].size, mrn['sil'].comp, 'sil10eV', md=mrn['sil'].md, scatm_from_file="sil_10eV.fits")

print(np.sum(new_silpop.tau_ext - mrn['sil'].tau_ext))

yields a non-zero value (170.12701232539766)

Why?

eblur commented 6 years ago

This may have to do with the nature of python, since it uses pointers. The old population changes after loading the new population.

Loading the table model in this way worked:

new_silpop = SingleGrainPop('Powerlaw', 'Silicate', 'sil10eV', 
    md=np.copy(mrn['sil'].md), amax=0.5, na=50, 
    scatm_from_file="sil_10eV.fits")
eblur commented 6 years ago

I want to do something internally with the code to make this workflow less stilted. (In this case, one has to know what parameters were used to run the original table model, and then initialize the new grain population with those old parameters.)

Two options: