interplevel

44 views
Skip to first unread message

Mark Seefeldt

unread,
Sep 3, 2024, 4:38:54 PM9/3/24
to wrfpython-talk
I am having an issue in working with the interpolation function: interplevel with the CONUS404 dataset.

The CONUS404 dataset: https://rda.ucar.edu/datasets/d559000/
is of WRF output with some post-processing involved. Specifically, they have removed pressure and height in WRF-terms and instead have created pressure (P) and height (Z) in absolute values. These values are similar to what would be retrieved with the getvar function of p and z. The one difference is that the CONUS404 Z is on the vertically staggered grid. Naturally, even this small level of post-processing makes it difficult to use some of the wrf-python functions with CONUS404.

I am able to retrieve the values for P and Z, and I am able to destagger Z.
wrf3d  = nc.Dataset(f"{wrf_dir}/wrf3d_d01_1980-01-01_00:00:00.nc")
p = wrf3d.variables["P"]
ht_st = wrf3d.variables["Z"]
ht = wrf.destagger(ht_st, 1)

However, when I run interplevel, the function simply returns all NaNs:
ht_500 = wrf.interplevel(ht, p, 500.)

It appears that something is not right with p and ht that results in interplevel choking and filling in with all NaNs. Is there anyway to investigate what is causing interplevel to choke and create all NaNs?

I can add that I also tried using interpz3d:
ht_500_2 = wrf.interpz3d(ht, p, 500.)
It results in an attribute error:
'float' object has no attribute 'shape'
It appears to be related to the desiredlevel (500.).

Thanks, Mark Seefeldt

Marco Miani

unread,
Sep 20, 2024, 9:36:54 AM9/20/24
to Mark Seefeldt, wrfpython-talk
Hi Mark,

wrf requires some additional ancillary variables to be in the dataset (geopot height and perturbation), to run interp and interp3d .
Your dataset was deprived of these, as only the resulting variables of that operation was appended. Therefore the function is not working.


#Ouput when inspecting metadata, for P and Z
ds.P.description
Out[53]: 'Total pressure (P0+PB)'

ds.Z.description
Out[54]: 'Geopotential height (PH + PHB)/9.81'  #you have all these fields in original wrf output netcdfs // but not in CONUS dataset!


What I would do is something along these lines: 
1. for pressure dataset, find the indices (over dim='bottom_top') where P=target_p
2. with those same indices, target the Z matrix for geopot height.
3. Since Z is staggered, use indices and indices+1 to find the 2 z-layers (height) bounding/sandwiching P_500:
4. average them, over vertical dimension, to get corresponding height.
5. Plot the result: approximated p_500 and approximated Z_p500

The result is very Andy-Warhol-psychedelic, but paves the way for a more sophisticated/elaborated solution.
Python script attached. Hope that helps in some way.

Happy coding.
Marco 
 

Extract_500_hPa.png


--
You received this message because you are subscribed to the Google Groups "wrfpython-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wrfpython-tal...@ucar.edu.
To view this discussion on the web visit https://groups.google.com/a/ucar.edu/d/msgid/wrfpython-talk/2a1b93f2-5845-47ea-9520-bf5166e2732bn%40ucar.edu.
interpLevel_test.__py__
Message has been deleted

Mark Seefeldt

unread,
Sep 24, 2024, 3:01:55 PM9/24/24
to wrfpython-talk, Marco Miani, Mark Seefeldt
Marco,

Thank you for explaining my issues with interplevel and providing a solution to get around those issues. I will take a close look at implementing this approach.

Mark

Reply all
Reply to author
Forward
0 new messages