human
I am working on the file "Scripts/Final_cube_analysis.ipynb".
The first task is:
sign flipper on extrapolated SMO cube
you used the cells below to correct NAC on the main plane... it was still flipping
Can you write Python program for it?
assistant
#Here is the Python program you requested.

# print(data.keys())
# data_new = data
# nacs_new = data['smoCube']
# NACS_new = nacs_new[15:-15,15:-15,30:-30]
# print(NACS_new.shape,nacs_new.shape)

# phi_ext_000_000 = 29
# phi_prev = 28
# phi_next = 30

# new_nacs = np.copy(nacs)

# for g in range(56):
#     for t in range(160):
#         not_correct  = nacs[phi_ext_000_000,g,t]
#         correct_prev = nacs[phi_prev       ,g,t]
#         correct_next = nacs[phi_next       ,g,t]
#         #if np.linalg.norm(not_correct) > 0.001:
#         #        print('{} {}\nThis {} \nMiddle {}\n After {}'.format(g,t,correct_prev[:,:,1], not_correct[:,:,1],correct_next[:,:,1]))
#         for state1 in range(8):
#             for state2 in range(8):
#                 for cart in range(3):
#                     value_prev = correct_prev[state1,state2,cart]
#                     value_this = not_correct [state1,state2,cart]
#                     value_next = correct_next[state1,state2,cart]
#                     average = (value_prev + value_next)/2
#                     if np.sign(average) == np.sign(value_this):
#                         new_value = value_this
#                     else:
#                         new_value = -value_this 
#                     new_nacs[phi_ext_000_000,g,t,state1,state2,cart] = new_value
                    
                    

# def do3dplot(xs,ys,zss):
#     'with mesh function'
#     fig = plt.figure(figsize=(9,9))
#     ax = fig.add_subplot(111, projection='3d')
#     X,Y = np.meshgrid(ys,xs)
#     #ax.set_zlim(-1, 1)
#     #ax.scatter(X, Y, zss)
#     ax.plot_wireframe(X, Y, zss)
#     fig.tight_layout()

# def visualize_this_thing(thing,state1,state2,cart,kind,dim):
#     print(thing.shape)

#     along = ['Phi','Gam','The']
#     print('NAC between state ({},{}) along {}\nDoing cut in {} with value ({:8.4f},{:8.4f})'.format(state1,
#                                                                 state2,
#                                                                 along[cart],
#                                              ...