Return the x,y points for the horizontal cross section line. Args: xdim (:obj:`int`): The x-dimension size. ydim (:obj:`int`): The y-dimension size. pivot_point (:obj:`tuple` or :obj:`list`, optional): A :obj:`tuple` or :obj:`list` with two entries,
(xdim, ydim, pivot_point=None, angle=None,
start_point=None, end_point=None)
| 35 | |
| 36 | |
| 37 | def _calc_xy(xdim, ydim, pivot_point=None, angle=None, |
| 38 | start_point=None, end_point=None): |
| 39 | """Return the x,y points for the horizontal cross section line. |
| 40 | |
| 41 | Args: |
| 42 | |
| 43 | xdim (:obj:`int`): The x-dimension size. |
| 44 | |
| 45 | ydim (:obj:`int`): The y-dimension size. |
| 46 | |
| 47 | pivot_point (:obj:`tuple` or :obj:`list`, optional): A |
| 48 | :obj:`tuple` or :obj:`list` with two entries, |
| 49 | in the form of [x, y] (or [west_east, south_north]), which |
| 50 | indicates the x,y location through which the plane will pass. |
| 51 | Must also specify `angle`. |
| 52 | |
| 53 | angle (:obj:`float`, optional): Only valid for cross sections where |
| 54 | a plane will be plotted through |
| 55 | a given point on the model domain. 0.0 represents a S-N cross |
| 56 | section. 90.0 is a W-E cross section. |
| 57 | |
| 58 | start_point (:obj:`tuple` or :obj:`list`, optional): A |
| 59 | :obj:`tuple` or :obj:`list` with two entries, in the form of |
| 60 | [x, y] (or [west_east, south_north]), which indicates the start |
| 61 | x,y location through which the plane will pass. |
| 62 | |
| 63 | end_point (:obj:`tuple` or :obj:`list`, optional): A |
| 64 | :obj:`tuple` or :obj:`list` with two entries, in the form of |
| 65 | [x, y] (or [west_east, south_north]), which indicates the end x,y |
| 66 | location through which the plane will pass. |
| 67 | |
| 68 | Returns: |
| 69 | |
| 70 | :class:`np.ndarray`: A two-dimensional array with the left index |
| 71 | representing each point along the line, and the rightmost dimension |
| 72 | having two values for the x and y coordinates [0=X, 1=Y]. |
| 73 | |
| 74 | """ |
| 75 | # Have a pivot point with an angle to find cross section |
| 76 | if pivot_point is not None and angle is not None: |
| 77 | xp = pivot_point[-2] |
| 78 | yp = pivot_point[-1] |
| 79 | |
| 80 | if xp >= xdim or yp >= ydim: |
| 81 | raise ValueError("pivot point {} is outside of domain " |
| 82 | "with shape {}".format(pivot_point, |
| 83 | (xdim, ydim))) |
| 84 | |
| 85 | if (angle > 315.0 or angle < 45.0 |
| 86 | or ((angle > 135.0) and (angle < 225.0))): |
| 87 | |
| 88 | slope = -(360.-angle)/45. |
| 89 | if(angle < 45.): |
| 90 | slope = angle/45. |
| 91 | if(angle > 135.): |
| 92 | slope = (angle-180.)/45. |
| 93 | |
| 94 | intercept = xp - yp*slope |