Code Duplication    Length = 34-34 lines in 2 locations

metpy/calc/thermo.py 2 locations

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