<jupyter_start><jupyter_text>![Astrofisica Computacional](../logo.png) --- Creation of Synthetic Data: signals+noise<NAME> (<EMAIL>)---<jupyter_code>import matplotlib.pyplot as plt
import numpy as np<jupyter_output><empty_output><jupyter_text>Synthetic Signal<jupyter_code>x = np.linspace(-5, 5, 200)
y = 0.5*np.sinc(x)

fig, ax = plt.subplots(figsize=(7,5))

ax.plot(x,y)
ax.set_xlabel(r'$x$')
ax.set_ylabel(r'Flux Density (Jy)')
plt.show()<jupyter_output><empty_output><jupyter_text>Creation of 100 synthetic profiles using the above signal and adding random noise.<jupyter_code>n = 100
rawprofiles = np.zeros([n,200])
for i in range(n):
  rawprofiles[i] = y + ( np.random.rand(200) - np.random.rand(200) )

recovered_signal = np.mean(rawprofiles, axis=0)

fig, ax = plt.subplots(figsize=(7,5))
ax.plot(x,recovered_signal, label='Recovered signal', color='cornflowerblue')
ax.plot(x,y, label='Original Gaussian signal', color='crimson')
ax.set_xlabel(r'$x$')
ax.set_ylabel(r'signal')
plt.legend()
plt.show()
rawprofiles[0]<jupyter_output><empty_output><jupyter_text>Definition of an array with the x-coordinate and the synthetic data<jupyter_code>raw1 = np.zeros([n+1,200])
raw1[0] = x
for i in range(n):
  raw1[i+1] = rawprofiles[i]
raw1<jupyter_output><empty_output><jupyter_text>Definition of the transpose of the array to write data as columns<jupyter_code>raw2 = np.transpose(raw1)
raw2<jupyter_output><empty_output><jupyter_text>Writting the file<jupyter_code>np.savetxt('rawsignals.txt', raw2, fmt='%.10f', header='First column=x ; Following 100 columns=Raw flux data')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15422885572139303, 'fraction_numerical': 0.029228855721393034, 'mean_word_length': 7.744565217391305, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '470114', 'license': 'MIT', 'n_tokens_mistral': 672, 'n_tokens_neox': 636, 'n_words': 117, 'path': '18. Statistics Basics/SyntheticDataCreation.ipynb', 'repo_name': 'ashcat2005/AstrofisicaComputacional2022', 'size': '1634'}