slcs-jsc / mptrac

Massive-Parallel Trajectory Calculations (MPTRAC) is a Lagrangian particle dispersion model for the analysis of atmospheric transport processes in the free troposphere and stratosphere.
GNU General Public License v3.0
36 stars 14 forks source link

bug in ERA5 polar trajectories? #32

Closed lars2015 closed 5 months ago

lars2015 commented 10 months ago

compare_traj

lars2015 commented 7 months ago
for ihem in range(2):
    if ihem == 0:
        i89 = 1
        i90 = 0
        lon = era5.variables['lon'][:] * np.pi/180
    else:
        i89 = nlats-2
        i90 = nlats-1
        # correct sign of longitude cycle that is opposite at the south pole
        lon = -era5.variables['lon'][:] * np.pi/180

    for ilev in range(nlevs):
        # transform 89 degree u and v winds into cartesian coordinates and take the mean
        u89 = era5.variables['U'][0,ilev,i89,:]
        v89 = era5.variables['V'][0,ilev,i89,:]
        u89x = u89 * np.cos(lon)
        u89y = u89 * np.sin(lon)
        v89x = -v89 * np.sin(lon)
        v89y = v89 * np.cos(lon)
        vel89x = np.mean(u89x + v89x)
        vel89y = np.mean(u89y + v89y)

        u90 = vel89x * np.cos(lon) + vel89y * np.sin(lon)
        v90 = -vel89x * np.sin(lon) + vel89y * np.cos(lon)

        era5.variables['U'][0,ilev,i90,:] = u90
        era5.variables['V'][0,ilev,i90,:] = v90