-1

I am trying to create a basic bitwise function that filters out a certain subset of my data for me.

>>>heads=fits.open('datafile.fits')
>>>data=heads[1].data

Now, I need to mask out data points that are in a certain column and which are set to bit 0.

>>>ind=np.where(data['COLUMN_NAME'] & np.power(2,9) = 0)

However, this input throws the error

File "<stdin>", line 1
SyntaxError: keyword cant be an expression

The error does not give the normal ^ which shows where the error is, so I'm not sure which part of my input python is having an issue with.

hlew528
  • 3
  • 2
  • Possible duplicate of [Python: SyntaxError: keyword can't be an expression](http://stackoverflow.com/questions/11633421/python-syntaxerror-keyword-cant-be-an-expression) – Andrew Li Aug 24 '16 at 20:08
  • 2
    The question of `==` and `=` has been asked tons and tons of times – Andrew Li Aug 24 '16 at 20:09

2 Answers2

1

equal comparsion is ==:

ind=np.where(data['COLUMN_NAME'] & (2**9) == 0)
Daniel
  • 42,087
  • 4
  • 55
  • 81
1

Could it be because you use '=' (assignment) instead of '==' (equality) in the call to 'where'?

BP8467
  • 1,949
  • 3
  • 15
  • 17