Getting GFS forecast variables for sounding-plotting #2474
-
Hey Metpy-ers, I would like to transform my observational sounding plotter script into a modeled plot (first tests with GFS data), and I am having trouble getting ahold of the data from the THREDDS server. I have followed along with MetPy Monday video # 164 on accessing the THREDDS server. I think I am on the right track (maybe?) but I am not sure how to declare the specific lat and lon I want for the data, I tested it with temp_raw.isel(time=0, lat=##.####, lon=-##.####) but that doesn't seem to work like I thought it should lol. I get this error: "TypeError: invalid indexer array, does not have integer dtype: array(42.242516)" I am likely thinking this is more simple than it really is, any ideas? here if my code thus far: --- define TDSCatalog as GFS 0p25deg Best--- ---access the ds and define variables --- --- create temp, RH (to calc depoint), u, v, and geopotential height variables from the GFS ---- ---- get temp_raw data for time of zero.... eventually also add lat= and lon= to get temp_raw for desired sounding location??? ---- Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
When using You can string together your selection I think like this: Note that I am not very familiar with lat/lon and using |
Beta Was this translation helpful? Give feedback.
When using
isel
from Xarray, you have to provide integers which correspond to the index into the lat/lon array that you want (like you do for time, usingtime=0
). If you want to use actual lat/lon values, you have to use plainsel
:https://docs.xarray.dev/en/latest/user-guide/indexing.html
You can string together your selection I think like this:
temp_raw.isel(time=0).sel(lat=##.####,lon=-##.####)
Note that I am not very familiar with lat/lon and using
sel
. If the exact lat/lon value of your sounding site isn't found within the lat/lon array, there may be ways you can tell Xarray how to select the "best" one by interpolating, or doing nearest, etc. For example: https://docs.xarray.dev/en/…