diff --git a/ifes_apt_tc_data_modeling/ato/ato_reader.py b/ifes_apt_tc_data_modeling/ato/ato_reader.py index 70e8d43..d9a75e1 100644 --- a/ifes_apt_tc_data_modeling/ato/ato_reader.py +++ b/ifes_apt_tc_data_modeling/ato/ato_reader.py @@ -41,7 +41,8 @@ def __init__(self, filename: str): self.number_of_events = None self.version = None retval = self.get_ato_version() - if retval in [3, 4, 5]: + if retval in [3, 5]: + # there also seems to exist a version 4 but I have never seen an example for it self.version = retval print(f"ATO file is in a supported version {self.version}") if self.version == 3: @@ -81,25 +82,26 @@ def get_reconstructed_positions(self): xyz.unit = "nm" if self.version == 3: - xyz.typed_value[:, 0] = \ - get_memory_mapped_data(self.filename, " x - xyz.typed_value[:, 1] = \ - get_memory_mapped_data(self.filename, " y - xyz.typed_value[:, 2] = \ - get_memory_mapped_data(self.filename, " z + for dim in [0, 1, 2]: + xyz.typed_value[:, dim] = \ + get_memory_mapped_data(self.filename, " x, wpy -> y, fpz -> z if self.version == 5: + # publicly available sources are inconclusive whether coordinates are in angstroem or nm + # based on the evidence of usa_denton_smith Si.epos converted to v5 ATO via CamecaRoot + # the resulting x, y coordinates suggests that v5 ATO stores in angstroem, while fpz is stored in nm? + # however https://zenodo.org/records/8382828 reports the reconstructed positions to be named + # not at all wpx, wpy and fpz but x, y, z instead and here claims the nm xyz.typed_value[:, 0] = \ np.float32(get_memory_mapped_data(self.filename, " x + 5000 + 0, 40, self.number_of_events) * 0.1) # wpx -> x xyz.typed_value[:, 1] = \ np.float32(get_memory_mapped_data(self.filename, " y + 5000 + 2, 40, self.number_of_events) * 0.1) # wpy -> y xyz.typed_value[:, 2] = \ get_memory_mapped_data(self.filename, " z + 5000 + 4, 40, self.number_of_events) # fpz -> z return xyz def get_mass_to_charge_state_ratio(self): diff --git a/ifes_apt_tc_data_modeling/rng/rng_reader.py b/ifes_apt_tc_data_modeling/rng/rng_reader.py index 3c21912..323c2cb 100644 --- a/ifes_apt_tc_data_modeling/rng/rng_reader.py +++ b/ifes_apt_tc_data_modeling/rng/rng_reader.py @@ -34,6 +34,9 @@ from ase.data import atomic_numbers, atomic_masses, chemical_symbols +# there are specific examples for unusual range files here: +# https://hg.sr.ht/~mycae/libatomprobe/browse/test/samples/ranges?rev=tip + def evaluate_rng_range_line( i: int, line: str, column_id_to_label: dict, n_columns: int) -> dict: diff --git a/ifes_apt_tc_data_modeling/utils/dev/ato/ato.m b/ifes_apt_tc_data_modeling/utils/dev/ato/ato.m new file mode 100644 index 0000000..cf166c3 --- /dev/null +++ b/ifes_apt_tc_data_modeling/utils/dev/ato/ato.m @@ -0,0 +1,11 @@ +raw = fopen(["/home/kaiobach/Research/paper_paper_paper/joss_nomad_apt/bb_analysis/data/fra_rouen_karam/Experimental Analysis of LaB6 ; Negative Pulse ; DC Voltage 6.6 kV ; Amplitudes 2.5 kV and 3 kV.ato"]); +attoread = inf; %max number of atoms +data.version = fread(raw,2,'uint32','l'); +display(data.version(2)); +header = 5000; +oneat = 320; +fseek(raw,header,'bof'); +wpx = fread(raw,attoread,'int16',oneat/8-2,'b'); +fseek(raw,header+2,'bof'); +wpy = fread(raw,attoread,'int16',oneat/8-2,'b'); +fclose(raw); diff --git a/tests/TestsForDevelopers.ipynb b/tests/TestsForDevelopers.ipynb index 074cba2..b7e0e19 100644 --- a/tests/TestsForDevelopers.ipynb +++ b/tests/TestsForDevelopers.ipynb @@ -41,6 +41,80 @@ "from ase.data import atomic_numbers, atomic_masses, chemical_symbols" ] }, + { + "cell_type": "markdown", + "id": "52294143-78c7-47bf-b39e-9e40eec3999d", + "metadata": {}, + "source": [ + "## ATO" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f1c42976-c225-40f4-9797-bfcc0d566012", + "metadata": {}, + "outputs": [], + "source": [ + "from ifes_apt_tc_data_modeling.ato.ato_reader import ReadAtoFileFormat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0d1f9d2f-ca12-4d74-9664-08a722d24c46", + "metadata": {}, + "outputs": [], + "source": [ + "prefix = f\"{os.getcwd()}/../../../../../paper_paper_paper/joss_nomad_apt/bb_analysis/data\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "084d2bb0-5a52-49fa-af88-d9851db48521", + "metadata": {}, + "outputs": [], + "source": [ + "directory = f\"{prefix}/usa_cameca_ato_format\"\n", + "fnm = [\"Si.epos.v3.ATO\",\n", + " \"Si.epos.v5.ATO\"]\n", + "# directory = f\"{prefix}/bel_leuven_imec/dataverse_files/correlative-APT-EM\"\n", + "# fnm = [\"finfet/finfet_system.ato\",\n", + "# \"multilayer/multilayer_system.ato\"]\n", + "# directory = f\"{prefix}/fra_rouen_karam\"\n", + "# fnm = [\"Experimental Analysis of LaB6 ; Negative Pulse ; DC Voltage 6.6 kV ; Amplitudes 2.5 kV and 3 kV.ato\",\n", + "# \"Experimental Analysis of LaB6 ; Positive Pulse ; Amplitude 15 kV ; DC Voltage 3.2 kV and 5 kV.ato\",\n", + "# \"Experimental Analysis of LaB6 ; Positive Pulse ; DC Voltage 2.5 kV ; Amplirudes 13.5 kV and 15 kV.ato\",\n", + "# \"Experimental Analysis of LaB6 ; Positive Pulse ; DC Voltage 7 kV ; Amplitudes 6.5 kV and 7.5 kV.ato\"]\n", + "# directory = f\"{prefix}/usa_richland_kruska/kruska/APT\"\n", + "# fnm = [\"R31_11378-v01.ato\",\n", + "# \"R31_11381-v02.ato\",\n", + "# \"R31_11553-v01.ato\",\n", + "# \"R31_11554-v01.ato\",\n", + "# \"R31_11556-v01.ato\"]\n", + "print(directory)\n", + "for filename in fnm:\n", + " print(os.path.getsize(f\"{directory}/{filename}\"))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b2a4eb3b-0a08-47a6-913b-cf4178e6bb24", + "metadata": {}, + "outputs": [], + "source": [ + "for filename in fnm:\n", + " print(f\"{directory}/{filename}\")\n", + " ato = ReadAtoFileFormat(f\"{directory}/{filename}\")\n", + " \n", + " xyz = ato.get_reconstructed_positions()\n", + " print(xyz.typed_value)\n", + " m_q = ato.get_mass_to_charge_state_ratio()\n", + " print(m_q.typed_value)" + ] + }, { "cell_type": "markdown", "id": "83369dab-5ce9-4c9e-810e-58e9f8bb93cc", @@ -415,7 +489,6 @@ "cell_type": "markdown", "id": "0ab488b6-ddb3-4507-8f4e-de1c425106d6", "metadata": { - "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -527,7 +600,6 @@ "cell_type": "markdown", "id": "8783c551-27b2-4902-93c4-2187b1ba0fab", "metadata": { - "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -703,7 +775,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.16" + "version": "3.11.5" } }, "nbformat": 4,