mscross / pysplit

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

ValueError: invalid literal for int() with base 10: '42.820' #54

Open djasantos opened 5 years ago

djasantos commented 5 years ago

Hi

I'm using python 3.6 in a virtual environment of anaconda to run pysplit. I'm using JupyterLab to run the scripts.

I tried to run the "bulk_trajgen_example.py" script, but I find the following error message.

Someone find the same error ?

I'm beggniner in python


ValueError Traceback (most recent call last)

in 151 years, months, hours, altitudes, location, runtime, 152 monthslice=slice(0, 32, 2), get_reverse=True, --> 153 get_clipped=True) 154 155 """ ~\Anaconda3\lib\site-packages\pysplit\trajectory_generator.py in generate_bulktraj(basename, hysplit_working, output_dir, meteo_dir, years, months, hours, altitudes, coordinates, run, meteoyr_2digits, outputyr_2digits, monthslice, meteo_bookends, get_reverse, get_clipped, hysplit) 168 if get_reverse: 169 _reversetraj_whilegen(trajname, run, hysplit, output_rdir, --> 170 meteo_dir, meteofiles, controlfname) 171 172 if get_clipped: ~\Anaconda3\lib\site-packages\pysplit\trajectory_generator.py in _reversetraj_whilegen(trajname, run, hysplit, output_rdir, meteo_dir, meteofiles, controlfname) 228 year = int(data[2]) 229 mon = int(data[3]) --> 230 day = int(data[4]) 231 hour = int(data[5]) 232 lat = float(data[9]) ValueError: invalid literal for int() with base 10: '42.820'
mscross commented 5 years ago

I've never seen this error before. Can you attach the file that this is occurring on?

aherrera1721 commented 5 years ago

I was having the same issue. Change int(data[4]) to int(float(data[4])).

Sciprios commented 4 years ago

I found the same issue.

When digging through the code I added a print statement of the data variable before line 228 (in trajectory_generator.py) knowing this variable was the cause of the error. Then, trialling the inputs I knew would throw the error I found the data variable doesn't contain everything that is expected by Pysplit. Instead it only contains the date and time of extraction with the initial lat/lon. Apologies but I didn't copy a broken example but a complete line should look like this: ['1', '1', '96', '1', '12', '6', '0', '0', '-48.0', '37.377', '-26.028', '1547.1', '850.3'] which is the line at the end of a full trajectory file.This led me to the conclusion that there was an issue with the HYSPLIT run rather than a bug with Pysplit.

From here I ran HYSPLIT manually using the same parameters as I passed to PYSPLIT and found that it was throwing an error regarding the meteorological files and the parameters fitting. The problem with HYSPLIT is that it still produces an output file even if there's something wrong with the run. But just to double check I was going down the right path I re-downloaded the meteorological file and behold, it worked perfectly.

Still I believe this bug still persists. If a HYSPLIT generation fails this could cause other unknown issues. @mscross have you considered how you might want Pysplit to handle these occurrences? I have got around this by simply ignoring and then listing all failed runs in an errors folder but this isn't hugely useful for most people.

So after a long ramble my suggestion would be to re-download your meteorological data, just to double check.

lindecai commented 4 years ago

I know how to reproduce the issue.

In the bulk_trajgen_example.py, the params: years=[2008] months=[1] hours=[11,17,23] get_reverse=True runtime=-120 monthslice=slice(0, 32, 1)

and if I have gdas datas in the meteo_dir: gads1.jan08.w1 gads1.jan08.w2 gads1.jan08.w3 gads1.jan08.w4 gads1.jan08.w5

then I run the script. when generate trajectory at jan 31th 23:00 in the code,that is colgatejan1500winter2008013123, the trajectogy points generaged by hysplit is empty,and then _reversetraj_whilegen function throw the exception.

But if I append one gdas data: gdas1.feb08.w1

then the problem gone.

Hysplit failed to generate traj points because of lacking of the last time session data. Then when we want to reverse traj,it will fail (int data convert).

jon-maurer commented 3 years ago

Hi I've run into a similar looking issue but none of these fixes seem to work. My error is: ValueError: invalid literal for int() with base 10: 'n'

I've made sure all my files are named properly (gdas1.jan2013.wk1) but the error still pops up. Does anyone have any ideas? I'm super lost. The only thing I could think of would be the file extension (.bin) but those are just there by default.

Any help would be super appreciated!