From 92644264cd2f16bb77ca9d271003f19ba0c8fd67 Mon Sep 17 00:00:00 2001 From: Ron Hildebrandt Date: Fri, 13 Dec 2024 08:55:27 +0100 Subject: [PATCH] add intitial version for jdx reader from thermo fischer --- .../dxr_sucrose780.JDX | 251 ++++++++++++++++++ .../config/config_file_thermo_fischer.json | 50 ++++ src/pynxtools_raman/reader.py | 72 +++++ 3 files changed, 373 insertions(+) create mode 100644 examples/thermo_fischer/Thermo Fischer Scientific Raman Example/Standard Raman dispersiv/dxr_sucrose780.JDX create mode 100644 src/pynxtools_raman/config/config_file_thermo_fischer.json diff --git a/examples/thermo_fischer/Thermo Fischer Scientific Raman Example/Standard Raman dispersiv/dxr_sucrose780.JDX b/examples/thermo_fischer/Thermo Fischer Scientific Raman Example/Standard Raman dispersiv/dxr_sucrose780.JDX new file mode 100644 index 0000000..6d71dd6 --- /dev/null +++ b/examples/thermo_fischer/Thermo Fischer Scientific Raman Example/Standard Raman dispersiv/dxr_sucrose780.JDX @@ -0,0 +1,251 @@ +##TITLE=bogus DXR sucrose 780 for installer testing +##JCAMP-DX=5.01 $$ Nicolet v. 521 +##DATATYPE=RAMAN SPECTRUM +##ORIGIN=TFS +##OWNER=Nicolet +##LONGDATE=2005/12/14 +##TIME=17:54:26 +##SPECTROMETER/DATA SYSTEM=Almega +##DATA PROCESSING= +Wavelength->Wavenumber +##COMMENTS= +Number of sample scans: 2 +Collection length: 22.00 sec +Number of background scans: 32 +Raman laser frequency: 12827.97 cm-1 +Number of rejected sample scans: 0 +Number of rejected background scans: 0 +##XUNITS=RAMAN SHIFT(1/CM) +##YUNITS=RAMAN INTENSITY +##FIRSTX=102.020508 +##LASTX=3480.694336 +##FIRSTY=610.938049 +##MAXX=3480.694336 +##MINX=102.020508 +##MAXY=1021.398743 +##MINY=-8.161715 +##XFACTOR=1.000000 +##YFACTOR=1.000000E-05 +##NPOINTS=1753 +##DELTAX=1.928467 +##ZPD=0 +##XYDATA=(X++(Y..Y)) +102.021 61093804 58696144 59781732 63696948 71314816 80571760 90214160 +115.520 101025744 102139872 87897152 71284496 55561012 41936796 33131580 +129.019 29224402 26620838 25342206 24701902 24571678 24772896 25000780 +142.518 25251282 25699488 26367042 27263700 28260526 29520936 31625474 +156.018 34489540 36553660 37542916 37769304 36937508 35722816 34934016 +169.517 34535204 34366888 34526564 34693184 34543852 34527092 35011112 +183.016 36014320 37704584 40337644 43047520 45603456 48169832 51827544 +196.515 55501336 55973552 52333588 48580144 44993068 42079628 39887096 +210.015 38719088 39108980 41214084 43247124 44367660 46079864 49775788 +223.514 53727504 56120684 56998328 56101648 52446828 48337368 43739632 +237.013 39148300 34822776 30831534 27369706 24320306 22295986 21699448 +250.512 21604424 22061358 22525330 22194982 20990928 20084848 19633648 +264.012 19375680 19086892 19149862 19763606 20942486 22897574 26258560 +277.511 29057052 31596856 33162976 32601502 31419308 31254358 32165876 +291.010 33442138 35548224 37279012 38322876 39135292 39890940 40645780 +304.510 41513032 42489656 43674392 45956480 46917888 45588124 42845452 +318.009 38968128 34284788 30040570 25971592 23288236 22360022 22197998 +331.508 22612684 23459800 24976214 26958480 27824258 27256278 26877692 +345.007 27147794 27072132 25920532 24426556 23191160 22206672 21434144 +358.507 20892866 20414002 20088674 19603558 18715740 17694006 16763542 +372.006 15919725 14996951 13866849 13625778 14753714 16187152 17375092 +385.505 18769532 20543624 22842424 26412912 31247518 36511660 43295996 +399.004 47551548 47688756 45092376 38949216 31146396 25965216 23222364 +412.504 21950430 22628878 22867172 21861868 20384990 18279470 16193056 +426.003 14995454 14615028 14721599 15318036 16323596 18160016 19720802 +439.502 21133180 21739320 20733038 18589866 16131868 13434579 11572625 +453.001 10873599 10449870 10298640 10140381 9687673 9295197 9479936 10029128 +468.429 10331496 10313957 10779263 12217413 13513089 14344650 15167915 +481.928 16273352 17479760 18447144 19327484 20776500 23048282 24656822 +495.428 24914202 25329950 26302532 27286676 27283152 27683484 29943020 +508.927 33837892 38409608 43392812 50141328 59632948 69351816 82937456 +522.426 91836288 90616808 83640376 72929840 60383284 51952156 48141316 +535.926 45456200 44457156 43483228 42473668 41408172 40217796 39036972 +549.425 38417844 37612916 35244492 31404712 27432708 22759118 19886128 +562.924 19373360 19347692 19271840 19720418 21398192 23392952 24951258 +576.423 26265836 28053492 30322872 31146558 30656988 28233750 22989908 +589.923 18113560 14375140 11619353 9969057 8999564 8445572 8255562 8379893 +605.350 8802899 9188202 9517233 10006478 10666216 11535256 12645932 13940855 +620.778 15251080 16875306 19066342 21687736 24697976 27966006 31052932 +634.277 33939272 36252168 38142828 38183556 35618468 32202734 27825962 +647.777 23588134 19872616 16621527 13685861 11226563 9679702 8873478 8226994 +663.204 7729739 7341048 7018962 7022146 7602082 8130003 8479890 8737914 +678.632 8845976 8975595 9306592 9713107 9901603 10067268 10804449 11999141 +694.060 12755788 12988271 13032033 12820276 12648136 12688184 12557346 +707.559 11966949 11438550 11264285 11236439 11126392 11100970 11391824 +721.058 11913626 12521307 13190334 13667874 13914049 14144812 14515799 +734.558 14574628 14330865 13744507 12577612 11395094 10354742 9432469 +748.057 8652480 7945988 7185599 6500617 6142162 6012882 5781806 5454982 +763.485 5211468 5069634 4918723 4754546 4586123 4370585 4278623 4444495 +778.912 4504270 4225389 3994944 4079858 4199746 4195939 4115988 3875404 +794.340 3678829 3993924 4585108 4675666 4358452 4425441 4899616 5277446 +809.768 5537410 5921858 6432432 7194280 8308623 9297256 9588461 10831532 +825.196 13795886 17544608 21623174 26417460 31844056 38414968 46956808 +838.695 56508424 66656164 76578616 87281376 95778160 93550088 81991464 +852.194 65414220 45222848 31087510 23219612 18986188 18369396 17842908 +865.693 16975022 16318030 16197495 15557167 13877655 12265273 10954119 +879.193 9724077 8219410 7221222 7341582 7670253 7637079 7692931 8148791 +894.620 8868315 9679504 10726407 12298679 14122810 16071329 17831564 +908.120 18758760 19105604 19397132 19656236 20006516 20386936 20439544 +921.619 20147236 19034070 16922452 15871788 16054149 16726831 17915978 +935.118 19504362 22302320 23840518 24194710 23112410 19913850 16649350 +948.617 13308414 10477029 8137494 6622925 6342976 6234234 6082325 5760590 +964.045 5039510 4480766 4376981 4440182 4624270 4763009 4526464 4549079 +979.473 5482600 6492237 6787983 7245550 8769685 10446480 11453030 12281386 +994.901 13113319 14315096 16574461 19142278 21257382 23023934 24690212 +1008.400 26006952 26982748 27063388 24716080 21323292 18965774 17538690 +1021.899 16562604 16558224 18961680 22903460 27148786 31162476 33797804 +1035.398 35211972 35782908 35417784 33609652 30799606 27769370 24773448 +1048.898 22667194 21054136 18633190 15989832 14642769 14309717 14407980 +1062.397 14871655 15682762 16662184 17418572 17968858 18262126 18439914 +1075.896 18814744 19345584 20101662 20840958 20827538 20501532 20931430 +1089.396 21700164 21827346 21719788 21942966 22685076 24311970 26672698 +1102.895 29565882 32964028 37078760 41456724 45875476 49732556 52667828 +1116.394 54079704 52639372 49785640 47417324 44304304 38301416 31830268 +1129.893 27063656 23068778 18768162 15272430 13571690 12857150 12688498 +1143.393 13113011 14308179 15869498 17516100 19571960 22639364 25367934 +1156.892 27817466 28262150 25371372 21834452 18243424 15126917 12591695 +1170.391 10775751 9868114 9069215 8191560 7473973 6968688 6531988 6112298 +1185.819 6118815 6623742 7030391 7286580 7754983 8433590 8859052 9021021 +1201.247 8987256 8781793 8400246 7988232 8105685 8602657 9089606 9669587 +1216.674 10338555 11422377 13481911 16165173 19354788 22586396 25642582 +1230.174 28251354 30762446 31930422 30713654 28506196 25495944 22296518 +1243.673 18772152 15662289 12856355 11019142 10467068 10168012 10153325 +1257.172 9863411 9236010 8817883 8619518 8476366 8386704 8452171 8546915 +1272.600 8248536 7708522 7200329 6668171 5836938 5197924 5387131 5659983 +1288.028 5349123 5256693 6042322 6598823 6433172 6200909 5982665 5964901 +1303.455 6232266 6464885 6620109 6911918 7339329 7514856 7520426 7838652 +1318.883 8373398 8932156 9470592 9893608 10288673 10515422 11083403 12595001 +1334.311 14031737 14839409 15927107 17731056 19130260 19891944 20404124 +1347.810 20716302 20420848 19601986 19462618 19910196 20757398 21713660 +1361.309 22393174 22593752 21998600 20895528 19214034 17571784 16253975 +1374.809 15035825 13720226 12993878 13040314 13034105 12903859 12785789 +1388.308 12649788 12158837 11593661 11564637 11945419 12820312 13675133 +1401.807 13995107 14268695 14865292 15255621 15159216 15107321 15095914 +1415.306 15435266 16129749 16012866 15321013 15054150 15114992 15561394 +1428.806 15907690 15470624 15115050 15442468 15788718 15933669 16059450 +1442.305 16109669 16346175 16746892 18075824 20224798 22912738 25899096 +1455.804 29593630 32234548 32464762 31149610 28239270 25180282 22372704 +1469.303 19312548 15844716 13514864 12094058 9601597 6825410 5503914 4899777 +1484.731 4482309 4078303 3564528 3158359 2931803 2684820 2390555 2547386 +1500.159 3035463 3046796 2765732 2445420 2176430 2016463 1998164 2223556 +1515.587 2385428 2447478 2249262 1815311 1607221 1585730 1590378 1603253 +1531.014 1668377 1626533 1120416 971189 1629436 1899325 1672633 1535858 +1546.442 1513320 1696312 1859555 1492817 1227182 1751472 2119487 1835123 +1561.870 1730359 1895143 1918549 1834741 1882441 1942230 1788404 1650730 +1577.298 1704219 1772406 1822655 1841367 1856038 1294471 486567 819911 +1592.725 1523928 1806845 1872333 1757420 1628609 1515801 1459659 1452173 +1608.153 1322213 1220159 1697977 1996836 1348267 887232 987524 1192036 +1623.581 1438696 1852295 2224509 1734467 1078962 958415 1098616 1502681 +1639.009 1674550 1537572 1397824 1293708 1291131 1351124 1481707 1552683 +1654.436 1452126 1481290 1689599 1330499 655006 800534 1239193 1393421 +1669.864 1441812 1399356 1462467 1659499 1655452 1520430 1635873 1654044 +1685.292 877016 449485 1210781 1634516 1611393 1680051 1720665 1306592 +1700.719 818962 390212 338765 1078678 1393819 1291607 1379392 1502093 +1716.147 1370669 1202527 987156 1191945 2124182 2214879 1683815 1229005 +1731.575 930426 898234 923635 935671 1005406 1131723 1246862 1309530 1162412 +1748.931 1095053 1299919 1351394 1170587 993298 869346 986524 1086865 906915 +1766.287 851366 1017610 969254 759035 689626 710026 795936 913641 1081091 +1783.644 957364 645857 888593 1260712 1245795 1110900 869913 1017005 1465408 +1801.000 1374887 1014651 560393 337637 630311 775389 761324 825620 887467 +1818.356 825748 731768 572442 632312 884696 795358 716312 1291294 1621851 +1835.712 1166609 867943 743758 552676 534889 1066173 1484364 1527419 1543536 +1853.068 1532821 1405035 1199989 886952 737902 854751 845230 763986 828963 +1870.425 883576 834669 710108 528069 890146 1367318 970006 748777 1197833 +1887.781 1304407 1004151 639332 444129 811785 1255463 1692226 1285144 493782 +1905.137 727780 1068417 840791 765394 895465 1059293 1099889 597631 356685 +1922.493 638097 1186427 1707616 1235435 682577 771924 866332 881636 305980 +1939.849 -201272 397697 910123 912291 879764 806995 539673 449588 931624 +1957.206 1107442 955928 845755 798419 843125 934354 1088229 735789 314013 +1974.562 698408 1074421 1160131 1088689 935971 867819 860714 892878 1085473 +1991.918 1366038 1158618 806913 485205 660379 1328906 1105618 599706 614672 +2009.274 693730 745103 1110528 1475851 1219302 853571 517332 542731 822929 +2026.630 1257063 1390288 943129 719412 717144 705676 844780 1433395 1514604 +2043.987 1104122 114569 -472492 406458 894393 933608 822889 633525 231665 +2061.343 335054 883054 994309 942355 932179 783482 522820 533671 625309 +2078.699 646978 775352 978598 681416 503851 1029635 954632 322313 686579 +2096.055 1134917 1041107 1060162 1200773 994311 776345 763627 546696 248832 +2113.411 591913 1028890 1341907 981024 336650 798230 1140928 847650 870976 +2130.768 1089400 1180680 1049131 669564 619985 627732 -56452 -25162 931396 +2148.124 863690 442665 378021 559797 885183 564144 219063 375632 642845 +2165.480 888484 566674 318263 744008 349397 -349397 -221490 204839 845947 +2182.836 813690 496725 272909 331253 647108 465355 320244 630692 650717 +2200.192 468684 626587 734411 633352 977488 1252538 313604 -25782 504998 +2217.549 615706 680977 1056717 906508 370155 -79096 -50255 559971 645745 +2234.905 592893 1054207 1290254 1252927 1273068 1185112 837399 701838 714469 +2252.261 748666 700425 566208 574714 649515 798349 736261 548901 450485 +2269.617 470487 636011 565642 444765 417343 554315 772245 757007 758324 +2286.973 888973 774586 616953 594999 667302 770837 691150 641303 695611 +2304.330 639385 514574 335509 278833 375823 809828 1038599 913226 560248 +2321.686 385918 735791 1041711 1187768 1062902 592408 -52512 634000 1045667 +2339.042 121703 265804 801062 443607 276381 343315 134851 112502 449368 +2356.398 916256 1177687 690376 715265 1044492 1247725 943206 203101 423681 +2373.754 717583 619945 379268 158161 171477 -120151 -409674 407476 865465 +2391.111 657847 417394 255321 221769 634705 970915 722498 264223 -69944 +2408.467 517158 1024076 1248613 1236700 904239 283580 372500 675017 813059 +2425.823 997459 1153942 1143976 1095655 909819 69479 -271199 22513 211134 +2443.179 524015 1070378 683458 74255 -271143 1324 428158 259211 490229 +2460.535 895694 662470 537228 594746 371938 254790 370293 280644 116207 +2477.892 -92189 195984 501988 407583 493730 643462 658658 682577 654914 +2495.248 302853 280300 542522 604393 291256 -285289 -71968 259751 449874 +2512.604 499342 412866 213196 452154 823380 1127742 940988 604933 455289 +2529.960 374364 444742 1020829 885100 376564 237770 314996 504818 665932 +2547.316 788337 808449 404256 180911 232933 421981 545070 560406 744896 +2564.673 544206 -168979 225948 547600 298355 726532 1045711 858194 576519 +2582.029 562580 987154 821449 491269 273712 90818 127235 485695 134879 +2599.385 -54443 562025 642732 409153 58121 168606 499862 902967 512091 +2616.741 141689 623973 93895 -361474 482769 420790 138634 422811 18162 +2634.097 -236236 783004 531141 113625 628716 970687 1138218 1104291 1073117 +2651.454 1104585 1297995 519809 -19084 490476 1151542 1520751 1361686 664788 +2668.810 449118 1124199 1181265 1065283 1025791 1500977 1810017 1676804 +2684.238 767969 637690 1262538 183254 -190706 402741 916830 927197 624894 +2701.594 616589 837436 1100588 1068085 1016478 1056381 1469107 1127443 +2717.021 630616 732052 1109725 1370613 1115190 1058106 1015745 881883 465975 +2734.378 433888 964967 968916 711975 436972 969136 1457341 1571806 740452 +2751.734 799212 1282129 1177680 1278380 1271020 801492 1023979 1111620 +2767.162 616400 326496 621982 1388145 1619140 1177242 377183 53098 347061 +2784.518 789495 422352 490850 662359 408450 925050 1117093 343025 861669 +2801.874 1424818 1600147 1380093 1152839 1046875 1172103 1317818 1475297 +2817.302 1706538 1245480 885918 1139345 1087458 968155 886731 972952 860037 +2834.658 725396 1050201 716810 406338 725812 980953 1099790 1080605 855353 +2852.014 857220 1121747 1635365 1497158 1304464 1812223 1971321 1840083 +2867.442 1542335 1520642 1789518 2198780 2471783 2617158 2741788 2901529 +2882.870 3513184 3995163 4161243 4887726 5144738 5082887 5386527 5313081 +2898.297 4972417 4524819 4849080 5083242 5211050 6639785 7243673 7333603 +2913.725 7633819 6722612 6558516 7797229 8455452 9329585 10162270 10163025 +2929.153 9669409 9036823 8501987 8250850 8526794 9004173 8818019 8927010 +2944.581 8182002 5528723 4514313 3721236 3089125 4024329 4852387 4989636 +2960.008 3978722 3129779 2800202 3117423 4200707 5275776 5340641 3739345 +2975.436 4599960 5155159 5165723 7021510 7967010 7170164 4616217 4166215 +2990.864 3294064 1995678 2284003 2058002 1620040 1291447 901896 1053090 +3006.292 1552432 1799008 2560749 3237312 3413681 2441196 2090415 1963756 +3021.719 1166016 987641 920327 704406 15931 -15678 246153 436749 250902 +3039.075 436373 670424 263987 675804 443891 -514876 20944 -283768 -415029 +3056.432 413761 696836 455936 129393 291285 234170 63731 -74910 53104 249091 +3075.716 318577 191428 145972 -85824 -212197 178937 -325825 -358787 -79237 +3093.073 -740209 -626811 -16088 596034 -83842 -105511 291322 666412 -23155 +3110.429 143963 435092 -140324 215806 145889 -189236 -18004 449341 448615 +3127.785 38542 -83716 -125591 180847 760234 1085235 595353 104437 55498 +3145.141 161255 532694 619309 160379 180700 303326 389774 381336 57902 +3162.497 -103158 6342 420298 551550 -2766 -515941 -16779 223570 451298 +3179.854 472636 -53045 -266887 -313884 -144076 360109 924 -165994 -102146 +3197.210 -286887 -219763 -101520 -164118 -611100 87916 120107 -383340 +3212.637 -361364 -302439 -235278 -70779 337028 199152 290364 481611 317201 +3229.994 462781 123742 -316592 -247814 881065 793441 176811 50258 -240446 +3247.350 -293927 -182031 -48704 -110208 -333132 -387151 -143033 219973 +3262.778 119564 185895 380524 -331471 157735 455072 206159 -186537 64400 +3280.134 70159 237540 1289231 480350 -80914 -66819 276320 115046 -199252 +3297.490 -143572 181249 -622324 -376360 66736 254050 243019 365060 396174 +3314.846 463526 696460 245324 -34309 155897 671225 666443 913805 778847 +3332.202 357707 310068 777426 432861 87309 606918 513800 110876 -191553 +3349.559 -170521 328498 400211 561088 533661 -175201 73148 154032 -204141 +3366.915 -696486 -278531 95298 387269 531911 424285 -116576 274106 280343 +3384.271 -351015 224123 -179132 50390 448767 26163 -120677 -34479 204541 +3401.627 303959 -320834 393593 370746 326980 916427 113981 51178 -255320 +3418.983 -515333 242035 368324 330259 -30768 -509285 -354300 -75300 206722 +3436.340 226058 -47692 -37557 394693 468988 192818 -85077 -307550 -816171 +3453.696 -520987 515446 1346831 429406 237335 49878 -351225 -188838 -145649 +3471.052 854229 1220925 433372 -102090 -311276 -309865 +##END= diff --git a/src/pynxtools_raman/config/config_file_thermo_fischer.json b/src/pynxtools_raman/config/config_file_thermo_fischer.json new file mode 100644 index 0000000..1ca4f16 --- /dev/null +++ b/src/pynxtools_raman/config/config_file_thermo_fischer.json @@ -0,0 +1,50 @@ +{ + "/ENTRY[entry]/INSTRUMENT[instrument]/scattering_configuration": "@data:_raman_measurement_device.direction_polarization", + "/ENTRY[entry]/INSTRUMENT[instrument]/beam_incident/wavelength": "@data:_raman_measurement_device.excitation_laser_wavelength", + "/ENTRY[entry]/INSTRUMENT[instrument]/beam_incident/wavelength/@units": "@data:nm", + "/ENTRY[entry]/INSTRUMENT[instrument]/beam_incident/average_power": "@data:_raman_measurement_device.power_on_sample", + "/ENTRY[entry]/INSTRUMENT[instrument]/beam_incident/average_power/@units": "@data:mW", + "/ENTRY[entry]/INSTRUMENT[instrument]/beam_incident/extent": "@data:_raman_measurement_device.spot_size", + "/ENTRY[entry]/INSTRUMENT[instrument]/beam_incident/extent/@units": "@data:µm", + "/ENTRY[entry]/INSTRUMENT[instrument]/beam_incident/parameter_reliability":"@data:nominal", + "/ENTRY[entry]/INSTRUMENT[instrument]/detector_TYPE[detector_ccd]/count_time/@units": "@data:s", + "/ENTRY[entry]/INSTRUMENT[instrument]/detector_TYPE[detector_ccd]/count_time": "@data:_raman_measurement.integration_time", + "/ENTRY[entry]/INSTRUMENT[instrument]/detector_TYPE[detector_ccd]/detector_channel_type":"@data:single-channel", + "/ENTRY[entry]/INSTRUMENT[instrument]/SOURCE[source_532nmlaser]/type": "@data:_raman_measurement_device.excitation_laser_type", + "/ENTRY[entry]/INSTRUMENT[instrument]/FABRICATION[device_information]/vendor":"@data:_raman_measurement_device.company", + "/ENTRY[entry]/INSTRUMENT[instrument]/FABRICATION[device_information]/model": "@data:_raman_measurement_device.model", + "/ENTRY[entry]/INSTRUMENT[instrument]/LENS_OPT[objective_lens]/type": "@data:_raman_measurement_device.optics_type", + "/ENTRY[entry]/INSTRUMENT[instrument]/LENS_OPT[objective_lens]/magnification": "@data:_raman_measurement_device.microscope_objective_magnification", + "/ENTRY[entry]/INSTRUMENT[instrument]/LENS_OPT[objective_lens]/numerical_aperture": "@data:_raman_measurement_device.microscope_numerical_aperture", + "/ENTRY[entry]/INSTRUMENT[instrument]/MONOCHROMATOR[monochromator]/grating/period": "@data:_raman_measurement_device.diffraction_grating", + "/ENTRY[entry]/INSTRUMENT[instrument]/MONOCHROMATOR[monochromator]/grating/period/@units": "@data:lines/mm", + "/ENTRY[entry]/SAMPLE[sample]/name":"@data:_chemical_name_systematic", + "/ENTRY[entry]/SAMPLE[sample]/physical_form":"@data:_[local]_chemical_compound_state", + "/ENTRY[entry]/SAMPLE[sample]/chemical_formula":"@data:_chemical_formula_structural", + "/ENTRY[entry]/SAMPLE[sample]/ENVIRONMENT[medium]/sample_medium":"@data:_raman_measurement.environment", + "/ENTRY[entry]/SAMPLE[sample]/ENVIRONMENT[env_temperature]/SENSOR[temperature_sensor]/measurement":"@data:temperature", + "/ENTRY[entry]/SAMPLE[sample]/ENVIRONMENT[env_temperature]/SENSOR[temperature_sensor]/value":"@data:_raman_measurement.temperature", + "/ENTRY[entry]/SAMPLE[sample]/ENVIRONMENT[env_temperature]/SENSOR[temperature_sensor]/value/@units":"@data:K", + "/ENTRY[entry]/SAMPLE[sample]/ENVIRONMENT[env_pressure]/SENSOR[sensor]/measurement":"@data:pressure", + "/ENTRY[entry]/SAMPLE[sample]/ENVIRONMENT[env_pressure]/SENSOR[sensor]/value":"@data:_raman_measurement.pressure", + "/ENTRY[entry]/SAMPLE[sample]/ENVIRONMENT[env_pressure]/SENSOR[sensor]/value/@units":"@data:kPa", + "/ENTRY[entry]/definition/@url": "@data:Remove_this_if_pynxtools_issue_#469_is_solved", + "/ENTRY[entry]/experiment_type": "@data:Raman spectroscopy", + "/ENTRY[entry]/raman_experiment_type": "@data:other", + "/ENTRY[entry]/title": "@data:_chemical_name_mineral", + "/ENTRY[entry]/start_time": "@data:##TIME", + "/ENTRY[entry]/@default": "@data:data", + "/ENTRY[entry]/DATA[data]/@signal": "@data:y_values", + "/ENTRY[entry]/DATA[data]/y_values": "@data:_raman_spectrum.intensity", + "/ENTRY[entry]/DATA[data]/y_values/@units": "@data:arb. units", + "/ENTRY[entry]/DATA[data]/y_values/@long_name": "@data:Intensity", + "/ENTRY[entry]/DATA[data]/@axes":"@data:x_values_raman", + "/ENTRY[entry]/DATA[data]/x_values_raman/@long_name": "@data:Raman Shift", + "/ENTRY[entry]/DATA[data]/x_values_raman": "@data:_raman_spectrum.raman_shift", + "/ENTRY[entry]/DATA[data]/x_values_raman/@units": "@data:1/cm", + "/ENTRY[entry]/experiment_identifier/service": "@data:DOI", + "/ENTRY[entry]/experiment_identifier/identifier": "@data:_journal_paper_doi", + "/ENTRY[entry]/entry_identifier/service": "@data:Raman open databse ID", + "/ENTRY[entry]/entry_identifier/identifier": "@data:_rod_database.code" + } + diff --git a/src/pynxtools_raman/reader.py b/src/pynxtools_raman/reader.py index 5021697..9981928 100644 --- a/src/pynxtools_raman/reader.py +++ b/src/pynxtools_raman/reader.py @@ -60,6 +60,7 @@ def __init__(self, *args, **kwargs): ".txt": self.handle_txt_file, ".json": self.set_config_file, ".rod": self.handle_rod_file, + ".jdx": self.handle_jdx_file, } def set_config_file(self, file_path: Path) -> Dict[str, Any]: @@ -79,6 +80,77 @@ def handle_eln_file(self, file_path: str) -> Dict[str, Any]: return {} + + def parse_jdx_file(self, filepath): + """ + Read a .txt file from Witec Alpha Raman spectrometer and return a data dictionary + which contains Raman shift and Intensity + """ + data_dict = {} + + with open(filepath, "r") as file: + data = file.readlines() + + # Separate metadata and measurement data + jdx_metadata = [] + jdx_measurement_data = [] + is_measurement = False + + for line in data: + if line.startswith("##XYDATA"): + is_measurement = True + elif line.startswith("##END"): + is_measurement = False + elif not is_measurement: + jdx_metadata.append(line.replace("\n","")) + else: + jdx_measurement_data.append(line.replace("\n","")) + + # extract float like measruement data colums: + jdx_data_list = [] + + for line in jdx_measurement_data: + string_list = line.split() + float_list = [float(item) for item in string_list] + jdx_data_list.append(float_list) + + # Transform: [[A, B], [C, D], [E, F]] into [[A, C, E], [B, D, F]] + jdx_data_list = [list(item) for item in zip(*jdx_data_list)] + + column_counter = 0 + for column in jdx_data_list: + if column_counter == 0: + data_dict["data_x"] = column + if column_counter > 0: + data_dict[f"data_y_{column_counter}"] = column + column_counter = column_counter + 1 + + # extract key value pair from meta data: + for i in range(len(jdx_metadata)): + # Metadata, always starts with ## + if jdx_metadata[i].startswith("##"): + key, value = jdx_metadata[i].split("=") + data_dict[key] = value + # this covers multi-line meta data such as comments or similar. This + # is appended to a list and then added to the dictionary + else: + if key in data_dict and isinstance(data_dict[key], list): + data_dict[key].append(jdx_metadata[i]) + else: + data_dict[key] = [jdx_metadata[i]] + + return data_dict + + + def handle_jdx_file(self, filepath) -> Dict[str, Any]: + + reader_dir = Path(__file__).parent + self.config_file = reader_dir.joinpath("config", "config_file_thermo_fischer.json") # pylint: disable=invalid-type-comment + + self.raman_data = self.parse_jdx_file(filepath) + print(self.raman_data) + return {} + def handle_rod_file(self, filepath) -> Dict[str, Any]: # specify default config file for rod files reader_dir = Path(__file__).parent