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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added (working but unpolished) scripts to calculate hot has properties. #137

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jemme07
Copy link

@jemme07 jemme07 commented Jul 28, 2021

Added (working but unpolished) scripts to calculate hot has properties for Flamingo, e.g. density, pressure and entropy profiles, etc.

This needs a lot of housekeeping! Unfortunately, I haven’t got much time on my hands at the moment. @bwvdnbro, could you please help with this?

Everything should work, but it needs tidying up.

It requires the observational data (also needs tidying up) from the fork https://github.com/jemme07/velociraptor-comparison-data.

…s for Flamingo, e.g. density, pressure and entropy profiles, etc.
@bwvdnbro
Copy link
Member

@jemme07 could you remove the __pycache__ files from your repository?

@bwvdnbro
Copy link
Member

And please open a pull request for the changes in the observational data as well, that makes it easier to keep track of things.

@jemme07
Copy link
Author

jemme07 commented Jul 28, 2021

Opened a pull request for the changes in the observational data as well. -> DONE

@jemme07
Copy link
Author

jemme07 commented Aug 19, 2021

@jemme07 could you remove the __pycache__ files from your repository?

Done

abundance_to_solar = np.c_[abundance_to_solar[:, :-1], abundance_to_solar[:, -2], abundance_to_solar[:, -2], abundance_to_solar[:, -1]] #Add columns for Calcium and Sulphur and add Iron at the end

#Find helium offsets
idx_he = find_idx_he(np.log10(abundances[:, 1]), interp.He_bins)
Copy link
Member

Choose a reason for hiding this comment

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

@jemme07 There is an inconsistency here: while idx_n and idx_T are determined using the mask joint_mask, idx_he is not. As a result, idx_n/idx_T and idx_he do not have the same length. This does not give any errors because you use the shorter length (that of idx_n) to determine the loop count in get_table_interp(), but it does mean that there is a mismatch between the elements in idx_n/idx_T and idx_he. In other words: you are probably using the wrong idx_he for most of the elements during the interpolation.

Copy link
Author

Choose a reason for hiding this comment

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

The interpolation code was written by Joey Braspenning. I'll contact him to take a look. Well spotted!

df_gas['lambda_c'] = np.power(10, xray.interpolate_X_Ray_pandas(np.log10(df_gas.nH.values), np.log10(df_gas.temp.values), df_elements, z, obs_data_dir, band = '0.5-2.0keV', fill_value = -400)) / df_gas.nH.values ** 2
df_gas['in_FOF'] = mask

df_elements = df_elements.div(df_elements.hydrogen, axis=0)
Copy link
Member

Choose a reason for hiding this comment

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

@jemme07 it looks like you are only setting the mass fractions of sulphur and calcium after you used the elemental mass fractions in the X-ray interpolation on line 118. Is this correct? Right now the interpolation is using the same mass fraction as for silicon for these elements. Do the tables already assume the same sulphur/silicon and calcium/silicon?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that is a standard assumption throughout EAGLE&co. Worth adding a comment though.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, as @MatthieuSchaller mentioned, this is a standard practice.


df_gas = pd.DataFrame(data.gas.coordinates.value, columns=['x', 'y', 'z'])
df_gas['temp'] = data.gas.temperatures.value
df_gas['mass'] = data.gas.masses.to('Msun').value.astype(np.float64) * u.Msun.to(u.gram)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a specific reason why you are not simply using data.gas.masses.to("gram").value? Is this a rounding issue?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, the problem is that the values are really small in grams, and rounding issues arise further down in the calculations and would return either inf of nan.

I tried different hacks here, but if I remember correctly, the only way I made this work is to convert to Msun first using float64, the convert to grams. But there might be a better solution.

Copy link
Member

Choose a reason for hiding this comment

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

I can imagine that rounding issues occur if the masses are stored as single precision. But can't you convert the masses to float64 immediately, without having to convert to Msun first?

Comment on lines +1 to +3
"""
Dummy
"""
Copy link
Member

Choose a reason for hiding this comment

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

Is there a particular reason that this exists?

Copy link
Author

Choose a reason for hiding this comment

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

This dummy was aded as a hacky work around to produce several plots with the same script. That is, we read the particle data only once, make all the calculations (x-ray, entropy, etc) and produce all the plots. Then call the dummy script in the pipeline config.yml to properly link the plots and names in the generated webpage.

Copy link
Member

Choose a reason for hiding this comment

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

The dummy script was removed in jemme07#1, since @EvgeniiChaikin implemented a feature that allows creating multiple figures with a single script (SWIFTSIM/pipeline#26).

kT = kb / ergs_keV * groups.wtemp.sum() / groups.mass.sum()
p = kT * groups.ne.sum()
s = kT / groups.ne.sum() ** (2./3)
p /= groups.head(1).P500.median()
Copy link
Member

Choose a reason for hiding this comment

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

@jemme07 I'm not sure I understand what you are doing here. Looks like you are constructing radial bins and then finding all halos that have particles within a bin. For those particles, you then compute the (total?) pressure and entropy within the bin and then you divide this by the median P500 and S500 of all halos that have particles in this particular bin. Is that right?

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.

4 participants