diff --git a/singlepulse.py b/singlepulse.py index 0ef63b1..0a70f25 100644 --- a/singlepulse.py +++ b/singlepulse.py @@ -25,7 +25,7 @@ from astropy.coordinates import Angle, Latitude, Longitude import astropy.units as u #AH: Modifying this to support multiple directories -main_dir = os.path.join("/ldata","trunk") +main_dir = os.path.join("ldata","trunk") pulsar_dir_list = [os.path.join(main_dir, name) for name in ["data_2025-04-24_07-36-04", "data_2025-04-29_07-50-16", "data_2025-04-30_07-53-07", "data_2025-04-30_08-18-17", "data_2025-05-01_07-47-34"]] #AH: old variable: pulsar_dir @@ -325,37 +325,35 @@ def compute_snr_from_h5(h5_file, detrend_ft=True, mad_filter=True, save=False, s #%% -for i, pulsar_dir in enumerate(pulsar_dir_list): +for pulsar_dir in pulsar_dir_list: save_path = save_path_list[i] #AH: link directory and save path in a bit of a messy way oops h5_dir = os.path.join(pulsar_dir,"cands","") - print(h5_dir) h5_files = sorted(glob.glob(f"{h5_dir}*.h5")) results = [] for filepath in h5_files: - print(filepath) - try: - fluxes_mjy, flux_stds, widths_t, peak_mjds, time_peaks, time_pulse, dm = compute_snr_from_h5(filepath, - detrend_ft=True, - mad_filter=True, - save=True, - show=False, - save_path=save_path) - - for i in range(0,(len(fluxes_mjy))): - results.append({ - "mjd": peak_mjds[i], - "flux_std": flux_stds[i], - "flux_mJy": fluxes_mjy[i], - "width_s": widths_t[i], - "Pulse time (ms)": time_peaks[i], - "tcand": time_pulse, - "dm": dm, - "filename": os.path.basename(filepath) - }) - except Exception as e: - print(f"Error processing {filepath}: {e}") + #try: + fluxes_mjy, flux_stds, widths_t, peak_mjds, time_peaks, time_pulse, dm = compute_snr_from_h5(filepath, + detrend_ft=True, + mad_filter=True, + save=True, + show=False, + save_path=save_path) + + for i in range(0,(len(fluxes_mjy))): + results.append({ + "mjd": peak_mjds[i], + "flux_std": flux_stds[i], + "flux_mJy": fluxes_mjy[i], + "width_s": widths_t[i], + "Pulse time (ms)": time_peaks[i], + "tcand": time_pulse, + "dm": dm, + "filename": os.path.basename(filepath) + }) + #except Exception as e: + #print(f"Error processing {filepath}: {e}") df = pd.DataFrame(results) #%%