analyzing .ovf files

1,591 views
Skip to first unread message

Alexandra Stuart

unread,
Sep 28, 2021, 2:26:56 PM9/28/21
to mumax2
Hello everyone,

I am trying to analyze an MFM .ovf file using a matlab script from my advisor that reads .ovf files and extracts the data from them. I have used this script before to analyze magnetization .ovf files without issue, but this script does not translate to the MFM .ovf file. If anyone is familiar with how to extract data from an .ovf file, I would greatly appreciate it. 

Best,
Alexandra

Felipe Brevis

unread,
Sep 28, 2021, 2:54:27 PM9/28/21
to mum...@googlegroups.com
Hello Alexandra,
I use OOMMF in order to convert the .ovf files into .txt files, then I use matlab to read them. You can download OOMMF from its website and use a command like this,
On linux
oommf avf2ovf -format text -grid irreg $filename ${filename%.ovf}.txt

If you are using Windows you have to install TCL, on windows:
tclsh.exe C:/oommf/oommf.tcl avf2ovf -format text -grid irreg $filename ${filename%.ovf}.txt

Regards,

Felipe Brevis

--
You received this message because you are subscribed to the Google Groups "mumax2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mumax2+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mumax2/803b7d40-eac4-410a-9941-61d0621f6750n%40googlegroups.com.


--
Felipe Brevis Garrido
Docente
Departamento de Ciencias Físicas
Universidad de La Frontera


La información contenida en este correo electrónico y cualquier anexo o respuesta relacionada puede contener datos e información confidencial y no puede ser usada o difundida por personas distintas a su(s) destinatario(s). Si usted no es el destinatario de esta comunicación, le informamos que cualquier divulgación, distribución o copia de esta información constituye un delito conforme a la ley chilena. Si lo ha recibido por error, por favor borre el mensaje y todos sus anexos y notifique al remitente.

Las opiniones vertidas en este correo, no contenidas en un documento oficial de la Universidad, son responsabilidad de quien las emite o de quien solicitó su envío, en el ejercicio de su libertad de opinión y de expresión que, como miembro de la comunidad universitaria se le reconoce, y no representan, necesariamente, el pensamiento de la Universidad de La Frontera y de sus directivos.

Alexandra Stuart

unread,
Sep 28, 2021, 3:04:12 PM9/28/21
to mumax2
Hello Felipe,

Thank you for your response. I already have oommf downloaded on my computer so I can definitely do that. Once I have it in .txt format, what commands should I use in Matlab to read it? 

Best,
Alexandra

Felipe Brevis

unread,
Sep 28, 2021, 3:28:21 PM9/28/21
to mum...@googlegroups.com
Alexandra,
There are many ways to read files, here I show you how I do it. You can create a script that does this within a for loop to read many files.

    textfilename = sprintf('name_file.txt');
    
    if exist(textfilename,'file')
        open_file = fopen(textfilename,'r');
        DATA      = textscan(open_file,repmat('%f',1,6), 'HeaderLines',24,'CollectOutput',1);
        data      = DATA{1};
        RX        = data(:,1);
        RY        = data(:,2);
        RZ        = data(:,3);
        MX        = data(:,4);
        MY        = data(:,5);
        MZ        = data(:,6);
    end

Also, in order to convert many .OVF to .TXT you can make a bash script to create them.

for filename in *.ovf;
do
oommf avf2ovf -format text -grid irreg $filename ${filename%.ovf}.txt
done
mkdir OVF
mv *.ovf OVF
mkdir TXT
mv *.txt TXT


Greetings and success !! 



Joshua Lauzier

unread,
Sep 30, 2021, 1:55:00 AM9/30/21
to mumax2
Hello,

If you give the command

OutputFormat = OVF2_Text

prior to saving an OVF file, it will be in text format (basically it's a .txt, just with the .ovf file extension. you can even open it up in notepad as is). (You can also convert using mumax3-convert tool to do the same types of file conversions). It's the same thing, but will save you the trouble of having to convert with oommf.

The OVF format is very simple: There's a header (stores stuff like dimensions, cell sizes) , then a column with the value (1 column for scalar values, 3 columns, for vector data) for each cell, then a footer. I would recommend opening up one in notepad after using 'OutputFormat = OVF2_Text' , you will recognize the format pretty quickly. For example, for a simulation of size 128x128x6=98,304 cells the column(s) will be exactly 98,304 lines long.

The method Felipe gave using fopen and then textscan is a good way to read it.

However, an MFM OVF is identical to other OVF files, with one notable difference. It is a singular column, because it is there is only one value per cell- the magnitude of the contrast/tip deflection, which is a scalar. whereas magnetization data is 3 columns, because it is a vector. You should be able to tweak your existing program to look for only 1 column instead of 3 and it should work.

Best,
Josh L.

SATEESH KANDUKURI

unread,
Oct 8, 2021, 9:22:32 AM10/8/21
to mumax2
Dear Josh,

I failed to convert all .ovf files into .txt format using mumax3-convert. I used the command mumax3-convert -ovf2 txt *.ovf 

Could you please help me out? I attached the error screenshot for your reference. 

Best regards,
Sateesh

Screenshot 2021-10-08 184718.png

Joshua Lauzier

unread,
Oct 8, 2021, 8:03:40 PM10/8/21
to mumax2
Hi Sateesh,

If you're trying to convert between ovf formats, you need to put the files in a different folder. Otherwise you'd have two files with identical file names, even if the contents are different- and you can't have two files both named "m001000.ovf", for instance or the operating system wouldn't be able to tell them apart. One way you can do this is to create a new folder, and specify the output files be put there. This can be done using the -o flag. So for example you could call

mumax3-convert -o=ovf2converted -ovf2=text m001000.ovf

This will create a new folder called 'ov2fconverted' for you (which will be located inside the current directory), and put the converted file for m001000.ovf there.

(You don't need to do this if you're converting to say, csv format or whatever. It's just because the conversion doesn't delete the input file, so you'd happen to have both input and output files with the same name if they're ovf's)

Best,
Josh

SATEESH KANDUKURI .

unread,
Oct 9, 2021, 12:15:43 AM10/9/21
to mumax2
Dear Josh,

Thank you so much for the clarification.

Best regards,
Sateesh


The information contained in this electronic communication is intended solely for the individual(s) or entity to which it is addressed. It may contain proprietary, confidential and/or legally privileged information. Any review, retransmission, dissemination, printing, copying or other use of, or taking any action in reliance on the contents of this information by person(s) or entities other than the intended recipient is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us by responding to this email or telephone and immediately and permanently delete all copies of this message and any attachments from your system(s). The contents of this message do not necessarily represent the views or policies of BITS Pilani.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages