| Conditions | 1 | 
| Total Lines | 57 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | # Copyright (c) 2008-2017 MetPy Developers.  | 
            ||
| 106 | @exporter.export  | 
            ||
| 107 | @check_units('[pressure]', '[speed]', '[speed]', '[length]') | 
            ||
| 108 | def bunkers_storm_motion(pressure, u, v, heights):  | 
            ||
| 109 | r"""Calculate the Bunkers right-mover and left-mover storm motions and sfc-6km mean flow.  | 
            ||
| 110 | |||
| 111 | Uses the storm motion calculation from [Bunkers et al, 2000]_.  | 
            ||
| 112 | |||
| 113 | Parameters  | 
            ||
| 114 | ----------  | 
            ||
| 115 | pressure : array-like  | 
            ||
| 116 | Pressure from sounding  | 
            ||
| 117 | u : array-like  | 
            ||
| 118 | U component of the wind  | 
            ||
| 119 | v : array-like  | 
            ||
| 120 | V component of the wind  | 
            ||
| 121 | heights : array-like  | 
            ||
| 122 | Heights from sounding  | 
            ||
| 123 | |||
| 124 | Returns  | 
            ||
| 125 | -------  | 
            ||
| 126 | right_mover: `pint.Quantity`  | 
            ||
| 127 | U and v component of Bunkers RM storm motion  | 
            ||
| 128 | left_mover: `pint.Quantity`  | 
            ||
| 129 | U and v component of Bunkers LM storm motion  | 
            ||
| 130 | wind_mean: `pint.Quantity`  | 
            ||
| 131 | U and v component of sfc-6km mean flow  | 
            ||
| 132 | |||
| 133 | """  | 
            ||
| 134 | # mean wind from sfc-6km  | 
            ||
| 135 | wind_mean = concatenate(mean_pressure_weighted(pressure, u, v, heights=heights,  | 
            ||
| 136 |                                                    depth=6000 * units('meter'))) | 
            ||
| 137 | |||
| 138 | # mean wind from sfc-500m  | 
            ||
| 139 | wind_500m = concatenate(mean_pressure_weighted(pressure, u, v, heights=heights,  | 
            ||
| 140 |                                                    depth=500 * units('meter'))) | 
            ||
| 141 | |||
| 142 | # mean wind from 5.5-6km  | 
            ||
| 143 | wind_5500m = concatenate(mean_pressure_weighted(pressure, u, v, heights=heights,  | 
            ||
| 144 |                                                     depth=500 * units('meter'), | 
            ||
| 145 | bottom=heights[0] +  | 
            ||
| 146 |                                                     5500 * units('meter'))) | 
            ||
| 147 | |||
| 148 | # Calculate the shear vector from sfc-500m to 5.5-6km  | 
            ||
| 149 | shear = wind_5500m - wind_500m  | 
            ||
| 150 | |||
| 151 | # Take the cross product of the wind shear and k, and divide by the vector magnitude and  | 
            ||
| 152 | # multiply by the deviaton empirically calculated in Bunkers (2000) (7.5 m/s)  | 
            ||
| 153 | shear_cross = concatenate([shear[1], -shear[0]])  | 
            ||
| 154 |     rdev = shear_cross * (7.5 * units('m/s').to(u.units) / np.hypot(*shear)) | 
            ||
| 155 | |||
| 156 | # Add the deviations to the layer average wind to get the RM motion  | 
            ||
| 157 | right_mover = wind_mean + rdev  | 
            ||
| 158 | |||
| 159 | # Subtract the deviations to get the LM motion  | 
            ||
| 160 | left_mover = wind_mean - rdev  | 
            ||
| 161 | |||
| 162 | return right_mover, left_mover, wind_mean  | 
            ||
| 163 | |||
| 207 |