sherpa icon indicating copy to clipboard operation
sherpa copied to clipboard

installing relxill models with sherpa

Open JohannesBuchner opened this issue 2 years ago • 6 comments

Is it currently possible to install these models https://www.sternwarte.uni-erlangen.de/~dauser/research/relxill/index.html and fit them with sherpa?

JohannesBuchner avatar Aug 31 '22 09:08 JohannesBuchner

@JohannesBuchner thanks for your question. We are currently investigating issues with compiling the most recent version of the model. @nplee will give you more detailed descriptions of the current status.

anetasie avatar Sep 01 '22 19:09 anetasie

I see. What is the latest model version known to work?

I guess the instructions to follow are https://cxc.harvard.edu/sherpa4.8/threads/xspec_user_model/

JohannesBuchner avatar Sep 02 '22 07:09 JohannesBuchner

@JohannesBuchner for a bit more information, are you presently using Sherpa with one of the CIAO distributions or as standalone?

Coincidentally, I've been looking into this the past week, and v1.4.3 of the model can be used with the Sherpa build packaged with the CIAO 4.13 binaries and Conda distribution.

With CIAO 4.14, I've finally been able to get v1.4.3 and v2.1 to build with the binaries. Unfortunately, my work system was migrated to a new OS earlier this week and it's taken a bit of time to get my Anaconda setup working again so that I can test against the 4.14 Conda distribution.

nplee avatar Sep 02 '22 11:09 nplee

oh excellent. I usually use the conda install. I think relxill combined with BXA could be a very good combination to fit effectively.

JohannesBuchner avatar Sep 02 '22 11:09 JohannesBuchner

Yes, using BXA and relxill should be the way to go. Hopefully, Nick will resolve issues with building the model.

anetasie avatar Sep 02 '22 13:09 anetasie

In your CIAO environment, please replace $ASCDS_CONTRIB/bin/convert_xspec_user_model with: convert_xspec_user_model.aug31-relxill.

Assuming you're using the Conda-compilers, then set:

(t)csh:

setenv CC ${CONDA_PREFIX}/bin/x86_64-conda-linux-gnu-gcc
setenv CXX ${CONDA_PREFIX}/bin/x86_64-conda-linux-gnu-g++
setenv CFLAGS "-Wno-unused-variable -Wno-array-bounds"

bash/zsh:

export CC="${CONDA_PREFIX}/bin/x86_64-conda-linux-gnu-gcc"
export CXX="${CONDA_PREFIX}/bin/x86_64-conda-linux-gnu-g++"
export CFLAGS="-Wno-unused-variable -Wno-array-bounds"

If installing with the CIAO 4.14 binaries and default system compilers instead, it may be necessary to set the LDFLAGS variable to -Wl,-rpath,${ASCDS_INSTALL}/ots/lib and on my clean RHEL8 system I also had to also explicitly point to the system's libfftw, "l:libfftw.so.3 -Wl,-rpath,${ASCDS_INSTALL}/ots/lib".

For relxill 2.1, in the unpacked directory with the source code you will need to change the line:

#include "fftw/fftw3.h"

to

#include "fftw3.h"

in the common.h and Relbase.cpp files.

The script can then be run from the source directory:

unix% convert_xspec_user_model relxill_v2 lmodel_relxill.dat --clobber

which should compile the model, and then import into Sherpa:

sherpa> import relxill_v2.ui

so you'll be able to then set a source model like set_source(xsumrelline.rll1). An important step is to make sure that the models are available to access the data tables the models are dependent upon. Assuming you've unpacked them in /path/to/directory/with/relxill/tables/files, then:

sherpa> os.environ["RELXILL_TABLE_MODEL"] = "/path/to/directory/with/relxill/tables/files"

will set the location from the models to look in. If you would like to avoid declaring the os.environ["RELXILL_TABLE_PATH"] each time you import the model package, you can hard code it on line 119 of common.h, changing:

#define RELXILL_TABLE_PATH "./"

to

#define RELXILL_TABLE_PATH "/path/to/directory/with/relxill/tables/files"

nplee avatar Sep 02 '22 18:09 nplee

I'm going to close this as there's not much more we can do (the heavy lifting is done by convert_xspec_user_model, which requires CIAO, although is uses code in Sherpa), but please let me know if we need to re-open it.

This model is "annoying" as it uses fftw headers which are in a different location to those in XSPEC, meaning the code needs to be updated, as mentioned above.

DougBurke avatar Feb 15 '23 21:02 DougBurke