mscross / pysplit

A package for HYSPLIT air parcel trajectory analysis.
BSD 3-Clause "New" or "Revised" License
149 stars 80 forks source link

sort() method for trajGroup #63

Open nicrie opened 4 years ago

nicrie commented 4 years ago

Hi Melissa, Would it be possible to include a sort() method to TrajectoryGroup which is sorting the trajectories based on their IDs in trajids?

The trajectory files that I have are named in a logical, unique way, e.g. YYYY-MM-DD-HH.txt. I thought of something like pandas DataFrame sorting function. An easy way would be to load trajectories and trajids in a DataFrame and apply its sort function. That would imply though to import pandas. For now, when I create my TrajectoryGroup I use

import pysplit as pys
traj_dir = r'/my/directory/to/files/*'
trajGroup = pys.make_trajectorygroup(traj_dir)

which imports all trajectory files in that directory but in a random order. For plotting it would be cool to have the trajGroup in order.

Cheers, Nic

mscross commented 4 years ago

It's been a while- if you have any ideas you've implemented I'd welcome a PR. In my experience I have not noticed the trajectories imported in any order but either alphabetical or perhaps by date modified.