Code Duplication    Length = 31-35 lines in 2 locations

metpy/calc/thermo.py 2 locations

@@ 236-270 (lines=35) @@
233
    return x[0], y[0]
234
235
236
@exporter.export
237
def el(pressure, temperature, dewpt):
238
    r"""Calculate the equilibrium level.
239
240
    This works by finding the last intersection of the ideal parcel path and
241
    the measured parcel temperature. If there is one or fewer intersections, there is
242
    no equilibrium level.
243
244
    Parameters
245
    ----------
246
    pressure : `pint.Quantity`
247
        The atmospheric pressure
248
    temperature : `pint.Quantity`
249
        The temperature at the levels given by `pressure`
250
    dewpt : `pint.Quantity`
251
        The dew point at the levels given by `pressure`
252
253
    Returns
254
    -------
255
    `pint.Quantity, pint.Quantity`
256
        The EL pressure and temperature
257
258
    See Also
259
    --------
260
    parcel_profile
261
    """
262
    ideal_profile = parcel_profile(pressure, temperature[0], dewpt[0]).to('degC')
263
    x, y = find_intersections(pressure[1:], ideal_profile[1:], temperature[1:])
264
265
    # If there is only one intersection, it's the LFC and we return None.
266
    if len(x) <= 1:
267
        return None, None
268
269
    else:
270
        return x[-1], y[-1]
271
272
273
@exporter.export
@@ 203-233 (lines=31) @@
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
    return x[0], y[0]
234
235
236
@exporter.export