generate multiple 2 dimensional data from given 2 dimensional data
<p>I have CCD with 512 x512 data of single frame (reference ). I need to generate 100000, 512x512 frames provided sum of value of pixel in each frame should give actual value of the corresponding pixel in the reference frame. Could you please help in this.  </p>

<p>I suppose you want to generate <code>1000000</code> frames with <strong>random</strong> values? Here is one approach. For simplicity and memory reasons I will take only <code>3x3</code> data instead of <code>512x512</code> and generate only <code>10</code> frames instead of <code>100000</code>.</p>

<pre><code>#I will generate a random reference with size 3x3, 
#you can take your original CCD data
reference = np.random.random(size=(3,3))
&gt;&gt;&gt; reference
array([[ 0.68618373,  0.69455787,  0.14494262],
       [ 0.83277638,  0.63792746,  0.27089728],
       [ 0.21380624,  0.30595052,  0.26136707]])

#Generate 10 random frames of size 3x3
frames = np.random.random(size=(10,3,3))

#Now normalize those random values such that their sum will result
#in your reference
frames = frames/np.sum(frames, axis=0)*reference

#Check whether the sum of all frames equals the reference
&gt;&gt;&gt; np.sum(frames, axis=0)
array([[ 0.68618373,  0.69455787,  0.14494262],
       [ 0.83277638,  0.63792746,  0.27089728],
       [ 0.21380624,  0.30595052,  0.26136707]])
</code></pre>

<p>However, please consider that the sum over the frames will not equal your reference <strong>exactly</strong>:</p>

<pre><code>&gt;&gt;&gt; np.sum(frames, axis=0)-reference
array([[  0.00000000e+00,  -1.11022302e-16,   0.00000000e+00],
       [  0.00000000e+00,  -1.11022302e-16,   0.00000000e+00],
       [ -2.77555756e-17,   0.00000000e+00,   5.55111512e-17]])
</code></pre>

<p>This is due to precision reasons and could be a problem depending on your actual task...</p>

python