Last active
September 30, 2023 17:58
-
-
Save samarlyka/245055573bf52266ddf0bda608d2c95b to your computer and use it in GitHub Desktop.
Kode Sumber - Tutorial Plotting Data Simulasi OOMMF dari Waktu ke Waktu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| # Alamat tempat berkas CSV berada | |
| wd = '/ssynthesia/ghostcity/git-local/02306.00013-neptunal-ix-oommf-nanoparticle/ix-meh-12/' | |
| # Berkas CSV masukan | |
| csv = '200nm.csv' | |
| # Membaca berkas CSV hasil simulasi OOMMF | |
| df = pd.read_csv(wd + csv) | |
| # Membaca kolom CSV (sumbu-y) | |
| c1 = df['Oxs_TimeDriver::mx'] | |
| c2 = df['Oxs_TimeDriver::my'] | |
| c3 = df['Oxs_TimeDriver::mz'] | |
| # Membaca kolom CSV (sumbu-x) | |
| t = df['Oxs_TimeDriver::Simulation time'] | |
| # Melakukan iterasi terhadap data pada CSV | |
| for i in range(0, 150): | |
| # Debugging | |
| print('Memplotting data baris nomor:', i) | |
| # Membuat grafik plotting | |
| plt.figure(dpi=150.0) | |
| plt.xlabel('Simulation Time') | |
| plt.ylabel('mx, my, mz') | |
| # Membuat sebaran data plotting | |
| plt.plot(t[:i], c1[:i], label='mx') | |
| plt.plot(t[:i], c2[:i], label='my') | |
| plt.plot(t[:i], c3[:i], label='mz') | |
| # Menampilkan legenda dari plotting | |
| plt.legend(fontsize='medium') | |
| # Menyimpan gambar plotting | |
| nama_ekspor = f'matplotlib-{i}.png' | |
| plt.savefig(wd + nama_ekspor) | |
| plt.close() | |
| continue | |
| # Selamat tinggal! | |
| exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment