Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Added a conditional statement and changed the error type that was being handled in tardis.io.model_reader.read_uniform_abundances. #2573

Merged
merged 19 commits into from
Jun 6, 2024

Conversation

KC210404
Copy link
Contributor

@KC210404 KC210404 commented Apr 4, 2024

馃摑 Description

Type: 馃 bugfix

While working on the first objective plots for GSOC'24, I found a bug in the function: tardis.io.model_reader.reader.read_uniform_abundances (model_reader.py file).

Bug Description: According to the schema of the abundances sub-section of the model section, after validation, the key model_isotope_time_0 gets added to the validated abundances section. However, when we pass this validated abundances section to the function read_uniform_abundances, there is no condition to handle model_isotope_time_0. Neither is it a "type" nor is it an elemental or isotopic species. Consequently, it reaches the last else statement (nested-else), where actually the isotopic species should go to, which are passed to the Nuclide of the radioactivedecay library of Python to get the multi-level index of the species in the isotope_abundance DataFrame. But since model_isotope_time_0 is not an isotopic species and is a compulsory inclusion at the validation stage, it must be handled by adding a string comparison like with the "type"-key in the abundances section. We can't loop until the last but one element (model_isotope_time_0 is the last key), because in cases where the config-dict is not validated then this key wouldn't be added, and we would lose the last species abundance.

Secondly, we need to handle such strings which are not either elemental or isotopic species for which the try-except block with a runtime error getting excepted is already added. However, when such strings are passed to the Nuclide function, radioactivedecay.utils.NuclideStrError gets generated, not a runtime error. So these two changes were done to the code.

Example: validated-abundances section of tardis_example.yml file: {'type': 'uniform', 'O': 0.19, 'Mg': 0.03, 'Si': 0.52, 'S': 0.19, 'Ar': 0.04, 'Ca': 0.03, 'model_isotope_time_0': <Quantity 0. s>}

Note: Key inclusions such as the "model_isotope_time_0" key occur at the validation stage for different sections of the YAML file configuration. So, when a specific section is parsed from the validated configuration dictionary (which is done by the functions in model_reader.py), it is important that such key inclusions be handled and debugged.

馃殾 Testing

How did you test these changes?

  • Testing pipeline
  • Other method (describe)
  • My changes can't be tested (explain why)

鈽戯笍 Checklist

  • I requested two reviewers for this pull request
  • I updated the documentation according to my changes
  • I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

A standalone code which can be easily integrated into the TARDIS code base, to build a plot functionality that visualizes the number of packet interactions as a function of the last interaction velocity for each element present in the ejecta.
Output of velocity_packet_tracker.py
They are added to a different repository in my Git account: https://github.com/KC210404/GSOC2024_tardis
They already exist in a different repository in my Git account: https://github.com/KC210404/GSOC2024_tardis
They already exist in a different repository in my Git account: https://github.com/KC210404/GSOC2024_tardis
They already exist in a different repository in my Git account: https://github.com/KC210404/GSOC2024_tardis
They already exist in a different repository in my Git account: https://github.com/KC210404/GSOC2024_tardis
They already exist in a different repository in my Git account: https://github.com/KC210404/GSOC2024_tardis
They already exist in a different repository in my Git account: https://github.com/KC210404/GSOC2024_tardis
@tardis-bot
Copy link
Contributor

tardis-bot commented Apr 4, 2024

*beep* *bop*

Hi, human.

The docs workflow has succeeded 鉁旓笍

Click here to see your results.

@tardis-bot
Copy link
Contributor

*beep* *bop*

Hi, human.

I'm the @tardis-bot and couldn't find your records in my database. I think we don't know each other, or you changed your credentials recently.

Please add your name and email to .mailmap in your current branch and push the changes to this pull request.

In case you need to map an existing alias, follow this example.

@tardis-bot
Copy link
Contributor

*beep* *bop*

Hi, human.

I'm the @tardis-bot and couldn't find your records in my database. I think we don't know each other, or you changed your credentials recently.

Please add your name and email to .mailmap in your current branch and push the changes to this pull request.

In case you need to map an existing alias, follow this example.

@wkerzendorf wkerzendorf merged commit 74c4662 into tardis-sn:master Jun 6, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants