Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
eblur opened this issue Feb 9, 2018 · 2 comments
Labels

Comments

@eblur
Copy link
Owner

eblur commented Feb 9, 2018

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 eblur added the bug label Feb 9, 2018
@eblur
Copy link
Owner Author

eblur commented Feb 10, 2018

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
Copy link
Owner Author

eblur commented Feb 12, 2018

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:

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant