nanograv / pint_pal

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

TimingConfiguration breaks with 1 tim in PINT=0.9.5 #29

Closed gooddc closed 1 year ago

gooddc commented 1 year ago

I just updated to PINT v0.9.5 for LEAP clock correction reasons, and unfortunately, it breaks tc.get_model_and_toas() for the special case where you only have 1 tim file in your config. Interestingly, we clearly knew this was a possible problem because there's a comment about checking it works with 1 tim in the source code. :)

Attached is the config, the par, the tim, and the traceback. (Par/Tim/Config in the zip file). Note that this will break if and only if you're in PINT 0.9.5 -- in 0.9.3, it's a-okay. issue_for_pintpal.txt pint_pal_issue0505.zip

gooddc commented 1 year ago

config = "configs/J1853+1303.ipta.nb.yaml" # fill in actual path par_directory = None # default location tim_directory = None # default location tc = TimingConfiguration(config, par_directory=par_directory, tim_directory=tim_directory) print(tc)

To combine TOAs, assumption is that cuts haave already been applied properly

mo,to = tc.get_model_and_toas(apply_initial_cuts=False,usepickle=False)


TypeError Traceback (most recent call last) Cell In[7], line 8 5 print(tc) 7 # To combine TOAs, assumption is that cuts haave already been applied properly ----> 8 mo,to = tc.get_model_and_toas(apply_initial_cuts=False,usepickle=False) 10 # add this line back if you find an individual TOA that does need to be cut. 11 tc.manual_cuts(to)

File ~/opt/anaconda3/envs/cleanenv/envs/IPTA_Env/lib/python3.9/site-packages/pint_pal/timingconfiguration.py:132, in TimingConfiguration.get_model_and_toas(self, usepickle, print_all_ignores, apply_initial_cuts, excised, pout_tim_path, include_pn) 130 picklefilename = os.path.basename(self.filename) + ".pickle.gz" 131 # Merge toa_objects (check this works for list of length 1) --> 132 t = toa.get_TOAs([os.path.join(self.tim_directory,t) for t in toas], 133 usepickle=usepickle, 134 bipm_version=BIPM, 135 ephem=EPHEM, 136 planets=PLANET_SHAPIRO, 137 model=m, 138 picklefilename=picklefilename, 139 include_pn=include_pn 140 ) 142 # if we're dealing with wideband TOAs, each epoch has a single TOA, 143 # so don't bother checking to see if we can reduce entries 144 #if self.get_toa_type() == "NB": 145 # self.check_for_bad_files(t, threshold=0.9, print_all=print_all_ignores) 146 147 # Make a clean copy of original TOAs table (to track cut TOAs, flag_values) 148 t.renumber(index_order=False) # Renumber so the index column matches the order of TOAs

File ~/opt/anaconda3/envs/cleanenv/envs/IPTA_Env/lib/python3.9/site-packages/pint/toa.py:271, in get_TOAs(timfile, ephem, include_bipm, bipm_version, include_gps, planets, include_pn, model, usepickle, tdb_method, picklefilename, limits) 269 t = TOAs(timfile) 270 else: --> 271 t = merge_TOAs([TOAs(t) for t in timfile]) 273 files = [t.filename] if isinstance(t.filename, (str, Path)) else t.filename 274 if files is not None:

File ~/opt/anaconda3/envs/cleanenv/envs/IPTA_Env/lib/python3.9/site-packages/pint/toa.py:2690, in merge_TOAs(TOAs_list, strict) 2688 # don't duplicate code: just use the existing method 2689 t = copy.deepcopy(TOAs_list[0]) -> 2690 t.merge(*TOAs_list[1:], strict=strict) 2691 return t

TypeError: merge() missing 1 required positional argument: 't'

JPGlaser commented 1 year ago

A fix was merged into 0.9.6 of pint, which was released today. Thanks to @rossjjennings ! https://github.com/nanograv/PINT/pull/1593 ~ Joe G.