<jupyter_start><jupyter_text>astrophysical simulation<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import numpy as np<jupyter_output><empty_output><jupyter_text>read the density file<jupyter_code>fname = "density_projection.dat"
d = np.fromfile(fname,dtype=np.float32)
d = np.reshape(d,(512,512)) #reshaping file<jupyter_output><empty_output><jupyter_text>repeat for the energy file<jupyter_code>fname = "energy_projection.dat"
energy = np.fromfile(fname,dtype=np.float32)
energy = np.reshape(energy,(512,512))<jupyter_output><empty_output><jupyter_text>plot them using the default color map<jupyter_code>d_log = np.log10(d)
f = plt.figure(figsize=(7,7))
plt.imshow(d_log)
e_log = np.log10(energy)
f = plt.figure(figsize=(7,7))
plt.imshow(e_log)<jupyter_output><empty_output><jupyter_text>make a 3-color imageH=[0,1] is the color wheelv=[0.1] is the intensity of the imageS=[0,1] is the saturation of the color, with 0 being white (for v=1) or black for v=0 and 1 being a deep color<jupyter_code>#map density to v ans s, and energy to h.
d_min = d_log.min()
d_max = d_log.max()

v = (d_log - d_min)/(d_max - d_min)
s = 1.0-v
e_min = e_log.min()
e_max = e_log.max()

h = 0.8 - 0.2*(e_log - e_min)/(e_max-e_min)<jupyter_output><empty_output><jupyter_text>make a HSV image, then convert to RGB<jupyter_code>hsv_image = np.zeros((512,512,3))

hsv_image[:,:,0]=h
hsv_image[:,:,1]=s
hsv_image[:,:,2]=v

rgb_image = colors.hsv_to_rgb(hsv_image)<jupyter_output><empty_output><jupyter_text>see the 3-color image<jupyter_code>f = plt.figure(figsize=(7,7))
plt.imshow(rgb_image)
#save as a png file
plt.imsave("test.png",rgb_image)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1431924882629108, 'fraction_numerical': 0.03169014084507042, 'mean_word_length': 7.357843137254902, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '368725', 'license': 'MIT', 'n_tokens_mistral': 746, 'n_tokens_neox': 718, 'n_words': 135, 'path': 'simulation-visualization.ipynb', 'repo_name': 'ashleyparrilla/astr-119-session-20', 'size': '1704'}