DiadFit 0.0.54__py3-none-any.whl → 0.0.57__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DiadFit/CO2_EOS.py +185 -18
- DiadFit/__init__.py +1 -2
- DiadFit/_version.py +1 -1
- DiadFit/diads.py +19 -8
- DiadFit/error_propagation.py +283 -165
- DiadFit/importing_data_files.py +160 -29
- DiadFit/ne_lines.py +117 -38
- {DiadFit-0.0.54.dist-info → DiadFit-0.0.57.dist-info}/METADATA +1 -1
- DiadFit-0.0.57.dist-info/RECORD +16 -0
- DiadFit/example_peak_params.py +0 -0
- DiadFit/microthermometry.py +0 -10
- DiadFit/ne_lines_BACKUP_966.py +0 -1431
- DiadFit/ne_lines_BASE_966.py +0 -1427
- DiadFit/ne_lines_LOCAL_966.py +0 -1427
- DiadFit/ne_lines_REMOTE_966.py +0 -1427
- DiadFit/skewness.py +0 -0
- DiadFit-0.0.54.dist-info/RECORD +0 -23
- {DiadFit-0.0.54.dist-info → DiadFit-0.0.57.dist-info}/WHEEL +0 -0
- {DiadFit-0.0.54.dist-info → DiadFit-0.0.57.dist-info}/top_level.txt +0 -0
DiadFit/importing_data_files.py
CHANGED
@@ -19,6 +19,21 @@ encode="ISO-8859-1"
|
|
19
19
|
|
20
20
|
|
21
21
|
def check_for_duplicates(spectra_path, prefix=True, prefix_str=' '):
|
22
|
+
""" This function checks for duplicate filenames in a specified directory and prints the duplicates if found.
|
23
|
+
|
24
|
+
Parameters:
|
25
|
+
spectra_path (str):
|
26
|
+
The path of the directory containing the files to be checked for duplicates.
|
27
|
+
prefix (bool):
|
28
|
+
If True, the function will remove the specified prefix string from the filenames before checking for duplicates. Default is True.
|
29
|
+
prefix_str (str:
|
30
|
+
The prefix string to be removed from filenames if 'prefix' is set to True. Default is a single space ' '.
|
31
|
+
|
32
|
+
Returns:
|
33
|
+
file_m (numpy.ndarray): A numpy array containing the modified filenames after removing the prefix (if specified).
|
34
|
+
|
35
|
+
|
36
|
+
"""
|
22
37
|
|
23
38
|
All_files_spectra= [f for f in listdir(spectra_path) if isfile(join(spectra_path, f))]
|
24
39
|
|
@@ -63,7 +78,7 @@ def get_files(path, ID_str=None, file_ext='txt', exclude_str=None, exclude_type=
|
|
63
78
|
|
64
79
|
Returns
|
65
80
|
-----------
|
66
|
-
|
81
|
+
list: file names as a list.
|
67
82
|
|
68
83
|
"""
|
69
84
|
|
@@ -118,6 +133,19 @@ def get_all_txt_files(path):
|
|
118
133
|
def get_data(*, path=None, filename=None, Diad_files=None, filetype='Witec_ASCII'):
|
119
134
|
"""
|
120
135
|
Extracts data as a np.array from user file of differen types
|
136
|
+
|
137
|
+
Parameters
|
138
|
+
---------------
|
139
|
+
path: str
|
140
|
+
path with spectra in
|
141
|
+
filename: str
|
142
|
+
Filename of specific spectra
|
143
|
+
filetype: str
|
144
|
+
choose from 'Witec_ASCII', 'headless_txt', 'headless_csv', 'head_csv', 'Witec_ASCII',
|
145
|
+
'HORIBA_txt', 'Renishaw_txt'
|
146
|
+
Diad_Files:
|
147
|
+
Name of file, if you dont want to have to specify a path
|
148
|
+
|
121
149
|
"""
|
122
150
|
if Diad_files is None:
|
123
151
|
if filetype == 'headless_txt':
|
@@ -168,7 +196,7 @@ def get_data(*, path=None, filename=None, Diad_files=None, filetype='Witec_ASCII
|
|
168
196
|
## Reading different file formats
|
169
197
|
def read_HORIBA_to_df(*, path=None, filename):
|
170
198
|
""" This function takes in a HORIBA .txt. file with headers with #, and looks down to the row where Data starts (no #),
|
171
|
-
and saves this to a new file called pandas_.... old file. It exports the data as a pandas dataframe
|
199
|
+
and saves this to a new csv file called pandas_.... old file. It exports the data as a pandas dataframe
|
172
200
|
|
173
201
|
Parameters
|
174
202
|
-----------
|
@@ -179,6 +207,11 @@ def read_HORIBA_to_df(*, path=None, filename):
|
|
179
207
|
filename: str
|
180
208
|
Specific file being read
|
181
209
|
|
210
|
+
Returns
|
211
|
+
------------
|
212
|
+
pd.DataFrame:
|
213
|
+
Dataframe of x-y data
|
214
|
+
|
182
215
|
|
183
216
|
"""
|
184
217
|
path2=path+'/'+ 'Peak_fits_txt'
|
@@ -233,6 +266,12 @@ def read_witec_to_df(*, path=None, filename):
|
|
233
266
|
filename: str
|
234
267
|
Specific file being read
|
235
268
|
|
269
|
+
|
270
|
+
Returns
|
271
|
+
------------
|
272
|
+
pd.DataFrame:
|
273
|
+
Dataframe of x-y data
|
274
|
+
|
236
275
|
"""
|
237
276
|
if path is None:
|
238
277
|
path=os.getcwd()
|
@@ -286,7 +325,25 @@ def read_witec_to_df(*, path=None, filename):
|
|
286
325
|
|
287
326
|
|
288
327
|
def convert_datastamp_to_metadata(path, filename, creation=True, modification=False):
|
289
|
-
""" Gets file modification or creation time, outputs as metadata
|
328
|
+
""" Gets file modification or creation time, outputs as metadata in the same format as for WITEC
|
329
|
+
|
330
|
+
Parameters
|
331
|
+
-------------
|
332
|
+
|
333
|
+
path: str
|
334
|
+
Path where spectra files are stored
|
335
|
+
filename: str
|
336
|
+
Specific filename
|
337
|
+
creation: bool
|
338
|
+
If True, gets timestamp based on creation date of file
|
339
|
+
modification: bool
|
340
|
+
If True, gets timestamp based on modification date of file
|
341
|
+
|
342
|
+
Returns
|
343
|
+
----------
|
344
|
+
df of timestamp, and other columns to have the same format as the WITEC metadata output
|
345
|
+
|
346
|
+
|
290
347
|
"""
|
291
348
|
if creation is True and modification is True:
|
292
349
|
raise Exception('select either Creation=True or modification=True, not both')
|
@@ -328,7 +385,25 @@ def convert_datastamp_to_metadata(path, filename, creation=True, modification=Fa
|
|
328
385
|
return Time_Df
|
329
386
|
|
330
387
|
def loop_convert_datastamp_to_metadata(path, files, creation=True, modification=False):
|
331
|
-
""" Loops over multiple files to get timestamp the file was created or modified
|
388
|
+
""" Loops over multiple files to get timestamp the file was created or modified
|
389
|
+
using the convert_datastamp_to_metadata function.
|
390
|
+
|
391
|
+
path: str
|
392
|
+
Path where spectra files are stored
|
393
|
+
files: list
|
394
|
+
list of filenames
|
395
|
+
creation: bool
|
396
|
+
If True, gets timestamp based on creation date of file
|
397
|
+
modification: bool
|
398
|
+
If True, gets timestamp based on modification date of file
|
399
|
+
|
400
|
+
Returns
|
401
|
+
----------
|
402
|
+
df of timestamp, and other columns to have the same format as the WITEC metadata output
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
"""
|
332
407
|
df_meta=pd.DataFrame([])
|
333
408
|
for file in files:
|
334
409
|
df_loop=convert_datastamp_to_metadata(path=path, filename=file,
|
@@ -343,6 +418,7 @@ creation=creation, modification=modification)
|
|
343
418
|
## HORIBA acquisition time
|
344
419
|
encode="ISO-8859-1"
|
345
420
|
def extract_duration_horiba(*, path, filename):
|
421
|
+
""" This function extracts the duration from a HORIBA file by finding the line starting with #Acq. """
|
346
422
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
347
423
|
|
348
424
|
while True:
|
@@ -353,7 +429,7 @@ def extract_duration_horiba(*, path, filename):
|
|
353
429
|
return line
|
354
430
|
|
355
431
|
def extract_accumulations_horiba(*, path, filename):
|
356
|
-
|
432
|
+
""" This function extracts the accumulations from a HORIBA file by finding the line starting with #Accumu. """
|
357
433
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
358
434
|
|
359
435
|
while True:
|
@@ -364,7 +440,7 @@ def extract_accumulations_horiba(*, path, filename):
|
|
364
440
|
return line
|
365
441
|
|
366
442
|
def extract_objective_horiba(*, path, filename):
|
367
|
-
|
443
|
+
""" This function extracts the objective used from a HORIBA file by finding the line starting with #Object. """
|
368
444
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
369
445
|
|
370
446
|
while True:
|
@@ -375,7 +451,7 @@ def extract_objective_horiba(*, path, filename):
|
|
375
451
|
return line
|
376
452
|
|
377
453
|
def extract_date_horiba(*, path, filename):
|
378
|
-
|
454
|
+
""" This function extracts the date used from a HORIBA file by finding the line starting with #Date. """
|
379
455
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
380
456
|
|
381
457
|
while True:
|
@@ -386,7 +462,7 @@ def extract_date_horiba(*, path, filename):
|
|
386
462
|
return line
|
387
463
|
|
388
464
|
def extract_spectral_center_horiba(*, path, filename):
|
389
|
-
|
465
|
+
""" This function extracts the spectral center used from a HORIBA file by finding the line starting with #Spectro (cm-¹). """
|
390
466
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
391
467
|
|
392
468
|
while True:
|
@@ -397,7 +473,7 @@ def extract_spectral_center_horiba(*, path, filename):
|
|
397
473
|
return line
|
398
474
|
|
399
475
|
def extract_24hr_time_horiba(*, path, filename):
|
400
|
-
|
476
|
+
""" This function extracts the 24 hr time from a HORIBA file by finding the line starting with #Acquired. """
|
401
477
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
402
478
|
|
403
479
|
while True:
|
@@ -406,8 +482,11 @@ def extract_24hr_time_horiba(*, path, filename):
|
|
406
482
|
line=l
|
407
483
|
break
|
408
484
|
return line
|
485
|
+
|
409
486
|
def extract_spectraname_horiba(*, path, filename):
|
410
|
-
"""
|
487
|
+
"""
|
488
|
+
This function extracts the spectral name from HORIBA files
|
489
|
+
"""
|
411
490
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
412
491
|
|
413
492
|
while True:
|
@@ -419,7 +498,7 @@ def extract_spectraname_horiba(*, path, filename):
|
|
419
498
|
|
420
499
|
|
421
500
|
def extract_acq_params_horiba(path, filename):
|
422
|
-
""" Extracts acquisition parameters from HORIBA
|
501
|
+
""" Extracts all relevant acquisition parameters from a HORIBA file, returns as a dataframe.
|
423
502
|
"""
|
424
503
|
from datetime import datetime
|
425
504
|
# Integration time in seconds
|
@@ -488,7 +567,18 @@ def extract_acq_params_horiba(path, filename):
|
|
488
567
|
|
489
568
|
def stitch_metadata_in_loop_horiba(AllFiles, path=None):
|
490
569
|
|
491
|
-
"""
|
570
|
+
""" Stitches acquisition parameters together from the function extract_acq_params_horiba for multiple files
|
571
|
+
Parameters
|
572
|
+
-------------
|
573
|
+
AllFiles: list
|
574
|
+
List of all file names
|
575
|
+
|
576
|
+
path: str
|
577
|
+
Path where files are found
|
578
|
+
|
579
|
+
Returns
|
580
|
+
-------------
|
581
|
+
df of aquisitoin parameters
|
492
582
|
"""
|
493
583
|
if path is None:
|
494
584
|
path=os.getcwd()
|
@@ -506,7 +596,7 @@ def stitch_metadata_in_loop_horiba(AllFiles, path=None):
|
|
506
596
|
## Functions to extract metadata from WITEC files (v instrument specific)
|
507
597
|
|
508
598
|
def extract_time_stamp_witec(*, path, filename):
|
509
|
-
""" Extracts time
|
599
|
+
""" Extracts time stamp from a WITEC file
|
510
600
|
"""
|
511
601
|
|
512
602
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
@@ -520,7 +610,7 @@ def extract_time_stamp_witec(*, path, filename):
|
|
520
610
|
return line
|
521
611
|
|
522
612
|
def extract_laser_power_witec(*, path, filename):
|
523
|
-
""" Extracts laser power
|
613
|
+
""" Extracts laser power from a WITEC file
|
524
614
|
"""
|
525
615
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
526
616
|
|
@@ -533,7 +623,7 @@ def extract_laser_power_witec(*, path, filename):
|
|
533
623
|
return line
|
534
624
|
|
535
625
|
def extract_accumulations_witec(*, path, filename):
|
536
|
-
""" Extracts accumulations
|
626
|
+
""" Extracts accumulations from a WITEC file
|
537
627
|
"""
|
538
628
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
539
629
|
|
@@ -547,7 +637,7 @@ def extract_accumulations_witec(*, path, filename):
|
|
547
637
|
|
548
638
|
|
549
639
|
def extract_integration_time_witec(*, path, filename):
|
550
|
-
""" Extracts Integration time
|
640
|
+
""" Extracts Integration time from a WITEC file
|
551
641
|
"""
|
552
642
|
|
553
643
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
@@ -560,7 +650,7 @@ def extract_integration_time_witec(*, path, filename):
|
|
560
650
|
return line
|
561
651
|
|
562
652
|
def extract_spectral_center_witec(*, path, filename):
|
563
|
-
""" Extracts Spectral Center
|
653
|
+
""" Extracts Spectral Center from a WITEC file
|
564
654
|
"""
|
565
655
|
|
566
656
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
@@ -573,7 +663,7 @@ def extract_spectral_center_witec(*, path, filename):
|
|
573
663
|
return line
|
574
664
|
|
575
665
|
def extract_objective_witec(*, path, filename):
|
576
|
-
""" Extracts objective magnification
|
666
|
+
""" Extracts objective magnification from a WITEC file
|
577
667
|
"""
|
578
668
|
|
579
669
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
@@ -587,7 +677,7 @@ def extract_objective_witec(*, path, filename):
|
|
587
677
|
return line
|
588
678
|
|
589
679
|
def extract_duration_witec(*, path, filename):
|
590
|
-
""" Extracts analysis duration
|
680
|
+
""" Extracts analysis duration from a WITEC file
|
591
681
|
"""
|
592
682
|
|
593
683
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
@@ -601,7 +691,7 @@ def extract_duration_witec(*, path, filename):
|
|
601
691
|
return line
|
602
692
|
|
603
693
|
def extract_date_witec(*, path, filename):
|
604
|
-
""" Extracts date"""
|
694
|
+
""" Extracts date from a WITEC file"""
|
605
695
|
|
606
696
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
607
697
|
|
@@ -615,7 +705,7 @@ def extract_date_witec(*, path, filename):
|
|
615
705
|
return line
|
616
706
|
|
617
707
|
def checks_if_video_witec(*, path, filename):
|
618
|
-
""" Checks if file is an image (as doesnt have all metadata)
|
708
|
+
""" Checks if a WITEC file is an image (as doesnt have all metadata)
|
619
709
|
"""
|
620
710
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
621
711
|
l1=fr.readline()
|
@@ -627,7 +717,7 @@ def checks_if_video_witec(*, path, filename):
|
|
627
717
|
return 'not Video'
|
628
718
|
|
629
719
|
def checks_if_imagescan_witec(*, path, filename):
|
630
|
-
""" Checks if file is an imagescan (as doesnt have all metadata)
|
720
|
+
""" Checks if a WITEC file is an imagescan (as doesnt have all metadata)
|
631
721
|
"""
|
632
722
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
633
723
|
l1=fr.readline()
|
@@ -639,7 +729,7 @@ def checks_if_imagescan_witec(*, path, filename):
|
|
639
729
|
return 'not Scan'
|
640
730
|
|
641
731
|
def checks_if_general_witec(*, path, filename):
|
642
|
-
""" Checks if file is a spectra file with all the right metadata
|
732
|
+
""" Checks if a WITEC file is a spectra file with all the right metadata
|
643
733
|
"""
|
644
734
|
fr = open(path+'/'+filename, 'r', encoding=encode)
|
645
735
|
l1=fr.readline()
|
@@ -653,7 +743,22 @@ def checks_if_general_witec(*, path, filename):
|
|
653
743
|
|
654
744
|
def extract_acq_params_witec(*, path, filename, trupower=False):
|
655
745
|
""" This function checks what type of file you have, and if its a spectra file,
|
656
|
-
uses the functions above to extract various bits of metadata
|
746
|
+
uses the functions above to extract various bits of metadata.
|
747
|
+
|
748
|
+
Parameters
|
749
|
+
--------------
|
750
|
+
path: str
|
751
|
+
Folder where spectra are stored
|
752
|
+
filename: str
|
753
|
+
Specific filename
|
754
|
+
|
755
|
+
Truepower: bool
|
756
|
+
True if your WITEC system has Trupower, else false, as no power in the metadata file
|
757
|
+
|
758
|
+
Returns
|
759
|
+
-------------
|
760
|
+
power, accums, integ, Obj, Dur, dat, spec
|
761
|
+
Values for each acquisition parameters.
|
657
762
|
"""
|
658
763
|
# Prints what it is, e.g. general if general, video if video
|
659
764
|
if path is None:
|
@@ -722,7 +827,9 @@ def extract_acq_params_witec(*, path, filename, trupower=False):
|
|
722
827
|
|
723
828
|
|
724
829
|
def calculates_time_witec(*, path, filename):
|
725
|
-
""" calculates time for non video files for WITEC files
|
830
|
+
""" calculates time as seconds after midnight for non video files for WITEC files
|
831
|
+
|
832
|
+
"""
|
726
833
|
|
727
834
|
|
728
835
|
|
@@ -776,7 +883,23 @@ def calculates_time_witec(*, path, filename):
|
|
776
883
|
return line3_sec_int, line2
|
777
884
|
|
778
885
|
def stitch_metadata_in_loop_witec(*, Allfiles, path, prefix=True, trupower=False):
|
779
|
-
""" Stitches together WITEC metadata for all files in a loop
|
886
|
+
""" Stitches together WITEC metadata for all files in a loop using the function
|
887
|
+
extract_acq_params_witec and calculates_time_witec, exports as a dataframe
|
888
|
+
|
889
|
+
Parameters
|
890
|
+
-----------------
|
891
|
+
Allfiles:list
|
892
|
+
List of files to fit
|
893
|
+
path: str
|
894
|
+
Name of folder with files in
|
895
|
+
prefix: bool
|
896
|
+
If True, removes any characters in the name before the space ' '
|
897
|
+
trupower: bool
|
898
|
+
Can only be True if you have Trupower on your Witec Raman
|
899
|
+
|
900
|
+
Returns
|
901
|
+
-----------
|
902
|
+
DataFrame of metadata parameters with a row for each file.
|
780
903
|
"""
|
781
904
|
if path is None:
|
782
905
|
path=os.getcwd()
|
@@ -894,17 +1017,20 @@ def extracting_filenames_generic(*, names, prefix=False,
|
|
894
1017
|
str_suffix=None,
|
895
1018
|
file_type=None):
|
896
1019
|
"""
|
897
|
-
Takes filenames from metadata,
|
1020
|
+
Takes filenames from a panda series (e.g., a column of a dataframe of metadata), outputs a numpy array that is consistent with the same function for
|
1021
|
+
spectra, to allow stitching of spectra and metadata.
|
1022
|
+
|
898
1023
|
|
899
1024
|
Parameters
|
900
1025
|
-----------
|
901
|
-
names: Pandas.Series
|
1026
|
+
names: Pandas.Series
|
1027
|
+
Series of sample names, e.g., from 'filename' column of metadata output
|
902
1028
|
|
903
1029
|
prefix: bool
|
904
1030
|
if True, has a number before the file name
|
905
1031
|
|
906
1032
|
str_prefix: str
|
907
|
-
The string separating the prefix from the file name
|
1033
|
+
The string separating the prefix from the file name (e.g. if file is 01 test, str_prefix=" ")
|
908
1034
|
|
909
1035
|
suffix: bool
|
910
1036
|
if True, has a number or name after the filename
|
@@ -915,6 +1041,10 @@ def extracting_filenames_generic(*, names, prefix=False,
|
|
915
1041
|
file_type: str
|
916
1042
|
The file extension, e.g., '.csv'
|
917
1043
|
|
1044
|
+
Returns
|
1045
|
+
-----------------
|
1046
|
+
np.array of names, with prefix, suffix and filetype stripped away
|
1047
|
+
|
918
1048
|
"""
|
919
1049
|
if isinstance(names, list):
|
920
1050
|
names_df=pd.DataFrame(data={'name': names})
|
@@ -957,6 +1087,7 @@ def extracting_filenames_generic(*, names, prefix=False,
|
|
957
1087
|
|
958
1088
|
return file_m
|
959
1089
|
|
1090
|
+
# These are largely redundant.
|
960
1091
|
def extract_temp_Aranet(df):
|
961
1092
|
""" Extracts temperature data from the aranet
|
962
1093
|
"""
|
DiadFit/ne_lines.py
CHANGED
@@ -23,6 +23,22 @@ encode="ISO-8859-1"
|
|
23
23
|
|
24
24
|
## Plotting Ne lines, returns peak position
|
25
25
|
def find_closest(df, line1_shift):
|
26
|
+
"""
|
27
|
+
This function finds the closest Raman shift value in the inputted dataframe to the inputted line position
|
28
|
+
|
29
|
+
Parameters
|
30
|
+
-------------
|
31
|
+
df: pd.DataFrame
|
32
|
+
Dataframe of Ne line positions based on laser wavelength from the function calculate_Ne_line_positions
|
33
|
+
|
34
|
+
line1_shift: int, float
|
35
|
+
input line position
|
36
|
+
|
37
|
+
Returns
|
38
|
+
-------------
|
39
|
+
Closest theoretical line position
|
40
|
+
|
41
|
+
"""
|
26
42
|
dist = (df['Raman_shift (cm-1)'] - line1_shift).abs()
|
27
43
|
return df.loc[dist.idxmin()]
|
28
44
|
|
@@ -30,7 +46,25 @@ def find_closest(df, line1_shift):
|
|
30
46
|
|
31
47
|
def calculate_Ne_splitting(wavelength=532.05, line1_shift=1117, line2_shift=1447, cut_off_intensity=2000):
|
32
48
|
"""
|
33
|
-
Calculates ideal splitting in air between lines closest to user-specified line shift
|
49
|
+
Calculates ideal splitting in air between lines closest to user-specified line shift. E.g. if user enters
|
50
|
+
1117 and 1447 line, it looks for the nearest theoretical Ne line position based on your wavelength,
|
51
|
+
and calculates the ideal splitting between these theoretical line positions. This is used to calculate the
|
52
|
+
ideal Ne line splitting for doing the Ne correction routine of Lamadrid et al. (2017)
|
53
|
+
|
54
|
+
Parameters
|
55
|
+
-------------
|
56
|
+
Wavelength: int
|
57
|
+
Wavelength of your laser
|
58
|
+
line1_shift: int, float
|
59
|
+
Estimate of position of line 1
|
60
|
+
line2_shift: int, float
|
61
|
+
Estimate of position of line 2
|
62
|
+
cut_off_intensity: int, float
|
63
|
+
only searches through lines with a theoretical intensity from NIST grater than this value
|
64
|
+
|
65
|
+
Returns
|
66
|
+
----------
|
67
|
+
df of theoretical splitting, line positions used for this, and entered Ne line positions
|
34
68
|
"""
|
35
69
|
|
36
70
|
df_Ne=calculate_Ne_line_positions(wavelength=wavelength, cut_off_intensity=cut_off_intensity)
|
@@ -51,7 +85,22 @@ def calculate_Ne_splitting(wavelength=532.05, line1_shift=1117, line2_shift=1447
|
|
51
85
|
|
52
86
|
def calculate_Ne_line_positions(wavelength=532.05, cut_off_intensity=2000):
|
53
87
|
"""
|
54
|
-
Calculates Ne
|
88
|
+
Calculates Raman shift for a given laser wavelength of Ne lines, using the datatable from NIST of Ne line
|
89
|
+
emissoin in air and the intensity of each line.
|
90
|
+
|
91
|
+
Parameters
|
92
|
+
---------------
|
93
|
+
Wavelength: float
|
94
|
+
Wavelength of laser
|
95
|
+
cut_off_intensity: float
|
96
|
+
Only chooses lines with intensities greater than this
|
97
|
+
|
98
|
+
Returns
|
99
|
+
------------
|
100
|
+
pd.DataFrame
|
101
|
+
df wih Raman shift, intensity, and emission line position in air.
|
102
|
+
|
103
|
+
|
55
104
|
"""
|
56
105
|
|
57
106
|
Ne_emission_line_air=np.array([
|
@@ -163,10 +212,24 @@ Ne_array=None):
|
|
163
212
|
|
164
213
|
"""
|
165
214
|
Loads Ne line, uses scipy find peaks to identify peaks, overlays these,
|
166
|
-
and returns peak positions to feed into fitting algorithms
|
215
|
+
and returns approximate peak positions, prominences etc to feed into fitting algorithms
|
167
216
|
|
168
217
|
Parameters
|
169
218
|
-----------
|
219
|
+
config: from Neon_id_config
|
220
|
+
This is used to identify peaks using Scipy find peaks. Parameters that can be tweaked
|
221
|
+
exclude_range_1: None, or Tuple[float, float]
|
222
|
+
Range to exclude (e.g, cosmic ray, instrument noise)
|
223
|
+
exclude_range_2: None, or Tuple[float, float]
|
224
|
+
Range to exclude (e.g, cosmic ray, instrument noise)
|
225
|
+
height, distance, prominence, width, threshold: float
|
226
|
+
Scipy find peak parameters you can tweak
|
227
|
+
peak1_cent: float
|
228
|
+
Estimate of location of Ne line 1
|
229
|
+
peak2_cent: float
|
230
|
+
Estimate of location of Ne line 2
|
231
|
+
n_peaks: float
|
232
|
+
Looks through the largest N peaks of scipy in the entire spectra and identifies them on the plot
|
170
233
|
|
171
234
|
path: str
|
172
235
|
Folder user wishes to read data from
|
@@ -175,33 +238,23 @@ Ne_array=None):
|
|
175
238
|
Specific file being read
|
176
239
|
|
177
240
|
filetype: str
|
178
|
-
|
179
|
-
|
180
|
-
headless_txt: Txt file with no headers, just data with wavenumber in 1st col, int 2nd
|
181
|
-
HORIBA_txt: Datafile from newer HORIBA machines with metadata in first rows
|
182
|
-
Renishaw_txt: Datafile from renishaw with column headings.
|
183
|
-
|
184
|
-
n_peaks: int
|
185
|
-
Number of peaks to return values for
|
241
|
+
choose from 'Witec_ASCII', 'headless_txt', 'headless_csv', 'head_csv', 'Witec_ASCII',
|
242
|
+
'HORIBA_txt', 'Renishaw_txt'
|
186
243
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
peak2_cent: int or float, default 1447
|
191
|
-
Position to look for 2nd peak in, finds peaks within +/- 5 of this
|
192
|
-
|
193
|
-
|
194
|
-
height, threshold, distance, prominence, width: int
|
195
|
-
parameters for scipy find peaks
|
244
|
+
plot_figure: bool
|
245
|
+
If True, plots a figure highlighting the identified peaks
|
196
246
|
|
197
|
-
|
198
|
-
|
199
|
-
perhaps to remove cosmic rays
|
247
|
+
print_df: bool
|
248
|
+
if True, prints the positions of the N biggest peaks it found
|
200
249
|
|
201
|
-
|
202
|
-
|
203
|
-
perhaps to remove cosmic rays
|
250
|
+
Ne_array: np.array
|
251
|
+
Can also enter data as a numpy array, rather than as a filename, filepath and filetype
|
204
252
|
|
253
|
+
Returns
|
254
|
+
--------------
|
255
|
+
Ne, df_fit_params
|
256
|
+
Ne: np.array of spectral data (with ranges excluded)
|
257
|
+
df_fit_params: DataFrame of approximate peak positions, prominences etc.
|
205
258
|
|
206
259
|
|
207
260
|
"""
|
@@ -259,7 +312,7 @@ Ne_array=None):
|
|
259
312
|
df_sort_Ne_trim=df_sort_Ne[0:n_peaks]
|
260
313
|
|
261
314
|
if print_df is True:
|
262
|
-
print('Biggest
|
315
|
+
print('Biggest N peaks:')
|
263
316
|
display(df_sort_Ne_trim)
|
264
317
|
|
265
318
|
# Get peak within +-5
|
@@ -338,9 +391,12 @@ Ne_array=None):
|
|
338
391
|
nearest_pk1=peak1_cent
|
339
392
|
|
340
393
|
|
341
|
-
ax1.annotate('peak=' + pos_pk1, xy=(df_fit_params['Peak1_cent'].iloc[0]+3,
|
342
|
-
Baseline_Neon1*1.5+700), xycoords="data", fontsize=10, rotation=90)
|
394
|
+
#ax1.annotate('peak=' + pos_pk1, xy=(df_fit_params['Peak1_cent'].iloc[0]+3,
|
395
|
+
#Baseline_Neon1*1.5+700), xycoords="data", fontsize=10, rotation=90)
|
343
396
|
|
397
|
+
ax1.annotate('peak=' + pos_pk1, xy=(0.8, 0.3),xycoords="axes fraction", fontsize=10, rotation=90)
|
398
|
+
|
399
|
+
|
344
400
|
|
345
401
|
ax1.plot(df_fit_params['Peak1_cent'], df_fit_params['Peak1_height'], '*k', mfc='yellow', ms=8, label='selected peak')
|
346
402
|
|
@@ -350,8 +406,9 @@ Ne_array=None):
|
|
350
406
|
pos_pk2=str(np.round(df_fit_params['Peak2_cent'].iloc[0], 2))
|
351
407
|
ax2.plot([peak2_cent-20, peak2_cent+20], [Baseline_Neon2, Baseline_Neon2], '-g')
|
352
408
|
|
353
|
-
ax2.annotate('peak=' + pos_pk2, xy=(df_fit_params['Peak2_cent'].iloc[0]-5,
|
354
|
-
Baseline_Neon1*2+700), xycoords="data", fontsize=10, rotation=90)
|
409
|
+
# ax2.annotate('peak=' + pos_pk2, xy=(df_fit_params['Peak2_cent'].iloc[0]-5,
|
410
|
+
# Baseline_Neon1*2+700), xycoords="data", fontsize=10, rotation=90)
|
411
|
+
ax2.annotate('peak=' + pos_pk2,xy=(0.8, 0.3),xycoords="axes fraction", fontsize=10, rotation=90)
|
355
412
|
|
356
413
|
|
357
414
|
|
@@ -385,7 +442,7 @@ Ne_array=None):
|
|
385
442
|
def remove_Ne_baseline_pk1(Ne, N_poly_pk1_baseline=None, Ne_center_1=None,
|
386
443
|
lower_bck=None, upper_bck1=None, upper_bck2=None, sigma_baseline=None):
|
387
444
|
""" This function uses a defined range of values to fit a baseline of Nth degree polynomial to the baseline
|
388
|
-
around
|
445
|
+
around a specified peak
|
389
446
|
|
390
447
|
Parameters
|
391
448
|
-----------
|
@@ -410,6 +467,18 @@ lower_bck=None, upper_bck1=None, upper_bck2=None, sigma_baseline=None):
|
|
410
467
|
upper_bck2: list (length 2). default [30, 50]
|
411
468
|
position used for 2nd upper background relative to peak, so =[30, 50] takes a
|
412
469
|
background +30 and +50 from the peak center
|
470
|
+
|
471
|
+
Returns
|
472
|
+
-----------
|
473
|
+
y_corr, Py_base, x, Ne_short, Py_base, Baseline_y, Baseline_x
|
474
|
+
|
475
|
+
y_corr (numpy.ndarray): The corrected y-values after subtracting the fitted polynomial baseline from the original data.
|
476
|
+
Py_base (numpy.ndarray): The y-values of the fitted polynomial baseline.
|
477
|
+
x (numpy.ndarray): The x-values of the trimmed data within the specified range.
|
478
|
+
Ne_short (numpy.ndarray): The trimmed data within the specified range.
|
479
|
+
Baseline_y (numpy.ndarray): The y-values of the baseline data points.
|
480
|
+
Baseline_x (numpy.ndarray): The x-values of the baseline data points
|
481
|
+
|
413
482
|
"""
|
414
483
|
|
415
484
|
lower_0baseline_pk1=Ne_center_1+lower_bck[0]
|
@@ -456,7 +525,7 @@ def remove_Ne_baseline_pk2(Ne, N_poly_pk2_baseline=None, Ne_center_2=None, sigma
|
|
456
525
|
lower_bck=None, upper_bck1=None, upper_bck2=None):
|
457
526
|
|
458
527
|
""" This function uses a defined range of values to fit a baseline of Nth degree polynomial to the baseline
|
459
|
-
around
|
528
|
+
around a second selected peak
|
460
529
|
|
461
530
|
Parameters
|
462
531
|
-----------
|
@@ -481,6 +550,19 @@ lower_bck=None, upper_bck1=None, upper_bck2=None):
|
|
481
550
|
upper_bck2: list (length 2) Default [50, 51]
|
482
551
|
position used for 2nd upper background relative to peak, so =[30, 50] takes a
|
483
552
|
background +30 and +50 from the peak center
|
553
|
+
|
554
|
+
Returns
|
555
|
+
-----------
|
556
|
+
y_corr, Py_base, x, Ne_short, Py_base, Baseline_y, Baseline_x
|
557
|
+
|
558
|
+
y_corr (numpy.ndarray): The corrected y-values after subtracting the fitted polynomial baseline from the original data.
|
559
|
+
Py_base (numpy.ndarray): The y-values of the fitted polynomial baseline.
|
560
|
+
x (numpy.ndarray): The x-values of the trimmed data within the specified range.
|
561
|
+
Ne_short (numpy.ndarray): The trimmed data within the specified range.
|
562
|
+
Baseline_y (numpy.ndarray): The y-values of the baseline data points.
|
563
|
+
Baseline_x (numpy.ndarray): The x-values of the baseline data points.
|
564
|
+
|
565
|
+
|
484
566
|
"""
|
485
567
|
|
486
568
|
|
@@ -930,11 +1012,8 @@ plot_figure=True, loop=True,
|
|
930
1012
|
used to save filename in datatable, and to make a new folder.
|
931
1013
|
|
932
1014
|
filetype: str
|
933
|
-
|
934
|
-
|
935
|
-
headless_txt: Txt file with no headers, just data with wavenumber in 1st col, int 2nd
|
936
|
-
HORIBA_txt: Datafile from newer HORIBA machines with metadata in first rows
|
937
|
-
Renishaw_txt: Datafile from renishaw with column headings.
|
1015
|
+
choose from 'Witec_ASCII', 'headless_txt', 'headless_csv', 'head_csv', 'Witec_ASCII',
|
1016
|
+
'HORIBA_txt', 'Renishaw_txt'
|
938
1017
|
|
939
1018
|
amplitude: int or float
|
940
1019
|
first guess of peak amplitude
|