a-renzini / pygwb

MIT License
3 stars 3 forks source link

Example parameter.ini file from tutorial has a hardcoded path #7

Closed GeorgySk closed 10 months ago

GeorgySk commented 11 months ago

I cannot open an issue on GitLab as it requires access which I do not have, so I'm opening it here instead.

While following a tutorial at https://pygwb.docs.ligo.org/pygwb/pipeline.html, I encountered an error when trying to run

pygwb_pipe --param_file parameters.ini --apply_dsc False

The error is as follows:

georgy@georgy-Aspire-E5-575G ~/pygwb_playground> pygwb_pipe --param_file parameters.ini --apply_dsc False                                                        (pygwb) 
2023-10-09 15:39:06.939 | INFO     | __main__:main:68 - Successfully imported parameters from paramfile and input.
2023-10-09 15:39:06.939 | INFO     | __main__:main:110 - Saved final param file at ./parameters_1247644138-1247645038_final.ini.
2023-10-09 15:42:01.281 | INFO     | __main__:main:116 - Loaded up interferometers with selected parameters.
2023-10-09 15:42:01.282 | INFO     | __main__:main:150 - Baseline with interferometers H1, L1 initialised.
2023-10-09 15:42:01.282 | INFO     | __main__:main:154 - Setting PSDs and CSDs of the baseline...
2023-10-09 15:42:03.427 | INFO     | __main__:main:159 - ... done.
2023-10-09 15:42:03.430 | DEBUG    | pygwb.baseline:calculate_delta_sigma_cut:1228 - loading notches for delta sigma cut from /home/arianna.renzini/PROJECTS/pygwb_main/test/test_data/Official_O3_HL_notchlist.txt
2023-10-09 15:42:03.430 | DEBUG    | pygwb.baseline:set_frequency_mask:229 - loading notches from /home/arianna.renzini/PROJECTS/pygwb_main/test/test_data/Official_O3_HL_notchlist.txt
Traceback (most recent call last):
  File "/home/georgy/miniconda3/envs/pygwb/bin/pygwb_pipe", line 237, in <module>
    main()
  File "/home/georgy/miniconda3/envs/pygwb/bin/pygwb_pipe", line 168, in main
    base_12.calculate_delta_sigma_cut(
  File "/home/georgy/miniconda3/envs/pygwb/lib/python3.8/site-packages/pygwb/baseline.py", line 1231, in calculate_delta_sigma_cut
    self.set_frequency_mask(self.notch_list_path)
  File "/home/georgy/miniconda3/envs/pygwb/lib/python3.8/site-packages/pygwb/baseline.py", line 230, in set_frequency_mask
    notch_list = StochNotchList.load_from_file(self.notch_list_path)
  File "/home/georgy/miniconda3/envs/pygwb/lib/python3.8/site-packages/pygwb/notch.py", line 194, in load_from_file
    fmin, fmax = np.loadtxt(filename, delimiter=",", unpack=True, usecols=(0, 1))
  File "/home/georgy/miniconda3/envs/pygwb/lib/python3.8/site-packages/numpy/lib/npyio.py", line 1356, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
  File "/home/georgy/miniconda3/envs/pygwb/lib/python3.8/site-packages/numpy/lib/npyio.py", line 975, in _read
    fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
  File "/home/georgy/miniconda3/envs/pygwb/lib/python3.8/site-packages/numpy/lib/_datasource.py", line 193, in open
    return ds.open(path, mode, encoding=encoding, newline=newline)
  File "/home/georgy/miniconda3/envs/pygwb/lib/python3.8/site-packages/numpy/lib/_datasource.py", line 533, in open
    raise FileNotFoundError(f"{path} not found.")
FileNotFoundError: /home/arianna.renzini/PROJECTS/pygwb_main/test/test_data/Official_O3_HL_notchlist.txt not found.

As you can see, the parameter file is successfully imported, but three minutes in, an error is thrown. I believe this is not optimal. My proposal is to:

  1. add a check if the file exists prior to the other time-consuming calculations;
  2. avoid using the hardcoded path
maxlalleman commented 11 months ago

Hi @GeorgySk,

I will check this out and let you know when it is fixed. You are right also, a test to see if the file exist would be a good addition.

kevinturbang commented 10 months ago

This was addressed in the most recent merge request. Thank you for flagging this.