nanograv / pint_pal

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

Parameter creation error with PINT 1.0.1 #67

Open rossjjennings opened 1 month ago

rossjjennings commented 1 month ago

Some of the changes in PINT 1.0.1 (recently released, mainly to provide support for Numpy 2.0) seem to have broken PINT Pal's F-test functions (some parts can't even be imported without causing an error). In particular, I am getting the following error traceback:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[1], line 2
      1 import pint_pal.par_checker as pc
----> 2 import pint_pal.dmx_utils as du
      3 import pint_pal.lite_utils as lu
      4 import pint_pal.noise_utils as nu

File ~/work/pint_pal/pint_pal/src/pint_pal/dmx_utils.py:3
      1 import numpy as np
      2 from astropy import log
----> 3 from pint_pal.utils import apply_cut_flag, apply_cut_select
      5 class DMXParameter:
      6     """
      7     Convenience class for DMX parameters.
      8     """

File ~/work/pint_pal/pint_pal/src/pint_pal/utils.py:19
     17 import astropy
     18 # import enterprise_extensions as e_e # NOTE - enterprise_extensions has no attribute __version__
---> 19 from pint_pal.ftester import get_fblist, param_check, summarize_Ftest
     20 import scipy.stats
     21 import copy

File ~/work/pint_pal/pint_pal/src/pint_pal/ftester.py:15
     11 import warnings
     12 #from pint.models import (
     13 #    parameter as p,
     14 #)
---> 15 import pint_pal.PINT_parameters as pparams
     16 from pint.models.timing_model import Component
     17 import copy

File ~/work/pint_pal/pint_pal/src/pint_pal/PINT_parameters.py:37
      5 """
      6 This file will be a list of pre-defined PINT parameters and components to be used for F-tests.
      7 Current parameters to be listed:
   (...)
     33 "DTH": 0 u.Unit("")
     34 """
     36 # Parallax
---> 37 PX = p.floatParameter(parameter_type="float",
     38     name="PX",
     39     value=0.0,
     40     units=u.mas,
     41     frozen = False)
     42 PX_Component = 'AstrometryEcliptic'
     44 # Proper Motion

File /usr/share/miniconda/envs/test/lib/python3.8/site-packages/pint/models/parameter.py:710, in floatParameter.__init__(self, name, value, units, description, uncertainty, frozen, aliases, continuous, long_double, unit_scale, scale_factor, scale_threshold, convert_tcb2tdb, tcb2tdb_scale_factor, **kwargs)
    702 self.special_arg += [
    703     "long_double",
    704     "unit_scale",
    705     "scale_threshold",
    706     "scale_factor",
    707 ]
    708 self.unit_scale = unit_scale
--> 710 assert (
    711     not convert_tcb2tdb or tcb2tdb_scale_factor is not None
    712 ), "Please specify the tcb2tdb_scale_factor explicitly."
    713 self.convert_tcb2tdb = convert_tcb2tdb
    714 self.tcb2tdb_scale_factor = tcb2tdb_scale_factor

AssertionError: Please specify the tcb2tdb_scale_factor explicitly.

It looks like this is happening because PINT Pal is creating a floatParameter, and there has been an API change that means that it now needs an extra parameter.

rossjjennings commented 1 month ago

@abhisrkckl has indicated he may be able to work on this issue.

abhisrkckl commented 1 month ago

The issue is arising because we changed the Parameter API. You can fix this particular error by adding the following to the floatParameter constructor:

tcb2tdb_scale_factor=(consts.c / u.au)

Note that this is specific to parallax. If there are other such instances, each one needs to be updated with the correct tcb2tdb_scale_factor argument.

abhisrkckl commented 1 month ago

https://nanograv-pint.readthedocs.io/en/latest/tcb2tdb-factors.html