Skip to content

Use atomic data for lanthanide ions V-VII from Carvajal-Gallego et al. (MONS university)#4

Open
ccollins22 wants to merge 25 commits intomainfrom
add_mons_data
Open

Use atomic data for lanthanide ions V-VII from Carvajal-Gallego et al. (MONS university)#4
ccollins22 wants to merge 25 commits intomainfrom
add_mons_data

Conversation

@ccollins22
Copy link
Member

No description provided.

@ccollins22 ccollins22 requested a review from lukeshingles July 19, 2024 15:45
Copy link
Member

@lukeshingles lukeshingles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor style issues, but what's really important is to add a test for the new functionality to avoid it getting broken by future changes. If the full dataset is too large, you can split out some representative data and test that. If it's under ~5MB, you can commit it directly to the repo.

Comment on lines +1026 to +1027
if levela is None or levela.parity is None or levelb.parity is None:
return False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would levela be None?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of energy_levels = [None]
Which I copied from your code to read Tanaka's data. Without initialising the array with None the lowest level doesn't get written out. With it levela doesn't have attribute parity and this fails

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's a relic of our 1-based indexing that we inherited from the existing artis file formats. However, if any of your transitions are referencing the dummy level in the 0 index, that suggests that there is an off-by-one error in the indexing of transitions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the transitions array have a dummy value initialised too then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we don't really keep track of a transition index, and all transitions get written out in write_transition_data(). write_adata() skips the 0-index when writing out the list of levels for each ion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important to manually verify that the first couple of levels and transitions are recorded correctly in the artis output files, because indexing errors are very easy to make.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One file with the transitions is ~30MB

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just take a sample of a few hundred transitions and compress it with zstd.

Comment on lines -1548 to +1561
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better as far as not repeating the forbidden conditions in several places, but I'm not sure we want to pay the cost of two more Python function calls on each one of ~50 million transition. Did this affect performance in any significant way?

I think a better way (but can be left for a separate PR) would be to use a forbidden attribute on each transition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice a big slow down but I didn't really check. Feel free to update

Comment on lines -1562 to +1575
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a blocker, but I would strongly prefer to avoid using pandas in any new code (so that eventually we can remove the import and save ~500ms of startup time). Polars should be a drop-in replacement here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to update - I'm not used to polars yet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest getting the test in place first, and then these style fixes can be implemented safely with a big warning if anything breaks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use an iterator for lower and upper but then access transition_wavelength_A and oscillator_strength by index? Wouldn't it be better to zip all of these arrays? Shouldn't strict be True here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add strict - I've no idea what it does. I think it was the automated checks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add strict - I've no idea what it does. I think it was the automated checks?

Ruff modified it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's a bit of an annoying autofix. Strict=False will stop iterating at the shortest of any arrays, while strict=True will raise an exception if the lengths don't match. I think we almost always want strict=True.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're not using the lowerlevel value from enumerate, why use enumerate? Better to zip lowerlevel, upperlevel, A_ul with strict=True to make sure they match lengths.

@@ -0,0 +1,4 @@
https://doi.org/10.5281/zenodo.10635803
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add direct URLs for the zip files that are needed as we do for other data sources.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the links are. Does it work to just add the files names to the end of the zenodo link?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://zenodo.org/records/10635803/files/outggf_Ln_V--VII.zip
https://zenodo.org/records/10635803/files/outglv_Ln_V--VII.zip
The readme should probably just be committed directly to the repo since it's so small.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The info from the readme is in comments at the top of the file

Comment on lines +5 to +6
from astropy import constants as const
from astropy import units as u
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding another dependency (astropy) to the package is not really necessary. hc_in_ev_cm and hc_in_ev_angstrom can be set with numeric literals.

@lukeshingles lukeshingles force-pushed the main branch 2 times, most recently from 4a34a7e to aa59f68 Compare September 3, 2025 13:40
@lukeshingles lukeshingles force-pushed the main branch 4 times, most recently from 610a929 to fa9465b Compare January 28, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments