[3565] | 1 | # Script to interpolate a temperature profile (profile.in) from altitudes |
---|
| 2 | # defined in z2sig.def.in on a new altitude grid (z2sig.def) |
---|
| 3 | |
---|
| 4 | import numpy as np |
---|
| 5 | import pandas as pd |
---|
[3731] | 6 | import sys |
---|
[3565] | 7 | |
---|
[3731] | 8 | if sys.argv[1] in ("-h", "--help"): |
---|
| 9 | print("Must be provided:\n" |
---|
| 10 | "profile.in : vertical profile to interpolate\n" |
---|
| 11 | "z2sig.def.in : input altitude profile\n" |
---|
| 12 | "z2sig.def : output altitude profile\n" |
---|
| 13 | ) |
---|
| 14 | exit(0) |
---|
| 15 | |
---|
[3565] | 16 | temperature_in = pd.read_csv("profile.in", header=None).iloc[:,0] |
---|
| 17 | print(len(temperature_in), temperature_in[0]) |
---|
[3731] | 18 | z2sig_in = pd.read_csv("z2sig.def.in", names=range(40), header=None, skiprows=1, delimiter=" +").iloc[:,0] |
---|
[3565] | 19 | print(len(z2sig_in), z2sig_in[0]) |
---|
[3731] | 20 | z2sig_out = pd.read_csv("z2sig.def", names=range(40), header=None, skiprows=1, delimiter=" +").iloc[:,0] |
---|
[3565] | 21 | print(len(z2sig_out), z2sig_out[0]) |
---|
| 22 | |
---|
| 23 | #add surface |
---|
| 24 | z2sig_in = np.insert(z2sig_in,0,0) |
---|
| 25 | z2sig_out = np.insert(z2sig_out,0,0) |
---|
| 26 | |
---|
[3731] | 27 | print("Input temperature") |
---|
| 28 | print(temperature_in) |
---|
| 29 | print("Input altitude") |
---|
| 30 | print(z2sig_in) |
---|
| 31 | print("Output altitude") |
---|
| 32 | print(z2sig_out) |
---|
[3565] | 33 | temperature_out = np.interp(z2sig_out, z2sig_in, temperature_in) |
---|
[3731] | 34 | print("Output temperature") |
---|
| 35 | print(temperature_out) |
---|
[3565] | 36 | np.savetxt("profile", temperature_out, fmt="%f") |
---|