{"id":49250979,"url":"https://github.com/jose-d/plc-2.0","last_synced_at":"2026-04-25T00:05:03.261Z","repository":{"id":87564082,"uuid":"160680650","full_name":"jose-d/plc-2.0","owner":"jose-d","description":"``plc`` is the public Planck Likelihood Code.  It provides C and Fortran libraries that allow users to compute the log likelihoods of the temperature, polarization, and lensing maps.  Optionally, it also provides a python version of this library, as well as tools to modify the predetermined options for some likelihoods (e.g. changing the high-ell and low-ell lmin and lmax values of the temperature).","archived":false,"fork":false,"pushed_at":"2021-11-12T10:07:47.000Z","size":1549,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-01-29T08:49:01.310Z","etag":null,"topics":["c","fortran","hpc-applications","python"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jose-d.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-12-06T13:44:40.000Z","updated_at":"2022-02-24T10:51:53.000Z","dependencies_parsed_at":"2023-09-25T00:41:36.174Z","dependency_job_id":"8c221b73-2760-4dab-a4c0-00674551a1b7","html_url":"https://github.com/jose-d/plc-2.0","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":"0.19999999999999996","last_synced_commit":"f135dcc3c8e9d52f3c5d734e86b97ac22ba21c34"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jose-d/plc-2.0","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-d%2Fplc-2.0","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-d%2Fplc-2.0/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-d%2Fplc-2.0/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-d%2Fplc-2.0/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jose-d","download_url":"https://codeload.github.com/jose-d/plc-2.0/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-d%2Fplc-2.0/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32245157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","fortran","hpc-applications","python"],"created_at":"2026-04-25T00:05:00.438Z","updated_at":"2026-04-25T00:05:03.213Z","avatar_url":"https://github.com/jose-d.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# plc 2.0\n\nthis repo contains few minor patches needed to build plc2.0 with recent Intel compilers.\nOriginal can be downloaded directly from this link:\n\nhttp://pla.esac.esa.int/pla/aio/product-action?COSMOLOGY.FILE_ID=COM_Likelihood_Code-v2.0_R2.00.tar.bz2\n\nOr browse to the archive:\n- go to: http://pla.esac.esa.int/pla/#home\n- clik on \"Cosmology\"\n- unselect \"Only legacy products\"\n- change release to \"PR2-2015\"\n\nrelease archive:\n\n- 3.10 http://pla.esac.esa.int/pla/aio/product-action?COSMOLOGY.FILE_ID=COM_Likelihood_Code-v3.0_R3.10.tar.gz\n- 3.01 http://pla.esac.esa.int/pla/aio/product-action?COSMOLOGY.FILE_ID=COM_Likelihood_Code-v3.0_R3.01.tar.gz\n- 3.00 http://pla.esac.esa.int/pla/aio/product-action?COSMOLOGY.FILE_ID=COM_Likelihood_Code-v3.0_R3.00.tar.gz\n- 2.00 http://pla.esac.esa.int/pla/aio/product-action?COSMOLOGY.FILE_ID=COM_Likelihood_Code-v2.0_R2.00.tar.bz2\n\n\n## Patches description\n\nall are *easybuild-compatible*.\n\n* `plc-2.0-fix-missing-bindir.patch` - *Install* step expects `$bindir` in place. If not present, fails. This patch adds check for `$bindir` and creates one if missing.\n* `plc-2.0-fix-openmp-flags.patch` - flag `-openmp` is unknown for compilers we use → replaced with flag `-fopenmp`.\n\n## Known unsolved problems\n\nThere are unclear dependencies between configure, build and install step. Some *install* actions are already done before *install* step itself. That breaks easyBuild procedure. This has been so far confirmed for:\n* `$prefix/lib/libclik_mkl.so` - this file is from whatever reason deployed before install step\n* `$prefix/lib/pkgconfig` directory - same.\n\n## Further reading\n\n- **Installing CosmoMC \u0026 the Planck likelihood**, Manuel Trashorras, IFT/UAM-CSIC,march 2017, https://workshops.ift.uam-csic.es/files/208/SoCT%20-%20Installing%20CosmoMC%20and%20the%20Planck%20likelihood.pdf\n\n-------------\n\n# Readme from upstream project\n\n(4 July 2015 version)\n\n``plc`` is the public Planck Likelihood Code.  It provides C and Fortran \nlibraries that allow users to compute the log likelihoods of the temperature, \npolarization, and lensing maps.  Optionally, it also provides a python version\nof this library, as well as tools to modify the predetermined options for some \nlikelihoods (e.g. changing the high-ell and low-ell lmin and lmax values of the\ntemperature).\n\n\n## Installing\n\n``plc`` can be installed either using the waf configuration and install tool, \nor using make.  Note that in the latter case, the installation procedure will\nnot test the availability of the tools and libraries needed by plc.\n\n\n### Prerequisites\n\n**Mandatory**\n\n- C compiler, either gcc, clang or icc. \n- Fortran compiler, either ifort of gfortran\n- ``blas/lapack`` library $\n- ``cfitsio`` library $\n\n**Optional**\n\n- Python v\u003e2.6, including the header and libraries.\n- numpy $\n- pyfits $\n- cython $ \n\nAll of the prerequisite labeled with a $ above can be installed by the waf\ntool.\n\nThere are some incompatibilities between different versions of the C and\nFortran compilers.  In particular, gcc v4.9 and ifort v\u003c14.1 are not\ncompatible.\n\nBoth ``blas/lapack`` and ``cfitsio`` need to be compiled as shared libraries\n(option ``make --shared`` of the ``cfitsio`` install).\n\nThe optional prerequisites are only needed for the optional ``plc`` tools. \nThey are not required for basic uses of the library.\n\n\n### installing with waf\n\nWaf (http://waf.io) is a tool based on python.  Installing with waf requires \npython v\u003e2.6.  The tool first needs to be configured with\n```\n./waf configure [OPTIONS]\n```\nA complete list of the install options can be obtained by doing\n```\n./waf --help\n```\n\nThe building and installation of the code is done using\n```\n./waf install\n```\n\n\n#### Simple configuration recipes\n\nDetailed instructions on installing are found below, including a few simple and\ntypical cases.\n\n\n##### MAC OS\n\nUse the following instructions to install on Mac OS, letting the tool install\nall of the optional prerequisites and using the stock blas/lapack library.  The\nC compiler will be either gcc, icc or clang (tested in that order).  The\nFortran compiler will be either ifort or gfortran (tested in that order).\nInstallation will be performed in the current plc directory.\n```\n./waf configure --install_all_deps \n./waf install\n```\n\n\n##### Linux with mkl\n\nUse the following instructions to install on a Linux machine with ifort and\nmkl, letting the tool install all the optional prerequisites.  The mkl library\nis available on the computer at the path ``$MKLROOT`` and its version is \u003e=10.3 \n(probably the case if your mkl library is post 2011).  The C compiler will be \neither gcc or clang (tested in that order). The C compiler will be either gcc, \nicc or clang (tested in that order).  The Fortran compiler will be eiher ifort\nor gfortran (tested in that order).  Installation will be performed in the\ncurrent plc directory.\n```\n./waf configure --install_all_deps --lapack_mkl=$MKLROOT\n./waf install\n```\n\n\n#### Detailed configuration instructions\n\n\n##### Install the prerequisites automatically\n\n```\n./waf configure --install_all_deps [OPTIONS]\n``` \nasks the tool to *try* to install all of the absent prerequisites.\n\n\n##### Changing the install path\n\nBy default, plc is installed in the source directory.  To select a different\ndirectory, use\n```\n./waf configure --prefix=/some/other/path [OPTIONS]\n```\n\n\n##### Selecting the C and Fortran compilers\n\nBy default, the tool will check for availability of gcc, icc, and clang, in\nthat order and select the first available compiler.  To force gcc, icc or clang\nuse one of ``--gcc``, ``--icc``, or ``--clang``.\n\nBy default, the tool will check for availability of ifort and gfortran, in that \norder and select the first available compiler.  To force ifort or gfortran, use \none of ``--ifort`` or ``--gfortran``.\n\n\n##### ``blas/lapack``\n\nBy default, on Mac OS, the stock ``blas/lapack`` will be used.  On Linux, the\nwaf tool  needs to be pointed to a particular library.  To use an alternative\nlibrary on Mac OS, or to point a particular library on Linux one can use the\nfollowing options.\n\n\n###### ``mkl``\n\nThe simplest option is to use the Intel ``mkl`` library.  Assuming that the\nlibrary is installed at ``$MKLROOT`` and that the version of the library is\n10.3 or higher (which should be the case if the library was installed post\n2011), use\n```\n./waf configure --lapack_mkl=$MKLROOT [OPTIONS]\n```\nTo use an earlier version of the library (10.0, 10.1, or 10.2), for example \nversion 10.2 use\n```\n./waf configure --lapack_mkl=$MKLROOT --lapack_mkl_version=10.2 [OPTIONS]\n```\n\n\n##### Other ``blas/lapack``\n\nOne can provide the location of the blas/lapack install using either\n1. ``--lapack_prefix=/some/path``, the include and library path will be \n``/some/path/lib`` and ``/some/path/include``, and the installer will try to \nlink to ``libblas.so`` and ``liblapack.so``\n2. ``--lapack_lib=/some/path/lib --lapack_include=/some/path/include``,\nallowing the user to define the library and include path.  The installer will\ntry to link to ``libblas.so`` and ``liblapack.so``\n3. ``--lapack_link='-I/some/path/include -L/some/path/lib -lmyblas -lmylapack',\nallowing the user to define the full link line for the lapack/blas install.\n\n\n##### Installing a basic blas/lapack automatically\n\nUsing either ``--install_all_deps`` or ``--install_lapack`` will ask the tool\nto install a plain vanilla, non-optimized blas/lapack library.\n\n\n#### ``cfitsio``\n\n``plc`` requires a ``cftisio`` library compiled as a shared library (option \n``--shared`` when building cfitsio). The tool will look for the include and \nlibrary in the usual locations.  If it fails, one can point it to a particular \nversion of the ``cfitsio`` library using either\n1. ``--cfitsio_prefix=/some/path``, the include and library will be \n``/some/path/include`` and ``/some/path/lib``\n2. ``--cfitsio_lib=/some/path/lib --cfitsio_include=/some/path/include``,\nallowing the user to define the library and include path. \n\nAlternatively, the ``cfitsio`` library can be installed by the tool using\neither ``--install_all_deps`` or ``--install_cfitsio``.\n\n\n### Installing with make\n\nAll prerequisites must be installed before running make.  The ``Makefile`` file \nmust be adapted to the particular computer configuration.  The C and Fortran\ncompiler must be selected, and in the case of the ifort compiler also the list\nof runtime libraries (needed to link with C).  Please look at the contents of\nthe file for details.\n\nOnce the ``Makefile`` file is correct, build and install with \n```\nmake install\n```\nThe optional python tools can be built using\n```\nmake python_install\n```\n\n\n### Testing the code\n\nFirst source the ``clik_profile.[c]sh`` file to import the environment\nvariables, e.g. ``source source path/to/plc-2.0/bin/clik_profile.sh``.  Then,\nrunning ``clik_example_C`` on any likelihood file should perform an automatic\ntest.  For example\n```\n$\u003e clik_example_C plik_dx11dr2_HM_v18_TT.clik\n----\nclik version 14f84626be57 MAKEFILE\n  smica\nChecking likelihood 'plik_dx11dr2_HM_v18_TT.clik' on test data. got -380.979\nexpected -380.979 (diff -8.68062e-09)\n----\n...\n```\n\n\n## Basic use\n\nThe base installation of plc consists of a library (libclik.so) along with a C \ninclude and a Fortran module, which allows the user to\n- initialize a likelihood\n- inquire about the characteristics of a likelihood (list of spectra, lmin,\nlmax and list of nuisance parameters)\n- compute a log likelihood\n- deallocate a likelihood\n\n\n### Setting up the environment\n\nTo set the environment path and variables, source the ``clik_profile.sh`` (or \n``clik_profile.csh``) file.  This can be added to your ``.login`` or other \nshell initialization script.\nThe ``clik_profile.sh`` file is located in the ``bin`` directory of your plc \ninstall, i.e. in the newly created ``bin``  directory of the plc source \ndirectory if you have not selected a particular install path (see above).\nOnce the script is executed, the variable ``$CLIK_PATH`` will point to the root\ndirectory of your plc install, and the plc ``bin`` directory will be included \nin your ``$PATH`` environment variable.\n\n\n### Compiling with plc\n\nThe compilation and link options to compile a C code against the clik library\ncan be obtained using the script ``clik-config``.\nSimilarly, ``clik-config_f90`` provides the same information when compiling\na Fortran code.\n\n\n### Clik file\n\nThe data for the library are stored in directories that will be named \n*clik files* in the following.  In these directories, one can find ascii\nmetadata files (``_mdb``) and data in multiple binary formats (FITS for\nnumerical data).\n\n\n### Using the C Library\n\nInclude ``clik.h`` to use the plc library. \n\n\n#### Initialization\n\nThe function \n```\nclik_object* clik_init(char* filepath, error **err);\n``` \ninitializes a CMB likelihood object of type ``clik_object`` from a clik file at \nlocation ``filepath``.  The error variable, ``err``, can be set to ``NULL``, in \nwhich case the function will exit in case of error.  Details on the optional \nerror reporting can be found in ``errorlist.h``.\n\nIn most cases, more than one likelihood can be initialized in a code. \n\nSimilarly,\n```\nclik_object* clik_lensing_init(char* filepath, error **err);\n``` \ninitializes a lensing likelihood.\n\nDuring the initialization, an automatic test is performed and displayed on\nstdout.\n\n\n#### Obtaining the list of spectra, lrange, nuisance parameters\n\n\n##### CMB likelihood\n\nThe function\n```\nvoid clik_get_lmax(clik_object *clikid, int lmax[6],error **err);\n```\nfills an array of 6 ``lmax`` integers.  Each element of the array corresponds to\nthe lmax of one of the CMB spectra needed by the CMB likelihood referred by\n``clikid``.  The ordering is **TT EE BB TE TB EB**. The array elements are set\nto -1 for each spectrum unused by the current likelihood.\n\nAs above, ``err`` can be set to ``NULL`` to ignore error management.  For\nexample, when used with the high-ell temperature likelihood, ``lmax`` will be \nset to `` 2508 -1 -1 -1 -1 -1``, meaning that only the TT spectrum is needed by \nthe likelihood, and goes up to lmax = 2508.\n\nThe function \n```\nint clik_get_extra_parameter_names(clik_object* clikid, parname **names, error\n**err);\n``` \nreturns the number of nuisance parameters.  If the ``names`` argument is not\n``NULL`` it will be filled with a pointer to a list of names of the nuisance\nparameters.  After usage, the memory pointed to by ``names`` must be freed by\nthe user.  As above, ``err`` can be set to ``NULL`` to ignore error\nmanagement.\n\n\n### Lensing likelihood\n\nThe function \n```\nint clik_lensing_get_lmaxs(clik_lensing_object *lclik, int lmax[7],\nerror **err);\n```\nworks like the CMB function ``clik_get_lmax``.\nNote that the lmax array is longer than in the CMB case.  The order in this\ncase is **phiphi TT EE BB TE TB EB**.  In the future, this array may be\nextended to include phi-CMB correlations. \n\nThe function \n```\nint clik_lensing_get_extra_parameter_names(clik_object* clikid, parname\n**names, error **err);\n``` \nworks like the CMB one.\n\n\n#### Computing a log likelihood\n\nThe function\n```\ndouble clik_compute(clik_object* clikid, double* cl_and_pars,error **err);\n```\ncomputes the log likelihood for the CMB likelihood pointed at by ``clikid`` and\nfor the Cls and nuisance parameters contained in the array ``cl_and_pars``.  As\nabove, ``err`` can be set to ``NULL`` to ignore error management.  The\n``cl_and_pars`` array is an array of double precision values that contains the\nCMB Cls and nuisance parameter.  The order in the array is as follows:\n\n- first the Cls, from l=0 to lmax (inclusive) in the order **TT EE BB TE TB\nEB**.\nNote that this really does start from l=0, even although the effective lmin\nof a given likelihood can be different from 0. Cls below the effective lmin \nwill be ignored in the computation and can be set to any  value.\nOnly the spectra whose ``lmax`` (from the function ``clik_get_lmax``) is \n\u003e-1 are present. \n\n- then the nuisance parameters in the order defined by \n``clik_get_extra_parameter_names``.\n\nFor example, for the low-ell TEB likelihood whose lmax = ``29 29 29 29 -1 -1`` \nand which has a single nuisance parameter, the Planck absolute calibration, the\n``cl_and_pars`` array should be\n```\nc0_TT\nc1_TT\nc2_TT\n...\nc28_TT\nc29_TT\nc0_EE\nc1_EE\n...\nc29_EE\nc0_BB\n...\nc29_BB\nc0_TE\n...\nc29_TE\nplanck_calibration\n```\n\n**Please note that this function expects Cl and not Dl=l(l+1)Cl/2pi.**\n**Also note that the function returns a log likelihood and not a chi2.**\n\nThe function\n```\ndouble clik_lensing_compute(clik_object* clikid, double* cl_and_pars,error\n**err);\n```\nprovides the log likelihood for lensing, and works similarly to the CMB \nfunction.  The only difference is in the ordering of the ``cl_and_pars`` array, \nwhich must include the **phiphi** spectrum, before the CMB spectra.  Note that\nCMB spectra are needed to compute the lensing normalization and biases.\n\n\n#### Cleaning up\n\nA CMB likelihood can be deallocated using \n```\nvoid clik_cleanup(clik_object** pclikid);\n``` \nand a lensing one with \n```\nvoid clik_lensing_cleanup(clik_lensing_object **plclik);\n```\n\n\n#### Example code\n\nThe file in ``src/clik_example_C.c`` demonstrates the use of the C library.\nThis code compiles to an executable, which reads the path of a clik file as its\nfirst argument and optionally Cl+nuisance ascii files as it next ones.\nThe likelihood is first initialized, and some information (lrange, nuisance\nparameters) is displayed on screen.  Then each optional Cl+nuisance ascii file\nis read and the log likelihood for each one is computed and displayed.\n\nThe Cl+nuisance files must be ascii files, containing one value on each line, \nforming a vector of values for the Cl (not Dl!) and nuisance parameters in the \norder expected for the compute functions. \n\n\n### Using the Fortran Library\n\nUse the ``clik`` module in your code.\n\n\n#### Initialization\n\nThe subroutine \n```\nsubroutine clik_init(clikid,filepath)\n``` \ninitializes a CMB likelihood with the data at ``filepath`` and fills ``clikid`` \nwith an integer referring to the likelihood. \n\nSimilarily \n```\nsubroutine clik_lensing_init(clikid,filepath)\n``` \ninitializes a lensing likelihood.\n\nDuring the initialization, an automatic test is performed and displayed on\nstdout.\n\n\n#### Obtaining the list of spectra, lrange, nuisance parameters\n\n\n##### CMB likelihood\n\nThe subroutine\n```\nsubroutine clik_get_lmax(clikid,lmax)\n```\nfills an array of 6 ``lmax`` integers.  Each element of the array corresponds\nto the lmax of one of the CMB spectra needed by the CMB likelihood referred to\nby ``clikid``.  The ordering is **TT EE BB TE TB EB**.  The array elements are\nset to -1 for each spectrum unused by the current likelihood.\n\nFor example, when used with the high-ell temperature likelihood, ``lmax`` will\nbe set to `` 2508 -1 -1 -1 -1 -1``, meaning that only the TT spectrum is needed\nby the likelihood, and goes up to lmax = 2508.\n\nThe function \n```\ninteger(kind=4) function clik_get_extra_parameter_names(clikid,names)\n``` \nreturns the number of nuisance parameters. ``names`` is filled with a list of \nnames of the nuisance parameters.\n\nAfter usage, the memory pointed to by ``names`` must be freed by the user.\n\n\n### Lensing likelihood\n\nThe subroutine\n```\nsubroutine clik_lensing_get_lmax(clikid,lmax)\n```\nworks like the CMB subroutine ``clik_get_lmax``.\nNote that the lmax array is longer than in the CMB case.  The order in this\ncase is **phiphi TT EE BB TE TB EB**.  In the future, this array may be\nextended to include phi-CMB correlations. \n\nThe function \n```\ninteger(kind=4) function clik_lensing_get_extra_parameter_names(clikid,names)\n``` \nworks like the CMB one.\n\n\n#### Computing a log likelihood\n\nThe function\n```\nreal(kind=8) function clik_compute(clikid,cl_and_pars)\n```\ncomputes the log likelihood for the CMB likelihood referred to by ``clikid`` and\nfor the Cl and nuisance parameters contained in the array ``cl_and_pars``.\nThe ``cl_and_pars`` array is an array of doubles that contains the CMB Cls and \nnuisance parameters.  The order in the array is as follows:\n\n- first the Cls, from l=0 to lmax (inclusive) in the order **TT EE BB TE TB\nEB**. \nNote that this really does start from l=0, even although the effective lmin\nof a given likelihood can be different from 0. Cls below the effective lmin \nwill be ignored in the computation and can be set to any  value.\nOnly the spectra whose ``lmax`` (from the function ``clik_get_lmax``) is \n\u003e-1 are present. \n\n- then the nuisance parameters in the order defined by \n``clik_get_extra_parameter_names``.\n\nFor example, for the low-ell TEB likelihood whose lmax = ``29 29 29 29 -1 -1`` \nand which has a unique nuisance parameter (the Planck absolute calibration),\nthe ``cl_and_pars`` array should be\n```\nc0_TT\nc1_TT\nc2_TT\n...\nc28_TT\nc29_TT\nc0_EE\nc1_EE\n...\nc29_EE\nc0_BB\n...\nc29_BB\nc0_TE\n...\nc29_TE\nplanck_calibration\n```\n\n**Please note that the function expects Cl and not l(l+1)Cl/2pi.**\n**Also note that the function returns a log likelihood and not a chi2.**\n\nThe function\n```\nreal(kind=8) function clik_lensing_compute(clikid,cl_and_pars)\n```\nprovides the log likelihood for a lensing map, and works similarly to the CMB \nfunction.  The only difference is in the ordering of the ``cl_and_pars`` array, \nwhich must include the **phiphi** spectrum, before the CMB spectra.  Note that\nCMB spectra are needed to compute the lensing normalization and biases.\n\n\n#### Cleaning up\n\nA CMB likelihood can be deallocated using \n```\nsubroutine clik_cleanup(clikid)\n``` \nand a lensing one with \n```\nsubroutine clik_lensing_cleanup(clikid)\n```\n\n\n#### Example code\n\nThe file in ``src/clik_example_F90.f90`` demonstrates the use of the C library.\nThis code compiles to an executable that reads the path of a clik file as its\nfirst argument and optionally Cl+nuisance ascii files as it next ones.  The\nlikelihood is first initialized, and some information (lrange, nuisance\nparameters) is displayed on screen.  Then each optional Cl+nuisance ascii file\nis read and the log likelihood for each one is computed and displayed.\n\nThe Cl+nuisance files must be ascii files, containing one value on each line, \nforming a vector of values for the Cl (not Dl!) and nuisance parameters in the \norder expected for the compute functions. \n\n\n### Test tools\n\nThe executable \n```\nclik_example_C /some/path/to/likelihood [Cl+nuisance.txt [Cl+nuisance.file\n[...]]]\n``` \nand \n```\nclik_example_F90 /some/path/to/likelihood [Cl+nuisance.txt [Cl+nuisance.file\n[...]]]\n``` \nperforms tests on a given likelihood file, displays some information and allows\nthe user to compute the log likelihood of Cl+nuisance vectors. \nThe Cl+nuisance files must be ascii files, containing one value on each line, \nforming a vector of values for the Cl (not Dl!) and nuisance parameters in the \norder expected for the compute functions. \n\n\n## Optional tools\n\nThe optional tools are only available if the optional requirements are met.\n\n\n### Using the python library\n\nThe library can be called from python by importing the ``clik`` python package.\n\n\n#### Initialization\n\nCMB Likelihoods are represented by an instance of the ``clik`` objects and\nlensing likelihoods by an instance of ``clik_lensing`` objects.  Both are\ninitialized from a clik file.\n\n```\nimport clik\nCMBlkl = clik.clik(\"/some/path/to/clikfile\")\nlenslkl = clik.clik_lensing(\"/some/path/to/cliklensingfile\")\n```\n\n\n#### Obtaining the list of spectra, lrange, nuisance parameters\n\n\n##### CMB likelihood\n\nThe ``get_lmax`` method of the ``clik`` object returns a 6 element tuple \ncontaining the maximum multipole for each of the CMB spectra.  Please see the C\ndescription above for further explanation.\n\nThe ``get_extra_parameter_names`` method of the ``clik`` object returns a tuple\ncontaining the names of the nuisance parameters\n\n\n##### Lensing likelihood\n\nThe ``get_lmax`` method of the ``clik_lensing`` object returns a 6 element\ntuple containing the maximum multipole for each of the phi and CMB spectra.\nPlease see the C description above for further explanation.\n\nThe ``get_extra_parameter_names`` method of the ``clik_lensing`` object returns \na tuple containing the names of the nuisance parameters\n\nThe ``get_clpp_fid`` method of the ``clik_lensing`` object returns the fiducial\nlensing spectrum, used to perform the automatic test, and to compute the N0 and \nN1 biases.  Corrections to those biases are computed as perturbations around\nthis spectrum.  It returns an array that contains the phiphi lensing spectra\nfrom 0 up to an lmax (inclusive) given by the first element of the tuple\nreturned by ``get_lmax``.\n\nThe ``get_clcmb_fid`` method of the ``clik_lensing`` object returns the\nfiducial CMB spectra, used to perform the automatic test, and to compute the N0\nand N1 biases.  Corrections to those biases are computed as perturbations\naround those spectra.  It returns an array containing all of the CMB spectra\nfrom 0 to the lmax given by the values at index \u003e=1 in the tuple returned by\nthe ``get_lmax`` method.\n\n\n#### Computing a log likelihood\n\nThe ``clik`` and ``clik_lensing`` objects are callable.  They expect a single \nargument ``cl_and_pars``, which must be either a 1-dimensional or a\n2-dimensional array of floats.  The shape of the array must be either\n``(ntot,)`` or ``(i,ntot)``.  If the array is 1-dimensional, it will be\nreshaped internally to ``(1,ntot)``.\n\n``ntot`` is the number of elements of the vector expected by the ``compute``\nfunction described in the C and F90 versions of the library.  The function will\ncompute the log likelihood for each vector of spectra and nuisance parameters\nand return an array of log likelihood values. \n\n\n#### Error handling\n\nIn the case where the library encounters an error, a ``clik.lkl.CError`` error\nobject will be raised.\n\n\n### Example code\n\nThe script ``clik_example_py`` demonstrates how to use the python library.  Its\nusage is similar to the ``clik_example_C`` and ``clik_exmaple_f90`` tools\ndescribed above.\n\n\n### Displaying some imformation with ``clik_print``\n\nThe script ``clik_print`` displays on the screen some more information than the\n``clik_example_XXX`` tools.  It can also be used to check the correct building\nand installation of the library.\n\nIt expects a single argument on its command line, giving the path to a\nlikelihood file:\n```\nclik_print /where/is/my/clikfile\n```\n\n\n### Retrieving the selfcheck vector\n\nThe script `` clik_get_selfchek`` allows the user to retrieve the data used in\nthe automatic test performed at each initialization.  The scripts expects 2\narguments on its command line, the path to a clik file, and the name of a file\nin which the Cl and parameters vector will be saved as an ascii file, in a\nformat suitable for the ``clik_example_XXX`` tools.  Indeed, calling any of the\n``clik_example_XXX`` tools with the same likelihood and using the data vector\nobtained this way should produce the same log likelihood value displayed during\nthe automatic test.\n```\nclik_get_selfcheck /some/clikfile /where/to/save/datavector\n```\n\n\n### Changing the lmin and lmax of some of the likelihoods\n\nThe ``clik_change_lrange`` allows users to change the lmin and lmax values of\nthe plik and commander likelihoods.  This allows for the reproduction of the\ntests performed on the hybridization multipole, and on the high-ell lmax\ndescribed in the Planck 2015 Likelihood paper.\n```\nclik_change_lrange input_clik lmin lmax output_clik\n```\nThe script expects an input clik file, the new lmin and lmax and an output clik \nfile.  The input file will not be modified.  A value of -1 for lmin (or lmax)\ndirects the script not to modify the value.  The lmin and lmax are targets.\nThe output file will have lmin and lmax as close as possible to those values,\ngiven the available data and the binning scheme (for plik).  They will be\ndisplayed.  The script will fail if the path ``output_clik`` already exists.\n\nNote that the output clik file will be stripped of the information needed by\nthe automatic test. When using this new clik file, no test will be performed\nduring initialization.\n\n### Exploring the content of clik files\n\nThe scripts ``clik_cldf_ls`` and ``clik_cldf_dump`` allow users to explore the\ncontents of a clik file.  ``clik_cldf_ls`` allow users to browse the data tree\nof the file, while ``clik_cldf_dump`` will display the content of a given\nleaf. ``clik_cldf_ls`` works on the branches of the data tree (i.e. directories), \nwhile ``clik_cldf_dump`` only displays the content of the leafs (i.e. files).\nPlease note that when the leaf contains a long array, only a subset\nof the first and last parts of the vector will be displayed.\n\nThe file can also be browsed in python using the ``clik.cldf`` module\n```\nimport clik.cldf\n\n# open file\nclf = clik.cldf.File(\"plik_dx11dr2_HM_v18_TT.clik\")\n\n# get the content of the root\nprint clf.keys()\n\n# is the path at clik a subtree or a leaf with data ?\n# prints True in the former case \nprint isinstance(clf[\"clik\"],clik.cldf.File)\n\n# get the list of content at path clik/lkl_0\nprint clf[\"clik/lkl_0\"].keys()\n\n# get the number of T channels in the likelihood\nprint  clf[\"clik/lkl_0/m_channel_T\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjose-d%2Fplc-2.0","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjose-d%2Fplc-2.0","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjose-d%2Fplc-2.0/lists"}