LSSTDESC / TJPCov

TJPCov is a general covariance calculator interface to be used within LSST DESC
https://tjpcov.readthedocs.io
MIT License
11 stars 1 forks source link

Quick fix to skip mass-richness relation #79

Closed m-aguena closed 1 year ago

m-aguena commented 1 year ago

This solves only part of issue #71

mattkwiecien commented 1 year ago

@m-aguena Did you mean to publish this PR to be ready for review or are you still working on it?

m-aguena commented 1 year ago

It is still in progress. I have to update the unittests

m-aguena commented 1 year ago

@mattkwiecien I tried to run the unit tests but got a sacc related error:

===================================================================================================== ERRORS ======================================================================================================
______________________________________________________________________________________ ERROR at setup of test_load_from_sacc ______________________________________________________________________________________

    @pytest.fixture
    def mock_sacc():
        # Using values from
        # https://github.com/nrussofer/Cosmological-Covariance-matrices
        # /blob/master/Full%20covariance%20N_N%20part%20vfinal.ipynb
        # As reference.
        s = sacc.Sacc()
        s.metadata["nbins_cluster_redshift"] = 18
        s.metadata["nbins_cluster_richness"] = 3
        s.metadata["min_mass"] = 1e13

        # This isnt how tracers actually look, but sort of
        # hacks the class to work without building
        # an entire sacc file for this test.
>       s.add_tracer(
            "misc",
            "clusters_0_0",
            metadata={
                "Mproxy_name": "richness",
                "Mproxy_min": 10,
                "Mproxy_max": 100,
                "z_name": "redshift",
                "z_min": 0.3,
                "z_max": 1.2,
            },
        )

tests/test_covariance_clusters.py:51: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../sacc/sacc/sacc.py:138: in add_tracer
    tracer = BaseTracer.make(tracer_type, name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'sacc.tracers.BaseTracer'>, tracer_type = 'misc', name = 'clusters_0_0', args = (), kwargs = {'metadata': {'Mproxy_max': 100, 'Mproxy_min': 10, 'Mproxy_name': 'richness', 'z_max': 1.2, ...}}

    @classmethod
    def make(cls, tracer_type, name, *args, **kwargs):
        """
        Select a Tracer subclass based on tracer_type
        and instantiate in instance of it with the remaining
        arguments.

        Parameters
        ----------
        tracer_type: str
            Must correspond to the tracer_type of a subclass

        name: str
            The name for this specific tracer.

        Returns
        -------
        instance: Tracer object
            An instance of a Tracer subclass
        """
>       subclass = cls._tracer_classes[tracer_type]
E       KeyError: 'misc'

../sacc/sacc/tracers.py:75: KeyError

I don't know the source of it. Could this be related to a latest sacc version?

joezuntz commented 1 year ago

Sorry, this is indeed caused my the latest sacc version which means you have to write "Misc" instead of "misc". I hadn't appreciated this would happen, apologies. I have a PR now in sacc to fix it.

m-aguena commented 1 year ago

Sorry, this is indeed caused my the latest sacc version which means you have to write "Misc" instead of "misc". I hadn't appreciated this would happen, apologies. I have a PR now in sacc to fix it.

Thanks @joezuntz !

mattkwiecien commented 1 year ago

@m-aguena I would recommend pulling latest master and rebasing (or merging into) your branch, we made some changes to the tests since you've branched off master.

@joezuntz thank you!