Hi,
I am trying to make a particle filter for just the old stars for which my simulation requires pruning with two fields "particle_mass" and "particle_age".
def old(pfilter, data): >
age = data["all", "particle_age"]
old_only = data["all", "particle_mass"]
filter = np.logical_and(age.in_units('Myr') = 0,
old_only.in_units('Msun') < 4e6)
return filter
But I encounter an error:
File "new-old-stars.py", line 14
filter = np.logical_and(age.in_units('Myr') =
0,
old_only.in_units('Msun') < 4e6) ^ SyntaxError: keyword can't be an expression
Could someone please point out what the issue here could be? Can I not use a filter with two different fields?
Hi Vadlamani,
I think that what is happening here is that “filter” is a reserved keyword in Python and so it can’t be used as a variable name. I would try using “pfilter” or something similar.
Best,
John
Dr. John ZuHone Astrophysicist, Chandra X-ray Center Center for Astrophysics | Harvard & Smithsonian
Office: (617) 496 1816 | Cell: (781) 708 5004 60 Garden Street | MS 03 | Cambridge, MA 02138 john.zuhone@cfa.harvard.edu http://hea-www.cfa.harvard.edu/~jzuhone
On Nov 28, 2018, at 2:54 AM, Vadlamani Samhitha vadlamani.samhitha@gmail.com wrote:
Hi,
I am trying to make a particle filter for just the old stars for which my simulation requires pruning with two fields "particle_mass" and "particle_age".
def old(pfilter, data): age = data["all", "particle_age"] old_only = data["all", "particle_mass"] filter = np.logical_and(age.in_units('Myr') = 0, old_only.in_units('Msun') < 4e6) return filter
But I encounter an error:
File "new-old-stars.py", line 14 filter = np.logical_and(age.in_units('Myr') = 0, old_only.in_units('Msun') < 4e6) ^ SyntaxError: keyword can't be an expression
Could someone please point out what the issue here could be? Can I not use a filter with two different fields?
yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Hi,
It may be that you wrote age.in_units('Myr') = 0
instead of
age.in_units('Myr') == 0
.
Best, Corentin
On 28/11/2018 08.54, Vadlamani Samhitha wrote:
Hi,
I am trying to make a particle filter for just the old stars for which my simulation requires pruning with two fields "particle_mass" and "particle_age".
defold(pfilter, data):
age = data["all", "particle_age"]
old_only = data["all", "particle_mass"]
filter= np.logical_and(age.in_units('Myr') = 0,
old_only.in_units('Msun') < 4e6)
returnfilter
But I encounter an error:
File "new-old-stars.py", line 14
filter = np.logical_and(age.in_units('Myr') = 0,
old_only.in_units('Msun') < 4e6)
^
SyntaxError: keyword can't be an expression
Could someone please point out what the issue here could be? Can I not use a filter with two different fields?
yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org