Skip to content

cmfgen2tardis not working #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Knights-Templars opened this issue Sep 16, 2020 · 6 comments
Open

cmfgen2tardis not working #1302

Knights-Templars opened this issue Sep 16, 2020 · 6 comments

Comments

@Knights-Templars
Copy link
Member

Knights-Templars commented Sep 16, 2020

Code Sample, a copy-pastable example if possible

Problem description

from tardis.atomic import AtomData
ModuleNotFoundError: No module named 'tardis.atomic'

While trying to convert a cmfgen file to tardis, shows the output above. Any help would be greatly appreciated

@wkerzendorf
Copy link
Member

could you please show us how you want to do that and post also the files - so we can try to follow

@Knights-Templars
Copy link
Member Author

Thankyou for your reply.

So, I want to model the spectra of a SN Ia which I am currently working on. I am trying to generate tardis readable file from a cmfgen file
PDDEL1n_SN_HYDRO_DATA_1.000d.txt

This is from a paper by Dessart, 2014.
I am running cmfgen2tardis /cmfgen-file /tardis-model as is described in the manual. I am getting this error

   from tardis.atomic import AtomData
ModuleNotFoundError: No module named 'tardis.atomic'

I also tried importing atomic from jupyter-notebook. It is not working there also.

@epassaro
Copy link
Member

epassaro commented Sep 17, 2020

Seems AtomData has been moved:

from tardis.io.atom_data import AtomData

Also in the script tardis/scripts/cmfgen2tardis.py there's a line:

AtomData.from_hdf5()

but currently AtomData has the to_hdf method instead. Also, you need to point to the atomic data file.

AtomData.from_hdf('/home/user/tardis-data/kurucz_cd23_chianti_H_He.h5')

After doing that I ran the script by doing:

cmfgen2tardis PDDEL1n_SN_HYDRO_DATA_1.000d.txt .

and got the following error:

ValueError: could not convert string to float: '100*0.00000D0'

because Python does not understand Fortran D type. I recommend change that values directly in the .txt file.

This script should be updated soon.

@Knights-Templars
Copy link
Member Author

Many thanks. I did the import as was mentioned by @epassaro , and also removed the string part '100*0.00000D0' to 100.00.
Now a new error comes as follows on the same text file that was provided earlier.

abundances_df.loc[element_symbol] = abundances
ValueError: cannot set a row with mismatched columns

Is there a change in the output format of cmfgen or the code ?

@epassaro
Copy link
Member

epassaro commented Sep 17, 2020

I understand that '100*0.00000D0' should be 0.0 (no abundance).

Then the ValueError happens because abundances for elements different than '100*0.00000D0' have the same length. Then what we need (I'm not really sure) is an array of zeros of the same length.

I wrote on line 80:

                if len(abundances) == 1:
                    abundances_df.loc[element_symbol] = [0.]*len(density)   # A big row of 0s
                else:
                    abundances_df.loc[element_symbol] = abundances

Then the code fails again because the function def get_atomic_number returns index -1 by default (line 14 and 69) and there's no element with Z=-1.

In line 70 added:

                if atomic_no == -1:
                    break

and got the output file . But I'm not sure if this approach makes sense, I never worked with this script.

@wkerzendorf knows more about this.

@wkerzendorf
Copy link
Member

I'll have a look hopefully soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants