Closed kurkutesa closed 7 years ago
Hi Sopan,
HYSPLIT can generate trajectories with any dataset that is first converted to the ARL-packed format. In the user guide, there is a section entitled: METEOROLOGY / Convert to ARL / NARR Archive that discusses how to use the desktop version of HYSPLIT to convert NARR archive datasets to the appropriate format.
PySPLIT can instruct HYSPLIT to do bulk trajectory generation with ARL-packed files that have names in the following format: *mon*YY*#
, where *
is a Bash-style wildcard, mon
is a three-letter lower-case abbreviation of the month, YY
is a two digit integer representation of the year, and #
is the number of the file within the month. For example, gdas1.jan2007.w2
and edas.jan2007_2
both fit this format. You may also have to adjust the keyword meteo_bookends
, which indicates the file numbers to include from the previous month and the next month. If you are generating 120-hour forward trajectories starting on every day in April, for example, you will need to indicate the file numbers (#
) that contain data for the last day of March (depending on the start hour) and the first five days of May.
So, when you convert your datasets to the ARL-packed format you should ensure your filenames fit the *mon*YY*#
format, if you want to use the PySPLIT interface for generating HYSPLIT trajectories.
Using the PySPLIT interface for trajectory generation is not required: PySPLIT can read any HYSPLIT trajectory file, no matter if it was generated with the PySPLIT interface or using the HYSPLIT program directly (proceed with caution for multi-trajectory files at this point, though).
Hope this helps! Mellissa
Thank you very much Mellissa for the reply. I am kind of newbie to the Python. I have installed the pysplit on my Mac computer. I have also installed Hysplit version for Mac. I have found many python codes in the ~/pysplit-master/pysplit directory. I have edited the "trajectory_generator.py" file as indicated the the python code. After editing "trajectory_generator.py"; the header of the file looks like this
def generate_bulktraj( Example, hysplit_working="/Users/sopan/Downloads/Hysplit4/working" ,output_dir="/Users/sopan/Downloads/Hysplit4/working", meteo_dir="/Users/sopan/Downloads/Hysplit4/working/", years=[2005],months=[6],hours= [6,12,18], altitudes=[500,1500], coordinates=(53.50,-110.00), run=-48, monthslice=slice(0, 32, 1), meteo_bookends=([0]), get_reverse=False, get_clipped=True, hysplit="/Users/sopan/Downloads/Hysplit4/exec/hyts_std"):
The meteo_dir contains "narr.jun2005" narr data file for June-2005.
After making the required changes as mentioned above I have tried to run python as follows "python2.7 trajectory_generator.py"
The command execute without error but it does not create any output files as well as output data files. Could you please help me where is it going wrong ?
Thank You, Sopan
Hi Sopan,
Trying to run "python2.7 trajectory_generator.py" will not work because there are no scripts in that file, only function definitions. No output was created because nothing happened! Also, you generally should not edit files in packages you install, unless you are planning on developing/contributing and have installed it that way.
Instead of editing "trajectory_generator.py" directly and running "python2.7 trajectory_generator.py", you should type in your terminal or Jupyter notebook:
import pysplit
pysplit.generate_bulktraj("Example", hysplit_working="/Users/sopan/Downloads/Hysplit4/working", output_dir="/Users/sopan/Downloads/Hysplit4/working", meteo_dir="/Users/sopan/Downloads/Hysplit4/working/", years=[2005], months=[6], hours= [6,12,18], altitudes=[500,1500], coordinates=(53.50,-110.00), run=-48, monthslice=slice(0, 32, 1), meteo_bookends=([0]), get_reverse=False, get_clipped=True, hysplit="/Users/sopan/Downloads/Hysplit4/exec/hyts_std")
What should happen when you execute those statements is first that the PySPLIT code will be brought into your namespace (import pysplit
) and be available for you to use. Second, HYSPLIT will begin calculating a trajectory/trajectories. You will be able to watch the calculation progress in your terminal. If you are working in a Jupyter notebook, the calculation progress will appear in the terminal you used to start Jupyter. Files about the calculation(s) will appear in hysplit_working
, and the actual trajectory files will appear in output_dir
.
However, even with this correct procedure, PySPLIT/HYSPLIT may be unhappy for three reasons:
*mon*YY*#*
; see my previous message for explanation. Your filename is good EXCEPT for the missing #
part; PySPLIT may be very unhappy about that. You could name your file narr.jun2005_0 and that would definitely work.monthslice
argument in the code above to read monthslice=slice(2, 32, 1)
Also, please note that in HYSPLIT, time is expressed in UTC. Your coordinates tell me that your desired location is in Canada. There, local time corresponds to UTC-6h (six hours behind). For example, local noon is actually 18 UTC, not 12 UTC.
Finally, have you used HYSPLIT before? If not, I highly recommend familiarizing yourself with how HYSPLIT works by learning how to calculate and display a trajectory using the HYSPLIT GUI. I believe the best first step to learning how to use PySPLIT is to get acquainted and comfortable with HYSPLIT itself.
Hi Mellissa, Thank you for your reply and suggestions. I had tried the sample code you had provided and it worked great. I am familier with the Hysplit. I have used R to plot the trajectories and daily runs. But, I found pysplit can eased does my research workload. Actually, I am trying to use the Hysplit to get the moisture source and trajectory clustering analysis. As you'd shown to me in the last message about how to generate the bulk trajectories; it worked for me. Now I am having following issues (This is due to my poor understanding of Python). I had read your scipy-2015 conference paper and tried to follow it. I am trying to get the moisture source and fluxes ( Using Hysplit we can get the meteorological fields in the tdump files).
How to get the meteorological fields in tdump/output trajectory files ? (1) I had tried to edit the TRAJ.CFG file and run pysplit to generate the bulk trajectories but it looks like pysplit had overwrite the original TRAJ.CFG and did not create the tdump files with meteorology in it.
(2) How to run the moisture uptakes ?
I do not know how to use the instances using python (I tried to follow your documents but i could not comprehend the concept). I tried the following command
pysplit.Trajectory.moisture_uptake('example',-0.2,0.5,uptake_window=6,window_overlap=0,vertical_criterion='pbl',pressure_threshold=900,mixdepth_factor=1,q_type='specific humidity')
I am getting following error
TypeError: unbound method moisture_uptake() must be called with Trajectory instance as first argument (got str instance instead)
(3) I would like to know how to use Pysplit for plotting of trajectories and moisture uptake locations, trajectories with meteorological outputs, moisture uptakes, checking of integration errors?
I dont understand what does self represents in all the trajectory related codes here ?
I am aware that I am asking for too much .. but I had tried pysplit.Trajectory.moisture_uptake
many times but i could not crack it ...
Can you just a toy examples here?
Thank You, Sopan
Hi Sopan,
In a method's list of arguments, self
is a reference to the object to which the method belongs. In Trajectory.moisture_uptake()
, Trajectory
is the object, moisture_uptake()
is the method, and self
refers to the Trajectory
instance. The error means that you gave the method a string instead of a Trajectory
. You should loop through the member Trajectory
s of your TrajectoryGroup
(called mytrajectorygroup
in the example) and run the method on each member trajectory like:
for traj in mytrajectorygroup:
traj.moisture_uptake(-0.2, 0.5)
Cheers, Mellissa
Greetings to all. I need some expert help here. I am doing my MSc thesis and need to run HYSPLIT backward trajectory but I don't have idea on any programming language. What can I do?
Can some help me with the code and steps in python for downloading met data as well as run the trajectory for a year.
Hi Melissa, The python package you have created for Hysplit is great. I am wondering can I use Pysplit with NARR datasets ?
Thank You, Sopan