Skip to content

Instantly share code, notes, and snippets.

@sixy6e
Last active March 25, 2025 22:40
Show Gist options
  • Save sixy6e/5ff1a3c3fc0c3a5b42c5afae20517799 to your computer and use it in GitHub Desktop.
Save sixy6e/5ff1a3c3fc0c3a5b42c5afae20517799 to your computer and use it in GitHub Desktop.
ERA5 pressure check
Just a toy script to demo handling no ascending pressure data from the ERA5 sources.
The issue is dumping into MODTRAN which is expecting it to be in ascending order.
index GeoPotential_Height Pressure Temperature Relative_Humidity
0 0.23604525831164314 997.203046875 17.728143310546898 55.18563409417312
1 0.21237263083457947 1000.0 -18.994674682617188 52.29852294921875
2 0.42727935314178467 975.0 -23.95172119140625 57.085166931152344
3 0.6473296284675598 950.0 -25.33441162109375 48.10903549194336
4 0.8731138706207275 925.0 -33.4669189453125 51.83966064453125
5 1.1036815643310547 900.0 -36.328643798828125 57.452884674072266
6 1.3389579057693481 875.0 -41.81904602050781 63.76068878173828
7 1.5792070627212524 850.0 -45.99176025390625 61.11436462402344
8 1.8256536722183228 825.0 -50.24961853027344 25.404701232910156
9 2.0798733234405518 800.0 -59.61915588378906 12.433944702148438
10 2.3416404724121094 775.0 -63.62153625488281 11.198783874511719
11 2.610961437225342 750.0 -69.918701171875 8.043304443359375
12 3.1743083000183105 700.0 -65.23504638671875 4.8941192626953125
13 3.7734224796295166 650.0 -63.82322692871094 13.584243774414062
14 4.412900924682617 600.0 -61.6898193359375 17.327438354492188
15 5.100045680999756 550.0 -55.858795166015625 37.190589904785156
16 5.840790748596191 500.0 -49.27703857421875 59.652915954589844
17 6.644465923309326 450.0 -45.35307312011719 33.36882019042969
18 7.520244598388672 400.0 -39.32035827636719 49.887916564941406
19 8.484905242919922 350.0 -30.123382568359375 88.37590789794922
20 9.560375213623047 300.0 -22.658676147460938 64.90470886230469
21 10.789100646972656 250.0 -15.814727783203125 40.88978576660156
22 11.486759185791016 225.0 -10.050933837890625 60.33492660522461
23 12.24677848815918 200.0 -5.64739990234375 86.14444732666016
24 13.083831787109375 175.0 -1.77947998046875 62.75810623168945
25 14.032429695129395 150.0 1.209991455078125 26.43557357788086
26 15.144684791564941 125.0 4.513214111328125 15.894279479980469
27 16.485414505004883 100.0 6.787811279296875 22.16436767578125
28 18.64069938659668 70.0 7.827606201171875 4.49810791015625
29 20.721773147583008 50.0 8.77105712890625 1.8769302368164062
30 23.987428665161133 30.0 8.56488037109375 0.35576629638671875
31 26.658166885375977 20.0 8.27581787109375 0.1451873779296875
32 31.338632583618164 10.0 10.086517333984375 0.047760009765625
33 33.780826568603516 7.0 12.305084228515625 0.01947021484375
34 36.125484466552734 5.0 14.310760498046875 0.01004791259765625
35 39.78499221801758 3.0 15.74273681640625 0.00376129150390625
36 42.73015594482422 2.0 14.83740234375 0.00061798095703125
37 47.86134338378906 1.0 16.437469482421875 0.00061798095703125
import pandas
CSV_FNAME = "ATMOSPHERIC-PROFILE.csv"
def main():
df_sfc = pandas.read_csv(CSV_FNAME, header=0, index_col="index", nrows=1)
df_full = pandas.read_csv(CSV_FNAME, header=0, index_col="index")
df = df_full[1:] # skip surface
wh = (df["GeoPotential_Height"] > df_sfc["GeoPotential_Height"].loc[0]) & (df["Pressure"] < df_sfc["Pressure"].loc[0].round())
new_df = pandas.concat([df_sfc, df[wh]])
print("surface data")
print(df_sfc)
print("full csv")
print(df_full)
print("filtered dataframe")
print(new_df)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment