Commit 7b97a739 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

fix remaining demos

parent f44d8758
Pipeline #64981 passed with stages
in 8 minutes and 42 seconds
...@@ -296,9 +296,9 @@ ...@@ -296,9 +296,9 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# Get signal data and reconstruction data\n", "# Get signal data and reconstruction data\n",
"s_data = HT(sh).to_global_data()\n", "s_data = HT(sh).val\n",
"m_data = HT(m).to_global_data()\n", "m_data = HT(m).val\n",
"d_data = d.to_global_data()\n", "d_data = d.val\n",
"\n", "\n",
"plt.figure(figsize=(15,10))\n", "plt.figure(figsize=(15,10))\n",
"plt.plot(s_data, 'r', label=\"Signal\", linewidth=3)\n", "plt.plot(s_data, 'r', label=\"Signal\", linewidth=3)\n",
...@@ -350,8 +350,8 @@ ...@@ -350,8 +350,8 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"s_power_data = ift.power_analyze(sh).to_global_data()\n", "s_power_data = ift.power_analyze(sh).val\n",
"m_power_data = ift.power_analyze(m).to_global_data()\n", "m_power_data = ift.power_analyze(m).val\n",
"plt.figure(figsize=(15,10))\n", "plt.figure(figsize=(15,10))\n",
"plt.loglog()\n", "plt.loglog()\n",
"plt.xlim(1, int(N_pixels/2))\n", "plt.xlim(1, int(N_pixels/2))\n",
...@@ -427,12 +427,12 @@ ...@@ -427,12 +427,12 @@
"\n", "\n",
"mask = np.full(s_space.shape, 1.)\n", "mask = np.full(s_space.shape, 1.)\n",
"mask[l:h] = 0\n", "mask[l:h] = 0\n",
"mask = ift.Field.from_global_data(s_space, mask)\n", "mask = ift.Field.from_arr(s_space, mask)\n",
"\n", "\n",
"R = ift.DiagonalOperator(mask)(HT)\n", "R = ift.DiagonalOperator(mask)(HT)\n",
"n = n.to_global_data_rw()\n", "n = n.val.copy()\n",
"n[l:h] = 0\n", "n[l:h] = 0\n",
"n = ift.Field.from_global_data(s_space, n)\n", "n = ift.Field.from_arr(s_space, n)\n",
"\n", "\n",
"d = R(sh) + n" "d = R(sh) + n"
] ]
...@@ -497,11 +497,11 @@ ...@@ -497,11 +497,11 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# Get signal data and reconstruction data\n", "# Get signal data and reconstruction data\n",
"s_data = s.to_global_data()\n", "s_data = s.val\n",
"m_data = HT(m).to_global_data()\n", "m_data = HT(m).val\n",
"m_var_data = m_var.to_global_data()\n", "m_var_data = m_var.val\n",
"uncertainty = np.sqrt(m_var_data)\n", "uncertainty = np.sqrt(m_var_data)\n",
"d_data = d.to_global_data_rw()\n", "d_data = d.val.copy()\n",
"\n", "\n",
"# Set lost data to NaN for proper plotting\n", "# Set lost data to NaN for proper plotting\n",
"d_data[d_data == 0] = np.nan" "d_data[d_data == 0] = np.nan"
...@@ -583,12 +583,12 @@ ...@@ -583,12 +583,12 @@
"\n", "\n",
"mask = np.full(s_space.shape, 1.)\n", "mask = np.full(s_space.shape, 1.)\n",
"mask[l:h,l:h] = 0.\n", "mask[l:h,l:h] = 0.\n",
"mask = ift.Field.from_global_data(s_space, mask)\n", "mask = ift.Field.from_arr(s_space, mask)\n",
"\n", "\n",
"R = ift.DiagonalOperator(mask)(HT)\n", "R = ift.DiagonalOperator(mask)(HT)\n",
"n = n.to_global_data_rw()\n", "n = n.val.copy()\n",
"n[l:h, l:h] = 0\n", "n[l:h, l:h] = 0\n",
"n = ift.Field.from_global_data(s_space, n)\n", "n = ift.Field.from_arr(s_space, n)\n",
"curv = Curvature(R=R, N=N, Sh=Sh)\n", "curv = Curvature(R=R, N=N, Sh=Sh)\n",
"D = curv.inverse\n", "D = curv.inverse\n",
"\n", "\n",
...@@ -602,10 +602,10 @@ ...@@ -602,10 +602,10 @@
"m_mean, m_var = ift.probe_with_posterior_samples(curv, HT, 20)\n", "m_mean, m_var = ift.probe_with_posterior_samples(curv, HT, 20)\n",
"\n", "\n",
"# Get data\n", "# Get data\n",
"s_data = HT(sh).to_global_data()\n", "s_data = HT(sh).val\n",
"m_data = HT(m).to_global_data()\n", "m_data = HT(m).val\n",
"m_var_data = m_var.to_global_data()\n", "m_var_data = m_var.val\n",
"d_data = d.to_global_data()\n", "d_data = d.val\n",
"uncertainty = np.sqrt(np.abs(m_var_data))" "uncertainty = np.sqrt(np.abs(m_var_data))"
] ]
}, },
...@@ -653,8 +653,8 @@ ...@@ -653,8 +653,8 @@
"ma = np.max(s_data)\n", "ma = np.max(s_data)\n",
"\n", "\n",
"fig, axes = plt.subplots(3, 2, figsize=(15, 22.5))\n", "fig, axes = plt.subplots(3, 2, figsize=(15, 22.5))\n",
"sample = HT(curv.draw_sample(from_inverse=True)+m).to_global_data()\n", "sample = HT(curv.draw_sample(from_inverse=True)+m).val\n",
"post_mean = (m_mean + HT(m)).to_global_data()\n", "post_mean = (m_mean + HT(m)).val\n",
"\n", "\n",
"data = [s_data, m_data, post_mean, sample, s_data - m_data, uncertainty]\n", "data = [s_data, m_data, post_mean, sample, s_data - m_data, uncertainty]\n",
"caption = [\"Signal\", \"Reconstruction\", \"Posterior mean\", \"Sample\", \"Residuals\", \"Uncertainty Map\"]\n", "caption = [\"Signal\", \"Reconstruction\", \"Posterior mean\", \"Sample\", \"Residuals\", \"Uncertainty Map\"]\n",
...@@ -731,7 +731,7 @@ ...@@ -731,7 +731,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.6" "version": "3.7.5"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -61,9 +61,9 @@ if __name__ == '__main__': ...@@ -61,9 +61,9 @@ if __name__ == '__main__':
# Generate mock data # Generate mock data
p = R(sky) p = R(sky)
mock_position = ift.from_random('normal', harmonic_space) mock_position = ift.from_random('normal', harmonic_space)
tmp = p(mock_position).to_global_data().astype(np.float64) tmp = p(mock_position).val.astype(np.float64)
data = np.random.binomial(1, tmp) data = np.random.binomial(1, tmp)
data = ift.Field.from_global_data(R.target, data) data = ift.Field.from_arr(R.target, data)
# Compute likelihood and Hamiltonian # Compute likelihood and Hamiltonian
position = ift.from_random('normal', harmonic_space) position = ift.from_random('normal', harmonic_space)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment