我目前正尝试将“反射率”、“发射率”和“最大源温度”分别绘制为数据集的X、Y和Z分量。完整数据文件的一部分如下所示:
Reflectivity Emissivity Max Source Temperature (K) Evaporation Flux (mg/s) Temperature Difference (K)
0.6 0.0 4093.4386841359888 0.6048990499172073 800.4386841359888
0.6 0.02564102564102564 4025.0643415926234 0.4161884105641208 732.0643415926234
0.6 0.05128205128205128 3944.1723231241936 0.26316934524311886 651.1723231241936
0.6 0.07692307692307693 3846.773147541462 0.1479131145621392 553.7731475414621
0.6 0.10256410256410256 3731.146666110107 0.07188813417550587 438.14666611010716
0.6 0.1282051282051282 3602.90603780689 0.030628121497460244 309.9060378068898
0.6 0.15384615384615385 3474.526898598499 0.012245367701619509 181.52689859849897
0.6 0.1794871794871795 3357.149084679844 0.004979816869050158 64.14908467984378
0.6 0.20512820512820512 3253.90294510584 0.002138016768402961 -39.09705489416001
0.6 0.23076923076923075 3163.857369720834 0.0009771206521967547 -129.14263027916604
0.6 0.2564102564102564 3084.7998933759804 0.00047291824998447216 -208.20010662401955
0.6 0.28205128205128205 3014.2856982857297 0.00023964643450894468 -278.7143017142703
0.6 0.3076923076923077 2951.690011787704 0.00012751152475361122 -341.30998821229605
0.6 0.3333333333333333 2895.2175905656113 7.047686014021697e-05 -397.7824094343887
0.6 0.358974358974359 2843.8854837765575 4.0272208015425235e-05 -449.1145162234425
0.6 0.3846153846153846 2796.4424913052017 2.3569593638895813e-05 -496.55750869479834
0.6 0.41025641025641024 2753.270626656453 1.4242758000337287e-05 -539.7293733435472
0.6 0.4358974358974359 2713.33466879976 8.809740923608618e-06 -579.66533120024
0.6 0.4615384615384615 2676.2228493772222 5.564679207121495e-06 -616.7771506227778
0.6 0.48717948717948717 2641.603940002951 3.5826798039874953e-06 -651.3960599970492
0.6 0.5128205128205128 2609.195548611385 2.34711752860102e-06 -683.8044513886148
0.6 0.5384615384615384 2578.7554243544596 1.5622264672933339e-06 -714.2445756455404
0.6 0.5641025641025641 2549.6240721552927 1.048466420965538e-06 -743.3759278447073
0.6 0.5897435897435898 2522.556370855503 7.178059040682267e-07 -770.4436291444972
0.6 0.6153846153846154 2496.9156076665554 4.97515321727389e-07 -796.0843923334446
0.6 0.641025641025641 2472.5714894952007 3.487920707673146e-07 -820.4285105047993
0.6 0.6666666666666666 2449.411398998468 2.4714438056596686e-07 -843.588601001532
0.6 0.6923076923076923 2427.3352464641503 1.7686817885330674e-07 -865.6647535358497
0.6 0.717948717948718 2406.2550389076464 1.2775786101787292e-07 -886.7449610923536
0.6 0.7435897435897436 2386.092739611005 9.309263749495561e-08 -906.9072603889949
0.6 0.7692307692307692 2366.781957597925 6.839567736867184e-08 -926.2180424020748
0.6 0.7948717948717948 2348.2540550602853 5.0638063345815074e-08 -944.7459449397147
0.6 0.8205128205128205 2330.4566456692905 3.776560782088704e-08 -962.5433543307095
0.6 0.8461538461538461 2312.914089760887 2.8157985384417206e-08 -980.0859102391132
0.6 0.8717948717948718 2296.4544173217364 2.1290457329787035e-08 -996.5455826782636
0.6 0.8974358974358974 2280.586690692045 1.619785866067175e-08 -1012.4133093079549
0.6 0.923076923076923 2265.2732950781196 1.2396055261430032e-08 -1027.7267049218804
0.6 0.9487179487179487 2250.481043980994 9.539935562792993e-09 -1042.518956019006
0.6 0.9743589743589743 2236.1785383496112 7.381194348516508e-09 -1056.8214616503888
0.6 1.0 2222.337352420465 5.740123925349904e-09 -1070.6626475795351
0.6102564102564102 0.0 4089.758485473484 0.5934782530683373 796.7584854734841
0.6102564102564102 0.02564102564102564 4020.015549033518 0.4050337178026037 727.0155490335178
0.6102564102564102 0.05128205128205128 3936.443014897932 0.2519373641307344 643.4430148979318
0.6102564102564102 0.07692307692307693 3835.9622135353943 0.13869108144140924 542.9622135353943
0.6102564102564102 0.10256410256410256 3716.001862593243 0.0652915198863712 423.001862593243
0.6102564102564102 0.1282051282051282 3583.276474169524 0.026780034204686637 290.27647416952414
0.6102564102564102 0.15384615384615385 3453.29301036468 0.010472592821755186 160.29301036467996
0.6102564102564102 0.1794871794871795 3335.2397797631425 0.004188552710560718 42.23977976314245
0.6102564102564102 0.20512820512820512 3231.5556367220734 0.0017714440394004838 -61.44436327792664
0.6102564102564102 0.23076923076923075 3141.8876107515835 0.0008034258071031709 -151.11238924841655
0.6102564102564102 0.2564102564102564 3063.258409345691 0.00038644023383260236 -229.74159065430922
0.6102564102564102 0.28205128205128205 2993.1018777930335 0.000194629404414767 -299.8981222069665
0.6102564102564102 0.3076923076923077 2930.9086182941815 0.00010305772351264343 -362.09138170581855
0.6102564102564102 0.3333333333333333 2874.80656912216 5.670575345634133e-05 -418.19343087784
0.6102564102564102 0.358974358974359 2823.8140078427205 3.226677086573632e-05 -469.18599215727954
0.6102564102564102 0.3846153846153846 2777.157327888055 1.8911940542269504e-05 -515.8426721119449
0.6102564102564102 0.41025641025641024 2733.7431368477382 1.1314809916125549e-05 -559.2568631522618
0.6102564102564102 0.4358974358974359 2694.076716673613 6.973617299774141e-06 -598.9232833263868
0.6102564102564102 0.4615384615384615 2657.221399283425 4.39012489175898e-06 -635.778600716575
0.6102564102564102 0.48717948717948717 2622.845931424028 2.8175420527631197e-06 -670.1540685759719
0.6102564102564102 0.5128205128205128 2590.6620810029694 1.8401214780453332e-06 -702.3379189970306
0.6102564102564102 0.5384615384615384 2560.4262157605667 1.2210244244245512e-06 -732.5737842394333
0.6102564102564102 0.5641025641025641 2531.9333666347898 8.221161478996223e-07 -761.0666333652102
0.6102564102564102 0.5897435897435898 2504.5473829105094 5.57302928823424e-07 -788.4526170894906
0.6102564102564102 0.6153846153846154 2479.081058589309 3.8521127824390946e-07 -813.9189414106909
0.6102564102564102 0.641025641025641 2454.902487883553 2.6934155696808167e-07 -838.097512116447
0.6102564102564102 0.6666666666666666 2431.8990679894373 1.9035323732555907e-07 -861.1009320105627
0.6102564102564102 0.6923076923076923 2409.97188068404 1.358817937526897e-07 -883.0281193159599
0.6102564102564102 0.717948717948718 2389.0332008649307 9.790978932177212e-08 -903.9667991350693
0.6102564102564102 0.7435897435897436 2369.006372028793 7.11720515957582e-08 -923.9936279712069
0.6102564102564102 0.7692307692307692 2349.8220009613638 5.216525355877487e-08 -943.1779990386362
0.6102564102564102 0.7948717948717948 2331.4217741692014 3.853533801029536e-08 -961.5782258307986
0.6102564102564102 0.8205128205128205 2313.743281127155 2.8675037620767172e-08 -979.2567188728449
0.6102564102564102 0.8461538461538461 2296.7403227753507 2.1486672067335364e-08 -996.2596772246493
0.6102564102564102 0.8717948717948718 2280.367822611922 1.620675650179381e-08 -1012.6321773880782
0.6102564102564102 0.8974358974358974 2264.1567397077774 1.2208653876788755e-08 -1028.8432602922226
0.6102564102564102 0.923076923076923 2248.9478344236195 9.324249727524238e-09 -1044.0521655763805
0.6102564102564102 0.9487179487179487 2234.255974742707 7.161596332134007e-09 -1058.7440252572928
0.6102564102564102 0.9743589743589743 2220.0503665890365 5.530200799471455e-09 -1072.9496334109635
0.6102564102564102 1.0 2206.3024238889902 4.292374196845114e-09 -1086.6975761110098
0.6205128205128205 0.0 4085.9562609151026 0.5818806524606029 792.9562609151026
0.6205128205128205 0.02564102564102564 4014.543968068865 0.393232872375126 721.5439680688651
0.6205128205128205 0.05128205128205128 3928.747576760244 0.24119897097118417 635.7475767602441
0.6205128205128205 0.07692307692307693 3824.169681232023 0.12922372944568014 531.1696812320229
0.6205128205128205 0.10256410256410256 3699.5150077169374 0.05873931928116341 406.51500771693736
0.6205128205128205 0.1282051282051282 3563.3409430738075 0.023331322606508734 270.34094307380747
0.6205128205128205 0.15384615384615385 3430.8070703284325 0.008854793881484713 137.80707032843247
0.6205128205128205 0.1794871794871795 3312.2578300362356 0.0034844161781834534 19.257830036235646
0.6205128205128205 0.20512820512820512 3209.275238718651 0.0014647335114379933 -83.72476128134895
0.6205128205128205 0.23076923076923075 3119.463656552239 0.0006560437426282356 -173.53634344776083
0.6205128205128205 0.2564102564102564 3041.2911680923103 0.00031357887902450115 -251.70883190768973
0.6205128205128205 0.28205128205128205 2972.0905951815694 0.00015787708885446115 -320.90940481843063
0.6205128205128205 0.3076923076923077 2909.727838603062 8.269049672567261e-05 -383.2721613969379
0.6205128205128205 0.3333333333333333 2854.008281739071 4.529049251803833e-05 -438.9917182609288
0.6205128205128205 0.358974358974359 2803.3653782260967 2.566016338292907e-05 -489.6346217739033
0.6205128205128205 0.3846153846153846 2757.0291906427346 1.4978320372571313e-05 -535.9708093572654
0.6205128205128205 0.41025641025641024 2714.3856746558727 8.97770262924924e-06 -578.6143253441273
0.6205128205128205 0.4358974358974359 2674.462733998719 5.477129079602506e-06 -618.5372660012808
0.6205128205128205 0.4615384615384615 2637.871119671546 3.436195865074016e-06 -655.1288803284542
0.6205128205128205 0.48717948717948717 2603.7392985295196 2.1979808002760715e-06 -689.2607014704804
0.6205128205128205 0.5128205128205128 2571.785490301246 1.4309077493310205e-06 -721.2145096987538
0.6205128205128205 0.5384615384615384 2541.7584979869102 9.464990586631703e-07 -751.2415020130898
0.6205128205128205 0.5641025641025641 2513.461946858778 6.353368050516752e-07 -779.538053141222
0.6205128205128205 0.5897435897435898 2486.7243094681153 4.322796565427778e-07 -806.2756905318847
0.6205128205128205 0.6153846153846154 2461.3975723077706 2.978260300355784e-07 -831.6024276922294
0.6205128205128205 0.641025641025641 2436.9052578882215 2.061855877907098e-07 -856.0947421117785
0.6205128205128205 0.6666666666666666 2414.062538764044 1.4533045520413267e-07 -878.9374612359561
0.6205128205128205 0.6923076923076923 2392.2881091188488 1.0347344997907934e-07 -900.7118908811512
0.6205128205128205 0.717948717948718 2371.495322913007 7.436968001354505e-08 -921.5046770869931
0.6205128205128205 0.7435897435897436 2351.6073277996775 5.392687676981694e-08 -941.3926722003225
0.6205128205128205 0.7692307692307692 2332.5556665786467 3.9430130799373704e-08 -960.4443334213533
0.6205128205128205 0.7948717948717948 2314.2791172529955 2.9057391641594306e-08 -978.7208827470045
0.6205128205128205 0.8205128205128205 2296.726049063505 2.1573729166044833e-08 -996.2739509364951
0.6205128205128205 0.8461538461538461 2279.8400358172066 1.6129061122026443e-08 -1013.1599641827934
0.6205128205128205 0.8717948717948718 2263.5799751899604 1.2138784673483903e-08 -1029.4200248100396
0.6205128205128205 0.8974358974358974 2247.905318866411 9.193412972071419e-09 -1045.094681133589
0.6205128205128205 0.923076923076923 2232.779198717875 7.004518656110249e-09 -1060.2208012821252
0.6205128205128205 0.9487179487179487 2217.733362577675 5.324671619961591e-09 -1075.266637422325
0.6205128205128205 0.9743589743589743 2203.6270946852055 4.103456454256474e-09 -1089.3729053147945
0.6205128205128205 1.0 2189.975488110135 3.178710518899966e-09 -1103.0245118898652
0.6307692307692307 0.0 4082.014910142676 0.5700710054063685 789.014910142676
0.6307692307692307 0.02564102564102564 4008.8408676948898 0.3812613450275986 715.8408676948898
0.6307692307692307 0.05128205128205128 3920.3047954046897 0.22988272700323523 627.3047954046897
0.6307692307692307 0.07692307692307693 3811.64966881932 0.11981751553993202 518.6496688193201
0.6307692307692307 0.10256410256410256 3682.5364750557437 0.052626268696471724 389.5364750557437
0.6307692307692307 0.1282051282051282 3541.918478375224 0.02008224969220397 248.9184783752239
0.6307692307692307 0.15384615384615385 3407.551202855716 0.007426357423113649 114.55120285571593
0.6307692307692307 0.1794871794871795 3288.67250906648 0.002876842800189789 -4.327490933520039
0.6307692307692307 0.20512820512820512 3186.00189758527 0.0011973438638229169 -106.99810241473006
0.6307692307692307 0.23076923076923075 3096.563994323525 0.0005317621070387426 -196.4360056764749
0.6307692307692307 0.2564102564102564 3018.8741331428364 0.00025256426670229945 -274.1258668571636
0.6307692307692307 0.28205128205128205 2950.1369732772646 0.00012645142700852004 -342.8630267227354
0.6307692307692307 0.3076923076923077 2888.6965556435757 6.624104803235243e-05 -404.3034443564243
0.6307692307692307 0.3333333333333333 2832.8023786778244 3.5890270343479926e-05 -460.19762132217556
0.6307692307692307 0.358974358974359 2782.519806360227 2.024441934775926e-05 -510.480193639773
0.6307692307692307 0.3846153846153846 2736.5132743993577 1.1767503561003353e-05 -556.4867256006423
0.6307692307692307 0.41025641025641024 2694.1740300173683 7.0251357388225254e-06 -598.8259699826317
0.6307692307692307 0.4358974358974359 2655.0166762734484 4.2956651737299366e-06 -637.9833237265516
0.6307692307692307 0.4615384615384615 2618.150572161647 2.666872852328474e-06 -674.8494278383532
0.6307692307692307 0.48717948717948717 2584.2711770530696 1.7000567174821655e-06 -708.7288229469304
0.6307692307692307 0.5128205128205128 2552.5431531883733 1.1029973810244411e-06 -740.4568468116267
0.6307692307692307 0.5384615384615384 2522.734599736544 7.272753305975323e-07 -770.2654002634558
0.6307692307692307 0.5641025641025641 2494.639434233172 4.866528913745321e-07 -798.3605657668281
0.6307692307692307 0.5897435897435898 2468.0915357584845 3.301098963460793e-07 -824.9084642415155
0.6307692307692307 0.6153846153846154 2442.944062781507 2.2676385592208542e-07 -850.055937218493
0.6307692307692307 0.641025641025641 2419.0694840188216 1.5760583132198434e-07 -873.9305159811784
0.6307692307692307 0.6666666666666666 2395.8850430225925 1.0992408706016279e-07 -897.1149569774075
0.6307692307692307 0.6923076923076923 2374.2674477037312 7.8055682485317e-08 -918.7325522962688
0.6307692307692307 0.717948717948718 2353.62399967357 5.595508300553129e-08 -939.3760003264301
0.6307692307692307 0.7435897435897436 2333.8784719361324 4.047100831731566e-08 -959.1215280638676
0.6307692307692307 0.7692307692307692 2314.9629595827046 2.9518054724771524e-08 -978.0370404172954
0.6307692307692307 0.7948717948717948 2296.8167308651996 2.1700073206423222e-08 -996.1832691348004
0.6307692307692307 0.8205128205128205 2279.385269710868 1.607212331527882e-08 -1013.6147302891318
0.6307692307692307 0.8461538461538461 2262.619474140465 1.1988061719036208e-08 -1030.3805258595348
0.6307692307692307 0.8717948717948718 2246.478710053116 9.00236895744079e-09 -1046.5212899468838
0.6307692307692307 0.8974358974358974 2230.914966434676 6.802820115727801e-09 -1062.085033565324
0.6307692307692307 0.923076923076923 2215.8953734468187 5.171748535762425e-09 -1077.1046265531813
0.6307692307692307 0.9487179487179487 2201.387282363486 3.954408080858642e-09 -1091.612717636514
0.6307692307692307 0.9743589743589743 2187.359868716557 3.0401965632714095e-09 -1105.6401312834432
0.6307692307692307 1.0 2173.340503564733 2.329704282785878e-09 -1119.659496435267
完整数据集可在此处找到:https://fz-juelich.sciebo.de/s/SjwZyAPB4oEerZE
我最好使用imshow
来表示它使用meshgrid
将X和Y分量网格化在一起,并使用颜色条来表示每个点的Z值。整个数据集总共有1600个点,这可能会使它非常繁重。我生成了以下代码来绘制它:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import scipy.interpolate
# Load the 3D data file
data = np.genfromtxt("Ta_parameterspace_2mm.txt", skip_header=14, delimiter="\t", dtype = float)
#print(data)
reflect = data[:,0]
emiss = data[:,1]
temp = data[:,2]
X,Y = np.meshgrid(reflect,emiss)
rbf = scipy.interpolate.Rbf(reflect,emiss,temp,function="linear")
Z = rbf(X,Y)
plt.imshow(Z, vmin = temp.min(), vmax = temp.max(), origin = 'lower', extent = [reflect.min(), reflect.max(), emiss.min(), emiss.max()], cmap = 'seismic')
plt.colorbar()
#im = ax.imshow(array, extent=[x1.min(), x1.max(), y1.min(), y1.max()], origin='lower', cmap='seismic')
plt.set_xlabel('Reflectivity')
plt.set_ylabel('Emissivity')
plt.set_zlabel('Temperature (K)')
plt.show()
plt.savefig('Ta_parameterplot.pdf', bbox_inches='tight', format='pdf')
plt.savefig('Ta_parameterplot.png', dpi=300, bbox_inches='tight', format='png')
但是目前代码并不像我想的那样工作。代码读取的数据集是1600 x 1600 x 1600个数据点,然后导致内存溢出,如下所示:
Traceback (most recent call last):
File "C:\Users\t.smart\Documents\Data\PhD_Work\Ta_simulations_Fenics\ParameterSpace\parameterplot.py", line 16, in <module>
Z = rbf(X,Y)
File "C:\Users\t.smart\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scipy\interpolate\_rbf.py", line 288, in __call__
r = self._call_norm(xa, self.xi)
File "C:\Users\t.smart\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scipy\interpolate\_rbf.py", line 277, in _call_norm
return cdist(x1.T, x2.T, self.norm)
File "C:\Users\t.smart\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scipy\spatial\distance.py", line 2939, in cdist
return cdist_fn(XA, XB, out=out, **kwargs)
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 30.5 GiB for an array with shape (2560000, 1600) and data type float64
而这个数据集实际上是40 x 40个点,每个点都有单独的z值。
我如何解决这个问题并获得使用imshow绘制数据集的代码?
1条答案
按热度按时间zxlwwiss1#
tricontourf
是否适合您?使用此方法,您将不必创建网格(我认为这是失败的,因为您没有使用唯一值
reflect
和emiss
创建网格)给予