mscross / pysplit

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

[Errno 2] No such file or directory: 'examplenov1500spring2017112403' error when generating bulk traj #69

Closed petegombert closed 3 years ago

petegombert commented 4 years ago

I am having receiving this error when attempting to generate bulk trajectories by pysplit.generate_bulktraj. I am under the assumption that using generate_bulktraj should return new files in my traj directory. I am seeing the error after the hysplit model is finished.

I am new to pysplit and don't have a lot of experience coding in general, any help would be appreciated. Below is my code.

import os import numpy as np import netCDF4 as nc import pysplit as py from matplotlib import pyplot as plt os.chdir('/Users/petergombert')

directories

working_direc = r'hysplit4/working' final_direc = r'traj' metero_direc = r'/Users/petergombert/hysplit4/gdas1'

py.generate_bulktraj('example', working_direc, final_direc, metero_direc, [2017], [11], [3, 6, 9, 12], [1500], (-63.79, 111.78), 24, monthslice = slice(23, 24, 1), get_reverse=False, get_clipped=False, hysplit='/Users/petergombert/hysplit4/exec/hyts_std')

jdegraw commented 4 years ago

I am having the same problem. I have code that I had been using to create bulk trajectories for quite some time, very similar to the the code provided in the examples on this site. When I ran the code yesterday, this error occurred. The error still occurred after pysplit was uninstalled and reinstalled. I am running the code in a Jupyter Notebook.

zhx215 commented 4 years ago

Hi,

I worked with pysplit for a small research project a while ago. I used generate.bulktraj to create 50k trajectories without any issue. Although I am not familiar with debugging, you can find my code at https://github.com/zhx215/Patagonia_HYSPLIT/blob/master/Trajectory%20generation%20and%20preparation.ipynb

I run code on Windows PC so directory format will be different. Hope it could help.

petegombert commented 4 years ago

zhx215, I tried running your code (with different variables) and got the same error as before.

petegombert commented 4 years ago

Not sure if this matters but I have noticed that the filename associated with the error is 'examplenov1500spring2017112403' which is odd because I believe the season should be fall?

mscross commented 4 years ago

generate_bulktraj() looks for the current working directory ('/Users/petergombert'), makes the output directory if it doesn't already exist ('/Users/petergombert/traj'), then changes the cwd to the hysplit4 working directory ('/Users/petergombert/hysplit4/working'). From within the hysplit working directory it calls HYSPLIT to make the trajectory, then tries to move it to the output directory.

What I think is happening here: because a relative path is provided for the output directory, shutil.move() is trying to send the file to '/Users/petergombert/hysplit4/working/traj/trajname' instead of '/Users/petergombert/traj/trajname'. Try trajectory generation again using an absolute path for your output directory and let us know if that works, and I will update the documentation for this function to indicate that absolute paths should be used.

The filename indicates 'spring' for November because -63.79 is a southern hemisphere latitude.

Hope this helps!

petegombert commented 4 years ago

That worked, thanks!

petegombert commented 3 years ago

I'm actually running into the same error again when running the below code. I had already run roughly 85,000 trajectories on the code and then today it stopped working. I have uninstalled and reinstalled the code on my python 3.7 environment.

Code:

import pysplit as py

hysplit_working = '/Users/petergombert/hysplit4/working' output_dir = '/Users/petergombert/trajectories' meteo_dir = '/Volumes/u1113223/Documents/mf'

lat = -62 lon = 137.5 time = 23 year = 2018 month = 1 runtime = -120 altitude = 1000 name = 'test'

py.generate_bulktraj(name, hysplit_working, output_dir, meteo_dir, [year], [month], [time], [altitude], (lat,lon), runtime, monthslice = slice(28, 29, 1), get_reverse=False, get_clipped=False, hysplit='/Users/petergombert/hysplit4/exec/hyts_std')