<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 BORG SDSS data products
borg_sdss_velocity package
Authors
Step1:  To access the 3D final velocity use
Step2:  Individual voxels in these 3D volumetric data cube can be accessed as follows
Step3:  where i,j and k index voxel positions along the x,y and z axes respectively. All indices run from 0 to 255.
The ranges describing the extent of the cubic cartesian volume along the x,y and z axes can be accessed as follows
Step4:  Units are km/s for the mean field and (km/s)$^2$ for the variance field.
(Note that all the maps that are part of the BORG SDSS data products have consistent coordinate systems. The coordinate transform to change from Cartesian to spherical coordinates and vice versa is given in appendix B of Jasche et al. 2015).
Example plot
Step5:  Example plot
<ASSISTANT_TASK:>
Python Code:
import numpy as np
velocity = np.load('borg_sdss_velocity.npz')
Explanation: BORG SDSS data products
borg_sdss_velocity package
Authors: Florent Leclercq, Jens Jasche, Guilhem Lavaux, Benjamin Wandelt, Will Percival
Last update: 09/10/2018
This package contains some of the results obtained by Leclercq et al. (2017): the posterior mean and variance for the velocity field in the SDSS volume, in terms of a 3D volumetric data cube
Data are provided in terms of a standard 3D numpy array and can easily be accessed and processed using python.
For further details on the data and employed inference methodologies please consult Leclercq et al. (2017) (reference below).
File content
This package consists of two files:
* borg_sdss_velocity.ipynb: The file you are currently reading.
* borg_sdss_velocity.tar.gz: Archive available on GitHub LFS and on the author's website.
The archive borg_sdss_velocity.tar.gz can be extracted using
bash
tar -xzf borg_sdss_velocity.tar.gz
It contains the file borg_sdss_velocity.npz.
Usage
Loading and accessing the data
The file borg_sdss_velocity.npz contains inferred large-scale structure data in a standard uncompressed .npz format. To load and process the data execute the following commands:
End of explanation
#3D probabilistic maps for velocity field
vx_mean=velocity['vx_mean']
vx_var=velocity['vx_var']
vy_mean=velocity['vy_mean']
vy_var=velocity['vy_var']
vz_mean=velocity['vz_mean']
vz_var=velocity['vz_var']
Explanation: To access the 3D final velocity use:
End of explanation
k=10;j=127;i=243
vx_mean_ijk=vx_mean[k,j,i]
Explanation: Individual voxels in these 3D volumetric data cube can be accessed as follows:
End of explanation
#Minimum and maximum position along the x-axis in Mpc/h
xmin=velocity['ranges'][0]
xmax=velocity['ranges'][1]
#Minimum and maximum position along the y-axis in Mpc/h
ymin=velocity['ranges'][2]
ymax=velocity['ranges'][3]
#Minimum and maximum position along the z-axis in Mpc/h
zmin=velocity['ranges'][4]
zmax=velocity['ranges'][5]
Explanation: where i,j and k index voxel positions along the x,y and z axes respectively. All indices run from 0 to 255.
The ranges describing the extent of the cubic cartesian volume along the x,y and z axes can be accessed as follows:
End of explanation
from matplotlib import pyplot as plt
%matplotlib inline
f, (ax1, ax2, ax3) = plt.subplots(1, 3, sharey=True, figsize=(15,5))
ax1.imshow(vx_mean[:,:,128], origin='lower', extent=[ymin,ymax,zmin,zmax], cmap="magma")
ax1.set_title('$v_x$')
ax1.set_aspect('equal')
ax2.imshow(vy_mean[:,:,128], origin='lower', extent=[ymin,ymax,zmin,zmax], cmap="magma")
ax2.set_title('$v_y$')
ax3.imshow(vz_mean[:,:,128], origin='lower', extent=[ymin,ymax,zmin,zmax], cmap="magma")
ax3.set_title('$v_z$')
plt.show()
Explanation: Units are km/s for the mean field and (km/s)$^2$ for the variance field.
(Note that all the maps that are part of the BORG SDSS data products have consistent coordinate systems. The coordinate transform to change from Cartesian to spherical coordinates and vice versa is given in appendix B of Jasche et al. 2015).
Example plot: mean
End of explanation
from matplotlib import pyplot as plt
%matplotlib inline
f, (ax1, ax2, ax3) = plt.subplots(1, 3, sharey=True, figsize=(15,5))
ax1.imshow(vx_var[:,:,128], origin='lower', extent=[ymin,ymax,zmin,zmax], cmap="viridis")
ax1.set_title('$v_x$')
ax1.set_aspect('equal')
ax2.imshow(vy_var[:,:,128], origin='lower', extent=[ymin,ymax,zmin,zmax], cmap="viridis")
ax2.set_title('$v_y$')
ax3.imshow(vz_var[:,:,128], origin='lower', extent=[ymin,ymax,zmin,zmax], cmap="viridis")
ax3.set_title('$v_z$')
plt.show()
Explanation: Example plot: variance
End of explanation
<END_TASK>