Git Product home page Git Product logo

Comments (13)

kdere avatar kdere commented on August 20, 2024 1

yes, that is what I meant, I was speaking in svn

from chiantipy.

wtbarnes avatar wtbarnes commented on August 20, 2024

What file and line number are being referenced specifically? is this in the Continuum module or spectrum module?

from chiantipy.

kdere avatar kdere commented on August 20, 2024

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.

kdere avatar kdere commented on August 20, 2024

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.

kdere avatar kdere commented on August 20, 2024

went back to the trunk version (~0.7.1) and the problem still seemed to be gone

from chiantipy.

wtbarnes avatar wtbarnes commented on August 20, 2024

When you say v0.7.1, do you mean the master branch at the most current commit?

from chiantipy.

wtbarnes avatar wtbarnes commented on August 20, 2024

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.

kdere avatar kdere commented on August 20, 2024

yes, your are right. I just forgot

from chiantipy.

wtbarnes avatar wtbarnes commented on August 20, 2024

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])

image

while the corresponding IDL output gives,
image

(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.

kdere avatar kdere commented on August 20, 2024

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.

wtbarnes avatar wtbarnes commented on August 20, 2024

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.

kdere avatar kdere commented on August 20, 2024

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.

kdere avatar kdere commented on August 20, 2024

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)

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.