<s> import numpy as np <EOL> from matplotlib . lines import Path <EOL> from astropy . coordinates . angle_utilities import angular_separation <EOL> ROUND_TRIP_TOL = <NUM_LIT> <EOL> DISCONT_FACTOR = <NUM_LIT> <EOL> def get_lon_lat_path ( lon_lat , pixel , lon_lat_check ) : <EOL> """<STR_LIT>""" <EOL> sep = angular_separation ( np . radians ( lon_lat [ : , <NUM_LIT:0> ] ) , <EOL> np . radians ( lon_lat [ : , <NUM_LIT:1> ] ) , <EOL> np . radians ( lon_lat_check [ : , <NUM_LIT:0> ] ) , <EOL> np . radians ( lon_lat_check [ : , <NUM_LIT:1> ] ) ) <EOL> sep [ sep > np . pi ] -= <NUM_LIT> * np . pi <EOL> mask = np . abs ( sep > ROUND_TRIP_TOL ) <EOL> mask = mask | np . isnan ( pixel [ : , <NUM_LIT:0> ] ) | np . isnan ( pixel [ : , <NUM_LIT:1> ] ) <EOL> codes = np . zeros ( lon_lat . shape [ <NUM_LIT:0> ] , dtype = np . uint8 ) <EOL> codes [ : ] = Path . LINETO <EOL> codes [ <NUM_LIT:0> ] = Path . MOVETO <EOL> codes [ mask ] = Path . MOVETO <EOL> codes [ <NUM_LIT:1> : ] [ mask [ : - <NUM_LIT:1> ] ] = Path . MOVETO <EOL> step = np . sqrt ( ( pixel [ <NUM_LIT:1> : , <NUM_LIT:0> ] - pixel [ : - <NUM_LIT:1> , <NUM_LIT:0> ] ) ** <NUM_LIT:2> + <EOL> ( pixel [ <NUM_LIT:1> : , <NUM_LIT:1> ] - pixel [ : - <NUM_LIT:1> , <NUM_LIT:1> ] ) ** <NUM_LIT:2> ) <EOL> discontinuous = step [ <NUM_LIT:1> : ] > DISCONT_FACTOR * step [ : - <NUM_LIT:1> ] <EOL> codes [ <NUM_LIT:2> : ] [ discontinuous ] = Path . MOVETO <EOL> if step [ <NUM_LIT:0> ] > DISCONT_FACTOR * step [ <NUM_LIT:1> ] : <EOL> codes [ <NUM_LIT:1> ] = Path . MOVETO <EOL> path = Path ( pixel , codes = codes ) <EOL> return path <EOL> def get_gridline_path ( world , pixel ) : <EOL> """<STR_LIT>""" <EOL> mask = np . isnan ( pixel [ : , <NUM_LIT:0> ] ) | np . isnan ( pixel [ : , <NUM_LIT:1> ] ) <EOL> codes = np . zeros ( world . shape [ <NUM_LIT:0> ] , dtype = np . uint8 ) <EOL> codes [ : ] = Path . LINETO <EOL> codes [ <NUM_LIT:0> ] = Path . MOVETO <EOL> codes [ mask ] = Path . MOVETO <EOL> codes [ <NUM_LIT:1> : ] [ mask [ : - <NUM_LIT:1> ] ] = Path . MOVETO <EOL> path = Path ( pixel , codes = codes ) <EOL> return path </s>
