XSPEC model grid using pyCloudy

114 views
Skip to first unread message

Tobias Beuchert

unread,
Nov 27, 2018, 10:45:00 AM11/27/18
to pyCloudy
Dear pyCloudy users, dear Christophe,

first of all thanks a lot for making pyCloudy possible. It is just extremely helpful.

I was following the example behind https://sites.google.com/site/pycloudy/examples/example-2 to calculate a Cloudy grid by looping over multiple input parameters.
Now, this approach provides me output files for each of the input parameter combination.
What I, however, want, is a XSPEC table model that contains all of these solutions in order to fit data with the corresponding number of free parameters.
I tried to run the loops, and then set 'save XSPEC atable spectrum "filename"' with 'set_other()' in PyCloudy, which drops the error:
> Cannot save xspec files unless doing a grid. <

Does this mean that there is no other way than adding the 'grid range' command from the hazy manual with 'set_other' in pyCloudy after I specified the input continuum like:
c_input.set_star(SED = 'table SED "table.mod"', SED_params="", lumi_unit = 'luminosity total', lumi_value=np.log10(lum_1) vary)
c_input.set_other('grid range from 38 to 42 step 1 linear')
c_input.set_other('save XSPEC atable incident continuum "atable_1_incident" ',
    'save XSPEC atable spectrum "atable_1_transmitted" ')
?

This may work for a single varied parameter, but what if I want to write a atable model with more variable parameters?
In my case, my parameters are the luminosities of separate incident spectra that I define one after another.
Could I therefore define several grids and in the end call 'save XSPEC atable...' to add all solutions to one atable model?

# variable parameter 1
c_input.set_star(SED = 'table SED "table_1.mod"', SED_params="", lumi_unit = 'luminosity total', lumi_value=np.log10(lum_1) vary)
c_input.set_other('grid range from 38 to 42 step 1 linear')
# variable parameter 2
c_input.set_star(SED = 'table SED "table_2.mod"', SED_params="", lumi_unit = 'luminosity total', lumi_value=np.log10(lum_2) vary)
c_input.set_other('grid range from 38 to 42 step 1 linear')
# write XSPEC atable
c_input.set_other('save XSPEC atable incident continuum "atable_incident" ',
    'save XSPEC atable spectrum "atable_transmitted" ')

Maybe, you can tell me how this can work and what would be the most elegant solution to it?

By the way, the PyCloudy function help suggests to set "total luminosity", for me only "luminosity total" worked.

Thank you very much for your help!

All the best,
Tobi 

Christophe Morisset

unread,
Nov 27, 2018, 7:23:19 PM11/27/18
to pyCloudy
Hi Tobi,

Thanks for using pyCloudy and give some feedback.

In your case, it seems that the problem is on the Cloudy side, as pyCloudy is not managing grids of models performed by Cloudy itself. The output of such grid of models may not be read by pyCloudy.CloudyModel object.
The other point is that the set_other will be printed in the input file after all the previous commands, and I do not think Cloudy likes when the vary and the grid commands are not following each other.

You may ask to the Cloudy yahoo group if there is a way to have a XSPEC output without running a grid of models. The group is there:
But if this is mandatory to obtain an XSPEC output, I am not sure pyCloudy can be used for this case.

Hope you will find a solution.
Give us feedback,
Christophe

Tobias Beuchert

unread,
Nov 28, 2018, 5:09:08 AM11/28/18
to pyCloudy
Dear Christophe,

thank you very much for you very quick answer.
I see the issue. 

I will both try to Cloudy yahoo group and adapt a pyCloudy input file in a way to have the vary and grid commands following each other. In that case, each XSPEC model only has a single variable parameter, which should be sufficient for the moment.

I will keep you posted.

All the best,
Tobi 
Reply all
Reply to author
Forward
0 new messages