Git Product home page Git Product logo

xpsi's Introduction

X-PSI

An open-source package for neutron star X-ray Pulse Simulation and Inference.

Build Status Main Docs GitHub release

X-PSI is designed to simulate rotationally-modified (pulsed) surface X-ray emission from neutron stars, taking into account relativistic effects on the emitted radiation. This can then be used to perform Bayesian statistical inference on real or simulated astronomical data sets. Model parameters of interest may include neutron star mass and radius (useful to constrain the properties of ultradense nuclear matter) or the system geometry and properties of the hot emitting surface-regions. To achieve this, X-PSI couples code for likelihood functionality (simulation) with existing open-source software for posterior sampling (inference).

It provides the following functionality:

  • Simulation of time- and energy resolved X-ray emission (pulse profiles) from the surfaces of neutron stars.
  • The facility to implement multiple models for surface patterns, atmospheres, and different instruments.
  • Coupling of pulse simulation functionality to statistical sampling software to infer spacetime and geometric parameters from pulse profile data.
  • An extensive suite of post-processing software to visualize posteriors and measures of model quality.

For more details on current and planned capabilities, check out the X-PSI documentation.

Installation and Testing

X-PSI has a complex set of dependencies, and is therefore currently best installed from source. The documentation provides step-by-step installation instructions for Linux and for limited MacOS systems.

Documentation

The documentation for XPSI, including a wide range of tutorials and scripts for running XPSI on HPC systems, can be found at https://xpsi-group.github.io/xpsi/.

How to get in touch or get involved

We always welcome contributions and feedback! We are especially interested in hearing from you if * something breaks, * you spot bugs, * if there is missing functionality, or you have suggestions for future development,

To get in touch, please open an issue. Even better, if you have code you'd be interested in contributing, please send a pull request (or get in touch and we'll help guide you through the process!).

For more information, you can take a look at the documentation's Contributing page. Please also make sure you take a look at the Code of Conduct.

Citing XPSI

If you find this package useful in your research, please provide the appropriate acknowledgment and citation. Our documentation provides more detail, including links to appropriate papers and BibTeX entries.

All content © 2016-2023 the authors. The code is distributed under the GNU General Public License v3.0; see LICENSE for details.

Legacy

An earlier version (pre-v0.5) of this project was named: A prototype open-source package for neutron star X-ray Pulsation Simulation and Inference.

xpsi's People

Contributors

basdorsman avatar devarshichoudhury avatar dfm avatar dhuppenkothen avatar drannawatts avatar mhoogkamer avatar serenavinciguerra89 avatar sguillot avatar thjsal avatar thomasedwardriley avatar yveskini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xpsi's Issues

Landing page for tutorials

The idea of this landing page is to guide new users in which tutorials they should do depending on their goals. I would also add additional pointers for other useful parts of the documentation.

code in examples folder is broken

Hi all, I've been poking around XPSI, and especially I'd like to synthesize some data based on the model. I've found some code to do this in the examples folder, but I suspect it might be outdated? It refers to functions and classes that don't seem to exist in XPSI. Specifically, I tried running synthesise.ipynb, but it refers to a synethesise function that I can't find in the module where it's supposed to be (there are two separate functions there, and I don't know which one to use), and it also refers to a xpsi.Pulse module that I also can't find.

At this point I stopped trying to make it run. I think this would be worth checking/updating/adding to the official documentation?

Second component of the dual temperature region added twice if caching turned on?

It seems that the ceding region of a dual temperature region is added twice if caching is turned on for the signal object. The problem is in Signal.py the following line (295):

signal = component
.

Here signal = component should be replaced by signal = component.copy() in order not to modify the original hot region components, when summing over them is done just for the caching purpose. Otherwise, the second component of the dual temperature region will be added to the signal again, when looping over the integrated signal.

UltraNest support

Would you be interested to add support for https://johannesbuchner.github.io/UltraNest/ ?
The interface should be very similar to pymultinest.

UltraNest is a very reliable tuning-parameter-free algorithm. I have published some examples where the UltraNest algorithm is unbiased while pymultinest gives a different answer. UltraNest is a pure-python package and very easy to install with pip or conda.

UltraNest also supports resuming from disk and MPI parallelisation, if that is useful to you.

emcee compatibility

emcee has been upgraded to version 3.1.1, which requires the package autocorr, which is not compatible with python2.7.
So it is recommended to install emcee with pip install emcee==3.0.1.
A note about this could be added to the installation tutorial.

`b_f` which determines the size extent of the `omit` region for CST or `cede` region for CDT is set to twice the size of the `super` region

self.b_f = 2.0

If b_f is allowed to be greater than 1 for CST, then the omit region will outgrow the super region and will lead to no radiation being emanated from this region.
If b_f is allowed to be greater than 1 for CDT, then the cede region will outgrow the super region, and essentially lead to all emission coming from the cede and thus behaving as a ST region in these situations.

Potential cryptic error in Signal.py when data.channels and instrument.channels[a:b] have different size

In Signal.py (lines 95-99), there is a check that the data.channels are identical to the instrument.channel (with the data.index_range):

if (data.channels != instrument.channels[a:b]).any():

However, in the case where the user does not define the instrument response and the data in the same channel range, the comparison data.channels != instrument.channels[a:b] will return a single False boolean. This also shows a warning (only once in python notebooks), that elementwise comparison will be deprecated. But in python2.7, this will remain the case that an element wise comparison of arrays of different size will return False and this raises a problem with the any() function since boolean.any() is not permitted. The error is:

AttributeError: 'bool' object has no attribute 'any'

So a problem of channels definition turns into a cryptic error for the user. Therefore, I suggest adding an extra check on the size of data.channels and instrument.channel with the data.index_range, before the comparison between the arrays is performed. Something simple, like:

a, b = data.index_range
if (len(data.channels) != len(instrument.channels[a:b]):
     raise ChannelError('Size of the channel array declared for event data does not match the size of the channel array declared for the loaded instrument response (sub)matrix.')

`photosphere.integrate` complains about missing `_spacetime` object if none of the `HotRegion` object parameters are left free.

Error message:

.../xpsi/Photosphere.pyc in integrate(self, energies, threads)
    322 
    323             if self._hot is not None:
--> 324                 self._signal = self._hot.integrate(self._spacetime,
    325                                                    energies,
    326                                                    threads,

AttributeError: 'CustomPhotosphere' object has no attribute '_spacetime'

When Star is instantiated, the following line should be called via __init__:

photosphere.spacetime = self._spacetime

which should ensure that Photosphere also has the spacetime object, contrary to the error.

Calling star.update prior to calling photosphere.integrate has no effect on the error. In fact, oddly star.update doesn't yield any error in itself when executed even though it's supposed to in-turn call photosphere.embed which also requires photosphere._spacetime to be present. However, calling photosphere.embed manually does lead to the same error.
This could be a consequence of the if clause present (link below) before photosphere.embed when executing star.update.

if photosphere.needs_update or self._spacetime.needs_update:

This in-turn suggests missing needs_update argument either in Photosphere or Star.

photosphere.embed subsequently calls hot.embed. Manually calling hot.embed to avoid missing photosphere._spacetime yields an error mentioning that fast_mode is not defined in the following line:

if self.fast_mode and not self.do_fast:

Manually passing spacetime object to photosphere also ends up complaining about the missing fast_mode.

Python3 conversion

X-PSI should really support Python3 in the near future.

A work-in-progress PR exists in #49 and is ready for a first round of testing.

Citations for dependencies

Dear all,

As you know, developing software is a underappreciated activity in astronomy research. The only reward we can obtain are citations. In the documentation, could you please encourage users to also cite the packages xpsi is built upon?
Here is an example I have used: https://johannesbuchner.github.io/BXA/#citing-bxa-correctly
pymultinest and multinest seem to be relevant in xpsi, and its users, for example https://arxiv.org/pdf/2104.06928.pdf .

Cheers,
Johannes

More bugs in Postprocessing for showing the true signal.

There are several typos in PostProcessing/_spectrum.py, that prevent the addition of the true signal (of the simulated data) in the plots from working.

ref.interstellar(self.energies, temp)

ref.interstellar(self.energies, temp) should be replaced with ref.interstellar(self._energies, temp)

ref = self._signals

ref = self._signals should be replaced with ref = self._signal.


toral = temp should be replaced with total = temp.

Attribute error raised

https://github.com/ThomasEdwardRiley/xpsi/blob/753527d46fcd6d19186d2be468d6ecc0f2304a56/xpsi/Instrument.py#L94

Error message below:

Traceback (most recent call last):
  File "main_Tom_comparison.py", line 102, in <module>
    channel_edges=args.channels_path)
  File "/home/devarshi/anaconda3/envs/xpsi/lib/python2.7/site-packages/xpsi-0.5.3-py2.7-linux-x86_64.egg/xpsi/__init__.py", line 59, in decorator
    final = func(*args, **kwargs)
  File "/home/devarshi/msc-thesis/J0437_updated_instr_data_prior/STU/CustomInstrument.py", line 101, in from_SWG
    return cls(channel_edges[30:300, 1], RSP, edges, channels, beta)
  File "/home/devarshi/msc-thesis/J0437_updated_instr_data_prior/STU/CustomInstrument.py", line 19, in __init__
    super(CustomInstrument, self).__init__(*args)
  File "/home/devarshi/anaconda3/envs/xpsi/lib/python2.7/site-packages/xpsi-0.5.3-py2.7-linux-x86_64.egg/xpsi/Instrument.py", line 94, in __init__
    self.channel_edges = channel_edges
AttributeError: can't set attribute

channel_edges takes in rmf_nicer_channel_energies.txt

[Feature] Elsewhere.py accepting dictionary

For consistency with other classes of the star (e.g. HotRegion), I think that Elsewhere.py should accept a dictionary even if it has only one parameter elsewhere_temperature.

That would mean changing:

            T = Parameter('elsewhere_temperature',
                          strict_bounds = (3.0, 7.0), # very cold --> very hot
                          bounds = bounds,
                          doc = 'log10 of the effective temperature elsewhere',
                          symbol = r'$\log_{10}(T_{\rm EW}\;[\rm{K}])$',
                          value = value)

into

            T = Parameter('elsewhere_temperature',
                          strict_bounds = (3.0, 7.0), # very cold --> very hot
                          bounds = bounds.get('elsewhere_temperature', None),
                          doc = 'log10 of the effective temperature elsewhere',
                          symbol = r'$\log_{10}(T_{\rm EW}\;[\rm{K}])$',
                          value = values.get('elsewhere_temperature', None))

Sporadic HotRegion.RayError for certain parameter vectors

Calculating the likelihood for the same parameter vector gives some times HotRegion.RayError and sometimes not. For example, for a PSTU model with these parameters:

ray_error_vectors = np.array([[1.3728983226417986, 9.582564795756147, -0.7370097897513533, 0.020341921535536933, 0.2446314271154956, 0.3085074478486652, 6.161726551051954, 0.2722385280880412, 0.1088424612562043, 0.09511118603417756, -0.20397333010845675, 0.2730089443679007, 0.07205267520343456, 6.268835877470614, 0.13892737773308714, 0.13929302462200066, -0.6673219825864303, 43.29572745711499, 0.15926106535697776],
                             [1.3948493394100352, 9.885809466634319, -0.7378059269623075, 0.05209046240242854, 0.26593829571027794, 0.30030074135308593, 6.152591362014215, 0.3028962567969266, 0.11189861364104065, 0.3163235156902475, -0.18090198671715718, 0.37831814486006277, 0.08062299887788903, 6.2837707690528735, 0.301823322227404, 0.0734556127347533, 0.038060242003100875, 38.12674267246425, 0.069950983677363], 
                             [1.4504741349215766, 9.964345293695063, -0.7376990825030287, 0.05231077261958955, 0.3125101665396582, 0.2883310085055355, 6.158536076365398, 0.34929965040108363, 0.13922416746314772, 0.3762910953045031, -0.1088833839030095, 0.3674370534557028, 0.0848153341067613, 6.283365299456526, 0.3277296346681094, 0.0789335506650999, 0.041164067903278756, 37.2022470540444, 0.3727061914382968],
                             [1.4735528282275252, 10.457830123791124, -0.7378484123368936, 0.037355529918352504, 0.2547006433955337, 0.3008791197170953, 6.1422486708067865, 0.3235375223078834, 0.06800264510371007, 0.26410349603068184, -0.1617038746390121, 0.4311675329816908, 0.0760231439178584, 6.3105097093930915, 0.45160313303673505, 0.14061958460494817, -0.2384724243174104, 40.67103216913422, 0.20448222807910185],
                             [1.4453407814357084, 10.146908699569305, -0.7368584267910054, 0.01964990147236456, 0.22389466926492813, 0.2901036575777484, 6.150388714872136, 0.24173029249541889, 0.031621557419247805, 0.12143903156214009, -0.04059643374757979, 0.3656508672709845, 0.07111131914906119, 6.2705901096745595, 0.25249421901181035, 0.25049555313159316, 0.8213846079640836, 37.201743090809224, 0.3557169757535461],
                             [1.3808755265352752, 9.938472600055215, -0.7373234241292637, 0.038090695714808, 0.20848955924558116, 0.3499019345952415, 6.137333628849363, 0.20874685687808478, 0.015647339958144758, 0.18401562094411084, -0.11270699145789095, 0.5151704479477742, 0.11024561408704435, 6.207609711463972, 0.4635566755582748, 0.04336617468826924, -0.08501577607156287, 39.77586219175194, 0.2241197817497454],
                             [1.3939678263044752, 10.032643585858235, -0.7378686469911245, -0.008163823813762433, 0.18064468998438807, 0.35549933794118727, 6.158157479592278, 0.1959883903008687, 0.05891540075708436, -0.18799746415470875, -0.09159001768682726, 0.39206722407268807, 0.05405417660686076, 6.33900627520628, 0.39021235725694337, 0.037841463115627395, 0.006661094136515722, 37.83603814467343, 0.14214428958513572],
                             [1.3882997991500199, 9.530617629629507, -0.7371227044400374, 0.0339982038930266, 0.2510280096822779, 0.2858787658417807, 6.160714815084994, 0.3135805766607258, 0.03732686055281593, 0.19705566106299255, -0.12764572477705569, 0.27824366870387945, 0.07300049378676185, 6.256549164904389, 0.261062611172553, 0.030864253237076814, -0.06273794537905707, 40.3896846420874, 0.1933777121353478],
                             [1.3963648946694658, 9.75180918818749, -0.7376789256868118, 0.04657606046523677, 0.207873337295747, 0.3197216371519362, 6.155871691557279, 0.2269811867788805, 0.0673456883838116, 0.10725984535658561, -0.08261332530872764, 0.24761442522190863, 0.0659951064231678, 6.260923369555037, 0.2477448120085302, 0.011670327376688053, 0.02494415987022336, 40.511153231310246, 0.10846480606826205],
                             [1.4186702446539952, 9.953520353284203, -0.737648320356077, 0.07808284376855712, 0.18872314542308272, 0.3185394382070733, 6.162273568477383, 0.3183941063273488, 0.06616832902059701, 0.1514926906332965, -0.11957389421224227, 0.4796207326694473, 0.06235653566369398, 6.321227088580457, 0.49361428099559557, 0.10689112819233139, -0.22389994753446957, 36.6482731608843, 0.14938838767845405],
                             [1.3787010362420065, 9.361996320671075, -0.7368516812337672, 0.035454524245767005, 0.26905101733036024, 0.24193662028865287, 6.177181907420643, 0.3300817447295375, 0.07238385399488184, 0.15105870445248648, -0.09711872283124207, 0.4993698858554692, 0.059190573473550376, 6.314681233490582, 0.4593524534164035, 0.11248086924505983, 0.27511595104407505, 40.56730410570455, 0.03656999657941817],
                             [1.3580021420080053, 9.322915124718374, -0.7368940262436027, 0.05492921076747426, 0.2348390891127287, 0.2857530623058969, 6.146885871788459, 0.34170106843859654, 0.05275083240658456, 0.12918683319018243, -0.048489812906943736, 0.440667075592995, 0.11308490624596565, 6.231901481614595, 0.4176169942397346, 0.16327455479758568, 0.2525615807538353, 43.08538477871486, 0.5053992005980066],
                             [1.4641891149190578, 9.753688831797174, -0.7379197878414928, 0.10009347169472876, 0.2871607970622169, 0.25477457029082534, 6.167602616866395, 0.3199608797521209, 0.10078890745658649, 0.4656943799322155, -0.1773768732856713, 0.31327972739655935, 0.11314131130604736, 6.268509044716219, 0.3526694912213938, 0.09356834407584315, -0.036039379591684614, 46.47057812181873, 0.4128718649157406],
                             [1.4030865876511545, 10.12386582429333, -0.737301463289495, 0.060689120323593915, 0.16473204546284323, 0.3270277317527089, 6.154129856639079, 0.18337297900801677, 0.0643035953633014, 0.3941169148887802, -0.06651607914796773, 0.3863107336992121, 0.0773954202891921, 6.219636265014224, 0.47415701705156127, 0.076670263099481, 0.11962485685015434, 39.43114795339812, 0.11528196288117881],
                             [1.3908219733986031, 10.165977977664983, -0.736994799173803, 0.04626243665486435, 0.19673301181783043, 0.36558995502760305, 6.136186399671636, 0.20813324506389438, 0.07967659181739094, 0.19080401977302675, -0.14582367711583719, 0.4959518942072795, 0.06270823319393146, 6.261927632333782, 0.48955272992646537, 0.05703423717565083, -0.06418005965328531, 43.87327156688406, 0.3836933338966083]])

calculating the likelihoods as

for ray_error_vector in ray_error_vectors:
    print(main.likelihood(ray_error_vector, reinitialise=True))

for the first time prints

-37043.9913545
-36497.1396261
-39029.1026809
Warning: HotRegion.RayError raised.
Parameter vector:  [1.4735528282275252, 10.457830123791124, -0.7378484123368936, 0.037355529918352504, 0.2547006433955337, 0.3008791197170953, 6.1422486708067865, 0.3235375223078834, 0.06800264510371007, 0.26410349603068184, -0.1617038746390121, 0.4311675329816908, 0.0760231439178584, 6.3105097093930915, 0.45160313303673505, 0.14061958460494817, -0.2384724243174104, 40.67103216913422, 0.20448222807910185]
[-7.94188579e+89]
-36899.6237636
-42989.1700518
-36036.5098474
-36707.4067268
Warning: HotRegion.RayError raised.
Parameter vector:  [1.3963648946694658, 9.75180918818749, -0.7376789256868118, 0.04657606046523677, 0.207873337295747, 0.3197216371519362, 6.155871691557279, 0.2269811867788805, 0.0673456883838116, 0.10725984535658561, -0.08261332530872764, 0.24761442522190863, 0.0659951064231678, 6.260923369555037, 0.2477448120085302, 0.011670327376688053, 0.02494415987022336, 40.511153231310246, 0.10846480606826205]
[-1.18676754e+89]
-40798.7330209
-38633.244213
-37748.5032624
-39338.9084573
Warning: HotRegion.RayError raised.
Parameter vector:  [1.4030865876511545, 10.12386582429333, -0.737301463289495, 0.060689120323593915, 0.16473204546284323, 0.3270277317527089, 6.154129856639079, 0.18337297900801677, 0.0643035953633014, 0.3941169148887802, -0.06651607914796773, 0.3863107336992121, 0.0773954202891921, 6.219636265014224, 0.47415701705156127, 0.076670263099481, 0.11962485685015434, 39.43114795339812, 0.11528196288117881]
[-6.70283411e+89]
-36202.9432183

and for the second time prints

-37043.9913545
-36497.1396261
-39029.1026809
-36787.4490869
-36899.6237636
-42989.1700518
-36036.5098474
-36707.4067268
-36368.6065683
Warning: HotRegion.RayError raised.
Parameter vector:  [1.4186702446539952, 9.953520353284203, -0.737648320356077, 0.07808284376855712, 0.18872314542308272, 0.3185394382070733, 6.162273568477383, 0.3183941063273488, 0.06616832902059701, 0.1514926906332965, -0.11957389421224227, 0.4796207326694473, 0.06235653566369398, 6.321227088580457, 0.49361428099559557, 0.10689112819233139, -0.22389994753446957, 36.6482731608843, 0.14938838767845405]
[-7.73923494e+89]
-38633.244213
-37748.5032624
-39338.9084573
Warning: HotRegion.RayError raised.
Parameter vector:  [1.4030865876511545, 10.12386582429333, -0.737301463289495, 0.060689120323593915, 0.16473204546284323, 0.3270277317527089, 6.154129856639079, 0.18337297900801677, 0.0643035953633014, 0.3941169148887802, -0.06651607914796773, 0.3863107336992121, 0.0773954202891921, 6.219636265014224, 0.47415701705156127, 0.076670263099481, 0.11962485685015434, 39.43114795339812, 0.11528196288117881]
[-5.48656311e+89]
-36202.9432183

Solution for showing the true parameters in corner plots with subset of all parameters.

The current version of showing cross hairs for true parameter values only works if plotting all the parameters in one corner plot (with a specific order). Here a solution (replace the existing lines with these) to make it work for any subset of parameters (in any order) shown in the corner plot (_corner.py https://github.com/xpsi-group/xpsi/blob/master/xpsi/PostProcessing/_corner.py):

if crosshairs:
    # only for topmost posterior
    self._add_crosshairs(plotter, self.params.names, self.subset_to_plot[0].truths)

...

    def _add_crosshairs(plotter, names, truths):
        """ Add parameter crosshairs to triangle plot. """
        spine = next(plotter.subplots[0,0].spines.itervalues())
        lw = spine.get_linewidth()
        for i, name in enumerate(names):        
            true_val = truths[name]
            if true_val is not None:            
                for ax in plotter.subplots[:,i]:
                    if ax is not None:
                        ax.axvline(true_val, color='black', ls='-', lw=lw)                            
                if i > 0:
                    for ax in plotter.subplots[i,:i]:
                        if ax is not None:
                            ax.axhline(true_val, color='black', ls='-', lw=lw)

Problem compile model atmosphere for "elsewhere" regions.

If I use archive/elsewhere/numerical.pyx for the elsewhere_radiation_field.pyx the compiler crashes:

/users/p19056/webb/.local/lib/python2.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /olympe3/p19056/webb/Softwares/xpsi/xpsi/surface_radiation_field/elsewhere_radiation_field.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...

ctypedef struct DATA:
    size_t ndims
    size_t N[4]
    size_t BLOCKS[3]
    const srcRadField_PRELOAD *p
         ^
------------------------------------------------------------

xpsi/surface_radiation_field/elsewhere_radiation_field.pyx:39:10: 'srcRadField_PRELOAD' is not a type identifier

followed by many more Cython related errors.

Using the numerical.pyx for the hot_radiation_field works fine.
Using blackbody.pyx for the elsewhere or the hot radiation fields work fine.
So this seems to be a problem with elsewhere/numerical.pyx only.

This problem happens both on my Mac and on the cluster.

Typos for dates in changelog

Hi , I've noticed that the latest version v[0.7.10] is dated at 2021-10-02 instead of 2022-10-02 .
Furthermore, for the 3 latest update , the date's format have switched from [YYYY-MM-DD] to [YYYY-DD-MM] , it could be better to keep only one format for the entire changelog to stay consistent.
Best regards,
Gwénaël

`KeyError: 'No parameter in subspace with matching name.'` when auto-generating CST/EST + DT models

if self._overlap(ref, '{0}', '{1}', 'cede', 'cede', {2:.1f}, {3:.1f}):

if self._overlap(ref, '{0}', '{1}', 'super', 'cede', {2:.1f}, {3:.1f}):

if self._overlap(ref, '{0}', '{1}', 'cede', 'cede', {2:.1f}, {3:.1f}):

The above lines check for overlap between DT super and cede regions with CST/EST cede regions. The latter is a fixed parameter for CST/EST and is therefore not available in the parameter subspace which only consists of free parameters. The check is to be performed against super region of CST/EST instead of cede.

AttributeError: 'CustomSignal' object has no attribute '_loglikelihood'

Calling the likelihood check function seem to result in AttributeError: 'CustomSignal' object has no attribute '_loglikelihood' error at least in the following cases:

  • If calling originally the star object with the same parameter vector p (by star(p)) as that which is provided to the likelihood check function (likelihood.check(None, [-3.27536126e+04], 1.0e-6,physical_points=[p])), and not clearing the cache (likelihood.clear_cache()) before the likelihood check or possibly not calculating the likelihood by calling the likelihood object directly first (likelihood(p)). This happens because the likelihood check then thinks that likelihood was already calculated (and the attribute _loglikelihood would then exist) even though it was actually not.

  • As in the previous case, but if the parameter vector provided is out of the prior bounds, calling just first likelihood(p) does not help since the likelihood will not be fully calculated and the attribute _loglikelihood will not be introduced. Clearing the cache before the likelihood check will anyway solve the problem.

I would suggest either handling this error better to give a more helpful error message about the likely cause of the issue or clearing the cache always by default before doing the rest of the likelihood check (which I think would always prevent the error from happening, at least for these cases). Clearing the cache could be automatically done at the beginning of the check() function in Likelihood.py by adding a line: self.clear_cache(). Unless people think it is good to keep the possibility for cached likelihood checks if parameters are unchanged?

The new instrumental phaseshift parameter is not merged to the parameter subspace

In the X-PSI version 0.7.9, in Signal.py the following line will produce an error (line 498) return self._shifts + self['phase_shift'] (KeyError: 'No parameter in subspace with matching name.'). The error occurs when trying to plot the signal. For fixing the error, I suggest merging this phaseshift parameter to the parameter subspace by changing (see following line in Signal.py:

super(Signal, self).__init__(self._instrument,
)

# merge the subspaces; order unimportant
super(Signal, self).__init__(self._instrument,
                                   self._background,
                                   self._interstellar,
                                   *args, **kwargs)

to

 # merge the subspaces; order unimportant
 super(Signal, self).__init__(self._instrument,
                                     self._background,
                                     self._interstellar,
                                     phase_shift,
                                     *args, **kwargs)

Typo in xpsi Postprocessing code

Hi , i found a typo in xpsi/PostProcessing/_pulse.py
in function " _add_true_registered_signals(self): " line 474 "eomponent" instead of what i believe should have been "component"

Likelihood synthetise method broken

The likelihood synthesise method return none ( hence does not synthesise data) when one of the parameters is not within the bounds instead of throwing a "StrictBoundsError" error.

Matplotlib imported in Photosphere.py even though it would not have to

The try-except-else clause checking if Matplotlib can be imported in xpsi/Photosphere.py is currently useless since it never gives any exception as _mpl is always set to None in xpsi/global_imports.py if no matplotlib can be imported and try: None does not raise any exception:

Suggested solution:
Change

try:
    _mpl
except NameError:
    pass
else:
    import matplotlib
    from matplotlib import pyplot as plt
    from matplotlib.figure import Figure
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib import rcParams
    from matplotlib.ticker import MultipleLocator, AutoLocator, AutoMinorLocator
    from matplotlib import gridspec
    from matplotlib import cm
    from matplotlib import animation
    import matplotlib.image as mgimg

to

if _mpl is not None:
    import matplotlib
    from matplotlib import pyplot as plt
    from matplotlib.figure import Figure
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib import rcParams
    from matplotlib.ticker import MultipleLocator, AutoLocator, AutoMinorLocator
    from matplotlib import gridspec
    from matplotlib import cm
    from matplotlib import animation
    import matplotlib.image as mgimg
else:
    pass

Fixing this should allow inference runs in clusters without having the need for installing and importing Matplotlib.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.