Skip to content

cross_section() does not match requested start and end #1089

@sgdecker

Description

@sgdecker

Here is my code:

import pickle
import numpy as np
import metpy
from metpy.interpolate import cross_section
import xarray as xr
import cartopy
import cartopy.crs as ccrs

with open('ds2.pickle', 'rb') as f:
    ds2 = pickle.load(f)

start = (40.0, -105.0)
end = (45.0, -68.0)

cross = cross_section(ds2, start, end)
cross.set_coords(('lat', 'lon'), True)

print(cross.lat[0].values, cross.lon[0].values)
print(cross.lat[-1].values, cross.lon[-1].values)

# Extra printouts to verify projection information agreed
#print(ds2.crs.to_dict()['data'].to_dict())
#print(ds2.LambertConformal)

print(metpy.__version__)
print(xr.__version__)
print(cartopy.__version__)
 

The output:

xsecbug.py:16: FutureWarning: The inplace argument has been deprecated and will be removed in a future version of xarray.
  cross.set_coords(('lat', 'lon'), True)
42.14027577619222 -91.72784705269194
43.045485539202936 -54.08897522118793
0.10.2
0.12.2
0.17.0

  • Expected output
    I would hope the start and end points in the cross section would be much closer to the (40, -105) and (45,-68) requested.

The pickle file can be downloaded from https://drive.google.com/file/d/1B-e1FIZMh6T6Px40FCtcfiGzKVxy8Zof/view?usp=sharing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Cross-sectionsPertains to making cross-sections through dataType: EnhancementEnhancement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions