Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
More explanations in the comments as requested by the reviewer C
  • Loading branch information
bochardn authored Aug 24, 2023
1 parent fa2cab1 commit 6fbe7a5
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/raw_data_processing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -96,7 +95,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -107,7 +105,20 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: '../data/Regular/S6v11_2/C_1/acq_20230405135452_km476_kd495_dff.bin'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"Input \u001b[1;32mIn [3]\u001b[0m, in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m## #########################################\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m## Main section\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m## #########################################\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \n\u001b[0;32m 5\u001b[0m \u001b[38;5;66;03m# Read data from binary file, returns a matrix of bits\u001b[39;00m\n\u001b[1;32m----> 6\u001b[0m full_data \u001b[38;5;241m=\u001b[39m \u001b[43mread_dff\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilename\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mKM\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mKD\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# N_CYCLES x KM\u001b[39;00m\n\u001b[0;32m 8\u001b[0m \u001b[38;5;66;03m# Compute rng data from dff and record it to a file\u001b[39;00m\n\u001b[0;32m 9\u001b[0m \u001b[38;5;66;03m# (uncomment the following line if you want to get the random bits)\u001b[39;00m\n\u001b[0;32m 10\u001b[0m \u001b[38;5;66;03m#get_rng_from_dff(filename, full_data, KM, KD)\u001b[39;00m\n\u001b[0;32m 11\u001b[0m \n\u001b[0;32m 12\u001b[0m \u001b[38;5;66;03m# Nb of periods : uncomment one of the 2 following lines (max possible periods or a fixed nb of periods)\u001b[39;00m\n\u001b[0;32m 13\u001b[0m \u001b[38;5;66;03m#Nsum = len(bin_data)//KD\u001b[39;00m\n\u001b[0;32m 14\u001b[0m Nsum \u001b[38;5;241m=\u001b[39m Nval_max\n",
"Input \u001b[1;32mIn [1]\u001b[0m, in \u001b[0;36mread_dff\u001b[1;34m(filename, KM, KD)\u001b[0m\n\u001b[0;32m 22\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mread_dff\u001b[39m(filename, KM, KD):\n\u001b[0;32m 23\u001b[0m \u001b[38;5;66;03m###############################\u001b[39;00m\n\u001b[0;32m 24\u001b[0m \u001b[38;5;124;03m\"\"\"Read dff bits from the raw file. Return a matrix of shape (n_cycles, KD)\"\"\"\u001b[39;00m\n\u001b[1;32m---> 25\u001b[0m bytes_data \u001b[38;5;241m=\u001b[39m \u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfromfile\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilename\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43muint8\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# read bytes\u001b[39;00m\n\u001b[0;32m 26\u001b[0m bits_data \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39munpackbits(bytes_data, axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, count\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, bitorder\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlittle\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;66;03m# unpack to bits\u001b[39;00m\n\u001b[0;32m 27\u001b[0m bits_data \u001b[38;5;241m=\u001b[39m bits_data\u001b[38;5;241m.\u001b[39mreshape((\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m32\u001b[39m))[:, ::\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\u001b[38;5;241m.\u001b[39mravel() \u001b[38;5;66;03m# reverse bits order in blocks of 32\u001b[39;00m\n",
"\u001b[1;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '../data/Regular/S6v11_2/C_1/acq_20230405135452_km476_kd495_dff.bin'"
]
}
],
"source": [
"## #########################################\n",
"## Main section\n",
Expand All @@ -116,19 +127,18 @@
"# Read data from binary file, returns a matrix of bits\n",
"full_data = read_dff(filename, KM, KD) # N_CYCLES x KM\n",
"\n",
"# Compute rng data from dff and record it to a file\n",
"# get_rng_from_dff(filename, full_data, KM, KD)\n",
"# Compute rng data from dff and record it to a file that is NIST compatible\n",
"# (uncomment the following line if you want to get the random bits)\n",
"#get_rng_from_dff(filename, full_data, KM, KD)\n",
"\n",
"# Max nb of periods\n",
"# Nsum = len(bin_data)//KD\n",
"# If you prefer to fix the number of periods\n",
"# Nb of periods : uncomment one of the 2 following lines (max possible periods or a fixed nb of periods)\n",
"#Nsum = len(bin_data)//KD\n",
"Nsum = Nval_max\n",
"\n",
"img = full_data[0:Nsum]"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -210,7 +220,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -258,7 +267,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -336,7 +344,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -350,15 +358,14 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.1"
"version": "3.9.6"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "7c41a376ffa545dfd4d7d65238dc7fe37d37b3a08798bf7fd1131939b8c4c15f"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit 6fbe7a5

Please sign in to comment.