Skip to content

Commit

Permalink
add features to parse all .rod files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Hildebrandt authored and Ron Hildebrandt committed Dec 17, 2024
1 parent 367c77c commit fffc403
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/download_rod_files/convert_all_rod_to_nxs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Define the folder containing the .rod files
folder_path="."
folder_path="." # took about 8min

# Loop over all .rod files in the folder
for file in "$folder_path"/*.rod; do
Expand Down
2 changes: 1 addition & 1 deletion src/download_rod_files/download_all_rod_files_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Define your input file
input_file="src/download_rod_files/ROD-numbers_subset_test.txt"
# Change it to this line, to download all .rod files.
#input_file="src/download_rod_files/ROD-numbers.txt"
#input_file="src/download_rod_files/ROD-numbers.txt" # took 7 minutes to download all files

# Ask for confirmation before proceeding
read -p "Are you sure you want to proceed with the download? (y/n): " confirmation
Expand Down
20 changes: 10 additions & 10 deletions src/pynxtools_raman/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def handle_rod_file(self, filepath) -> Dict[str, Any]:

# This changes all uppercase string elements to lowercase string elements for the given key, within a given key value pair
key_to_make_value_lower_case = "_raman_measurement.environment"
self.raman_data[key_to_make_value_lower_case] = self.raman_data.get(
key_to_make_value_lower_case
).lower()
environment_name_str = self.raman_data.get(key_to_make_value_lower_case)
if environment_name_str is not None:
self.raman_data[key_to_make_value_lower_case] = environment_name_str.lower()

# transform the string into a datetime object
time_key = "_raman_measurement.datetime_initiated"
Expand All @@ -121,13 +121,13 @@ def handle_rod_file(self, filepath) -> Dict[str, Any]:

# remove capitalization
objective_type_key = "_raman_measurement_device.optics_type"
self.raman_data[objective_type_key] = self.raman_data.get(
objective_type_key
).lower()
# set a valid raman NXDL value, but only if it matches one of the correct ones:
objective_type_list = ["objective", "lens", "glass fiber", "none"]
if self.raman_data.get(objective_type_key) not in objective_type_list:
self.raman_data[objective_type_key] = "other"
objective_type_str = self.raman_data.get(objective_type_key)
if objective_type_str is not None:
self.raman_data[objective_type_key] = objective_type_str.lower()
# set a valid raman NXDL value, but only if it matches one of the correct ones:
objective_type_list = ["objective", "lens", "glass fiber", "none"]
if self.raman_data.get(objective_type_key) not in objective_type_list:
self.raman_data[objective_type_key] = "other"

return {}

Expand Down

0 comments on commit fffc403

Please sign in to comment.