Closed dopplershift closed 2 years ago
Okay, I just ran into this as well for the following date:
date = datetime(2007, 5, 4, 18)
In inspecting the data, it appears that there were two pressure levels that were the same. In this instance it was all the way up at 24.4 hPa. If I subset to use only levels where the pressure > 90, it runs just fine.
Checking the example provided above - there the culprit is 27.7 hPa (and would also error at 19.0 hPa).
So to overcome this error my data parsing would look like:
from datetime import datetime
import matplotlib.pyplot as plt
import metpy.calc as mpcalc
from metpy.plots import SkewT
from metpy.units import units, pandas_dataframe_to_unit_arrays
import numpy as np
from siphon.simplewebservice.wyoming import WyomingUpperAir
# Set date that you want
# Data goes back to the 1970's
date = datetime(2007, 5, 4, 18)
# Set station ID, there are different stations back in the day
# Current station IDs found at http://weather.rap.ucar.edu/upper
station = 'DDC'
# Use Siphon module to grab data from remote server
df = WyomingUpperAir.request_data(date, station)
# Create dictionary of unit arrays
data = pandas_dataframe_to_unit_arrays(df)
# Isolate united arrays from dictionary to individual variables
p = data['pressure']
idx = p.m > 90
p = p[idx]
T = data['temperature'][idx]
Td = data['dewpoint'][idx]
u = data['u_wind'][idx]
v = data['v_wind'][idx]
So at the very least we should check the pressures to see if there are any repeats and error on that to give the suggestion of subsetting the data.
The question is whether we want to bake in any subsetting by default to limit this from happening for users?
In general, this is likely to happen only at very high altitudes (low pressure) since the change of pressure is less rapid at those levels. But I also wonder if this will be more frequent (and happen at higher pressure) with the increased amount of data coming from modern data files.
@kgoebber Another very recent example is the KLIX 3/23/2022 0000 UTC sounding (just prior to the EF-3 in New Orleans). Similar to your example (and others I'm aware of) it's also an instance of adjacent levels with the same pressure, well up in the stratosphere (in this case, 17.4 hPa).
The workaround I've employed in an example notebooki is to call pandas' drop_duplicates
before calling parcel_profile
as follows:
df.drop_duplicates(inplace=True,subset='pressure',ignore_index=True)
Perhaps this could be integrated into the parcel_profile
function?
Discussed in https://github.com/Unidata/MetPy/discussions/2308