在Python中构建轮廓线

时间:2018-06-18 19:30:19

标签: python pandas numpy matplotlib

我需要根据文本文件中的数据绘制等高线图(类似于this example)。我正在建立一个坐标网格。 Z值仅在主对角线上已知。建议外推的剩余点中的值。如何从生成的网格中推断出来?

链接到文件:https://drive.google.com/open?id=1l4cEVo6SYunwnMNrIIjBPcIe3YxaGsKz

以下是一小段代码,可帮助将此文件加载到Pandas DataFrame中:

import pandas as pd

df = pd.read_fwf(r'D:\download\image2015010100.col2', skiprows=[1], na_values=[99999.9])
d = {
    'YYYY': 'year',
    'MM':'month',
    'DD':'day',
    'HH':'hour',
    'MM.1':'minute',
    'SS':'second',
    }
df = df.rename(columns=d)
df.index = pd.to_datetime(df.iloc[:, :6])
df = df.iloc[:, 6:]

这就是DF的样子:

In [171]: df
Out[171]:
                      NAL X  NAL Y    NAL Z   LYR X   LYR Y    LYR Z   HOR X   HOR Y  ...     TAR Y    TAR Z  SUW X  SUW Y  SUW Z  BRZ X  BRZ Y  BRZ Z
2015-01-01 00:00:00  7154.0  781.9  54297.5  7388.6  1046.0  54320.9  7821.3  1002.6  ...    2479.3  49164.9 -125.4 -114.8  -61.0   18.9   62.6   45.0
2015-01-01 00:00:10  7155.7  782.4  54298.5  7388.3  1046.0  54321.1  7821.3  1002.6  ...    2479.2  49164.9 -125.3 -114.8  -61.0   19.0   62.4   45.0
2015-01-01 00:00:20  7154.3  783.4  54296.8  7388.6  1045.8  54321.1  7821.3  1002.4  ...    2479.1  49165.0 -125.3 -114.9  -61.0   19.0   62.4   45.0
2015-01-01 00:00:30  7153.8  781.9  54296.6  7388.4  1045.5  54321.1  7821.1  1002.2  ...    2479.1  49165.0 -125.3 -115.0  -61.1   19.1   62.3   45.0
2015-01-01 00:00:40  7153.5  782.0  54299.5  7388.4  1045.0  54320.9  7821.1  1001.9  ...    2478.9  49165.0 -125.3 -115.1  -61.1   19.1   62.2   45.0
...                     ...    ...      ...     ...     ...      ...     ...     ...  ...       ...      ...    ...    ...    ...    ...    ...    ...
2015-01-01 23:59:10  7133.9  768.5  54474.8  7326.1  1082.7  54537.2  7746.0  1058.9  ...    2513.5  49151.7 -127.4  -86.8  -65.4   16.8   94.5   36.3
2015-01-01 23:59:20  7134.1  767.0  54471.9  7328.1  1076.6  54535.9  7743.4  1050.7  ...    2513.4  49151.7 -127.5  -86.8  -65.4   16.8   94.5   36.3
2015-01-01 23:59:30  7133.6  766.0  54468.4  7328.5  1071.4  54534.2  7740.6  1044.8  ...    2513.4  49151.6 -127.6  -86.8  -65.4   16.8   94.4   36.3
2015-01-01 23:59:40  7134.1  763.6  54465.3  7328.4  1067.0  54532.5  7738.0  1040.4  ...    2513.3  49151.7 -127.7  -86.8  -65.4   16.7   94.3   36.3
2015-01-01 23:59:50  7133.1  763.8  54464.5  7327.3  1063.4  54530.6  7735.7  1038.0  ...    2513.4  49151.8 -127.7  -86.8  -65.4   16.5   94.4   36.3

[8640 rows x 102 columns]

0 个答案:

没有答案