Skip to content

Implementation of HySPLIT based trajectory modeling and analysis in python.

License

Notifications You must be signed in to change notification settings

pankajkarman/HyTraj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


PyPI version License Downloads Code style: black


HyTraj

This python library implements HySPLIT based trajectory modeling and analysis.

Installation

Install using pip:

pip install hytraj

or

pip install git+https://github.com/pankajkarman/HyTraj.git

Dependencies

  1. Plotting requires cartopy.

  2. Hierarchical clustering requires traj_dist.

Documentation

Latest documentation is available here. Improved documentation will come up shortly.

Usage

See this notebook for example usecase.

import hytraj as ht

Generate Trajectories

from hytraj import HyTraj

met_type = "ncep_new"
dates = pd.date_range("2010-02-01", freq="24h", end="2010-02-10")
hy = HyTraj(stations, height, run_time, working, metdir, outdir, met_type)
data = hy.run(dates, njobs=7)
hy.plot(data["Neumayer"], vertical="alt", show=True)

Example Trajectories

Cluster Trajectories

KMeans Clustering using wavelet features

from hytraj import HyCluster

labels = HyCluster(data).fit(kmax=10, method='KMeans')

Hierarchical Agglomerative Clustering (HAC)

from hytraj import HyHAC

trj = HyHAC(data)
labels = trj.fit(nclus=4, metric='sspd')
trj.plot_dendrogram()

Dendrogram

Receptor Modeling

from hytraj import HyReceptor, HyData

station = 'South Pole'
data = HyData(files, stations).read()[station]
model = HyReceptor(ozone, data, station_name="South Pole")
cwt = model.calculate_cwt(weighted=False)
pscf = model.calculate_pscf(thresh=0.95)
rtwc = model.calculate_rtwc(normalise=True)
model.plot_map(rtwc, boundinglats=[-55, -90])

Features

  1. HyTraj: Higher level implementation of Parallel Generation, reading and plotting of Trajectories (Recommended).

  2. HyGen: Generation of Trajectories using various meteo datasets (NCEP and GDAS implemented).

  3. HyControl: Generation of control files for parallel trajectory generation afterwards.

  4. HyParallel: Parallel generation of trajectories using control files produced using HyControl.

  5. HyData: Reading and binning trajectories data (NetCDF with xarray support).

  6. HyCluster: Clustering of trajectories with KMeans using wavelet features.

  7. HyHAC: Clustering of trajectories with Hierarchical Agglomerative Clustering (HAC) using various trajectory distance metric like DTW, EDR, LCSS, SSPD, Frechet Distance, Hausdorf Distance.

  8. HyReceptor: Single site Receptor Modeling ( both weighted and unweighted):

    • Concentration weighted Trajectory (CWT)
    • Potential Source Contribution Function (PSCF)
    • Residence Time Weighted Concentration (RTWC)

To Do

  1. Support for more meteorology like ERA5.
  2. Add documentation.
  3. GUI: Medium-term goal

PS: Find pre-built HYSPLIT executable at this link and copy executeble to working directory.

About

Implementation of HySPLIT based trajectory modeling and analysis in python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages