traja-team / traja

Python tools for spatial trajectory and time-series data analysis
https://traja.readthedocs.io
MIT License
98 stars 25 forks source link

Not able to animate using traja.plotting.animate #20

Closed dhivya-jayaraman closed 3 years ago

dhivya-jayaraman commented 4 years ago
traja.plotting.animate(trj: TrajaDataFrame, polar = True, save = False)

Error:
File "<ipython-input-179-b9f35fc742bf>", line 2
    gsts_ais_grp.traja.plotting.animate(trj: TrajaDataFrame, polar = True, save = False)
                                           ^
SyntaxError: invalid syntax

I'm trying to animate a trajectory by using plotting.animate(). I'm not sure if trj is the dataframe or should it be like gsts_ais_grp.traja.plotting.animate(trj: TrajaDataFrame, polar = True, save = False). Either way I'm getting syntax error. Please help me with this. Thanks in advance!

JustinShenk commented 4 years ago

The ability to call all methods through the traja accessor (df.traja...) was not previously possible. This feature has just been added to traja==0.2.0. Please upgrade to the new version and try again (ex: gsts_ais_grp.traja.animate()). Let me know if you have any further issues.

On Mon, Jan 13, 2020 at 8:10 PM dhivya-jayaraman notifications@github.com wrote:

traja.plotting.animate(trj: TrajaDataFrame, polar = True, save = False)

Error: File "", line 2 gsts_ais_grp.traja.plotting.animate(trj: TrajaDataFrame, polar = True, save = False) ^ SyntaxError: invalid syntax

I'm trying to animate a trajectory by using plotting.animate(). I'm not sure if trj is the dataframe or should it be like gsts_ais_grp.traja.plotting.animate(trj: TrajaDataFrame, polar = True, save = False). Either way I'm getting syntax error. Please help me with this. Thanks in advance!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/justinshenk/traja/issues/20?email_source=notifications&email_token=ACOLMZHBXBZWNQWEEPOEHHLQ5S4CBA5CNFSM4KGHLFRKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IF27TCA, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOLMZAAV75JVN2RMLF2FB3Q5S4CBANCNFSM4KGHLFRA .

dhivya-jayaraman commented 4 years ago
pip install -I traja==0.2.0
Collecting traja==0.2.0
  ERROR: Could not find a version that satisfies the requirement traja==0.2.0 (from versions: 0.0.1, 0.0.2a1, 0.0.2a2, 0.0.2a4, 0.0.4, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.14, 0.0.17, 0.0.20, 0.1.0, 0.1.1.dev0, 0.1.1.dev1, 0.1.1, 0.1.1.post0, 0.1.2.dev0, 0.1.2, 0.1.2.post0, 0.1.2.post2, 0.1.2.post4, 0.1.3.dev3, 0.1.4, 0.1.7, 0.1.8)
ERROR: No matching distribution found for traja==0.2.0

I'm not able to upgrade the version to 0.2.0. Tried using both pip and conda. It says that the specified version is not found.

JustinShenk commented 4 years ago

Sorry, I just realized the PyPI build did not complete. Please try again: https://pypi.org/project/traja/.

On Tue 14. Jan 2020 at 20:39, dhivya-jayaraman notifications@github.com wrote:

pip install -I traja==0.2.0 Collecting traja==0.2.0 ERROR: Could not find a version that satisfies the requirement traja==0.2.0 (from versions: 0.0.1, 0.0.2a1, 0.0.2a2, 0.0.2a4, 0.0.4, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.14, 0.0.17, 0.0.20, 0.1.0, 0.1.1.dev0, 0.1.1.dev1, 0.1.1, 0.1.1.post0, 0.1.2.dev0, 0.1.2, 0.1.2.post0, 0.1.2.post2, 0.1.2.post4, 0.1.3.dev3, 0.1.4, 0.1.7, 0.1.8) ERROR: No matching distribution found for traja==0.2.0

I'm not able to upgrade the version to 0.2.0. Tried using both pip and conda. It says that the specified version is not found.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/justinshenk/traja/issues/20?email_source=notifications&email_token=ACOLMZD3TNPFKWUOYXYWZZTQ5YIHPA5CNFSM4KGHLFRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI53LLQ#issuecomment-574338478, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOLMZFE35GLQEBJ67BQJPDQ5YIHPANCNFSM4KGHLFRA .

dhivya-jayaraman commented 4 years ago
--------------------------------------------------------------------------
AttributeError                           Traceback (most recent call last)
<ipython-input-26-f81b91719e6f> in <module>
----> 1 gsts.traja.animate()

/opt/anaconda3/lib/python3.7/site-packages/traja/accessor.py in method(*args, **kwargs)
    272         def method(*args, **kwargs):
    273             if name in traja.plotting.__all__:
--> 274                 return getattr(traja.plotting, name)(self._obj, *args, **kwargs)
    275             elif name in traja.trajectory.__all__:
    276                 return getattr(traja.plotting, name)(self._obj, *args, **kwargs)

/opt/anaconda3/lib/python3.7/site-packages/traja/plotting.py in animate(trj, polar, save)
   1285         xlim=xlim,
   1286         ylim=ylim,
-> 1287         ylabel=trj.spatial_units or "m",
   1288         xlabel=trj.spatial_units or "m",
   1289         aspect="equal",

/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5177             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5178                 return self[name]
-> 5179             return object.__getattribute__(self, name)
   5180 
   5181     def __setattr__(self, name, value):

AttributeError: 'DataFrame' object has no attribute 'spatial_units'

Hello Justin, sorry to keep bothering you. I'm not sure if I'm doing something wrong here. I have dataframe of id, lat, lon, time (in seconds) and distance (using traja.calc_displacement()). I'm trying to call the animate() function with traja version 0.2.0. It throws an attribute error.

id x y time distance
0001 47.743962 162.365457 0.0 NaN
0001 47.749235 162.447688 851.0 0.082401
JustinShenk commented 4 years ago

Sorry, the error you received was due to Traja expecting a TrajaDataFrame rather than pandas DataFrame. This has now been fixed in traja==0.2.1.

Let me know if you have any further issues.

On Wed, Jan 15, 2020 at 1:53 PM dhivya-jayaraman notifications@github.com wrote:


AttributeError Traceback (most recent call last)

in ----> 1 gsts.traja.animate() /opt/anaconda3/lib/python3.7/site-packages/traja/accessor.py in method(*args, **kwargs) 272 def method(*args, **kwargs): 273 if name in traja.plotting.__all__: --> 274 return getattr(traja.plotting, name)(self._obj, *args, **kwargs) 275 elif name in traja.trajectory.__all__: 276 return getattr(traja.plotting, name)(self._obj, *args, **kwargs) /opt/anaconda3/lib/python3.7/site-packages/traja/plotting.py in animate(trj, polar, save) 1285 xlim=xlim, 1286 ylim=ylim, -> 1287 ylabel=trj.spatial_units or "m", 1288 xlabel=trj.spatial_units or "m", 1289 aspect="equal", /opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in __getattr__(self, name) 5177 if self._info_axis._can_hold_identifiers_and_holds_name(name): 5178 return self[name] -> 5179 return object.__getattribute__(self, name) 5180 5181 def __setattr__(self, name, value): AttributeError: 'DataFrame' object has no attribute 'spatial_units' Hello Justin, sorry to keep bothering you. I'm not sure if I'm doing something wrong here. I have dataframe of id, lat, lon, time (in seconds) and distance (using traja.calc_displacement()). I'm trying to call the animate() function with traja version 0.2.0. It throws an attribute error. — You are receiving this because you commented. Reply to this email directly, view it on GitHub , or unsubscribe .
dhivya-jayaraman commented 4 years ago

I'm still getting the same error with pandas dataframe so I converted to traja dataframe which got it to work but I'm not sure it is animating. It just has 1 frame. The trajectory of the item which plotted using TrajaCollection() is shown in the figure below. Screen Shot 2020-01-15 at 10 40 46 AM

When I try to animate the same but I get this static image with just frame 0 shown below. Screen Shot 2020-01-15 at 10 40 56 AM

JustinShenk commented 4 years ago

Thanks for bringing this to my attention. The frozen screen issue is hopefully fixed in v0.2.2, along with the support for the pandas DataFrame.

Now this should work:

df = pd.DataFrame({"x":[1,10,20,5]10,"y":[2,30,40,20]10}) df.traja.animate()

Can you share a minimal amount of data so I can test it? Also via email is find (shenkjustin@gmail.com).

On Wed, Jan 15, 2020 at 3:43 PM dhivya-jayaraman notifications@github.com wrote:

I'm still getting the same error with pandas dataframe so I converted to traja dataframe which got it to work but I'm not sure it is animating. It just has 1 frame. The trajectory of the item which plotted using TrajaCollection() is shown in the figure below. [image: Screen Shot 2020-01-15 at 10 40 46 AM] https://user-images.githubusercontent.com/23284270/72442794-8fbd1b00-3783-11ea-88b0-5c28e9dca160.png

When I try to animate the same but I get this static image with just frame 0 shown below. [image: Screen Shot 2020-01-15 at 10 40 56 AM] https://user-images.githubusercontent.com/23284270/72442956-d90d6a80-3783-11ea-8295-d08a23457702.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/justinshenk/traja/issues/20?email_source=notifications&email_token=ACOLMZBTNQOU6W2I4TK5UJ3Q54OJDA5CNFSM4KGHLFRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJARHOI#issuecomment-574690233, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOLMZFU67J6PTX2GRR7NO3Q54OJDANCNFSM4KGHLFRA .

JustinShenk commented 3 years ago

Closing due to inactivity