source: trunk/UTIL/interpolate_1d_tprofile_z2sig.py @ 3567

Last change on this file since 3567 was 3565, checked in by afalco, 4 days ago

Script to interpolate temperatures profiles from one altitude grid to another in 1D.
AF

File size: 768 bytes
Line 
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
4import numpy as np
5import pandas as pd
6
7temperature_in = pd.read_csv("profile.in", header=None).iloc[:,0]
8print(len(temperature_in), temperature_in[0])
9z2sig_in = pd.read_csv("z2sig.def.in", names=range(40), header=None, skiprows=1, delimiter=" ").iloc[:,0]
10print(len(z2sig_in), z2sig_in[0])
11z2sig_out = pd.read_csv("z2sig.def", names=range(40), header=None, skiprows=1, delimiter=" ").iloc[:,0]
12print(len(z2sig_out), z2sig_out[0])
13
14#add surface
15z2sig_in = np.insert(z2sig_in,0,0)
16z2sig_out = np.insert(z2sig_out,0,0)
17
18temperature_out = np.interp(z2sig_out, z2sig_in, temperature_in)
19np.savetxt("profile", temperature_out, fmt="%f")
Note: See TracBrowser for help on using the repository browser.