started removing absolut file paths in the middle of the scripts

This commit is contained in:
2025-09-03 11:27:02 +02:00
parent d45a1699f3
commit a538055e46
6 changed files with 96 additions and 53 deletions

View File

@@ -5,8 +5,8 @@
"id": "ca3c9c7af43b4e58",
"metadata": {
"ExecuteTime": {
"end_time": "2025-09-01T10:47:47.838080Z",
"start_time": "2025-09-01T10:47:47.739342Z"
"end_time": "2025-09-03T09:11:36.449408Z",
"start_time": "2025-09-03T09:11:36.393235Z"
}
},
"source": [
@@ -82,13 +82,10 @@
"id": "62f32f705df821b4",
"metadata": {},
"source": [
"## Measurement dashbord\n",
"# General analysis tools\n",
"Statistics of all measurements, multiple plots drop down sith mesurement selection and statistical evaluation\n",
"\n",
"- Zeilscheiben plot mit statistischen kreisen, auf der seite je ein binning plot\n",
"- FFt\n",
"- Moving avarage\n",
"-"
"Collection of scripts for creating plots for different measurements, some scripts also include data processing which has to pe turned off/on in the code."
]
},
{
@@ -97,8 +94,8 @@
"metadata": {
"scrolled": true,
"ExecuteTime": {
"end_time": "2025-09-01T13:25:54.148793Z",
"start_time": "2025-09-01T13:25:54.100908Z"
"end_time": "2025-09-03T09:18:21.231127Z",
"start_time": "2025-09-03T09:18:21.185128Z"
}
},
"source": [
@@ -132,7 +129,7 @@
"temp_correction = 0\n",
"\n",
"\n",
"ROOT_DIR = rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\" # ← Change this to your root directory\n",
"ROOT_DIR = rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\" # ← Change this to your root directory\n",
"# =====================\n",
"output1 = widgets.Output()\n",
"output2 = widgets.Output()\n",
@@ -150,7 +147,7 @@
"\n",
"# First dropdown: subfolders of ROOT_DIR\n",
"first_dropdown = widgets.Dropdown(\n",
" options=list_subfolders(ROOT_DIR),\n",
" options=list_subfolders(rf\"{ROOT_DIR}\\data\"),\n",
" description='Folder:',\n",
" layout=widgets.Layout(width='50%')\n",
")\n",
@@ -163,8 +160,7 @@
")\n",
"\n",
"def init_correcrtion():\n",
" conf = myu.load_object(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Config\\display.json\")\n",
" return 1#conf.get(\"temp_correction\")==1\n",
" return 1\n",
"\n",
"displyscatter = widgets.Button(description='Display Scatterplot', layout=widgets.Layout(width='50%'))\n",
"displyFFT = widgets.Button(description='Display PFT', layout=widgets.Layout(width='50%'))\n",
@@ -181,35 +177,35 @@
"def on_button_clicked(o):\n",
" with output1:\n",
" clear_output()\n",
" print(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" display_my(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" print(rf\"{ROOT_DIR}\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" display_my(rf\"{ROOT_DIR}\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
"def on_button_clicked_ft(o):\n",
" with output1:\n",
" clear_output()\n",
" print(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" display_my_ft(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" print(rf\"{ROOT_DIR}\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" display_my_ft(rf\"{ROOT_DIR}\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
"def on_btn_clicked_raw(o):\n",
" with output3:\n",
" clear_output()\n",
" print(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" display_raw(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" print(rf\"{ROOT_DIR}\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" display_raw(rf\"{ROOT_DIR}\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
"def on_btn_clicked_stat(o):\n",
" with output4:\n",
" clear_output()\n",
" print(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" rolling(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" print(rf\"{ROOT_DIR}\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
" rolling(rf\"{ROOT_DIR}\\data\\{first_dropdown.value}\\{second_dropdown.value}\")\n",
"\n",
"def update_second_dropdown(change):\n",
" selected_folder = os.path.join(ROOT_DIR, change['new'])\n",
" selected_folder = os.path.join(rf\"{ROOT_DIR}\\data\", change['new'])\n",
" subfolders = list_subfolders(selected_folder)\n",
" second_dropdown.options = subfolders if subfolders else [\"<no subfolders>\"]\n",
" second_dropdown.value = subfolders[-1] if subfolders else \"<no subfolders>\"\n",
"\n",
"def set_temp_correction(change_c):\n",
" new_state = 1 if change_c['new']==1 else 0\n",
" conf_corr = myu.load_object(r\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Config\\display.json\")\n",
" conf_corr = myu.load_object(rf\"{ROOT_DIR}\\Config\\display.json\")\n",
" conf_corr['temp_correction'] = new_state\n",
" myu.save_config(r\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Config\\display.json\",conf_corr)\n",
" myu.save_config(rf\"{ROOT_DIR}\\Config\\display.json\",conf_corr)\n",
"\n",
" with output5:\n",
" clear_output()\n",
@@ -348,11 +344,11 @@
" # Fixing random state for reproducibility\n",
"def display_my_ft(path):\n",
" axis_data_file_path_1 = myu.find_newest_dat_file(path)\n",
" #mf.analyze_repeatability(axis_data_file_path_1,1.1)\n",
"\n",
"\n",
"\n",
" x_vals1, y_vals1, times1 = myu.load_xy_data(axis_data_file_path_1)\n",
" # some random data\n",
"\n",
" conf_path = path.split(\"\\\\\")[-1]\n",
" conf_path = conf_path.split(\"_\")[0]\n",
" print(conf_path)\n",
@@ -378,8 +374,7 @@
" conf_path = path.split(\"\\\\\")[-1]\n",
" conf_path = conf_path.split(\"_\")[0]\n",
" print(conf_path)\n",
" a = 0\n",
" b = 5000\n",
"\n",
" # Convert pixel values and slice the relevant time window\n",
" scale = get_pixel_size(rf\"{path}\\conf_{conf_path}.json\")\n",
" x = (x_vals1 * scale)[a:b]\n",
@@ -437,11 +432,11 @@
"\n",
" #path to folders\n",
" axis_data_file_path_1 = myu.find_newest_dat_file(path)\n",
" data_folder = r'C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\Temp'\n",
" data_folder = rf'{ROOT_DIR}\\data\\Temp'\n",
" file_path = myu.find_newest_dat_file(data_folder)\n",
"\n",
" x_vals1, y_vals1, times1 = myu.load_xy_data(axis_data_file_path_1)\n",
" timesT, temps = myu.load_temp_data(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\Temp\\20250825_160150.dat\")\n",
" timesT, temps = myu.load_temp_data(file_path)\n",
"\n",
"\n",
" df1 = pd.DataFrame({'temp': temps[2][:]},index=timesT)\n",
@@ -527,19 +522,16 @@
"\n",
"\n",
" diff_y = (y_high_std - y_low_std)\n",
" \"\"\"good_h = y_high_std.where(diff < 1)\n",
" good_t = times1.where(diff < 1)\n",
" good_l = times1.where(diff < 1)\"\"\"\n",
"\n",
" # Plot y over time\n",
" ax2_raw.plot(times1, rolling_avg_y['y'].to_numpy(),linewidth= 0.5 , label=\"Y avg Position\")\n",
" corr_conf = myu.load_object(rf\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Config\\display.json\")\n",
" corr_conf = myu.load_object(rf\"{ROOT_DIR}\\Config\\display.json\")\n",
" if corr_conf.get(\"temp_correction\")==1:\n",
" ax2_raw.plot(rolling_avg_merged.index.to_numpy(), rolling_avg_merged['y'].to_numpy(),linewidth= 0.5,c='purple' , label=\"camera pole temp corrected Position\")\n",
" ax2_raw.fill_between(times1, y_high_std, y_low_std,linewidth=0, alpha=0.5,facecolor='green',where=diff_y<minHalafstdy)\n",
" ax2_raw.fill_between(times1, y_high_std, y_low_std,linewidth=0, alpha=0.5,facecolor='orange',where=((diff_y >= minHalafstdy) & (diff_y <= maxHalfstdy)))\n",
" ax2_raw.fill_between(times1, y_high_std, y_low_std,linewidth=0, alpha=0.5,facecolor='red',where=diff_y>maxHalfstdy)\n",
"\n",
" #ax2_raw.fill_between(times1, 1, where=diff > 1, facecolor='green', alpha=.5)\n",
"\n",
"\n",
"\n",
@@ -575,7 +567,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "f67b5d33350945dc9467d9313ce10308"
"model_id": "94c0dae5adb947f5bbee31283d75a323"
}
},
"metadata": {},
@@ -589,7 +581,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "14fd2925171943f4aa8e57231402365a"
"model_id": "b87eaba00c4446ce91c03d16c6d7aff8"
}
},
"metadata": {},
@@ -603,7 +595,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "b1ee4aa15add48a9ad2a3f6af526e8b0"
"model_id": "a6b072252eff4e99b9eb6d001c214a20"
}
},
"metadata": {},
@@ -617,7 +609,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "9569138c60de4934bbe6f4eb84a48769"
"model_id": "adae3df1efa745ebb586a35354715c54"
}
},
"metadata": {},
@@ -631,7 +623,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "34792bcf1dcb4e66a978f1bb7c99a389"
"model_id": "7308eed6d70d4b9a8bfb36e9271de1ba"
}
},
"metadata": {},
@@ -645,7 +637,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "d72bc18bfa614f7faadb92e1e2f10e13"
"model_id": "2701a20100864586a13a516c38498ff1"
}
},
"metadata": {},
@@ -659,7 +651,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "53d473ca53cd474dbe34232cf8fe08c1"
"model_id": "b3092f1a437a4ed4be516bad208ae871"
}
},
"metadata": {},
@@ -673,7 +665,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "a71f37b5f09a4cf48db951cab08404b6"
"model_id": "8eb3322e708541a6a9ee8d01f2f11d2b"
}
},
"metadata": {},
@@ -687,7 +679,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "9280e01058124a3f8ff1b695cb786bd6"
"model_id": "647d2e66779a487f9cdfc24809ae50be"
}
},
"metadata": {},
@@ -701,7 +693,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "f52682ac3d254ee98c2baee2964c398b"
"model_id": "aa7a7ce839fe487daf706f18e1e637ca"
}
},
"metadata": {},
@@ -715,7 +707,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "3daccf784e40479792028bdb3b1e30b8"
"model_id": "05e08f4683974a90a02f97a4e03ad1e6"
}
},
"metadata": {},
@@ -729,7 +721,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "7aa19653ad4f41f18a29ef3566774e2c"
"model_id": "35c1735497ce46f1b9e28002757e3209"
}
},
"metadata": {},
@@ -830,11 +822,16 @@
"execution_count": null
},
{
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2025-09-03T09:25:03.496022Z",
"start_time": "2025-09-03T09:25:03.108257Z"
}
},
"cell_type": "code",
"source": [
"pooling = 0\n",
"STATIC_LOG_FILE = \"static_tests_log.csv\"\n",
"STATIC_LOG_FILE = \"CSV_logs/static_tests_log.csv\"\n",
"\n",
"def log_static_test(x_std, y_std, x_p2v, y_p2v, nr_of_cycles=0, path=None):\n",
" if path is None:\n",
@@ -1011,8 +1008,44 @@
"pd.read_csv(STATIC_LOG_FILE)\n"
],
"id": "39fcd9032d757549",
"outputs": [],
"execution_count": null
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using daily folder: C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\data20250829_alignment_tests\n",
"no measruments on that day\n",
"going one day back\n",
"no measruments on that day\n",
"going one day back\n",
"no measruments on that day\n",
"going one day back\n",
"no measruments on that day\n",
"going one day back\n",
"no measruments on that day\n",
"going one day back\n",
"no measruments on that day\n",
"going one day back\n",
"no measruments on that day\n",
"going one day back\n",
"None\n"
]
},
{
"ename": "TypeError",
"evalue": "expected str, bytes or os.PathLike object, not NoneType",
"output_type": "error",
"traceback": [
"\u001B[31m---------------------------------------------------------------------------\u001B[39m",
"\u001B[31mTypeError\u001B[39m Traceback (most recent call last)",
"\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[7]\u001B[39m\u001B[32m, line 52\u001B[39m\n\u001B[32m 50\u001B[39m \u001B[38;5;28mprint\u001B[39m(axis_path_1)\n\u001B[32m 51\u001B[39m \u001B[38;5;66;03m#axis_path_1 = r\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\data\\data20250718_alignment_tests\\20250718_113013_static_0\" #uncomment for specific path\u001B[39;00m\n\u001B[32m---> \u001B[39m\u001B[32m52\u001B[39m axis_data_file_path_1 = \u001B[43mmyu\u001B[49m\u001B[43m.\u001B[49m\u001B[43mfind_newest_dat_file\u001B[49m\u001B[43m(\u001B[49m\u001B[43maxis_path_1\u001B[49m\u001B[43m)\u001B[49m\n\u001B[32m 53\u001B[39m \u001B[38;5;28mprint\u001B[39m(axis_data_file_path_1)\n\u001B[32m 54\u001B[39m \u001B[38;5;66;03m#mf.analyze_repeatability(axis_data_file_path_1,1.1)\u001B[39;00m\n",
"\u001B[36mFile \u001B[39m\u001B[32m~\\Python_Projects\\StagePerformaceDocu\\Scripts\\myutility.py:22\u001B[39m, in \u001B[36mfind_newest_dat_file\u001B[39m\u001B[34m(folder)\u001B[39m\n\u001B[32m 21\u001B[39m \u001B[38;5;28;01mdef\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34mfind_newest_dat_file\u001B[39m(folder):\n\u001B[32m---> \u001B[39m\u001B[32m22\u001B[39m dat_files = glob.glob(\u001B[43mos\u001B[49m\u001B[43m.\u001B[49m\u001B[43mpath\u001B[49m\u001B[43m.\u001B[49m\u001B[43mjoin\u001B[49m\u001B[43m(\u001B[49m\u001B[43mfolder\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[33;43m'\u001B[39;49m\u001B[33;43m*.dat\u001B[39;49m\u001B[33;43m'\u001B[39;49m\u001B[43m)\u001B[49m)\n\u001B[32m 23\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m dat_files:\n\u001B[32m 24\u001B[39m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mFileNotFoundError\u001B[39;00m(\u001B[33m\"\u001B[39m\u001B[33mNo .dat files found in the specified directory.\u001B[39m\u001B[33m\"\u001B[39m)\n",
"\u001B[36mFile \u001B[39m\u001B[32m<frozen ntpath>:100\u001B[39m, in \u001B[36mjoin\u001B[39m\u001B[34m(path, *paths)\u001B[39m\n",
"\u001B[31mTypeError\u001B[39m: expected str, bytes or os.PathLike object, not NoneType"
]
}
],
"execution_count": 7
},
{
"cell_type": "code",

View File

@@ -581,7 +581,7 @@
"source": [
"pooling = 0\n",
"\n",
"STATIC_LOG_FILE = \"static_tests_log.csv\"\n",
"STATIC_LOG_FILE = \"CSV_logs/static_tests_log.csv\"\n",
"\n",
"def log_static_test(x_std, y_std, x_p2v, y_p2v, nr_of_cycles=0, path=None):\n",
" if path is None:\n",
@@ -770,7 +770,7 @@
},
"source": [
"# Log format: date, change_description, measurement_id, notes\n",
"LOG_FILE = \"controller_improvements_log.csv\"\n",
"LOG_FILE = \"CSV_logs/controller_improvements_log.csv\"\n",
"\n",
"def log_improvement(change_desc, meas_id, notes):\n",
" new_entry = pd.DataFrame([{\n",

View File

@@ -1,5 +1,15 @@
{
"cells": [
{
"metadata": {},
"cell_type": "markdown",
"source": [
"## No Scripts which found use in the final Measurements\n",
"\n",
"Collection of function tests and discarded solutions"
],
"id": "862775db0f0d910b"
},
{
"cell_type": "code",
"id": "initial_id",