nanograv / pint_pal

A long-lived repository for NANOGrav Pulsar Timing workflows and analysis.
MIT License
6 stars 17 forks source link

toa.get_TOAs() Doesn't Allow for Relative Pathing #6

Closed JPGlaser closed 1 year ago

JPGlaser commented 1 year ago

See this job here: https://github.com/nanograv/timing_analysis/actions/runs/3578033081/jobs/6017718911

---------------------------------------------------------------------------
E           FileNotFoundError                         Traceback (most recent call last)
E           Cell In[4], line 10
E                 8 # Use excise.tim file if it exists, else revert to raw TOAs & initial cuts
E                 9 mo,to = tc.get_model_and_toas(excised=True,usepickle=use_toa_pickle)
E           ---> 10 if not to: mo,to = tc.get_model_and_toas(apply_initial_cuts=True)
E                11 tc.manual_cuts(to)
E                13 if log_to_file:
E           
E           File ~/work/timing_analysis/timing_analysis/src/timing_analysis/timingconfiguration.py:121, in TimingConfiguration.get_model_and_toas(self, usepickle, print_all_ignores, apply_initial_cuts, excised, pout_tim_path)
E               119 picklefilename = os.path.basename(self.filename) + ".pickle.gz"
E               120 # Merge toa_objects (check this works for list of length 1)
E           --> 121 t = toa.get_TOAs([os.path.join(self.tim_directory,t)fortintoas],
E               122 usepickle=usepickle,
E               123 bipm_version=BIPM,
E               124 ephem=EPHEM,
E               125 planets=PLANET_SHAPIRO,
E               126 model=m,
E               127 picklefilename=picklefilename)
E               129 # if we're dealing with wideband TOAs, each epoch has a single TOA, 
E               130 # so don't bother checking to see if we can reduce entries
E               131 #if self.get_toa_type() == "NB":
E               132 #    self.check_for_bad_files(t, threshold=0.9, print_all=print_all_ignores)
E               133 
E               134 # Make a clean copy of original TOAs table (to track cut TOAs, flag_values)
E               [135](https://github.com/nanograv/timing_analysis/actions/runs/3578033081/jobs/6017718911#step:6:136) t.renumber(index_order=False)  # Renumber so the index column matches the order of TOAs
E           
E           File /usr/share/miniconda/lib/python3.9/site-packages/pint/toa.py:263, in get_TOAs(timfile, ephem, include_bipm, bipm_version, include_gps, planets, model, usepickle, tdb_method, picklefilename, limits)
E               261     t = TOAs(timfile)
E               262 else:
E           --> 263     t = merge_TOAs([TOAs(t) for t in timfile])
E               265 files = [t.filename] if isinstance(t.filename, (str, Path)) else t.filename
E               266 if files is not None:
E           
E           File /usr/share/miniconda/lib/python3.9/site-packages/pint/toa.py:263, in <listcomp>(.0)
E               261     t = TOAs(timfile)
E               262 else:
E           --> 263     t = merge_TOAs([TOAs(t) for t in timfile])
E               265 files = [t.filename] if isinstance(t.filename, (str, Path)) else t.filename
E               266 if files is not None:
E           
E           File /usr/share/miniconda/lib/python3.9/site-packages/pint/toa.py:1291, in TOAs.__init__(self, toafile, toalist)
E              1288     raise ValueError("Cannot initialize TOAs from both file and list.")
E              1290 if isinstance(toafile, (str, Path)):
E           -> 1291     toalist, self.commands = read_toa_file(toafile)
E              1292     # Check to see if there were any INCLUDEs:
E              1293     inc_fns = [x[0][1] for x in self.commands if x[0][0].upper() == "INCLUDE"]
E           
E           File /usr/share/miniconda/lib/python3.9/site-packages/pint/toa.py:706, in read_toa_file(filename, process_includes, cdict, dir)
E               704     if dir is None:
E               705         dir = Path(filename).parent
E           --> 706     with open(filename,"r") as f:
E               707         return read_toa_file(
E               708             f, process_includes=process_includes, cdict=cdict, dir=dir
E               709         )
E               710 else:
E           
E           FileNotFoundError: [Errno 2] No such file or directory: 'tests/tim/J0605+3757.Rcvr1_2.GUPPI.15y.x.wb.tim'
E           FileNotFoundError: [Errno 2] No such file or directory: 'tests/tim/J0605+3757.Rcvr1_2.GUPPI.15y.x.wb.tim'

~ Joe G.

JPGlaser commented 1 year ago

You'll want to look at this branch which has the GitHub Actions being used, but this bug is also replicable on all hardware: https://github.com/nanograv/timing_analysis/tree/feature/GitHubActions

cuantar commented 1 year ago

... what's the working directory of this process?

cuantar commented 1 year ago

my intuition is that relative paths should work just fine as long as they're correct

cuantar commented 1 year ago

fixed in the GitHubActions branch