Comments (7)
I had come up with the following redesign of the try-except-else block in Star.__init__
:
try:
assert isinstance(photospheres, list)
except AssertionError:
try:
assert isinstance(photospheres, Photosphere)
except AssertionError:
raise TypeError('Invalid type for a photosphere object')
else:
self._photospheres = [photospheres]
else:
try:
for photosphere in photospheres:
assert isinstance(photosphere, Photosphere)
except AssertionError:
raise TypeError('Invalid type for a photosphere object')
else:
self._photospheres = photospheres
This ensures that it doesn't encounter these errors, and we won't have to modify user scripts and tutorials, etc. The only reason I hadn't pushed it is that even though this is a fix for the exact error message reported, this isn't the root cause of it. There is some issue with ParameterSubspace
handling which causes it, when all the parameters are fixed. Using this fix, the code proceeds further but then gets stuck with a new error message:
AttributeError Traceback (most recent call last)
<ipython-input-6-fabd87490191> in <module>()
----> 1 main.photosphere.integrate(energies, threads=1)
2
3 _ = plot_pulse()
/Users/dc1408/opt/anaconda3/envs/xpsi/lib/python2.7/site-packages/xpsi-0.7.10-py2.7-macosx-10.7-x86_64.egg/xpsi/Photosphere.pyc in integrate(self, energies, threads)
326 threads,
327 self._hot_atmosphere,
--> 328 self._elsewhere_atmosphere)
329
330 if not isinstance(self._signal[0], tuple):
/Users/dc1408/opt/anaconda3/envs/xpsi/lib/python2.7/site-packages/xpsi-0.7.10-py2.7-macosx-10.7-x86_64.egg/xpsi/HotRegion.pyc in integrate(self, st, energies, threads, hot_atmosphere, elsewhere_atmosphere)
1085 st.r_s,
1086 st.i,
-> 1087 self._super_cellArea,
1088 self._super_r,
1089 self._super_r_s_over_r,
AttributeError: 'HotRegion' object has no attribute '_super_cellArea'
@yves mentioned that he had thought of some not-so-straightforward fix for the root cause which we can discuss and apply. I could still push the above fix in the meantime since it acts as an additional safety check regardless.
from xpsi.
Causes of all the issues:
The following line doesn't execute as intended:
Line 32 in b0ab3c6
The photosphere
variable doesn't get assigned and the body of the for-loop doesn't get executed. The for statement doesn't raise a TypeError
however, as it should if the object is non-iterable. No exception is subsequently raised as a result and the else body in line 41 is executed instead.
Thus self._photosphere
has the same object as photospheres
in the line above which runs into the same for-statement execution issue in the following line:
Line 45 in b0ab3c6
The loop body is then supposed to assign
photosphere.spacetime
which it never does, thereby causing the original error message posted.
@yves and I suspect that this is caused by iterable object handling in the ParameterSubspace.py
. This issue isn't raised for other classes since assignment typically doesn't depend on iterating over the object as it does in Photosphere.py
from xpsi.
So looks like the solution is to have star = xpsi.Star(spacetime = spacetime, photospheres = [photosphere,])
instead of star = xpsi.Star(spacetime = spacetime, photospheres = photosphere)
in your main file, right?
Perhaps this is the correct syntax we always should have used, but have been just lucky to not have problems caused by this when having at least some free parameters for the HotRegion object? In that case, we should probably anyway fix this in the example X-PSI scripts.
At least the old scripts seem to still work with this change in them.
from xpsi.
I still don't see that there would be other root causes for this issue than those lines that you fixed above. I don't see how ParameterSubspace
would be responsible for this. Can you give more details if you still think that is the case?
For the new error, I understood that you get that if have also fixed all the space-time parameters. This happens because then the embed function of the photosphere is never called here (the update function of Star thinks nothing needs to be updated since everything is fixed):
Line 94 in 29ead0d
To fix this, we could perhaps replace the line above with
if photosphere.needs_update or self._spacetime.needs_update or force_update:
where
force_update
would be an input argument used to force to do the full calculation:def update(self, fast_counts=None, threads=1, force_update=False):
I checked that error is then avoided when calling
star.update(force_update=True)
.
If we want that also calling and checking likelihood to work with parameters that are all fixed, looks like similar arguments really forcing X-PSI to calculate everything, should be also added to Likelihood.py
in driver()
and check()
functions and change if self.needs_update:
to if self.needs_update or force:
in the call function.
from xpsi.
Alternatively, we could also modify needs_update()
functions in ParameterSubspace.py
and Parameter.py
to return True
instead of False
, in case of all the parameters are fixed. But I guess having the power to force X-PSI to calculate all the relevant code blocks would be more useful anyway?
from xpsi.
Yea, I think I was hinting at the needs_update()
function in ParameterSubspace.py
to be the root issue here. I do agree however, that having the power to force X-PSI to compute the relevant code blocks is a better approach, and also having that power when computing likelihood. Have you already tried and tested modifying the likelihood.check
and likelihood.driver
?
from xpsi.
Yes, I tried and tested modifying those, and it worked. However, I did not yet add the new variables as input arguments to all these functions. The function descriptions also need to still be updated to explain these arguments. If you agree, I can add these to the next pull request.
from xpsi.
Related Issues (20)
- "ValueError: Invalid caching targets" issue when post processing HOT 3
- Bug when defining a `param_plot_lims` in a Corner plot post-processing HOT 6
- Retrieve curves data from SpectrumPlot HOT 2
- Residual (and probably signal) plots not working if having many photosphere objects
- Several bugs with zero count cases in likelihood marginalisation over background
- No API for CornerPlotter showing on documentation page HOT 4
- `HotRegion.set_num_cells` reverts to default values for arguments not passed
- Wrong units for the output flux in documentation HOT 1
- Useless argument `multimodal` generated for config file by `module_generator`
- Tight layout not working with corner plots HOT 2
- Module generator example is not working
- Newly released Cython may be backward incompatible for an X-PSI installation HOT 1
- Simplify the creation of a `CustomInstrument` from response matrice
- CI tests fail due to Cython issues HOT 1
- Possible bug in HotRegion.py HOT 4
- Make Cython crash in a clean way (or catch the errors) when atmosphere extensions are wrong
- Add X-ray polarization functionality
- Strict bounds for many of the geometry parameters in the `HotRegion` class use `_pi = math.pi`. HOT 1
- Installation instruction updates HOT 2
- Set maximum version of the NumPy dependency (NumPy 2.0 is coming)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xpsi.