Comments (13)
yes, that is what I meant, I was speaking in svn
from chiantipy.
What file and line number are being referenced specifically? is this in the Continuum
module or spectrum
module?
from chiantipy.
I just ran the code again, just as the user supplied, and got no errors. I may have done a pull from my origin master in between the two runs.
The problem had been in the Spectrum module after line 170
from chiantipy.
I just checked and I was using the v0.7.0 release so th bug may still be there in Spectrum after line 170
from chiantipy.
went back to the trunk version (~0.7.1) and the problem still seemed to be gone
from chiantipy.
When you say v0.7.1, do you mean the master branch at the most current commit?
from chiantipy.
I ran the code snippet from the mailing list on the most current commit of master and it didn't error, but I didn't think that was the issue. I thought the problem was that the free-bound contribution to spectrum gives zero over that particular wavelength range and that this result is not correct.
from chiantipy.
yes, your are right. I just forgot
from chiantipy.
Just to consolidate the issue to this thread, the code to calculate the spectrum in ChiantiPy is,
temp=[1.e+7,2.e+7]
dens=1.e+9
wvl = 1. + 0.002*np.arange(4501)
emeas=[1.e+27,1.e+27]
s3 = ch.spectrum(temperature=temp,eDensity=dens,wavelength=wvl,filter = (chfilters.gaussian,.015),doContinuum=1, em=emeas,minAbund=1.e-5,verbose=0)
plt.plot(wvl,s3.FreeFree['intensity'][0])
plt.plot(wvl,s3.FreeBound['intensity'][0])
while the corresponding IDL output gives,
(solid is free-free, dashed is free-bound, dot-dashed is two-photon)
The next step I guess would just be to make sure that the Continuum
module alone is giving the expected output, e.g. something like
mport numpy as np
import ChiantiPy.core as ch
import ChiantiPy.tools.data as chdata
temperature = np.array([1e7,2e7])
wavelength = np.linspace(1,10,4501)
total_fb_emission = np.zeros((temperature.shape[0],wavelength.shape[0]))
for ion in chdata.MasterList:
tmp = ch.Continuum(ion,temperature)
tmp.calculate_free_bound_emission(wavelength)
total_fb_emission += tmp.free_bound_emission
If it does, then we know the problem is confined to spectrum
from chiantipy.
the problem is in Continuum, at line 449, in inserted
if self.emission_measure is not None:
for i, em in enumerate(self.emission_measure):
fb_emiss[i] *= em
for this problem, fb has a shape of [2,4501] and emeas has a shape of [2] and they can not be directly multiplied together. I have put a correction and have pushed to to my fork and then will do it to the upstream master
also, line 421: requires an array of temperatures, not a float - it tries to get len(temperature)
I will let you work on this because the code with regard to this has changed from what I had
in v
from chiantipy.
Ok yes that's a problem. There are a couple of other corner cases I've hit where things cannot be multiplied together because of weird dimension mismatches. Note that this can be solved with numpy.newaxis
. See my comment in #139. As they come up, I'll try to fix them. I think most of the time it is just a matter of using the numpy.newaxis
fix. This is probably a case where more tests with a larger range of inputs would be useful...
Regarding line 421, I don't think this is an issue because of this line in the constructor which makes sure temperature is a Numpy array so calling len()
on it shouldn't be a problem.
from chiantipy.
there is another problem with the fix and that is when emission_measure is not interable.
never used numpy.newaxis
I think I should leave this to you
from chiantipy.
the free-bound calculation now works with a single temperature. However, the syntax has mostly reverted to the original style
`import numpy as np
import ChiantiPy.core as ch
import ChiantiPy.tools.data as chdata
temperature = np.array([1e7,2e7])
wavelength = np.linspace(1,10,4501)
total_fb_emission = np.zeros((temperature.shape[0],wavelength.shape[0]))
for ion in chdata.MasterList:
tmp = ch.continuum(ion,temperature)
tmp.freeBound(wavelength)
total_fb_emission += tmp.FreeBound['intensity']`
previously, freeBound would through an error if the data file necessary to do the calculation was missing. Now it just returns a correctly shaped array of zeros.
from chiantipy.
Related Issues (20)
- ch_ss like synthetic spectra with chiantipy HOT 5
- AttributeError: module 'ChiantiPy.tools.data' has no attribute 'Abundance' HOT 27
- conda-forge package HOT 4
- KeyError on windows 10 HOT 5
- Error on running provided jupyter notebooks in the repo HOT 3
- line identifications in spectrum plot HOT 13
- Ability to give custom abundance files HOT 8
- Error while using spectrum with elementList only when all the ions are not present in the masterlist HOT 7
- Unexpected behavior when setting minAbund lower than lowest abund HOT 3
- Error when giving "Zn" in elementlist HOT 2
- How much memory does the mspectrum process consumes? HOT 1
- Chianti is taking more threads than specified HOT 2
- Clarify emission measure units in the function documentations. HOT 2
- Question: Support for photons/keV completed? HOT 10
- Getting spectrum from Ch.spectrum without smoothing/filtering HOT 4
- IDL and ChiantiPy gives different results. HOT 4
- Possible typo in function's documentation HOT 1
- NaNs generated when calculating spectra under certain conditions HOT 9
- Upload 0.15.1 to PyPI HOT 3
- Non-ionization equilibrium? HOT 2
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 chiantipy.