Using python array's column as boolean to change another column's values -


i farily new python, may why haven't been able search in site answer problem, in case know already.

i reading several data files consisting in 6 columns: xyz coordinates , 3-vector components around sphere. using x , z coordinates find angle location of vectors, , using angle results new column array, fourth column. so, have 7 column array.

the angles calculated np.arctan , (-) or (+) sign depending on quadrant xz coordinates located.

now, want make angles around upper half of sphere (z positive) positive , spanning 0º 180º. on other hand, want angles around lower half negative, , going 0º -180º.

the operations change sign , apply 0º-180º range easy implement. but, want use third column of array (z coordinates) boolean decide how change angles (fourth column of array). have read quite lot of info slicing arrays, or modifying columns/rows based on arbitrary boolean conditions applied same columns/rows.

i trying avoid combining for-loops , if-statements, , learn how use power of python :)

thanks in advance!

np.where(cond, if_true, if_false) solves problem think have:

fixed_angle = np.where(z > 0, angle, -angle) 

the problem actually have not using atan2, or it's spelt in numpy, np.arctan2


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -