sigmt 2.2.0__tar.gz → 2.2.1__tar.gz

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.
Files changed (47) hide show
  1. {sigmt-2.2.0/sigmt.egg-info → sigmt-2.2.1}/PKG-INFO +5 -16
  2. {sigmt-2.2.0 → sigmt-2.2.1}/README.md +4 -3
  3. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/__version__.py +1 -1
  4. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/metronix/metronix.py +15 -13
  5. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/phoenix/phoenix.py +223 -90
  6. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/main.py +1 -1
  7. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/phoenix/phoenix_readers.py +28 -7
  8. sigmt-2.2.1/sigmt/utils/phoenix/phoenix_utils.py +846 -0
  9. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/utils.py +1 -3
  10. {sigmt-2.2.0 → sigmt-2.2.1/sigmt.egg-info}/PKG-INFO +5 -16
  11. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt.egg-info/SOURCES.txt +0 -1
  12. sigmt-2.2.0/sigmt/gui/phoenix/disclaimer_dialog.py +0 -107
  13. sigmt-2.2.0/sigmt/utils/phoenix/phoenix_utils.py +0 -564
  14. {sigmt-2.2.0 → sigmt-2.2.1}/LICENSE +0 -0
  15. {sigmt-2.2.0 → sigmt-2.2.1}/MANIFEST.in +0 -0
  16. {sigmt-2.2.0 → sigmt-2.2.1}/setup.cfg +0 -0
  17. {sigmt-2.2.0 → sigmt-2.2.1}/setup.py +0 -0
  18. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/__init__.py +0 -0
  19. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/core/band_averaging.py +0 -0
  20. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/core/data_selection_tools.py +0 -0
  21. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/core/perform_data_selection.py +0 -0
  22. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/core/plots.py +0 -0
  23. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/core/robust_estimation.py +0 -0
  24. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/core/sigproc.py +0 -0
  25. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/core/statistics.py +0 -0
  26. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/__init__.py +0 -0
  27. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/about_dialog.py +0 -0
  28. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/edi_merger.py +0 -0
  29. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/metronix/__init__.py +0 -0
  30. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/metronix/metronix_dialogs.py +0 -0
  31. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/phoenix/__init__.py +0 -0
  32. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/project_related/create_project.py +0 -0
  33. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/gui/project_related/edit_project.py +0 -0
  34. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/images/sigmt.ico +0 -0
  35. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/__init__.py +0 -0
  36. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/edi/edi_ops.py +0 -0
  37. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/frequency_table.py +0 -0
  38. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/metronix/cal_from_metronix_txt.py +0 -0
  39. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/metronix/cal_from_xml.py +0 -0
  40. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/metronix/calibration.py +0 -0
  41. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/metronix/metronix_utils.py +0 -0
  42. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/phoenix/__init__.py +0 -0
  43. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt/utils/phoenix/calibration.py +0 -0
  44. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt.egg-info/dependency_links.txt +0 -0
  45. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt.egg-info/entry_points.txt +0 -0
  46. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt.egg-info/requires.txt +0 -0
  47. {sigmt-2.2.0 → sigmt-2.2.1}/sigmt.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sigmt
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: A tool for magnetotelluric time series processing
5
5
  Home-page: https://github.com/ajithabhks/sigmt
6
6
  Author: Ajithabh K.S.
@@ -12,27 +12,16 @@ Classifier: Development Status :: 4 - Beta
12
12
  Requires-Python: >=3.8
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
- Requires-Dist: h5py
16
- Requires-Dist: matplotlib
17
- Requires-Dist: numpy
18
- Requires-Dist: pandas
19
- Requires-Dist: pyyaml
20
- Requires-Dist: PyQt5
21
- Requires-Dist: scikit-learn
22
- Requires-Dist: scipy
23
- Requires-Dist: seaborn
24
- Requires-Dist: setuptools>=64.0.0
25
- Requires-Dist: xarray
26
- Requires-Dist: PhoenixGeoPy==1.0.2
27
15
 
28
16
  [![PyPI version](https://img.shields.io/pypi/v/sigmt)](https://pypi.org/project/sigmt/)
29
17
 
30
- # SigMT: An open-source python package for magnetotelluric data processing
18
+ # SigMT: An open-source Python package for magnetotelluric data processing
31
19
 
32
- SigMT is a python package designed for the processing of the raw magnetotelluric (MT) data to obtain the MT impedance and tipper estimates. It works in an automated way, so that manual time series inspection and editing are not required. Mahalanobis based data selection tool is implemented in the package to avoid the manual editing of time series. The final impedance estimation is done using the robust estimation method. Different data selection tools such as coherency threshold, polarization direction are included in this package.
20
+ SigMT is an open-source Python package developed for the processing of magnetotelluric (MT) time series data to estimate MT impedance and tipper responses. The package enables data processing with minimal manual intervention by utilizing a Mahalanobis distance–based data selection tool. Final estimation is performed using a robust statistical approach. In addition, SigMT includes noise rejection tools such as coherency thresholding and polarization direction analysis to enhance the reliability of the estimated MT responses.
21
+
22
+ The package currently supports Metronix and Phoenix (MTU-5C) time series formats through a graphical user interface.
33
23
 
34
24
  ## How to install?
35
- Please note that SigMT currently supports only Metronix data format (.ats).
36
25
 
37
26
  Open anaconda prompt and type:
38
27
 
@@ -1,11 +1,12 @@
1
1
  [![PyPI version](https://img.shields.io/pypi/v/sigmt)](https://pypi.org/project/sigmt/)
2
2
 
3
- # SigMT: An open-source python package for magnetotelluric data processing
3
+ # SigMT: An open-source Python package for magnetotelluric data processing
4
4
 
5
- SigMT is a python package designed for the processing of the raw magnetotelluric (MT) data to obtain the MT impedance and tipper estimates. It works in an automated way, so that manual time series inspection and editing are not required. Mahalanobis based data selection tool is implemented in the package to avoid the manual editing of time series. The final impedance estimation is done using the robust estimation method. Different data selection tools such as coherency threshold, polarization direction are included in this package.
5
+ SigMT is an open-source Python package developed for the processing of magnetotelluric (MT) time series data to estimate MT impedance and tipper responses. The package enables data processing with minimal manual intervention by utilizing a Mahalanobis distance–based data selection tool. Final estimation is performed using a robust statistical approach. In addition, SigMT includes noise rejection tools such as coherency thresholding and polarization direction analysis to enhance the reliability of the estimated MT responses.
6
+
7
+ The package currently supports Metronix and Phoenix (MTU-5C) time series formats through a graphical user interface.
6
8
 
7
9
  ## How to install?
8
- Please note that SigMT currently supports only Metronix data format (.ats).
9
10
 
10
11
  Open anaconda prompt and type:
11
12
 
@@ -1,4 +1,4 @@
1
1
  """
2
2
  Returns version of the package
3
3
  """
4
- __version__ = "2.2.0"
4
+ __version__ = "2.2.1"
@@ -764,6 +764,9 @@ class MainWindow(QMainWindow):
764
764
  :rtype: NoneType
765
765
 
766
766
  """
767
+ self.fft_length_dropdown.blockSignals(True)
768
+ self.fft_length_dropdown.clear()
769
+
767
770
  # Reseting some buttons
768
771
  self.apply_coh_thresh_button.setText("Apply coherency threshold")
769
772
  self.apply_pd_thresh_button.setText("Perform PD thresholding")
@@ -873,19 +876,17 @@ class MainWindow(QMainWindow):
873
876
 
874
877
  if len(common_time) == 0:
875
878
  # Continue as local station processing
876
- print("No overlapping time series.")
877
- print("Continuing as local station processing.")
878
- # Write local data to database
879
- ts = f.create_group(f'ts_{num}')
880
- for key in ts_dict.keys():
881
- ts.create_dataset(key, data=ts_dict[key].values)
882
- # Write remote data to database
883
- # Rx
884
- self.header[f'ts_{num}']['rx'] = self.header[f'ts_{num}']['hx']
885
- ts.create_dataset('rx', data=ts_dict['hx'].values)
886
- # Ry
887
- self.header[f'ts_{num}']['ry'] = self.header[f'ts_{num}']['hy']
888
- ts.create_dataset('ry', data=ts_dict['hy'].values)
879
+ qapp_instance.processEvents()
880
+ progress_dialog.close()
881
+ QMessageBox.warning(
882
+ self,
883
+ "Warning",
884
+ "No overlapping time series. "
885
+ "\nContinue as local station processing."
886
+ )
887
+ self.remotesite = None
888
+ self.remotesite_dropdown.setCurrentIndex(0)
889
+ return
889
890
  else:
890
891
  # Else, use only the overlapping time series
891
892
  ts_dict = {k: v.sel(time=common_time) for k, v in ts_dict.items()}
@@ -919,6 +920,7 @@ class MainWindow(QMainWindow):
919
920
  fftlength = utils.get_fftlength(self.procinfo['nsamples_mostly'])
920
921
  # Updating FFT length dropdown
921
922
  self.fft_length_dropdown.addItems(self.fft_values)
923
+ self.fft_length_dropdown.blockSignals(False)
922
924
  self.fft_length_dropdown.setCurrentIndex(self.fft_length_dropdown.findText(str(fftlength)))
923
925
  # Updating parzen window radius
924
926
  parzen_radius = utils.get_parzen(self.procinfo['fs'])
@@ -27,7 +27,6 @@ from sigmt.core import plots
27
27
  from sigmt.core.band_averaging import BandAveraging
28
28
  from sigmt.core.robust_estimation import RobustEstimation
29
29
  from sigmt.gui.about_dialog import AboutDialog
30
- from sigmt.gui.phoenix.disclaimer_dialog import DisclaimerDialog
31
30
  from sigmt.gui.edi_merger import EDIMerger
32
31
  from sigmt.gui.project_related.create_project import ProjectSetupDialog
33
32
  from sigmt.gui.project_related.edit_project import EditProjectSetupDialog
@@ -129,7 +128,7 @@ class MainWindow(QMainWindow):
129
128
 
130
129
  """
131
130
  self.setWindowTitle('[No Project Opened] SigMT | A Tool for '
132
- f'Magnetotelluric Data Processing ({self.interface})')
131
+ f'Magnetotelluric Data Processing ({self.interface} MTU-5C)')
133
132
  self.setWindowIcon(QIcon(r'sigmt\images\sigmt.ico'))
134
133
  self.setGeometry(100, 100, 700, 500)
135
134
 
@@ -169,24 +168,6 @@ class MainWindow(QMainWindow):
169
168
  about_action.triggered.connect(self.show_about_dialog)
170
169
  about_menu.addAction(about_action)
171
170
 
172
- disclaimer_menu = self.menubar.addMenu("⚠️ IMPORTANT DISCLAIMER")
173
- disclaimer_menu.setProperty("warning", True)
174
-
175
- disclaimer_menu.setStyleSheet("""
176
- QMenu {
177
- background-color: #fff5f5;
178
- color: #842029;
179
- font-weight: bold;
180
- }
181
- QMenu::item:selected {
182
- background-color: #f1aeb5;
183
- }
184
- """)
185
-
186
- disclaimer_action = QAction("Read this BEFORE using Phoenix", self)
187
- disclaimer_action.triggered.connect(self.show_disclaimer)
188
- disclaimer_menu.addAction(disclaimer_action)
189
-
190
171
  # Central Widget
191
172
  central_widget = QWidget(self)
192
173
  self.setCentralWidget(central_widget)
@@ -536,17 +517,6 @@ class MainWindow(QMainWindow):
536
517
  self.about_dialog = AboutDialog()
537
518
  self.about_dialog.show()
538
519
 
539
- def show_disclaimer(self):
540
- """
541
- Opens a dialog box with some message.
542
-
543
- :return: None
544
- :rtype: NoneType
545
-
546
- """
547
- self.disclaimer_dialog = DisclaimerDialog()
548
- self.disclaimer_dialog.show()
549
-
550
520
  def load_sites(self) -> None:
551
521
  """
552
522
  Method to load the sites in the time_series folder in the project folder.
@@ -618,8 +588,9 @@ class MainWindow(QMainWindow):
618
588
  )
619
589
 
620
590
  # Find the first valid recording folder
591
+ # allow anything after the timestamp
621
592
  recording_pattern = re.compile(
622
- r"^\d+_\d{4}-\d{2}-\d{2}-\d{6}$"
593
+ r"^\d+_\d{4}-\d{2}-\d{2}-\d{6}(?:_.+)?$"
623
594
  )
624
595
 
625
596
  recording_folders = sorted(
@@ -690,45 +661,78 @@ class MainWindow(QMainWindow):
690
661
  local_start_time = self.recmeta_data_local.get('start', None)
691
662
  remote_start_time = self.recmeta_data_remote.get('start', None)
692
663
 
693
- if local_start_time != remote_start_time:
694
- QMessageBox.warning(self, 'Warning',
695
- "Remote reference processing cannot be done as "
696
- "local and remote start time doesn't match. "
697
- "Currently, SigMT needs same start time.")
664
+ local_stop_time = self.recmeta_data_local.get('stop', None)
665
+ remote_stop_time = self.recmeta_data_remote.get('stop', None)
666
+
667
+ local_firmware_version = self.recmeta_data_local.get('sw_version', None)
668
+ remote_firmware_version = self.recmeta_data_remote.get('sw_version', None)
669
+
670
+ if not phoenix_utils.is_firmware_compatible(
671
+ local_firmware_version=local_firmware_version,
672
+ remote_firmware_version=remote_firmware_version
673
+ ):
674
+ QMessageBox.warning(
675
+ self,
676
+ "Firmware Version Mismatch",
677
+ "Cannot proceed with the remote reference due to a firmware "
678
+ "version mismatch.\n\n"
679
+ "The local and remote stations must both be running firmware "
680
+ "below v2.0, or both be running firmware v2.0 or later. "
681
+ "Using firmware versions from different ranges may cause timing issues."
682
+ )
698
683
  self.remotesite = None
699
684
  self.remotesite_dropdown.setCurrentIndex(0)
700
685
  return
701
686
 
702
- unique_sampling_rates_rr = phoenix_utils.get_sampling_rate_list(
703
- recording_path=self.remotesite_path
687
+ overlap_seconds, overlap_hms = phoenix_utils.get_time_overlap(
688
+ local_start=local_start_time,
689
+ local_stop=local_stop_time,
690
+ remote_start=remote_start_time,
691
+ remote_stop=remote_stop_time,
704
692
  )
705
693
 
706
- unique_combined = sorted(set(unique_samp_values) | set(unique_sampling_rates_rr))
694
+ if overlap_seconds > 0:
695
+ print(f"Overlap: {overlap_hms}")
696
+ else:
697
+ print("No overlap")
698
+
699
+ if overlap_seconds < 1:
700
+ QMessageBox.warning(
701
+ self,
702
+ 'Warning',
703
+ "Remote reference processing cannot be done as "
704
+ f"only {overlap_hms} (hh:mm:ss) overlap is found based on the start and stop "
705
+ f"times in recmeta.json."
706
+ )
707
707
 
708
- verified_sampling_rates = []
708
+ self.remotesite = None
709
+ self.remotesite_dropdown.setCurrentIndex(0)
710
+ return
709
711
 
710
- if unique_combined:
711
- for sampling_rate in unique_combined:
712
- file_extension = phoenix_utils.sampling_rate_to_extension(
713
- sampling_rate=int(sampling_rate)
714
- )
712
+ else:
713
+ reply = QMessageBox.question(
714
+ self,
715
+ 'Confirm Remote Reference',
716
+ f"An overlap of {overlap_hms} (hh:mm:ss) is found based on the start and stop "
717
+ f"times in recmeta.json.\n\n"
718
+ "Do you want to continue with remote reference processing?",
719
+ QMessageBox.Yes | QMessageBox.No,
720
+ QMessageBox.Yes
721
+ )
715
722
 
716
- time_stamp = phoenix_utils.return_overlapping_info(
717
- file_extension=file_extension,
718
- local_station_path=self.localsite_path,
719
- remote_station_path=self.remotesite_path,
720
- )
723
+ if reply == QMessageBox.No:
724
+ self.remotesite = None
725
+ self.remotesite_dropdown.setCurrentIndex(0)
726
+ return
727
+
728
+ # Here get unique sampling rates in both
729
+ unique_sampling_rates_rr = phoenix_utils.get_sampling_rate_list(
730
+ recording_path=self.remotesite_path
731
+ )
721
732
 
722
- if time_stamp:
723
- verified_sampling_rates.append(sampling_rate)
733
+ verified_sampling_rates = sorted(
734
+ set(unique_samp_values) | set(unique_sampling_rates_rr))
724
735
 
725
- # If no overlapping found with remote, return to single site mode
726
- if not verified_sampling_rates:
727
- QMessageBox.warning(self, 'Warning',
728
- "No overlapping time series found!")
729
- self.remotesite = None
730
- self.remotesite_dropdown.setCurrentIndex(0)
731
- verified_sampling_rates = unique_samp_values
732
736
  else:
733
737
  self.recmeta_data_remote = None
734
738
  self.remote_channel_map = None
@@ -750,6 +754,9 @@ class MainWindow(QMainWindow):
750
754
  :rtype: NoneType
751
755
 
752
756
  """
757
+ self.fft_length_dropdown.blockSignals(True)
758
+ self.fft_length_dropdown.clear()
759
+
753
760
  # Resetting some buttons
754
761
  self.apply_coh_thresh_button.setText("Apply coherency threshold")
755
762
  self.apply_pd_thresh_button.setText("Perform PD thresholding")
@@ -765,6 +772,22 @@ class MainWindow(QMainWindow):
765
772
  QMessageBox.warning(self, 'Warning', "Please choose local and/or remote site.")
766
773
  return
767
774
 
775
+ progress_dialog = QProgressDialog(
776
+ "Reading time series data...\nPlease wait.",
777
+ None,
778
+ 0,
779
+ 0,
780
+ self
781
+ )
782
+ progress_dialog.setWindowModality(Qt.WindowModal)
783
+ progress_dialog.setWindowTitle("Please wait")
784
+ progress_dialog.setCancelButton(None)
785
+ progress_dialog.setMinimumDuration(0)
786
+ progress_dialog.show()
787
+
788
+ qapp_instance = QApplication.instance()
789
+ qapp_instance.processEvents()
790
+
768
791
  if int(self.sfreq_selected) > 150:
769
792
  self.file_type = 'decimated_segmented'
770
793
  print('Decimated Segmented')
@@ -778,39 +801,75 @@ class MainWindow(QMainWindow):
778
801
 
779
802
  # Reading time series data
780
803
  if self.file_type == 'decimated_continuous':
781
- self.time_series = phoenix_utils.read_decimated_continuous_data(
804
+ self.time_series, local_timestamp = phoenix_utils.read_decimated_continuous_data(
782
805
  recording_path=self.localsite_path,
783
806
  channel_map=self.local_channel_map,
784
807
  file_extension=self.file_extension
785
808
  )
786
809
 
787
810
  if self.remotesite:
788
- remote_time_series = phoenix_utils.read_decimated_continuous_data(
811
+ # need to fix remote time alignment for this decimated continuous
812
+ remote_time_series, remote_timestamp = phoenix_utils.read_decimated_continuous_data(
789
813
  recording_path=self.remotesite_path,
790
814
  channel_map=self.remote_channel_map,
791
815
  file_extension=self.file_extension
792
816
  )
817
+
818
+ try:
819
+ self.time_series, remote_time_series = (
820
+ phoenix_utils.align_continuous_time_series(
821
+ local_ts=self.time_series,
822
+ local_timestamp=local_timestamp,
823
+ remote_ts=remote_time_series,
824
+ remote_timestamp=remote_timestamp,
825
+ sampling_rate=int(self.sfreq_selected),
826
+ )
827
+ )
828
+ except ValueError:
829
+ progress_dialog.close()
830
+ qapp_instance.processEvents()
831
+ QMessageBox.warning(
832
+ self,
833
+ "Warning",
834
+ "Remote reference processing cannot be performed because "
835
+ "no valid time-series overlap was found. This may be due to "
836
+ "inconsistent sampling durations."
837
+ )
838
+
839
+ self.remotesite = None
840
+ self.remotesite_dropdown.setCurrentIndex(0)
841
+ return
842
+
793
843
  remote_time_series_length = len(
794
- next(iter(remote_time_series.get('run0', {}).values())))
844
+ next(iter(remote_time_series.get("run0", {}).values()))
845
+ )
795
846
  local_time_series_length = len(
796
- next(iter(self.time_series.get('run0', {}).values())))
847
+ next(iter(self.time_series.get("run0", {}).values()))
848
+ )
797
849
 
798
- min_time_series_length = min(remote_time_series_length, local_time_series_length)
850
+ if remote_time_series_length != local_time_series_length:
851
+ progress_dialog.close()
852
+ qapp_instance.processEvents()
853
+ QMessageBox.warning(
854
+ self,
855
+ "Warning",
856
+ "Remote reference processing cannot be performed because "
857
+ "the aligned local and remote time series have different lengths."
858
+ )
799
859
 
800
- # Assuming same start time for local and remote station
801
- for run in remote_time_series.keys():
802
- for channel in remote_time_series[run].keys():
803
- remote_time_series[run][channel] = remote_time_series[run][channel][
804
- :min_time_series_length]
860
+ self.remotesite = None
861
+ self.remotesite_dropdown.setCurrentIndex(0)
862
+ return
805
863
 
806
- for run in self.time_series.keys():
807
- for channel in self.time_series[run].keys():
808
- self.time_series[run][channel] = self.time_series[run][channel][
809
- :min_time_series_length]
810
- if 'hx' in remote_time_series[run].keys():
811
- self.time_series[run]['rx'] = remote_time_series[run]['hx'].copy()
812
- if 'hy' in remote_time_series[run].keys():
813
- self.time_series[run]['ry'] = remote_time_series[run]['hy'].copy()
864
+ for run in self.time_series:
865
+ if run not in remote_time_series:
866
+ continue
867
+
868
+ if "hx" in remote_time_series[run]:
869
+ self.time_series[run]["rx"] = remote_time_series[run]["hx"].copy()
870
+
871
+ if "hy" in remote_time_series[run]:
872
+ self.time_series[run]["ry"] = remote_time_series[run]["hy"].copy()
814
873
 
815
874
  elif self.file_type == 'decimated_segmented':
816
875
  self.time_series = phoenix_utils.read_decimated_segmented_data(
@@ -825,6 +884,64 @@ class MainWindow(QMainWindow):
825
884
  file_extension=self.file_extension
826
885
  )
827
886
 
887
+ overlap_count, _ = phoenix_utils.count_matching_timestamps(
888
+ local_ts=self.time_series,
889
+ remote_ts=remote_time_series,
890
+ )
891
+
892
+ if overlap_count < 1:
893
+ progress_dialog.close()
894
+ qapp_instance.processEvents()
895
+ QMessageBox.warning(
896
+ self,
897
+ "Warning",
898
+ "Remote reference processing cannot be performed because "
899
+ "no valid time-series overlap was found. This may be due to "
900
+ "inconsistent sampling durations."
901
+ )
902
+
903
+ self.remotesite = None
904
+ self.remotesite_dropdown.setCurrentIndex(0)
905
+ return
906
+
907
+ reply = QMessageBox.question(
908
+ self,
909
+ 'Confirm Remote Reference',
910
+ f"{overlap_count} overlapping decimated segment(s) found "
911
+ f"at a sampling frequency of {self.sfreq_selected} Hz.\n\n"
912
+ "Do you want to continue with remote reference processing?",
913
+ QMessageBox.Yes | QMessageBox.No,
914
+ QMessageBox.Yes
915
+ )
916
+
917
+ if reply == QMessageBox.No:
918
+ self.remotesite = None
919
+ self.remotesite_dropdown.setCurrentIndex(0)
920
+ progress_dialog.close()
921
+ qapp_instance.processEvents()
922
+ return
923
+
924
+ try:
925
+ self.time_series, remote_time_series = (
926
+ phoenix_utils.trim_to_matching_timestamps(
927
+ local_ts=self.time_series,
928
+ remote_ts=remote_time_series,
929
+ )
930
+ )
931
+
932
+ except ValueError as error:
933
+ progress_dialog.close()
934
+ qapp_instance.processEvents()
935
+ QMessageBox.warning(
936
+ self,
937
+ "Remote Reference Error",
938
+ f"Remote reference processing cannot continue.\n\n{error}"
939
+ )
940
+
941
+ self.remotesite = None
942
+ self.remotesite_dropdown.setCurrentIndex(0)
943
+ return
944
+
828
945
  num_remote_segments = len(remote_time_series.keys())
829
946
  num_local_segments = len(self.time_series.keys())
830
947
 
@@ -844,20 +961,32 @@ class MainWindow(QMainWindow):
844
961
  self.procinfo['fs'] = int(self.sfreq_selected)
845
962
 
846
963
  # Read calibration data
847
- self.calibration_data_electric = phoenix_utils.prepare_calibration_data_electric(
848
- local_recmeta_data=self.recmeta_data_local,
849
- channel_map=self.local_channel_map
850
- )
964
+ try:
965
+ self.calibration_data_electric = phoenix_utils.prepare_calibration_data_electric(
966
+ local_recmeta_data=self.recmeta_data_local,
967
+ channel_map=self.local_channel_map
968
+ )
851
969
 
852
- self.calibration_data_magnetic = phoenix_utils.prepare_calibration_data_magnetic(
853
- project_dir=self.project_dir,
854
- local_recmeta_data=self.recmeta_data_local,
855
- local_channel_map=self.local_channel_map,
856
- remote_recmeta_data=self.recmeta_data_remote,
857
- remote_channel_map=self.remote_channel_map,
858
- )
970
+ self.calibration_data_magnetic = phoenix_utils.prepare_calibration_data_magnetic(
971
+ project_dir=self.project_dir,
972
+ local_recmeta_data=self.recmeta_data_local,
973
+ local_channel_map=self.local_channel_map,
974
+ remote_recmeta_data=self.recmeta_data_remote,
975
+ remote_channel_map=self.remote_channel_map,
976
+ )
977
+
978
+ except (ValueError, FileNotFoundError) as error:
979
+ progress_dialog.close()
980
+ qapp_instance.processEvents()
981
+ QMessageBox.warning(
982
+ self,
983
+ "Calibration Error",
984
+ f"{error}\n\nFix the issue and run again."
985
+ )
986
+ return
859
987
 
860
- num_samples = len(next(iter(next(iter(self.time_series.values())).values())))
988
+ num_samples = len(next(
989
+ v for v in next(iter(self.time_series.values())).values() if isinstance(v, np.ndarray)))
861
990
 
862
991
  QMessageBox.information(
863
992
  self,
@@ -881,6 +1010,7 @@ class MainWindow(QMainWindow):
881
1010
  fft_values = [str(v) for v in fft_values if int(v) < self.procinfo["nsamples_mostly"]]
882
1011
 
883
1012
  self.fft_length_dropdown.addItems(fft_values)
1013
+ self.fft_length_dropdown.blockSignals(False)
884
1014
 
885
1015
  if self.file_type == 'decimated_continuous':
886
1016
  self.fft_length_dropdown.setCurrentIndex(
@@ -893,6 +1023,9 @@ class MainWindow(QMainWindow):
893
1023
  # Updating MD thresholds
894
1024
  self.md_threshold_entry.setText(str(1.5))
895
1025
 
1026
+ progress_dialog.close()
1027
+ qapp_instance.processEvents()
1028
+
896
1029
  def decimate(self) -> None:
897
1030
  """
898
1031
  Decimate the time series.
@@ -55,7 +55,7 @@ class Welcome(QDialog):
55
55
  layout.addWidget(select_label, alignment=Qt.AlignHCenter)
56
56
 
57
57
  self.metronix_button = QPushButton('Metronix', self)
58
- self.phoenix_button = QPushButton(' Phoenix (Experimental) ', self)
58
+ self.phoenix_button = QPushButton(' Phoenix MTU-5C ', self)
59
59
 
60
60
  # Prevent default focus / highlight
61
61
  for btn in (self.metronix_button, self.phoenix_button):
@@ -1,13 +1,15 @@
1
1
  import glob
2
2
  import os
3
- from pathlib import Path
3
+ import pathlib
4
+ from datetime import datetime, timezone
5
+ from typing import List
4
6
 
5
7
  import numpy as np
6
8
  from PhoenixGeoPy.Reader import TimeSeries as PhoenixReader
7
9
 
8
10
 
9
11
  def read_decimated_continuous(
10
- channel_path: Path,
12
+ channel_path: pathlib.Path,
11
13
  file_extension: str
12
14
  ):
13
15
  """
@@ -16,7 +18,7 @@ def read_decimated_continuous(
16
18
  """
17
19
  ## DecimatedContinuousReader
18
20
  # Step 1: Get the first file (the earliest sequence)
19
- channel_path = Path(channel_path)
21
+ channel_path = pathlib.Path(channel_path)
20
22
  files = sorted(glob.glob(os.path.join(channel_path, f"*.{file_extension}")))
21
23
  first_file = files[0]
22
24
 
@@ -28,6 +30,10 @@ def read_decimated_continuous(
28
30
  frag_s = decimated_reader.header_info['frag_period']
29
31
  samples_per_file = int(sample_rate * frag_s)
30
32
 
33
+ timestamp = get_timestamp_from_filename(
34
+ file_path=pathlib.Path(first_file)
35
+ )
36
+
31
37
  # Step 4: Read continuously until data ends
32
38
  all_data = []
33
39
  while True:
@@ -38,19 +44,19 @@ def read_decimated_continuous(
38
44
 
39
45
  ts = np.concatenate(all_data) * 1000 # Convert to mV
40
46
 
41
- return ts
47
+ return ts, timestamp
42
48
 
43
49
 
44
50
  def read_decimated_segmented(
45
- channel_path: Path,
51
+ channel_path: pathlib.Path,
46
52
  file_extension: str
47
- ):
53
+ ) -> List:
48
54
  """
49
55
  Helper function to use PhoenixReader to read decimated
50
56
  segmented time series.
51
57
  """
52
58
  # Step 1: Locate all td_24K files
53
- channel_path = Path(channel_path)
59
+ channel_path = pathlib.Path(channel_path)
54
60
  files = sorted(glob.glob(os.path.join(channel_path, f"*.{file_extension}")))
55
61
  first_file = files[0]
56
62
 
@@ -75,3 +81,18 @@ def read_decimated_segmented(
75
81
  print(f"Read {len(segments)} segments across {len(files)} files")
76
82
 
77
83
  return segments
84
+
85
+
86
+ def get_timestamp_from_filename(
87
+ file_path: pathlib.Path
88
+ ) -> datetime:
89
+ """
90
+ Extract the 32-bit unsigned hex timestamp from a TD filename.
91
+ :param file_path: File path
92
+ :type file_path: pathlib.Path
93
+ :return: time samp as datetime
94
+ :rtype: datetime
95
+
96
+ """
97
+ hex_timestamp = file_path.name.split("_")[1]
98
+ return datetime.fromtimestamp(int(hex_timestamp, 16), tz=timezone.utc)