Iterating through a large array filling it with identically sized, but different, smaller arrays

Iterating through a large array filling it with identically sized, but different, smaller arrays

I have a large array full of zeros simply defined by:

I have a large array full of zeros simply defined by:

BigArray = np.zeros((100,1000,1000),np.float16)

I then have a 3D volume that I randomly rotate outside of python and each time it is rotated I want to import the file into python and add it to the next bit of the array. I currently have the following code that will do it:

n = 0

while n < 99: Zaxisangle = randint(0,360) Yaxisangle = randint(0,360) Xaxisangle = randint(0,360)

os.system('rotatevol -angles {},{},{} -input {} -output {}'.format(Zaxisangle, Yaxisangle, Xaxisangle,
                                                               MRCfilewithextension, MRCforoutput))
particledata = mrcopen(MRCforoutput)



if n &lt; 10:
    ArtTomo[:, 0:100, (100*(n+1))-100:100*(n+1)] = particledata
    n = n+1
else:
    n = n+1

For the purpose of this example we can simplify it down to the following:

BigArray = np.zeros((100,1000,1000),np.float16)
particledata = np.random.rand(100,100,100)
n = 0
while n < 99:
    if n < 10:
        ArtTomo[:, 0:100, (100(n+1))-100:100(n+1)] = particledata
        n = n+1
    elif: 10 < n < 20
        ArtTomo[:, 100:200, (100(n+1))-100:100(n+1)] = particledata
        n = n+1
    else:
        n = n+1

I would then write lots of elif statements for each 'row'. Because I am iterating through the array with different files I can't simply fill it with a 'in range(0,1000,100)' statement annoyingly.

whilst I can write out all the elif statements I feel as if there must be a more efficient way to write this code I am just not good enough to see it. Could anyone else write this in a nicer way or am I just going to have to write 10 elif statments (i just don't feel like it is neat code!).

python numpy

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

NumPy Array Tutorial - Python NumPy Array Operations and Methods

Learn about NumPy Array, NumPy Array creation, various array functions, array indexing & Slicing, array operations, methods and dimensions,It also includes array splitting, reshaping, and joining of arrays. Even the other external libraries in Python relate to NumPy arrays.

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

NumPy Applications - Uses of Numpy

Learn the uses of numpy - Alternate for lists in python, multi dimensional array, mathematical operations. See numpy applications with python libraries.

NumPy Installation - How to Install Numpy in Python

Python is an open-source object-oriented language. It has many features of which one is the wide range of external packages. There are a lot of packages for installation and use for expanding functionalities. These packages are a repository of functions in python script. NumPy is one such package to ease array computations.

NumPy Features - Why we should use Numpy?

Learn numpy features to see why you should use numpy - high performance, multidimensional container, broadcasting functions, working with varied databases