<jupyter_start><jupyter_text>Example 1 : A Simple Denoising CaseIn this example, we are going to denoise a galaxy image and visualize the result.We first start by import the required libraries.<jupyter_code>from score import score
import numpy as np
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Data preparationThen we load the data.<jupyter_code># %% load data
#true galaxies
gals = np.load('convolved_galaxies.npy')
#observed galaxies
gals_obs = np.load('observed_galaxies.npy')<jupyter_output><empty_output><jupyter_text>Image SelectionAfterwards, we select one of the 5 galaxy images.<jupyter_code>#pick a galaxy image number (between 0 and 4, in this case)
gal_num = 2
gal = gals[gal_num]
gal_obs = gals_obs[gal_num]<jupyter_output><empty_output><jupyter_text>DenoisingNow we denoise the chosen galaxy image by instanciating score and using its `denoise` method.<jupyter_code># %% perform denoising of the chosen galaxy image
#initiate score
#set the value of gamma for example
denoiser = score(gamma=0.5)
#denoise
denoiser.denoise(obs=gal_obs) #the result will be in denoiser.solution<jupyter_output>/Users/fnammour/Documents/Librairies/score/cadmos_lib.py:104: ComplexWarning: Casting complex values to real discards the imaginary part
  coeff[s] = trafo.adjoint_transform(temp, do_norm=False)<jupyter_text>Visualizing the ResultWe start by setting the parameters to the graphs. We would like to give the same colorbar scale for the observed image, the true one and the denoised one.<jupyter_code># %% plot result
vmin = np.min(gal_obs)
vmax = np.max([gal_obs,gal,denoiser.solution])
colormap = 'gist_stern'<jupyter_output><empty_output><jupyter_text>Now we can show the images.<jupyter_code>plt.figure(figsize=(18,5))

plt.subplot(131)
plt.imshow(gal,vmin=vmin,vmax=vmax,cmap=colormap)
plt.colorbar()
plt.title('True Galaxy')

plt.subplot(132)
plt.imshow(gal_obs,vmin=vmin,vmax=vmax,cmap=colormap)
plt.colorbar()
plt.title('Observed Galaxy')

plt.subplot(133)
plt.imshow(denoiser.solution,vmin=vmin,vmax=vmax,cmap=colormap)
plt.colorbar()
plt.title('Reconstructed Galaxy')

plt.suptitle('Restoration Results of Galaxy #{}'.format(gal_num))

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.103199639477242, 'fraction_numerical': 0.009914375844975214, 'mean_word_length': 7.505747126436781, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, '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': '310272', 'license': 'MIT', 'n_tokens_mistral': 821, 'n_tokens_neox': 776, 'n_words': 196, 'path': 'examples/example1.ipynb', 'repo_name': 'CosmoStat/OSCAR', 'size': '2219'}