Author: Lianet Hernández pardo
This script calculates the trajectories of parcels in a 4D wind field. It takes initial positions of parcels and integrates their movement over time. The trajectories are computed in either a 2D or 3D mode based on user-defined parameters.
To run this project, follow these steps:
-
Clone the Repository:
git clone https://github.com/lhpardo90/trajectory_calculator.git cd trajectory_calculator -
Create a Conda Environment:
Use the provided YAML file to create a Conda environment with the necessary dependencies:
conda env create -f environment.yml
-
Activate the Conda Environment:
conda activate trajectories
-
Run the Script:
python trajectories.py [options] <start_datetime> <wind_filename> <in_filename> <out_filename>
-h, --help Show help message, including the full list of options, and exit.
- start_datetime: Start date and time for trajectory calculation (format: <YYYY>-<MM>-<DD>T<HH>).
- wind_filename: Path to the netcdf file containing wind data.
- in_filename: Path to the file storing initial parcel positions in CSV format. Each row should contain comma-separated values in the following order: pressure (hPa), latitude (degrees), longitude (degrees).
- out_filename: Path to the output trajectories file.
The wind field needs to be provided as a single netcdf file via the 'wind_filename' argument. This file must contain at least the variables 'u' and 'v' in m/s. For 3D trajectories, the variable 'w' in Pa/s must be provided in the same file as 'u' and 'v'. All time steps in the desired integration interval must be included in the same file. The grid must be regular in the horizontal dimension, using either pressure or hybrid sigma-pressure levels. If using hybrid levels, the wind must be provided at 'full' levels, and a separate netcdf file containing the surface pressure (variable 'sp', in Pa units) and a CSV file containing the hybrid coefficients 'a' and 'b' at interface (or 'half') levels in separate columns must be provided via the '--sp_filename' and '--coeff_filename' arguments (see Options). The netcdf files should have dimensions: 'time', 'level', 'latitude', 'longitude' (excluding 'level' for the surface pressure file).
Calculating trajectories from 3D model-level wind data:
python trajectories.py -sf /path/to/your/surface/pressure/file/12UTC_sf.nc -cf /path/to/your/hybrid/coefficients/file/L137_hybrid_levels_NOHEADER.csv 2023-01-04T15 /path/to/your/wind/file/12UTC_ml.nc /path/to/your/initial/locations/init_locations_0000_2023-01-04_15Z.txt /path/to/your/output/dir/my_outputCalculating trajectories from 3D pressure-level wind data:
python trajectories.py --levels_type pl 2023-01-04T15 /path/to/your/wind/file/12UTC_pl.nc /path/to/your/initial/locations/init_locations_0000_2023-01-04_15Z.txt /path/to/your/output/dir/my_outputThe DOI of this repository is: 10.5281/zenodo.10498508
I am grateful to Prof. Dr. Anna Possner for her insightful discussions and valuable suggestions. The core of this code drew inspiration from Tom Gowa's code, which can be found at https://github.com /tomgowan/trajectories. This work was funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – TRR 301 – Project-ID 4283127