mscross / pysplit

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

Problem loading 'hysplitfile' #60

Open cross85 opened 5 years ago

cross85 commented 5 years ago

I'm using the 0.35 version of pysplit. I run it once without a problem, but now with another run of hysplit I get this error message:

File "C:\Miniconda3\envs\pysplitenv\lib\site-packages\pysplit\hy_processor.py", line 63, in make_trajectorygroup
    data, path, head, datetime, multitraj = load_hysplitfile(hyfile)

  File "C:\Miniconda3\envs\pysplitenv\lib\site-packages\pysplit\hyfile_handler.py", line 146, in load_hysplitfile
    if len(contents[ind + 1]) > len(contents[ind + 2]):

IndexError: list index out of range

This happens when I run this line from the cluster analysis docs/examples/hysplit_clustering.py trajgroup = pysplit.make_trajectorygroup(r'C:/hysplit4/E-3/endpts/fdump*')

the fdump* files seems to be ok, and I run Hysplit with no problem, so I can't figure out what could be the problem here.

mscross commented 5 years ago

When file loading fails here, that means you have a file that has a header and at most one line of data: The loader found "PRESSURE" at line ind, and this if statement is an attempt to determine whether your t=0 consists of the next one or next two lines in the file.

cross85 commented 5 years ago

Thanks, as you said, it was a couple of file without trajectories. If anyone has the same problem an a lot of files, the easiest way I found to know which file is making the problem, is adding print(filename) to this file hyfile_handler.py like this:

    with open(filename, 'r') as hyfile:

        contents = hyfile.readlines()
        print(filename)

        skip = False
        atdata = False

So the las name of the list is the file without trajectories. After you solve the problem, you can delete that line.

tingvan commented 4 years ago

Hello, I got the same problem as yours. In my case, I followed your method to determine which file is making problem, and I found that the files named the last hours in last day of every month I assigned are problem files (i.e. umnjan0500winter2011013123 & umnjul0500summer2012073123). What should I do next, to solve this problem?

cross85 commented 4 years ago

Hi @tingvan, you can just delete the files and create the INFILE again. There will be no problem, because you won't use them to create the clusters anyways.