<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Some comments from homework 4
Don't do lines too long, it's considered bad style as horizontal
scrolling is awkward. Most projects demand lines < 80 or, more rarely, < 100 chars.
This also helps the case when you want to compare two codes next to
 each other
Include a space between argumenst for increased readability
Step1:  little matplotlib config trick
As the colormap default is still the awful 'jet' colormap (creates artificial visual boundaries that don't exist in the data -> it fools you.), I want to switch the default to 'viridis'.
(exercise to the reader
Step2:  Now, this config dictionary is huge
Step3:  Visualizing Multi-Dimensional Arrays
Step4:  Q. What is the rank of x?
Q. What is the shape of x?
Step5:  Notice that the first row of the array was plotted 
at the top of the image.
This may be counterintuitive if when you think of 
row #0 you think of y=0, which in a normal x-y coordinate 
system is on the bottom.
This be changed using the "origin" keyword argument.
The reason for this is that this command was made for displaying 
CCD image data, and often the pixel (0,0) was considered to be the
one in the upper left.
But it also matches the standard print-out of arrays, so that's good as well.
Step6:  To look up other interpolations, just use the help feature.
And by the way, there shouldn't be any space after the question mark!
Step7:  Q. And what should this yield?
Step8:  Arrays can be indexed in one of two ways
Step9:  Q. What should this be?
Step10:  Can access x and y index information using numpy.indices
Step11:  Q. How to isolate the element in xT corresponding to i = 1 and j = 2?
Step12:  Q. How about the indices of all even elements in xT?
Step13:  Note you only need this if you want to use these indices somewhere else, e.g. in another array of same shape.
Because if you just wanted the values, you of course would do that
Step14:  How to find particular elements in a 2-D array?
Step15:  Array Computing
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as pl
Explanation: Some comments from homework 4
Don't do lines too long, it's considered bad style as horizontal
scrolling is awkward. Most projects demand lines < 80 or, more rarely, < 100 chars.
This also helps the case when you want to compare two codes next to
 each other
Include a space between argumenst for increased readability:
Good: myfunc(a, b, c, d, e)
Bad:  myfunc(a,b,c,d,e)
Only use elif if there's another differing case to check. Otherwise, just use else.
Help yourself by doing unit conversions before the actual equation.
Otherwise, already awkward looking equations become even harder to read.
imports at top of module, not inside functions!
Makes the reader immediately understand the dependencies of your code.
This paradigm is being softened for parallel processing, where it becomes easier to send a logically complete function (with imports at beginning of function) to the different processors.
Comments on HW 5
python
Narr = [N(i) for i in xArr] # list comprehension, **NOT** okay for vectorial
is not the same as
python
Narr = N(xArr)  # optimal
is not the same as
python
Narr = np.exp(xArr**2/[....])   # kinda cheating...
And when the instructions say, call f() on each element of a vector, it means that.
So:
python
xList = [f(i) for i in vector]
Q. Review:  what is the rank of $A_{i,j,k,l}$?
End of explanation
from matplotlib import rcParams
Explanation: little matplotlib config trick
As the colormap default is still the awful 'jet' colormap (creates artificial visual boundaries that don't exist in the data -> it fools you.), I want to switch the default to 'viridis'.
(exercise to the reader: this also can be done in a config file that is being read everytime matplotlib is being loaded!)
End of explanation
rcParams.keys()
[key for key in rcParams.keys() if 'map' in key]
rcParams['image.cmap']
rcParams['image.cmap'] = 'viridis'
rcParams['image.interpolation'] = 'none'
Explanation: Now, this config dictionary is huge:
End of explanation
x = np.array([[1,2,3], [4,5,6], [7,8,9], [10,11,12]])
x
Explanation: Visualizing Multi-Dimensional Arrays
End of explanation
x.shape
x.ndim
print(x)  # for reference
pl.imshow(x)
pl.colorbar();
Explanation: Q. What is the rank of x?
Q. What is the shape of x?
End of explanation
print(x)  # for reference
pl.imshow(x, origin='lower')
pl.colorbar();
# Interpolation (by default) makes an image look 
# smoother.
# Instead:
pl.imshow(x, origin='lower', interpolation='bilinear')
pl.colorbar()
Explanation: Notice that the first row of the array was plotted 
at the top of the image.
This may be counterintuitive if when you think of 
row #0 you think of y=0, which in a normal x-y coordinate 
system is on the bottom.
This be changed using the "origin" keyword argument.
The reason for this is that this command was made for displaying 
CCD image data, and often the pixel (0,0) was considered to be the
one in the upper left.
But it also matches the standard print-out of arrays, so that's good as well.
End of explanation
pl.imshow?
x # for reference
print(x)
print()
print(x.T)
xT = x.T
pl.imshow(xT)
pl.colorbar()
Explanation: To look up other interpolations, just use the help feature.
And by the way, there shouldn't be any space after the question mark!
End of explanation
xT.shape
Explanation: Q. And what should this yield?
End of explanation
xT  # Reminder
Explanation: Arrays can be indexed in one of two ways:
End of explanation
xT[2][1]
xT[2,1]
Explanation: Q. What should this be?
End of explanation
xT
print(np.indices(xT.shape))
print("-" * 50)
for i in range(xT.shape[0]):
    for j in range(len(xT[0])):
        print(i, j)
i, j = np.indices(xT.shape)
i
j
Explanation: Can access x and y index information using numpy.indices:
End of explanation
xT
xT[1,2]
print(xT[np.logical_and(i == 1, j == 2)])
# Q. How did this work?
print(np.logical_and(i == 1, j == 2))
i == 1
Explanation: Q. How to isolate the element in xT corresponding to i = 1 and j = 2?
End of explanation
xT # for reference
np.argwhere(xT % 2 == 0)
Explanation: Q. How about the indices of all even elements in xT?
End of explanation
xT[xT % 2 == 0]
Explanation: Note you only need this if you want to use these indices somewhere else, e.g. in another array of same shape.
Because if you just wanted the values, you of course would do that:
End of explanation
xT # for reference
np.argwhere(xT > 5)
xT
Explanation: How to find particular elements in a 2-D array?
End of explanation
xT
pl.imshow(xT)
pl.colorbar()
pl.clim(1, 12)        # colorbar limits, 
                      # analogous to xlim, ylim
print(xT + 5)
pl.imshow(xT+5)
pl.colorbar()
# pl.clim(1, 12)    
Explanation: Array Computing
End of explanation
<END_TASK>