Code Duplication    Length = 31-35 lines in 2 locations

metpy/calc/thermo.py 2 locations

@@ 232-266 (lines=35) @@
229
    return x[0], y[0]
230
231
232
@exporter.export
233
def el(pressure, temperature, dewpt):
234
    r"""Calculate the equilibrium level (EL).
235
236
    This works by finding the last intersection of the ideal parcel path and
237
    the measured parcel temperature. If there is one or fewer intersections, there is
238
    no equilibrium level.
239
240
    Parameters
241
    ----------
242
    pressure : `pint.Quantity`
243
        The atmospheric pressure
244
    temperature : `pint.Quantity`
245
        The temperature at the levels given by `pressure`
246
    dewpt : `pint.Quantity`
247
        The dew point at the levels given by `pressure`
248
249
    Returns
250
    -------
251
    `pint.Quantity, pint.Quantity`
252
        The EL pressure and temperature
253
254
    See Also
255
    --------
256
    parcel_profile
257
    """
258
    ideal_profile = parcel_profile(pressure, temperature[0], dewpt[0]).to('degC')
259
    x, y = find_intersections(pressure[1:], ideal_profile[1:], temperature[1:])
260
261
    # If there is only one intersection, it's the LFC and we return None.
262
    if len(x) <= 1:
263
        return None, None
264
265
    else:
266
        return x[-1], y[-1]
267
268
269
@exporter.export
@@ 199-229 (lines=31) @@
196
    return new_p, td
197
198
199
@exporter.export
200
def lfc(pressure, temperature, dewpt):
201
    r"""Calculate the level of free convection (LFC).
202
203
    This works by finding the first intersection of the ideal parcel path and
204
    the measured parcel temperature.
205
206
    Parameters
207
    ----------
208
    pressure : `pint.Quantity`
209
        The atmospheric pressure
210
    temperature : `pint.Quantity`
211
        The temperature at the levels given by `pressure`
212
    dewpt : `pint.Quantity`
213
        The dew point at the levels given by `pressure`
214
215
    Returns
216
    -------
217
    `pint.Quantity`
218
        The LFC
219
220
    See Also
221
    --------
222
    parcel_profile
223
    """
224
    ideal_profile = parcel_profile(pressure, temperature[0], dewpt[0]).to('degC')
225
226
    # The parcel profile and data have the same first data point, so we ignore
227
    # that point to get the real first intersection for the LFC calculation.
228
    x, y = find_intersections(pressure[1:], ideal_profile[1:], temperature[1:])
229
    return x[0], y[0]
230
231
232
@exporter.export