diff --git a/environment_3x2pt.yml b/environment_3x2pt.yml new file mode 100644 index 0000000..b4b89f8 --- /dev/null +++ b/environment_3x2pt.yml @@ -0,0 +1,409 @@ +name: cosmopipe +channels: + - conda-forge + - defaults +dependencies: + - _libgcc_mutex=0.1=conda_forge + - _openmp_mutex=4.5=2_gnu + - _r-mutex=1.0.1=anacondar_1 + - _sysroot_linux-64_curr_repodata_hack=3=h69a702a_13 + - astropy-base=6.0.0=h67a7307_0 + - asttokens=3.0.0=pyhd8ed1ab_1 + - atk-1.0=2.38.0=hd4edc92_1 + - attrs=23.1.0=pyh71513ae_1 + - binutils=2.40=hdd6e379_0 + - binutils_impl_linux-64=2.40=hf600244_0 + - binutils_linux-64=2.40=hbdbef99_2 + - blas=1.0=openblas + - bleach=6.2.0=py311h06a4308_0 + - bottleneck=1.4.2=py311hf4808d0_0 + - brotli=1.1.0=hd590300_1 + - brotli-bin=1.1.0=hd590300_1 + - brotli-python=1.1.0=py311hb755f60_1 + - brotlipy=0.7.0=py311h459d7ec_1006 + - bwidget=1.9.14=ha770c72_1 + - bzip2=1.0.8=hd590300_5 + - c-ares=1.23.0=hd590300_0 + - c-compiler=1.7.0=hd590300_0 + - ca-certificates=2025.9.9=h06a4308_0 + - cairo=1.16.0=ha61ee94_1014 + - camb=1.5.2=py311hbc92942_0 + - certifi=2025.8.3=py311h06a4308_0 + - cffi=1.16.0=py311hb3a22ac_0 + - cfitsio=4.2.0=hd9d235c_0 + - charset-normalizer=3.3.2=pyhd8ed1ab_0 + - colorama=0.4.6=pyhd8ed1ab_0 + - comm=0.2.2=pyhd8ed1ab_1 + - compilers=1.7.0=ha770c72_0 + - contourpy=1.2.0=py311h9547e67_0 + - cosmosis-build-standard-library=1.2=py311h8783aee_3 + - cryptography=41.0.7=py311hcb13ee4_1 + - curl=8.1.2=h409715c_0 + - cxx-compiler=1.7.0=h00ab1b0_0 + - cycler=0.12.1=pyhd8ed1ab_0 + - debugpy=1.8.5=py311hf86e51f_0 + - defusedxml=0.7.1=pyhd3eb1b0_0 + - dill=0.3.7=py311h06a4308_0 + - docutils=0.21.2=py311h06a4308_0 + - dulwich=0.21.6=py311h459d7ec_2 + - dynesty=2.1.2=pyhd8ed1ab_0 + - emcee=3.1.4=pyhd8ed1ab_0 + - exceptiongroup=1.2.0=pyhd8ed1ab_0 + - executing=2.2.0=pyhd8ed1ab_0 + - expat=2.5.0=hcb278e6_1 + - fast-pt=3.1.1=pyhd8ed1ab_0 + - fftw=3.3.10=nompi_hc118613_108 + - font-ttf-dejavu-sans-mono=2.37=hab24e00_0 + - font-ttf-inconsolata=3.000=h77eed37_0 + - font-ttf-source-code-pro=2.038=h77eed37_0 + - font-ttf-ubuntu=0.83=h77eed37_1 + - fontconfig=2.14.2=h14ed4e7_0 + - fonts-conda-ecosystem=1=0 + - fonts-conda-forge=1=0 + - fonttools=4.46.0=py311h459d7ec_0 + - fortran-compiler=1.7.0=heb67821_0 + - freetype=2.12.1=h267a509_2 + - fribidi=1.0.10=h36c2ea0_0 + - future=0.18.3=pyhd8ed1ab_0 + - gcc=12.3.0=h8d2909c_2 + - gcc_impl_linux-64=12.3.0=he2b93b0_3 + - gcc_linux-64=12.3.0=h76fc315_2 + - gdk-pixbuf=2.42.10=h05c8ddd_0 + - gettext=0.21.1=h27087fc_0 + - gfortran=12.3.0=h499e0f7_2 + - gfortran_impl_linux-64=12.3.0=hfcedea8_3 + - gfortran_linux-64=12.3.0=h7fe76b4_2 + - giflib=5.2.2=hd590300_0 + - git=2.42.0=pl5321h86e50cf_0 + - gmp=6.3.0=h59595ed_0 + - gmpy2=2.1.2=py311h6a5fa03_1 + - graphite2=1.3.13=h58526e2_1001 + - graphviz=8.0.3=h2e5815a_0 + - gtk2=2.24.33=h90689f9_2 + - gts=0.7.6=h977cf35_4 + - gxx=12.3.0=h8d2909c_2 + - gxx_impl_linux-64=12.3.0=he2b93b0_3 + - gxx_linux-64=12.3.0=h8a814eb_2 + - harfbuzz=6.0.0=h8e241bc_0 + - icu=70.1=h27087fc_0 + - idna=3.6=pyhd8ed1ab_0 + - imagesize=1.4.1=py311h06a4308_0 + - importlib-metadata=7.0.0=pyha770c72_0 + - importlib-resources=6.1.1=pyhd8ed1ab_0 + - importlib_resources=6.1.1=pyhd8ed1ab_0 + - iniconfig=2.0.0=pyhd8ed1ab_0 + - ipykernel=6.29.5=pyh3099207_0 + - ipython_pygments_lexers=1.1.1=pyhd8ed1ab_0 + - jedi=0.19.2=pyhd8ed1ab_1 + - joblib=1.3.2=pyhd8ed1ab_0 + - jpeg=9e=h0b41bf4_3 + - jsonschema=4.23.0=py311h06a4308_0 + - jupyter_client=8.6.3=pyhd8ed1ab_1 + - jupyter_core=5.8.1=pyh31011fe_0 + - jupyterlab_pygments=0.3.0=py311h06a4308_0 + - kernel-headers_linux-64=4.18.0=he073ed8_0 + - keyutils=1.6.1=h166bdaf_0 + - kiwisolver=1.4.5=py311h9547e67_1 + - krb5=1.20.1=h81ceb04_0 + - lcms2=2.15=hfd0df8a_0 + - ld_impl_linux-64=2.40=h41732ed_0 + - lerc=4.0.0=h27087fc_0 + - libblas=3.9.0=20_linux64_openblas + - libbrotlicommon=1.1.0=hd590300_1 + - libbrotlidec=1.1.0=hd590300_1 + - libbrotlienc=1.1.0=hd590300_1 + - libcblas=3.9.0=20_linux64_openblas + - libcurl=8.1.2=h409715c_0 + - libdeflate=1.17=h0b41bf4_0 + - libedit=3.1.20191231=he28a2e2_2 + - libev=4.33=h516909a_1 + - libexpat=2.5.0=hcb278e6_1 + - libffi=3.4.2=h7f98852_5 + - libgcc-devel_linux-64=12.3.0=h8bca6fd_103 + - libgcc-ng=13.2.0=h807b86a_3 + - libgd=2.3.3=h5aea950_4 + - libgfortran-ng=13.2.0=h69a702a_3 + - libgfortran5=13.2.0=ha4646dd_3 + - libglib=2.78.1=hebfc3b9_0 + - libgomp=13.2.0=h807b86a_3 + - libiconv=1.17=h166bdaf_0 + - liblapack=3.9.0=20_linux64_openblas + - libllvm14=14.0.6=hecde1de_4 + - libnghttp2=1.58.0=h47da74e_0 + - libnsl=2.0.1=hd590300_0 + - libopenblas=0.3.25=pthreads_h413a1c8_0 + - libopenlibm4=0.8.1=hd590300_1 + - libpng=1.6.39=h753d276_0 + - librsvg=2.54.4=h7abd40a_0 + - libsanitizer=12.3.0=h0f45ef3_3 + - libsodium=1.0.18=h36c2ea0_1 + - libsqlite=3.44.2=h2797004_0 + - libssh2=1.11.0=h0841786_0 + - libstdcxx-devel_linux-64=12.3.0=h8bca6fd_103 + - libstdcxx-ng=13.2.0=h7e041cc_3 + - libtiff=4.5.0=h6adf6a1_2 + - libtool=2.4.7=he02047a_1 + - libuuid=2.38.1=h0b41bf4_0 + - libwebp=1.3.2=h11a3e52_0 + - libwebp-base=1.3.2=hd590300_0 + - libxcb=1.13=h7f98852_1004 + - libxml2=2.10.3=hca2bb57_4 + - libzlib=1.2.13=hd590300_5 + - llvm-openmp=8.0.1=hc9558a2_0 + - llvmlite=0.43.0=py311h6a678d5_0 + - lsstdesc.coord=1.3.0=py311h9547e67_1 + - make=4.3=hd18ef5c_1 + - matplotlib-inline=0.1.7=pyhd8ed1ab_1 + - minuit2_standalone=6.22.06=h9c3ff4c_100 + - mistune=3.1.2=py311h06a4308_0 + - mock=5.1.0=pyhd8ed1ab_0 + - mpc=1.3.1=hfe3b2da_0 + - mpfr=4.2.1=h9458935_0 + - mpi=1.0=openmpi + - mpi4py=3.1.5=py311h4267d7f_0 + - mpmath=1.3.0=pyhd8ed1ab_0 + - munkres=1.1.4=pyh9f0ad1d_0 + - nbclient=0.10.2=py311h06a4308_0 + - nbconvert=7.16.6=py311h06a4308_0 + - nbconvert-core=7.16.6=py311h06a4308_0 + - nbconvert-pandoc=7.16.6=py311h06a4308_0 + - nbformat=5.10.4=py311h06a4308_0 + - ncurses=6.4=h59595ed_2 + - nest-asyncio=1.6.0=pyhd8ed1ab_1 + - numba=0.60.0=py311h4bc866e_0 + - numexpr=2.10.1=py311hd28fd6d_0 + - openjpeg=2.5.0=hfec8fc6_2 + - openlibm=0.8.1=hd590300_1 + - openmp=8.0.1=0 + - openmpi=4.1.6=hc5af2df_101 + - openssl=3.3.1=hb9d3cd8_3 + - packaging=23.2=pyhd8ed1ab_0 + - pandas=2.3.2=py311h277b779_0 + - pango=1.50.14=hd33c08f_0 + - parso=0.8.4=pyhd8ed1ab_1 + - patsy=0.5.4=pyhd8ed1ab_0 + - pcre2=10.40=hc3806b6_0 + - perl=5.32.1=4_hd590300_perl5 + - pexpect=4.9.0=pyhd8ed1ab_1 + - pickleshare=0.7.5=pyhd8ed1ab_1004 + - pip=23.3.1=pyhd8ed1ab_0 + - pixman=0.42.2=h59595ed_0 + - platformdirs=4.1.0=pyhd8ed1ab_0 + - pluggy=1.3.0=pyhd8ed1ab_0 + - pooch=1.8.0=pyhd8ed1ab_0 + - psutil=6.0.0=py311h331c9d8_0 + - pthread-stubs=0.4=h36c2ea0_1001 + - ptyprocess=0.7.0=pyhd8ed1ab_1 + - pure_eval=0.2.3=pyhd8ed1ab_1 + - pybind11=2.11.1=py311h9547e67_2 + - pybind11-global=2.11.1=py311h9547e67_2 + - pyccl=3.0.2=py311h671ba89_0 + - pycparser=2.21=pyhd8ed1ab_0 + - pygraphviz=1.10=py311h15e4e5d_4 + - pyopenssl=23.3.0=pyhd8ed1ab_0 + - pyparsing=3.1.1=pyhd8ed1ab_0 + - pysocks=1.7.1=pyha2e5f31_6 + - pytest=7.4.3=pyhd8ed1ab_0 + - python=3.11.6=hab00c5b_0_cpython + - python-dateutil=2.8.2=pyhd8ed1ab_0 + - python-fastjsonschema=2.20.0=py311h06a4308_0 + - python-tzdata=2023.3=pyhd8ed1ab_0 + - python_abi=3.11=4_cp311 + - pytz=2023.3.post1=pyhd8ed1ab_0 + - pyyaml=6.0.1=py311h459d7ec_1 + - r=4.2=r42hd8ed1ab_1007 + - r-base=4.2.3=ha7d60f8_0 + - r-boot=1.3_28.1=r42hc72bb7e_1 + - r-class=7.3_22=r42h57805ef_1 + - r-cluster=2.1.6=r42h61816a4_0 + - r-codetools=0.2_19=r42hc72bb7e_1 + - r-foreign=0.8_86=r42h57805ef_0 + - r-kernsmooth=2.23_22=r42h13b3f57_0 + - r-lattice=0.22_5=r42h57805ef_0 + - r-mass=7.3_60=r42h57805ef_1 + - r-matrix=1.6_4=r42h316c678_0 + - r-mgcv=1.9_0=r42h316c678_0 + - r-nlme=3.1_164=r42h61816a4_0 + - r-nnet=7.3_19=r42h57805ef_1 + - r-recommended=4.2=r42hd8ed1ab_1006 + - r-remotes=2.4.2.1=r42hc72bb7e_0 + - r-rpart=4.1.21=r42h57805ef_0 + - r-spatial=7.3_17=r42h57805ef_0 + - r-survival=3.5_7=r42h57805ef_0 + - readline=8.2=h8228510_1 + - requests=2.31.0=pyhd8ed1ab_0 + - rpds-py=0.22.3=py311h4aa5aa6_0 + - sacc=0.16=pyhd8ed1ab_2 + - scikit-learn=1.7.1=py311hc74f9fe_0 + - seaborn=0.13.0=hd8ed1ab_0 + - seaborn-base=0.13.0=pyhd8ed1ab_0 + - sed=4.8=he412f7d_0 + - setuptools=68.2.2=pyhd8ed1ab_0 + - six=1.16.0=pyh6c4a22f_0 + - snowballstemmer=2.2.0=pyhd3eb1b0_0 + - sphinxcontrib-applehelp=2.0.0=pyhd3eb1b0_1 + - sphinxcontrib-devhelp=2.0.0=pyhd3eb1b0_0 + - sphinxcontrib-htmlhelp=2.1.0=pyhd3eb1b0_0 + - sphinxcontrib-jsmath=1.0.1=pyhd3eb1b0_0 + - sphinxcontrib-qthelp=2.0.0=pyhd3eb1b0_1 + - sphinxcontrib-serializinghtml=2.0.0=pyhd3eb1b0_0 + - stack_data=0.6.3=pyhd8ed1ab_1 + - statsmodels=0.14.0=py311h1f0f07a_2 + - sympy=1.12=pypyh9d50eac_103 + - sysroot_linux-64=2.28=he073ed8_0 + - threadpoolctl=3.2.0=pyha21a80b_0 + - tinycss2=1.4.0=py311h06a4308_0 + - tk=8.6.13=noxft_h4845f30_101 + - tktable=2.10=h0c5db8f_5 + - tomli=2.0.1=pyhd8ed1ab_0 + - tqdm=4.66.1=pyhd8ed1ab_0 + - traitlets=5.14.3=pyhd8ed1ab_1 + - tree=2.1.3=h4bc722e_0 + - tzdata=2023c=h71feb2d_0 + - unicodedata2=15.1.0=py311h459d7ec_0 + - urllib3=2.1.0=pyhd8ed1ab_0 + - wcwidth=0.2.13=pyhd8ed1ab_1 + - wheel=0.42.0=pyhd8ed1ab_0 + - xorg-kbproto=1.0.7=h7f98852_1002 + - xorg-libice=1.0.10=h7f98852_0 + - xorg-libsm=1.2.3=hd9c2040_1000 + - xorg-libx11=1.8.4=h0b41bf4_0 + - xorg-libxau=1.0.11=hd590300_0 + - xorg-libxdmcp=1.1.3=h7f98852_0 + - xorg-libxext=1.3.4=h0b41bf4_2 + - xorg-libxrender=0.9.10=h7f98852_1003 + - xorg-libxt=1.3.0=hd590300_0 + - xorg-renderproto=0.11.1=h7f98852_1002 + - xorg-xextproto=7.3.0=h0b41bf4_1003 + - xorg-xproto=7.0.31=h7f98852_1007 + - xz=5.2.6=h166bdaf_0 + - yaml=0.2.5=h7f98852_2 + - zeromq=4.3.5=h59595ed_1 + - zeus-mcmc=2.5.4=pyhd8ed1ab_0 + - zipp=3.17.0=pyhd8ed1ab_0 + - zlib=1.2.13=hd590300_5 + - zstd=1.5.5=hfc55251_0 + - pip: + - absl-py==2.0.0 + - alabaster==1.0.0 + - annotated-types==0.6.0 + - argparse==1.4.0 + - astropandas==1.2.2 + - astropy==7.1.0 + - astropy-iers-data==0.2025.9.8.0.36.17 + - astunparse==1.6.3 + - babel==2.17.0 + - beautifulsoup4==4.13.3 + - cached-property==1.5.2 + - cachetools==5.3.2 + - cfgv==3.4.0 + - chainconsumer==0.34.0 + - click==8.1.7 + - cloudpickle==3.0.0 + - colossus==1.3.6 + - corner==2.2.2 + - cosmopower==0.1.3 + - cosmosis==3.23 + - coverage==7.6.1 + - cryptograpy==0.0.0 + - cython==0.29.33 + - d2to1==0.2.12.post1 + - dark-emulator==1.1.2 + - decorator==5.1.1 + - deprecation==2.1.0 + - distlib==0.3.9 + - dm-tree==0.1.8 + - fastjsonschema==2.21.1 + - filelock==3.17.0 + - fitsio==1.2.6 + - flatbuffers==23.5.26 + - furo==2024.8.6 + - galselect @ git+https://github.com/jlvdb/galselect.git + - gast==0.4.0 + - george==0.4.3 + - google-auth==2.24.0 + - google-auth-oauthlib==1.0.0 + - google-pasta==0.2.0 + - grpcio==1.59.3 + - gsl==0.0.3 + - h5py==3.14.0 + - halomod @ git+https://github.com/halomod/halomod.git@main + - hankel==1.2.2 + - healpy==1.18.1 + - hmf==3.5.2 + - identify==2.6.7 + - ipython==8.32.0 + - jax==0.4.21 + - jinja2==3.1.5 + - jsonschema-specifications==2024.10.1 + - jupyter-core==5.7.2 + - keras==2.13.1 + - legacy-blinding==0.0.0 + - levin==0.0.1 + - libclang==16.0.6 + - markdown==3.5.1 + - markdown-it-py==3.0.0 + - markupsafe==2.1.3 + - matplotlib==3.10.6 + - mdurl==0.1.2 + - ml-dtypes==0.3.1 + - nautilus-sampler==1.0.5 + - nbsphinx==0.9.6 + - nodeenv==1.9.1 + - numpy==2.2.0 + - numpydoc==1.8.0 + - oauthlib==3.2.2 + - onepower==0.7.2 + - opt-einsum==3.3.0 + - palettable==3.3.3 + - pandoc==2.4 + - pandocfilters==1.5.1 + - pillow==10.1.0 + - plumbum==1.9.0 + - ply==3.11 + - pre-commit==4.1.0 + - prompt-toolkit==3.0.50 + - protobuf==4.25.1 + - py-bobyqa==1.5.0 + - pyasn1==0.5.1 + - pyasn1-modules==0.3.0 + - pydantic==2.5.2 + - pydantic-core==2.14.5 + - pyerfa==2.0.1.5 + - pygments==2.17.2 + - pytest-cov==5.0.0 + - pytest-plt==1.1.1 + - pytest-runner==6.0.1 + - pyzmq==26.2.1 + - referencing==0.36.2 + - requests-oauthlib==1.3.1 + - rich==13.7.0 + - roman-numerals-py==3.0.0 + - rsa==4.9 + - scipy==1.13.1 + - setuptools-scm==8.1.0 + - soupsieve==2.6 + - sphinx==8.2.0 + - sphinx-basic-ng==1.0.0b2 + - sphinx-rtd-theme==3.0.2 + - sphinxcontrib-jquery==4.1 + - tabeval==1.5 + - tabulate==0.9.0 + - tensorboard==2.13.0 + - tensorboard-data-server==0.7.2 + - tensorboard-plugin-wit==1.8.1 + - tensorflow==2.13.0 + - tensorflow-estimator==2.13.0 + - tensorflow-io-gcs-filesystem==0.32.0 + - tensorflow-probability==0.19.0 + - termcolor==2.4.0 + - toml==0.10.2 + - tornado==6.4.2 + - treecorr==5.1.2 + - typing-extensions==4.5.0 + - virtualenv==20.29.2 + - webencodings==0.5.1 + - werkzeug==3.0.1 + - wget==3.2 + - wrapt==1.14.1 +prefix: /net/home/fohlen13/dvornik/anaconda3/envs/cosmopipe diff --git a/man/add_datavector.man.sh b/man/add_datavector.man.sh index 01c7e64..1432446 100644 --- a/man/add_datavector.man.sh +++ b/man/add_datavector.man.sh @@ -97,10 +97,11 @@ function _outputs { then output="obs_vec" else - _message "BV:DATAVEC_TYPE is not set to a known value: ${DATAVEC_TYPE^^} is not one of {COSEBIS,PSI_STATS_GM,PSI_STATS_GG,BANDPOWERS_EE,BANDPOWERS_NE,BANDPOWERS_NN,XIPM,GT,WT}" + _message "BV:DATAVEC_TYPE is not set to a known value: ${DATAVEC_TYPE^^} is not one of {COSEBIS,PSI_STATS_GM,PSI_STATS_GG,BANDPOWERS_EE,BANDPOWERS_NE,BANDPOWERS_NN,XIPM,GT,WT,OBS}" exit 1 fi #}}} + _message "$output" echo ${output} } #}}} diff --git a/man/calculate_psistats.man.sh b/man/calculate_psistats.man.sh index 0016f32..aed784c 100644 --- a/man/calculate_psistats.man.sh +++ b/man/calculate_psistats.man.sh @@ -56,8 +56,11 @@ function _inp_data { # Output data {{{ function _outputs { #Data outputs (leave blank if none) - output=`_parse_blockvars psi_stats_@BV:MODES@` - echo $output + # Need to fix this to output gg and gm instad of nn and ne + echo psi_stats_gm psi_stats_gg + #output=`_parse_blockvars psi_stats_@BV:MODES@` + #output=${output,,} + #echo $output } #}}} diff --git a/man/make_cosmosis_nz_3x2pt.man.sh b/man/make_cosmosis_nz_3x2pt.man.sh new file mode 100644 index 0000000..ec664b9 --- /dev/null +++ b/man/make_cosmosis_nz_3x2pt.man.sh @@ -0,0 +1,144 @@ +# +# make_cosmosis_nz.sh Documentation & Housekeeping functions +# + +#Starting Prompt {{{ +function _prompt { + #Check if we do want verbose output + if [ "$1" != "0" ] + then + _message "@BLU@========================================@DEF@\n" + _message "@BLU@== @RED@ Running make_cosmosis_nz_3x2pt.sh Mode @BLU@ ==@DEF@\n" + _message "@BLU@========================================@DEF@\n" + fi +} +#}}} + +#Mode description {{{ +function _description { + echo "#" + echo '# Construct an Nz file in the format expected by ' + echo '# cosmosis' + echo "#" + echo "# Function takes input data:" + echo "# `_inp_data`" + echo "#" +} +#}}} + +# Abort Message {{{ +_abort() +{ + #Message to print when script aborts + #$0 is the script that was running when this error occurred + _message "@BLU@ An error occured while running:\n@DEF@$0.\n" >&2 + _message "@BLU@ Check the logging file for this step in:\n" >&2 + _message "@DEF@@RUNROOT@/@LOGPATH@/\n" >&2 + exit 1 +} +trap '_abort' 0 +set -e +#}}} + +# Input variables {{{ +function _inp_var { + #Variable inputs (leave blank if none) + echo ALLPATCH BLU BV:MODES BV:NLENSBINS BV:NSMFLENSBINS BV:PATCHLIST BV:TOMOLIMS DATABLOCK DEF PYTHON3BIN RED RUNROOT SCRIPTPATH STORAGEPATH +} +#}}} + +# Input data {{{ +function _inp_data { + #Data inputs (leave blank if none) + outlist='' + #input is dynamic, depending on the value of BV:COSMOSIS_PATCHLIST + patchvar="@BV:COSMOSIS_PATCHLIST@" + patchvar=`_parse_blockvars ${patchvar}` + MODES_IN=`_parse_blockvars @BV:MODES@` + modes='' + if [[ .*\ $MODES_IN\ .* =~ " EE " ]] || [[ .*\ $MODES_IN\ .* =~ " NE " ]] + then + modes="${modes} source" + fi + if [[ .*\ $MODES_IN\ .* =~ " NE " ]] || [[ .*\ $MODES_IN\ .* =~ " NN " ]] + then + modes="${modes} lens" + fi + if [[ .*\ $MODES_IN\ .* =~ " OBS " ]] + then + modes="${modes} obs" + fi + #Define the patches to loop over {{{ + if [ "${patchvar}" == "ALL" ] || [ "${patchvar}" == "@BV:COSMOSIS_PATCHLIST@" ] + then + patchlist=`echo @BV:PATCHLIST@ @ALLPATCH@ @ALLPATCH@comb` + else + patchlist="${patchvar}" + fi + #}}} + for mode in ${modes} + do + for patch in ${patchlist} + do + #>&2 echo ${patch} + outlist="${outlist} cosmosis_neff_${mode} nz_${mode}_${patch}" + done + done + echo ${outlist} +} +#}}} + +# Output data {{{ +function _outputs { + #Data outputs (leave blank if none) + outlist='' + patchvar="@BV:COSMOSIS_PATCHLIST@" + patchvar=`_parse_blockvars ${patchvar}` + MODES_IN=`_parse_blockvars @BV:MODES@` + modes='' + if [[ .*\ $MODES_IN\ .* =~ " EE " ]] || [[ .*\ $MODES_IN\ .* =~ " NE " ]] + then + modes="${modes} source" + fi + if [[ .*\ $MODES_IN\ .* =~ " NE " ]] || [[ .*\ $MODES_IN\ .* =~ " NN " ]] + then + modes="${modes} lens" + fi + if [[ .*\ $MODES_IN\ .* =~ " OBS " ]] + then + modes="${modes} obs" + fi + #Define the patches to loop over {{{ + if [ "${patchvar}" == "ALL" ] || [ "${patchvar}" == "@BV:COSMOSIS_PATCHLIST@" ] + then + patchlist=`echo @BV:PATCHLIST@ @ALLPATCH@ @ALLPATCH@comb` + else + patchlist="${patchvar}" + fi + for mode in ${modes} + do + for patch in ${patchlist} + do + outlist="${outlist} cosmosis_nz_${mode}_${patch}" + done + done + echo ${outlist} +} +#}}} + +# Execution command {{{ +function _runcommand { + #Command for running the script + echo bash @RUNROOT@/@SCRIPTPATH@/make_cosmosis_nz_3x2pt.sh +} +#}}} + +# Unset Function command {{{ +function _unset_functions { + #Remove these functions from the environment + unset -f _prompt _description _inp_data _inp_var _abort _outputs _runcommand _unset_functions +} +#}}} + +#Additional Functions + diff --git a/scripts/add_gt.sh b/scripts/add_gt.sh index 9bb6ef3..f7fbfe3 100644 --- a/scripts/add_gt.sh +++ b/scripts/add_gt.sh @@ -25,7 +25,7 @@ then outlist=${file} elif [ -d @BV:TREECORRGT@ ] then - filelist=`ls @BV:TREECORRGT@/*.asc*` + filelist=`ls @BV:TREECORRGT@/*.txt*` for file in ${filelist} do cp ${file} @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/gt/${file##*/} diff --git a/scripts/add_wt.sh b/scripts/add_wt.sh index c65c066..19777ff 100644 --- a/scripts/add_wt.sh +++ b/scripts/add_wt.sh @@ -25,7 +25,7 @@ then outlist=${file} elif [ -d @BV:TREECORRWT@ ] then - filelist=`ls @BV:TREECORRWT@/*.asc*` + filelist=`ls @BV:TREECORRWT@/*.txt*` for file in ${filelist} do cp ${file} @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/wt/${file##*/} diff --git a/scripts/add_xipm.sh b/scripts/add_xipm.sh index 4ad1a8f..2336400 100644 --- a/scripts/add_xipm.sh +++ b/scripts/add_xipm.sh @@ -25,7 +25,7 @@ then outlist=${file} elif [ -d @BV:TREECORRXIPM@ ] then - filelist=`ls @BV:TREECORRXIPM@/*.asc*` + filelist=`ls @BV:TREECORRXIPM@/*.txt*` for file in ${filelist} do cp ${file} @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/xipm/${file##*/} diff --git a/scripts/calc_smf.py b/scripts/calc_smf.py index 0b4c4fd..56b6340 100644 --- a/scripts/calc_smf.py +++ b/scripts/calc_smf.py @@ -140,6 +140,10 @@ stellar_mass_in = data[stellar_mass_column] z_in = data[z_column] + # Check that data covers min_z, max_z + if not np.any((z_in >= min_z) & (z_in <= max_z)): + raise ValueError(f"No data in redshift range {min_z} < z < {max_z}") + # We set the possible minimum z to 0.001 z_min = np.maximum(0.001, min_z) # max_z is given as an input, this is the maximum redshift in the stellar mass-redshift bin. @@ -151,7 +155,6 @@ # or maximum redshift of the stellar mass-redshift bin z_max_i = np.minimum(z_max_bin, z_max) - if estimator == 'simple': # Comoving distance at z_min and z_max_i in units of Mpc h # z_max_i is the maximum redshift at which galaxy i is visible in the sample diff --git a/scripts/cosmosis_constructor_3x2pt.sh b/scripts/cosmosis_constructor_3x2pt.sh index c6d2424..d583ca5 100644 --- a/scripts/cosmosis_constructor_3x2pt.sh +++ b/scripts/cosmosis_constructor_3x2pt.sh @@ -43,8 +43,8 @@ zmax_def = 1.2 nmass_def = 100 ; 200 logmassmin_def = 9.0 logmassmax_def = 18.0 -beta_nl = True -mead2020_corrections = fit_feedback +nonlinear_mode_ = bnl +hmcode_ingredients_ = fit SAMPLER_NAME = @BV:SAMPLER@ RUN_NAME = %(SAMPLER_NAME)s_%(blind)s${CHAINSUFFIX} @@ -591,7 +591,7 @@ input_section_name = shear_cl output_section_name = shear_xi [xip_conv] -file = %(CSL_PATH)s/utility/convert_theta/convert_theta.py +file = %(HMPATH)s/cosmosis_modules/convert_theta/convert_theta.py output_units = arcmin section_name = shear_xi_plus @@ -704,7 +704,7 @@ cat > @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_con [multinest] max_iterations=100000 multinest_outfile_root= %(OUTPUT_FOLDER)s/%(RUN_NAME)s_ -resume=T +resume=F tolerance = 0.01 constant_efficiency = F live_points = 1000 @@ -738,13 +738,13 @@ fast_slow="F" n_batch=`echo "@BV:NTHREADS@" | awk '{printf "%d", 4*$1}'` cat > @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_constructed_sampler.ini <<- EOF [nautilus] -live_points = 4000 +n_live = 4000 enlarge_per_dim = 1.1 split_threshold = 100 n_networks = 8 n_batch = $n_batch filepath = %(OUTPUT_FOLDER)s/run_nautilus.hdf5 -resume = False ; True +resume = False ; True f_live = 0.01 discard_exploration = True verbose = True @@ -1062,7 +1062,6 @@ EOF fi cat >> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_constructed_pipe.ini <<- EOF extra_output = ${extraparams} ${shifts} ${listparam} ${tpdparams} -quiet = T timing = F ; T debug = F fast_slow = ${fast_slow} @@ -1070,7 +1069,7 @@ first_fast_module = hod ; halo_model_ingredients_halomod [runtime] sampler = %(SAMPLER_NAME)s -verbosity = quiet +verbosity = quiet ; normal ; quiet pool_stdout = F ; T [output] @@ -1215,15 +1214,15 @@ do sets="" if [[ .*\ $MODES\ .* =~ " EE " ]] || [[ .*\ $MODES\ .* =~ " NE " ]] then - sets="${sets} %(redshift_name)s" + sets="${sets} %(redshift_name)s" fi if [[ .*\ $MODES\ .* =~ " NE " ]] || [[ .*\ $MODES\ .* =~ " NN " ]] then - sets="${sets} %(redshift_name_lens)s" + sets="${sets} %(redshift_name_lens)s" fi if [[ .*\ $MODES\ .* =~ " OBS " ]] then - sets="${sets} %(redshift_name_obs)s" + sets="${sets} %(redshift_name_obs)s" fi cat >> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_constructed_other.ini <<- EOF [$module] @@ -1276,6 +1275,8 @@ do z_maxs="" suffix=`seq -s ' ' ${NSMFLENSBINS}` file1="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/smf_lens_cats_metadata/stats_LB1.txt" + if [ -f ${file1} ] + then slice=`grep '^slice_in' ${file1} | awk '{printf $2}'` if [ "${slice}" == "obs" ] then @@ -1302,6 +1303,17 @@ do else _message "Got wrong or no information about slicing of the lens sample.\n" #exit 1 + fi + else + _message "No SMF lens catalog metadata found, setting default CSMF parameters from saved variables.\n" + if [ "${NSMFLENSBINS}" = "1" ] + then + z_mins=$(echo @BV:SMFLENSLIMSY@ | awk '{print $1}') + z_maxs=$(echo @BV:SMFLENSLIMSY@ | awk '{print $2}') + else + z_mins=$(echo @BV:SMFLENSLIMSY@ | awk '{for(i=1; i> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_constructed_other.ini <<- EOF - [$module] + cat >> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_constructed_other.ini <<- EOF + [$module] file= %(HMPATH)s/cosmosis_modules/onepower_interface.py p_mm = ${ee} p_gg = ${nn} @@ -1445,29 +1496,29 @@ do EOF else - cat >> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_constructed_other.ini <<- EOF - [$module] + cat >> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_constructed_other.ini <<- EOF + [$module] file= %(HMPATH)s/cosmosis_modules/onepower_interface.py - p_mm = ${ee} - p_gg = ${nn} - p_gm = ${ne} - p_gI = False - p_mI = False - p_II = False + p_mm = ${ee} + p_gg = ${nn} + p_gm = ${ne} + p_gI = False + p_mI = False + p_II = False split_ia = True EOF fi cat >> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_inputs/@SURVEY@_CosmoPipe_constructed_other.ini <<- EOF - bnl = %(beta_nl)s + nonlinear_mode = %(nonlinear_mode_)s update_bnl = 10 poisson_type = constant point_mass = True dewiggle = True response = False output_suffix = onepower - use_mead2020_corrections = %(mead2020_corrections)s + hmcode_ingredients = %(hmcode_ingredients_)s log_mass_min = %(logmassmin_def)s log_mass_max = %(logmassmax_def)s diff --git a/scripts/covariance_constructor_3x2pt.sh b/scripts/covariance_constructor_3x2pt.sh index 177452a..2aacb99 100644 --- a/scripts/covariance_constructor_3x2pt.sh +++ b/scripts/covariance_constructor_3x2pt.sh @@ -36,6 +36,40 @@ NTOMO=`echo @BV:TOMOLIMS@ | awk '{print NF-1}'` NLENS="@BV:NLENSBINS@" NOBS="@BV:NSMFLENSBINS@" +use_arbitrary=True +arb_base=@RUNROOT@/@CONFIGPATH@/covariance_arb_summary/ +outfold=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_inputs/arb_summary_filters/ + +# Function to check and copy files +check_and_copy_files() { + local n=$1 + shift + local files=("$@") + + for i in $(seq -f "%02g" 1 "$n"); do + missing=False + expanded_files=() + for f in "${files[@]}"; do + file="${f//\?/$i}" + expanded_files+=("$file") + if [ ! -f "$arb_base$file" ]; then + missing=True + fi + done + + if [ "$missing" == "True" ]; then + run_arbitrary=True + _message "One or more arbitrary input files do not exist. Please run the run_cov_weights.sh script before!\n" + break + else + for f in "${expanded_files[@]}"; do + cp "$arb_base$f" "$outfold" + done + fi + done +} + + if [ "${STATISTIC^^}" == "2PCF" ] then @@ -44,10 +78,10 @@ then est_shear=xi_pm cosmic_shear=True n_arb_ee=@BV:NXIPM@ - arb_fourier_filter_mmE_file_@BV:STATISTIC@="fourier_weight_realspace_cf_mm_p_?.table" - arb_fourier_filter_mmB_file_@BV:STATISTIC@="fourier_weight_realspace_cf_mm_m_?.table" - arb_real_filter_mm_p_file_@BV:STATISTIC@="real_weight_realspace_cf_mm_p_?.table" - arb_real_filter_mm_m_file_@BV:STATISTIC@="real_weight_realspace_cf_mm_m_?.table" + arb_fourier_filter_mmE_file="fourier_weight_realspace_cf_mm_p_?.table" + arb_fourier_filter_mmB_file="fourier_weight_realspace_cf_mm_m_?.table" + arb_real_filter_mm_p_file="real_weight_realspace_cf_mm_p_?.table" + arb_real_filter_mm_m_file="real_weight_realspace_cf_mm_m_?.table" else est_shear=xi_pm cosmic_shear=False @@ -57,8 +91,8 @@ then est_ggl=gamma_t ggl=True n_arb_ne=@BV:NGT@ - arb_fourier_filter_gm_file_@BV:STATISTIC@="fourier_weight_realspace_cf_gm_?.table" - arb_real_filter_gm_file_@BV:STATISTIC@="real_weight_realspace_cf_gm_?.table" + arb_fourier_filter_gm_file="fourier_weight_realspace_cf_gm_?.table" + arb_real_filter_gm_file="real_weight_realspace_cf_gm_?.table" else est_ggl=gamma_t ggl=False @@ -68,8 +102,8 @@ then est_clust=w clustering=True n_arb_nn=@BV:NWT@ - arb_fourier_filter_gg_file_@BV:STATISTIC@="fourier_weight_realspace_cf_gg_?.table" - arb_real_filter_gg_file_@BV:STATISTIC@="real_weight_realspace_cf_gg_?.table" + arb_fourier_filter_gg_file="fourier_weight_realspace_cf_gg_?.table" + arb_real_filter_gg_file="real_weight_realspace_cf_gg_?.table" else est_clust=w clustering=False @@ -81,10 +115,10 @@ then est_shear=cosebi cosmic_shear=True n_arb_ee=@BV:NMAXCOSEBIS@ - arb_fourier_filter_mmE_file_@BV:STATISTIC@="Wn_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" - arb_fourier_filter_mmB_file_@BV:STATISTIC@="Wn_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" - arb_real_filter_mm_p_file_@BV:STATISTIC@="Tp_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" - arb_real_filter_mm_m_file_@BV:STATISTIC@="Tm_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" + arb_fourier_filter_mmE_file="Wn_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" + arb_fourier_filter_mmB_file="Wn_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" + arb_real_filter_mm_p_file="Tp_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" + arb_real_filter_mm_m_file="Tm_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" else est_shear=cosebi cosmic_shear=False @@ -94,8 +128,8 @@ then est_ggl=cosebi ggl=True n_arb_ne=@BV:NMAXCOSEBISNE@ - arb_fourier_filter_gm_file_@BV:STATISTIC@="Qgm_@BV:THETAMINGT@_to_@BV:THETAMAXGT@_?.table" - arb_real_filter_gm_file_@BV:STATISTIC@="Wn_psigm_@BV:THETAMINGT@_to_@BV:THETAMAXGT@_?.table" + arb_fourier_filter_gm_file="Qgm_@BV:THETAMINGT@_to_@BV:THETAMAXGT@_?.table" + arb_real_filter_gm_file="Wn_psigm_@BV:THETAMINGT@_to_@BV:THETAMAXGT@_?.table" else est_ggl=cosebi ggl=False @@ -105,8 +139,8 @@ then est_clust=cosebi clustering=True n_arb_nn=@BV:NMAXCOSEBISNN@ - arb_fourier_filter_gg_file_@BV:STATISTIC@="Ugg_@BV:THETAMINWT@_to_@BV:THETAMAXWT@_?.table" - arb_real_filter_gg_file_@BV:STATISTIC@="Wn_psigg_@BV:THETAMINWT@_to_@BV:THETAMAXWT@_?.table" + arb_fourier_filter_gg_file="Ugg_@BV:THETAMINWT@_to_@BV:THETAMAXWT@_?.table" + arb_real_filter_gg_file="Wn_psigg_@BV:THETAMINWT@_to_@BV:THETAMAXWT@_?.table" else est_clust=cosebi clustering=False @@ -122,10 +156,10 @@ then theta_up=`echo 'e(l(@BV:THETAMAXXI@)-@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` t_lo=`printf "%.2f" $theta_lo` t_up=`printf "%.2f" $theta_up` - arb_fourier_filter_mmE_file_@BV:STATISTIC@="fourier_weight_bandpowers_mmE_?.table" - arb_fourier_filter_mmB_file_@BV:STATISTIC@="fourier_weight_bandpowers_mmB_?.table" - arb_real_filter_mm_p_file_@BV:STATISTIC@="real_weight_bandpowers_mmE_?.table" - arb_real_filter_mm_m_file_@BV:STATISTIC@="real_weight_bandpowers_mmB_?.table" + arb_fourier_filter_mmE_file="fourier_weight_bandpowers_mmE_?.table" + arb_fourier_filter_mmB_file="fourier_weight_bandpowers_mmB_?.table" + arb_real_filter_mm_p_file="real_weight_bandpowers_mmE_?.table" + arb_real_filter_mm_m_file="real_weight_bandpowers_mmB_?.table" else est_shear=bandpowers cosmic_shear=False @@ -139,8 +173,8 @@ then theta_up_lensing=`echo 'e(l(@BV:THETAMAXGT@)-@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` t_lo=`printf "%.2f" $theta_lo_lensing` t_up=`printf "%.2f" $theta_up_lensing` - arb_fourier_filter_gm_file_@BV:STATISTIC@="fourier_weight_bandpowers_gm_?.table" - arb_real_filter_gm_file_@BV:STATISTIC@="real_weight_bandpowers_gm_?.table" + arb_fourier_filter_gm_file="fourier_weight_bandpowers_gm_?.table" + arb_real_filter_gm_file="real_weight_bandpowers_gm_?.table" else est_ggl=bandpowers ggl=False @@ -154,8 +188,8 @@ then theta_up_clustering=`echo 'e(l(@BV:THETAMAXWT@)-@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` t_lo=`printf "%.2f" $theta_lo_clustering` t_up=`printf "%.2f" $theta_up_clustering` - arb_fourier_filter_gg_file_@BV:STATISTIC@="fourier_weight_bandpowers_gg_?.table" - arb_real_filter_gg_file_@BV:STATISTIC@="real_weight_bandpowers_gg_?.table" + arb_fourier_filter_gg_file="fourier_weight_bandpowers_gg_?.table" + arb_real_filter_gg_file="real_weight_bandpowers_gg_?.table" else est_clust=bandpowers clustering=False @@ -174,46 +208,64 @@ then z_mins="" z_maxs="" file1="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/smf_lens_cats_metadata/stats_LB1.txt" - slice=`grep '^slice_in' ${file1} | awk '{printf $2}'` - if [ "${slice}" == "obs" ] - then - for i in `seq ${NOBS}` - do - file="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/smf_lens_cats_metadata/stats_LB${i}.txt" - x_lo=`grep '^x_lims_lo' ${file} | awk '{printf $2}'` - x_hi=`grep '^x_lims_hi' ${file} | awk '{printf $2}'` - y_lo=`grep '^y_lims_lo' ${file} | awk '{printf $2}'` - y_hi=`grep '^y_lims_hi' ${file} | awk '{printf $2}'` - obs_mins="${obs_mins} $(echo "$x_lo + l(@BV:H0_IN@)/l(10)" | bc -l)" - obs_maxs="${obs_maxs} $(echo "$x_hi + l(@BV:H0_IN@)/l(10)" | bc -l)" - z_mins="${z_mins} ${y_lo}" - z_maxs="${z_maxs} ${y_hi}" - done - elif [ "${slice}" == "z" ] + if [ -f ${file1} ] then - for i in `seq ${NOBS}` - do - file="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/smf_lens_cats_metadata/stats_LB${i}.txt" - x_lo=`grep '^x_lims_lo' ${file} | awk '{printf $2}'` - x_hi=`grep '^x_lims_hi' ${file} | awk '{printf $2}'` - y_lo=`grep '^y_lims_lo' ${file} | awk '{printf $2}'` - y_hi=`grep '^y_lims_hi' ${file} | awk '{printf $2}'` - obs_mins="${obs_mins} $(echo "$y_lo + l(@BV:H0_IN@)/l(10)" | bc -l)" - obs_maxs="${obs_maxs} $(echo "$y_hi + l(@BV:H0_IN@)/l(10)" | bc -l)" - z_mins="${z_mins} ${x_lo}" - z_maxs="${z_maxs} ${x_hi}" - done + slice=`grep '^slice_in' ${file1} | awk '{printf $2}'` + if [ "${slice}" == "obs" ] + then + for i in `seq ${NOBS}` + do + file="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/smf_lens_cats_metadata/stats_LB${i}.txt" + x_lo=`grep '^x_lims_lo' ${file} | awk '{printf $2}'` + x_hi=`grep '^x_lims_hi' ${file} | awk '{printf $2}'` + y_lo=`grep '^y_lims_lo' ${file} | awk '{printf $2}'` + y_hi=`grep '^y_lims_hi' ${file} | awk '{printf $2}'` + obs_mins="${obs_mins} $(echo "$x_lo + l(@BV:H0_IN@)/l(10)" | bc -l)" + obs_maxs="${obs_maxs} $(echo "$x_hi + l(@BV:H0_IN@)/l(10)" | bc -l)" + z_mins="${z_mins} ${y_lo}" + z_maxs="${z_maxs} ${y_hi}" + done + elif [ "${slice}" == "z" ] + then + for i in `seq ${NOBS}` + do + file="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/smf_lens_cats_metadata/stats_LB${i}.txt" + x_lo=`grep '^x_lims_lo' ${file} | awk '{printf $2}'` + x_hi=`grep '^x_lims_hi' ${file} | awk '{printf $2}'` + y_lo=`grep '^y_lims_lo' ${file} | awk '{printf $2}'` + y_hi=`grep '^y_lims_hi' ${file} | awk '{printf $2}'` + obs_mins="${obs_mins} $(echo "$y_lo + l(@BV:H0_IN@)/l(10)" | bc -l)" + obs_maxs="${obs_maxs} $(echo "$y_hi + l(@BV:H0_IN@)/l(10)" | bc -l)" + z_mins="${z_mins} ${x_lo}" + z_maxs="${z_maxs} ${x_hi}" + done + else + _message "Got wrong or no information about slicing of the lens sample.\n" + #exit 1 + fi + cstellar_mf=True + csmf_Mmin=`echo ${obs_mins} | sed 's/ /,/g'` + csmf_Mmax=`echo ${obs_maxs} | sed 's/ /,/g'` + csmf_N_log10M_bin=@BV:NSMFBINS@ + csmf_directory="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/smf/" + V_max_file="@DB:vmax@" # This assumes one file, currently we have NSMFLENSBINS + f_tomo_file="@DB:f_tomo@" # This assumes one file, currently we have NSMFLENSBINS else - _message "Got wrong or no information about slicing of the lens sample.\n" - #exit 1 + _message "No SMF lens catalog metadata found, setting default CSMF parameters from saved variables.\n" + if [ "${NOBS}" = "1" ] + then + csmf_Mmin=$(echo @BV:SMFLENSLIMSX@ | awk '{print $1}') + csmf_Mmax=$(echo @BV:SMFLENSLIMSX@ | awk '{print $2}') + else + csmf_Mmin=$(echo @BV:SMFLENSLIMSX@ | awk '{for(i=1; i> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_inputs/@SURVEY@_CosmoPipe_constructed_other.ini <<- EOF ;arb_summary_directory = @RUNROOT@/@CONFIGPATH@/covariance_arb_summary/ arb_summary_directory = @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_inputs/arb_summary_filters/ -arb_fourier_filter_mmE_file = ${arb_fourier_filter_mmE_file_@BV:STATISTIC@}, ${arb_fourier_filter_mmE_file_@BV:SECONDSTATISTIC@} -arb_fourier_filter_mmB_file = ${arb_fourier_filter_mmB_file_@BV:STATISTIC@}, ${arb_fourier_filter_mmB_file_@BV:SECONDSTATISTIC@} -arb_real_filter_mm_p_file = ${arb_real_filter_mm_p_file_@BV:STATISTIC@}, ${arb_real_filter_mm_p_file_@BV:SECONDSTATISTIC@} -arb_real_filter_mm_m_file = ${arb_real_filter_mm_m_file_@BV:STATISTIC@}, ${arb_real_filter_mm_m_file_@BV:SECONDSTATISTIC@} -arb_fourier_filter_gm_file = ${arb_fourier_filter_gm_file_@BV:STATISTIC@}, ${arb_fourier_filter_gm_file_@BV:SECONDSTATISTIC@} -arb_real_filter_gm_file = ${arb_real_filter_gm_file_@BV:STATISTIC@}, ${arb_real_filter_gm_file_@BV:SECONDSTATISTIC@} -arb_fourier_filter_gg_file = ${arb_fourier_filter_gg_file_@BV:STATISTIC@}, ${arb_fourier_filter_gg_file_@BV:SECONDSTATISTIC@} -arb_real_filter_gg_file = ${arb_real_filter_gg_file_@BV:STATISTIC@}, ${arb_real_filter_gg_file_@BV:SECONDSTATISTIC@} +arb_fourier_filter_mmE_file = ${arb_fourier_filter_mmE_file}, ${arb_fourier_filter_mmE_file_second_stat} +arb_fourier_filter_mmB_file = ${arb_fourier_filter_mmB_file}, ${arb_fourier_filter_mmB_file_second_stat} +arb_real_filter_mm_p_file = ${arb_real_filter_mm_p_file}, ${arb_real_filter_mm_p_file_second_stat} +arb_real_filter_mm_m_file = ${arb_real_filter_mm_m_file}, ${arb_real_filter_mm_m_file_second_stat} +arb_fourier_filter_gm_file = ${arb_fourier_filter_gm_file}, ${arb_fourier_filter_gm_file_second_stat} +arb_real_filter_gm_file = ${arb_real_filter_gm_file}, ${arb_real_filter_gm_file_second_stat} +arb_fourier_filter_gg_file = ${arb_fourier_filter_gg_file}, ${arb_fourier_filter_gg_file_second_stat} +arb_real_filter_gg_file = ${arb_real_filter_gg_file}, ${arb_real_filter_gg_file_second_stat} [arbitrary_summary] do_arbitrary_obs = True @@ -1069,14 +1048,14 @@ then cat >> @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_inputs/@SURVEY@_CosmoPipe_constructed_other.ini <<- EOF ;arb_summary_directory = @RUNROOT@/@CONFIGPATH@/covariance_arb_summary/ arb_summary_directory = @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_inputs/arb_summary_filters/ -arb_fourier_filter_mmE_file = ${arb_fourier_filter_mmE_file_@BV:STATISTIC@} -arb_fourier_filter_mmB_file = ${arb_fourier_filter_mmB_file_@BV:STATISTIC@} -arb_real_filter_mm_p_file = ${arb_real_filter_mm_p_file_@BV:STATISTIC@} -arb_real_filter_mm_m_file = ${arb_real_filter_mm_m_file_@BV:STATISTIC@} -arb_fourier_filter_gm_file = ${arb_fourier_filter_gm_file_@BV:STATISTIC@} -arb_real_filter_gm_file = ${arb_real_filter_gm_file_@BV:STATISTIC@} -arb_fourier_filter_gg_file = ${arb_fourier_filter_gg_file_@BV:STATISTIC@} -arb_real_filter_gg_file = ${arb_real_filter_gg_file_@BV:STATISTIC@} +arb_fourier_filter_mmE_file = ${arb_fourier_filter_mmE_file} +arb_fourier_filter_mmB_file = ${arb_fourier_filter_mmB_file} +arb_real_filter_mm_p_file = ${arb_real_filter_mm_p_file} +arb_real_filter_mm_m_file = ${arb_real_filter_mm_m_file} +arb_fourier_filter_gm_file = ${arb_fourier_filter_gm_file} +arb_real_filter_gm_file = ${arb_real_filter_gm_file} +arb_fourier_filter_gg_file = ${arb_fourier_filter_gg_file} +arb_real_filter_gg_file = ${arb_real_filter_gg_file} [arbitrary_summary] do_arbitrary_obs = True diff --git a/scripts/make_cosmosis_nz_3x2pt.sh b/scripts/make_cosmosis_nz_3x2pt.sh new file mode 100644 index 0000000..6fc489f --- /dev/null +++ b/scripts/make_cosmosis_nz_3x2pt.sh @@ -0,0 +1,291 @@ +#========================================= +# +# File Name : make_cosmosis_nz_3x2pt.sh +# Created By : awright +# Creation Date : 30-03-2023 +# Last Modified : Tue 21 Nov 2023 12:55:58 AM CET +# +#========================================= + +MODES="@BV:MODES@" +NTOMO=`echo @BV:TOMOLIMS@ | awk '{print NF-1}'` +NLENS="@BV:NLENSBINS@" +NOBS="@BV:NSMFLENSBINS@" +outputlist='' +found_source="FALSE" +found_lens="FALSE" +found_obs="FALSE" + +need_source="FALSE" +need_lens="FALSE" +need_obs="FALSE" + +if [[ .*\ $MODES\ .* =~ " EE " ]] || [[ .*\ $MODES\ .* =~ " NE " ]] +then + need_source="TRUE" +fi +if [[ .*\ $MODES\ .* =~ " NE " ]] || [[ .*\ $MODES\ .* =~ " NN " ]] +then + need_lens="TRUE" +fi +if [[ .*\ $MODES\ .* =~ " OBS " ]] +then + need_obs="TRUE" +fi + +if [ ${need_source} == "TRUE" ] +then + for patch in @BV:PATCHLIST@ @ALLPATCH@ + do + _message " ->@BLU@ Patch @RED@${patch}@DEF@" + #Get all the files in this stat and patch {{{ + inputs=`_read_datablock "nz_source_${patch}"` + inputs=`_blockentry_to_filelist ${inputs}` + #}}} + filelist='' + #Get the file list {{{ + for ZBIN1 in `seq ${NTOMO}` + do + #Define the Z_B limits from the TOMOLIMS {{{ + ZB_lo=`echo @BV:TOMOLIMS@ | awk -v n=$ZBIN1 '{print $n}'` + ZB_hi=`echo @BV:TOMOLIMS@ | awk -v n=$ZBIN1 '{print $(n+1)}'` + #}}} + #Define the string to append to the file names {{{ + ZB_lo_str=`echo $ZB_lo | sed 's/\./p/g'` + ZB_hi_str=`echo $ZB_hi | sed 's/\./p/g'` + appendstr="_ZB${ZB_lo_str}t${ZB_hi_str}" + #}}} + #file=`echo ${inputs} | sed 's/ /\n/g' | grep "_${patch}_" | grep ${appendstr} || echo ` + file=`echo ${inputs} | sed 's/ /\n/g' | grep ${appendstr} || echo ` + #Check if the output file exists {{{ + if [ "${file}" == "" ] + then + #If not, loop + continue + fi + #}}} + filelist="${filelist} @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/nz_source_${patch}/${file}" + done + #}}} + #If filelist is empty, skip {{{ + if [ "${filelist}" == "" ] + then + _message "@RED@ - skipping! (No matching source Nz files)@DEF@\n" + continue + fi + #}}} + found_source='TRUE' + #Construct the output directory {{{ + if [ ! -d @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_source_${patch} ] + then + mkdir @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_source_${patch}/ + fi + #}}} + _message "@RED@ - OK! (`date +'%a %H:%M'`)@DEF@\n" + #Construct the output base {{{ + file=${filelist##* } + output_base=${file##*/} + output_base=${output_base%%_ZB*} + output_base="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_source_${patch}/${output_base}" + #}}} + #Remove existing files {{{ + if [ -f ${output_base}_comb_Nz.fits ] + then + _message " > @BLU@Removing previous COSMOSIS Nz file@DEF@ ${output_base##*/}_comb_Nz.fits@DEF@" + rm ${output_base}_comb_Nz.fits + _message " - @RED@Done! (`date +'%a %H:%M'`)@DEF@\n" + fi + #}}} + #Construct the redshift file {{{ + _message " > @BLU@Constructing COSMOSIS Nz file @RED@${output_base}_comb_Nz.fits@DEF@" + #Construct the Nz combined fits file and put into covariance/input/ + @PYTHON3BIN@ @RUNROOT@/@SCRIPTPATH@/MakeNofZForCosmosis_function.py \ + --inputs ${filelist} \ + --neff @DB:cosmosis_neff_source@ \ + --output_base ${output_base} \ + --suffix "source" 2>&1 + _message " - @RED@Done! (`date +'%a %H:%M'`)@DEF@\n" + #}}} + + #Update the datablock + _write_datablock cosmosis_nz_source_${patch} "${output_base##*/}_comb_Nz.fits" + done +fi + +if [ ${need_lens} == "TRUE" ] +then + for patch in @BV:PATCHLIST@ @ALLPATCH@ + do + _message " ->@BLU@ Patch @RED@${patch}@DEF@" + #Get all the files in this stat and patch {{{ + inputs_lens=`_read_datablock "nz_lens_${patch}"` + inputs_lens=`_blockentry_to_filelist ${inputs_lens}` + #}}} + filelist_lens='' + #Get the file list {{{ + for LBIN in `seq ${NLENS}` + do + #Define the string to append to the file names {{{ + appendstr="_LB${LBIN}" + #}}} + #file=`echo ${inputs} | sed 's/ /\n/g' | grep "_${patch}_" | grep ${appendstr} || echo ` + file=`echo ${inputs_lens} | sed 's/ /\n/g' | grep ${appendstr} || echo ` + appendstr="_LB${LBIN}" + #Check if the output file exists {{{ + if [ "${file}" == "" ] + then + #If not, loop + continue + fi + #}}} + filelist_lens="${filelist_lens} @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/nz_lens_${patch}/${file}" + done + #}}} + #If filelist is empty, skip {{{ + if [ "${filelist_lens}" == "" ] + then + _message "@RED@ - skipping! (No matching lens Nz files)@DEF@\n" + continue + fi + #}}} + found_lens='TRUE' + #Construct the output directory {{{ + if [ ! -d @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_lens_${patch} ] + then + mkdir @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_lens_${patch}/ + fi + #}}} + _message "@RED@ - OK! (`date +'%a %H:%M'`)@DEF@\n" + #Construct the output base {{{ + file=${filelist_lens##* } + output_base=${file##*/} + output_base=${output_base%%_LB*} + output_base="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_lens_${patch}/${output_base}" + #}}} + #Remove existing files {{{ + if [ -f ${output_base}_comb_Nz.fits ] + then + _message " > @BLU@Removing previous COSMOSIS Nz file@DEF@ ${output_base##*/}_comb_Nz.fits@DEF@" + rm ${output_base}_comb_Nz.fits + _message " - @RED@Done! (`date +'%a %H:%M'`)@DEF@\n" + fi + #}}} + #Construct the redshift file {{{ + _message " > @BLU@Constructing COSMOSIS Nz file @RED@${output_base}_comb_Nz.fits@DEF@" + #Construct the Nz combined fits file and put into covariance/input/ + @PYTHON3BIN@ @RUNROOT@/@SCRIPTPATH@/MakeNofZForCosmosis_function.py \ + --inputs ${filelist_lens} \ + --neff @DB:cosmosis_neff_lens@ \ + --output_base ${output_base} \ + --suffix "lens" 2>&1 + _message " - @RED@Done! (`date +'%a %H:%M'`)@DEF@\n" + #}}} + + #Update the datablock + _write_datablock cosmosis_nz_lens_${patch} "${output_base##*/}_comb_Nz.fits" + done +fi + +if [ ${need_obs} == "TRUE" ] +then + for patch in @BV:PATCHLIST@ @ALLPATCH@ + do + _message " ->@BLU@ Patch @RED@${patch}@DEF@" + #Get all the files in this stat and patch {{{ + inputs_obs=`_read_datablock "nz_obs_${patch}"` + inputs_obs=`_blockentry_to_filelist ${inputs_obs}` + #}}} + filelist_obs='' + #Get the file list {{{ + for LBIN in `seq ${NOBS}` + do + #Define the string to append to the file names {{{ + appendstr="_LB${LBIN}" + #}}} + #file=`echo ${inputs} | sed 's/ /\n/g' | grep "_${patch}_" | grep ${appendstr} || echo ` + file=`echo ${inputs_obs} | sed 's/ /\n/g' | grep ${appendstr} || echo ` + appendstr="_LB${LBIN}" + #Check if the output file exists {{{ + if [ "${file}" == "" ] + then + #If not, loop + continue + fi + #}}} + filelist_obs="${filelist_obs} @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/nz_obs_${patch}/${file}" + done + #}}} + #If filelist is empty, skip {{{ + if [ "${filelist_obs}" == "" ] + then + _message "@RED@ - skipping! (No matching obs Nz files)@DEF@\n" + continue + fi + #}}} + found_obs='TRUE' + #Construct the output directory {{{ + if [ ! -d @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_obs_${patch} ] + then + mkdir @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_obs_${patch}/ + fi + #}}} + _message "@RED@ - OK! (`date +'%a %H:%M'`)@DEF@\n" + #Construct the output base {{{ + file=${filelist_obs##* } + output_base=${file##*/} + output_base=${output_base%%_LB*} + output_base="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/cosmosis_nz_obs_${patch}/${output_base}" + #}}} + #Remove existing files {{{ + if [ -f ${output_base}_comb_Nz.fits ] + then + _message " > @BLU@Removing previous COSMOSIS Nz file@DEF@ ${output_base##*/}_comb_Nz.fits@DEF@" + rm ${output_base}_comb_Nz.fits + _message " - @RED@Done! (`date +'%a %H:%M'`)@DEF@\n" + fi + #}}} + #Construct the redshift file {{{ + _message " > @BLU@Constructing COSMOSIS Nz file @RED@${output_base}_comb_Nz.fits@DEF@" + #Construct the Nz combined fits file and put into covariance/input/ + @PYTHON3BIN@ @RUNROOT@/@SCRIPTPATH@/MakeNofZForCosmosis_function.py \ + --inputs ${filelist_obs} \ + --neff @DB:cosmosis_neff_obs@ \ + --output_base ${output_base} \ + --suffix "obs" 2>&1 + _message " - @RED@Done! (`date +'%a %H:%M'`)@DEF@\n" + #}}} + + #Update the datablock + _write_datablock cosmosis_nz_obs_${patch} "${output_base##*/}_comb_Nz.fits" + done +fi + +#Error if no stat files found {{{ +if [ "${found_source}" == "FALSE" ] && [ "${need_source}" == "TRUE" ] +then + #If not found, error + _message " - @RED@ERROR!@DEF@\n" + _message "@RED@There are no nz_source files in any patch?!@DEF@\n" + _message "@BLU@You probably didn't run rename an 'nz_source' block for a particular patch?!@DEF@\n" + exit 1 +fi + +if [ "${found_lens}" == "FALSE" ] && [ "${need_lens}" == "TRUE" ] +then + #If not found, error + _message " - @RED@ERROR!@DEF@\n" + _message "@RED@There are no nz_lens files in any patch?!@DEF@\n" + _message "@BLU@You probably didn't run rename an 'nz_lens' block for a particular patch?!@DEF@\n" + exit 1 +fi + +if [ "${found_obs}" == "FALSE" ] && [ "${need_obs}" == "TRUE" ] +then + #If not found, error + _message " - @RED@ERROR!@DEF@\n" + _message "@RED@There are no nz_obs files in any patch?!@DEF@\n" + _message "@BLU@You probably didn't run rename an 'nz_obs' block for a particular patch?!@DEF@\n" + exit 1 +fi +#}}} + diff --git a/scripts/make_data_vector_allstats.py b/scripts/make_data_vector_allstats.py index 160925a..8ad15a2 100644 --- a/scripts/make_data_vector_allstats.py +++ b/scripts/make_data_vector_allstats.py @@ -32,7 +32,7 @@ def make_2pt_vector(input_files, m_corr,col=1, xipm=False, correlations='EE'): for rp in range(len(input_files)): with open(input_files[rp]) as f: header=f.readline().strip('#').split() - data = pd.read_csv(input_files[rp], delim_whitespace=True, comment = '#', names = header) + data = pd.read_csv(input_files[rp], sep='\s+', comment = '#', names = header) if correlations == 'EE': data_xip = data['xip'] data_xim = data['xim'] diff --git a/scripts/prepare_cosmosis.sh b/scripts/prepare_cosmosis.sh index 1648e60..926f0a3 100644 --- a/scripts/prepare_cosmosis.sh +++ b/scripts/prepare_cosmosis.sh @@ -10,17 +10,50 @@ #For each of the files in the nz directory MODES="@BV:MODES@" +required_stats="" if [[ .*\ $MODES\ .* =~ " EE " ]] then headfiles_xi="@DB:xipm_comb@" + # add neff_source if not already present + if [[ " $required_stats " != *" neff_source "* ]] + then + required_stats="$required_stats neff_source" + fi + if [[ " $required_stats " != *" sigmae "* ]] + then + required_stats="$required_stats sigmae" + fi fi if [[ .*\ $MODES\ .* =~ " NE " ]] then headfiles_gt="@DB:gt_comb@" + if [[ " $required_stats " != *" neff_source "* ]] + then + required_stats="$required_stats neff_source" + fi + if [[ " $required_stats " != *" neff_lens "* ]] + then + required_stats="$required_stats neff_lens" + fi + if [[ " $required_stats " != *" sigmae "* ]] + then + required_stats="$required_stats sigmae" + fi fi if [[ .*\ $MODES\ .* =~ " NN " ]] then headfiles_wt="@DB:wt_comb@" + if [[ " $required_stats " != *" neff_lens "* ]] + then + required_stats="$required_stats neff_lens" + fi +fi +if [[ .*\ $MODES\ .* =~ " OBS " ]] +then + if [[ " $required_stats " != *" neff_obs "* ]] + then + required_stats="$required_stats neff_obs" + fi fi #Number of tomographic bins @@ -36,11 +69,8 @@ else fi #}}} -blocklist="neff_source neff_lens neff_obs sigmae" -blocklist="neff_source sigmae" - #N_effective & sigmae {{{ -for stat in $blocklist +for stat in $required_stats do found="FALSE" foundlist="" @@ -123,11 +153,13 @@ done #}}} #npair {{{ -if [ "${headfiles_xi}" != "" ] || [ "${headfiles_gt}" != "" ] || [ "${headfiles_wt}" != "" ] +outall='' +if [[ .*\ $MODES\ .* =~ " EE " ]] && [ "${headfiles_xi}" != "" ] then - _message "Copying 2pcf catalogues from datahead into cosmosis_npair {\n" + _message "\n" + _message "Copying xipm catalogues from datahead into cosmosis_npair {\n" #Loop over patches {{{ - outall='' + outlist_check='' for patch in ${patchlist} do outlist='' @@ -189,10 +221,27 @@ then #Update the datablock {{{ #_write_datablock "cosmosis_npair_${patch}_@BV:BLIND@" "${outlist}" outall="${outall} ${outlist}" + outlist_check="${outlist_check} ${outlist}" #}}} - #}}} - - + done + if [ "${outlist_check}" == "" ] + then + #If not, error + _message " - @RED@ERROR!@DEF@\n" + _message "@RED@There were no catalogues added to the cosmosis npair folder?!@DEF@" + _message "@BLU@You probably didn't load the all correlation function files into the datahead?!@DEF@" + exit 1 + fi +fi + +if [[ .*\ $MODES\ .* =~ " NE " ]] && [ "${headfiles_gt}" != "" ] +then + _message "\n" + _message "Copying gamma_t catalogues from datahead into cosmosis_npair {\n" + #Loop over patches {{{ + outlist_check='' + for patch in ${patchlist} + do outlist_gt='' #Loop over tomographic bins in this patch {{{ for LBIN1 in `seq ${NLENS}` @@ -238,7 +287,7 @@ then _message " - @RED@ Done! (`date +'%a %H:%M'`)@DEF@\n" #}}} #Save the file to the output list {{{ - outlist_gt="${outlist_gt} GT_@SURVEY@_${patch}_nBins_${NLENS}_Bin${ZBIN1}_Bin${ZBIN2}.ascii" + outlist_gt="${outlist_gt} GT_@SURVEY@_${patch}_nBins_${NLENS}_Bin${LBIN1}_Bin${ZBIN2}.ascii" #}}} done #}}} @@ -246,9 +295,27 @@ then #Update the datablock {{{ #_write_datablock "cosmosis_npair_${patch}_@BV:BLIND@" "${outlist_gt}" outall="${outall} ${outlist_gt}" + outlist_check="${outlist_check} ${outlist_gt}" #}}} - #}}} - + done + if [ "${outlist_check}" == "" ] + then + #If not, error + _message " - @RED@ERROR!@DEF@\n" + _message "@RED@There were no catalogues added to the cosmosis npair folder?!@DEF@" + _message "@BLU@You probably didn't load the all correlation function files into the datahead?!@DEF@" + exit 1 + fi +fi + +if [[ .*\ $MODES\ .* =~ " NN " ]] && [ "${headfiles_wt}" != "" ] +then + _message "\n" + _message "Copying w(theta) catalogues from datahead into cosmosis_npair {\n" + #Loop over patches {{{ + outlist_check='' + for patch in ${patchlist} + do outlist_wt='' #Loop over tomographic bins in this patch {{{ for LBIN1 in `seq ${NLENS}` @@ -296,22 +363,24 @@ then #Update the datablock {{{ #_write_datablock "cosmosis_npair_${patch}_@BV:BLIND@" "${outlist_wt}" outall="${outall} ${outlist_wt}" - _write_datablock "cosmosis_npair_${patch}_@BV:BLIND@" "${outall}" + outlist_check="${outlist_check} ${outlist_wt}" #}}} #}}} done - #}}} #Were there any files in any of the patches? {{{ - if [ "${outall}" == "" ] - then + if [ "${outlist_check}" == "" ] + then #If not, error _message " - @RED@ERROR!@DEF@\n" - _message "@RED@There were no catalogues added to the cosmosis xipm folder?!@DEF@" - _message "@BLU@You probably didn't load the xipm files into the datahead?!@DEF@" + _message "@RED@There were no catalogues added to the cosmosis npair folder?!@DEF@" + _message "@BLU@You probably didn't load the all correlation function files into the datahead?!@DEF@" exit 1 fi - #}}} - _message "}\n" fi #}}} +#Update the datablock {{{ +_write_datablock "cosmosis_npair_${patch}_@BV:BLIND@" "${outall}" +#}}} +_message "}\n" + diff --git a/scripts/run_cov_weights.sh b/scripts/run_cov_weights.sh index ee33521..62f0751 100644 --- a/scripts/run_cov_weights.sh +++ b/scripts/run_cov_weights.sh @@ -1,213 +1,203 @@ -# +#!/bin/bash # # Script to construct weights needed for arbitrary covariance stats # -# STATISTIC="@BV:STATISTIC@" -#Output folder: +# Output folder: outfold=@RUNROOT@/@CONFIGPATH@/covariance_arb_summary/ -if [ ! -d ${outfold} ] -then - mkdir ${outfold} -fi - +mkdir -p "${outfold}" -if [ "${STATISTIC^^}" == "2PCF" ] -then +# Set variables depending on the statistic +case "${STATISTIC^^}" in + "2PCF") n_arb_ee=@BV:NXIPM@ - arb_fourier_filter_mmE_file_@BV:STATISTIC@="fourier_weight_realspace_cf_mm_p_?.table" - arb_fourier_filter_mmB_file_@BV:STATISTIC@="fourier_weight_realspace_cf_mm_m_?.table" - arb_real_filter_mm_p_file_@BV:STATISTIC@="real_weight_realspace_cf_mm_p_?.table" - arb_real_filter_mm_m_file_@BV:STATISTIC@="real_weight_realspace_cf_mm_m_?.table" n_arb_ne=@BV:NGT@ - arb_fourier_filter_gm_file_@BV:STATISTIC@="fourier_weight_realspace_cf_gm_?.table" - arb_real_filter_gm_file_@BV:STATISTIC@="real_weight_realspace_cf_gm_?.table" n_arb_nn=@BV:NWT@ - arb_fourier_filter_gg_file_@BV:STATISTIC@="fourier_weight_realspace_cf_gg_?.table" - arb_real_filter_gg_file_@BV:STATISTIC@="real_weight_realspace_cf_gg_?.table" + + arb_fourier_filter_mmE_file="fourier_weight_realspace_cf_mm_p_?.table" + arb_fourier_filter_mmB_file="fourier_weight_realspace_cf_mm_m_?.table" + arb_real_filter_mm_p_file="real_weight_realspace_cf_mm_p_?.table" + arb_real_filter_mm_m_file="real_weight_realspace_cf_mm_m_?.table" + + arb_fourier_filter_gm_file="fourier_weight_realspace_cf_gm_?.table" + arb_real_filter_gm_file="real_weight_realspace_cf_gm_?.table" + + arb_fourier_filter_gg_file="fourier_weight_realspace_cf_gg_?.table" + arb_real_filter_gg_file="real_weight_realspace_cf_gg_?.table" + arb_base=@RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/rcf/ - -elif [ "${STATISTIC^^}" == "COSEBIS" ] -then + ;; + "COSEBIS") n_arb_ee=@BV:NMAXCOSEBIS@ - arb_fourier_filter_mmE_file_@BV:STATISTIC@="Wn_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" - arb_fourier_filter_mmB_file_@BV:STATISTIC@="Wn_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" - arb_real_filter_mm_p_file_@BV:STATISTIC@="Tp_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" - arb_real_filter_mm_m_file_@BV:STATISTIC@="Tm_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" n_arb_ne=@BV:NMAXCOSEBISNE@ - arb_fourier_filter_gm_file_@BV:STATISTIC@="Qgm_@BV:THETAMINGT@_to_@BV:THETAMAXGT@_?.table" - arb_real_filter_gm_file_@BV:STATISTIC@="Wn_psigm_@BV:THETAMINGT@_to_@BV:THETAMAXGT@_?.table" n_arb_nn=@BV:NMAXCOSEBISNN@ - arb_fourier_filter_gg_file_@BV:STATISTIC@="Ugg_@BV:THETAMINWT@_to_@BV:THETAMAXWT@_?.table" - arb_real_filter_gg_file_@BV:STATISTIC@="Wn_psigg_@BV:THETAMINWT@_to_@BV:THETAMAXWT@_?.table" - arb_base=@RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/cosebis/ -elif [ "${STATISTIC^^}" == "BANDPOWERS" ] -then + arb_fourier_filter_mmE_file="Wn_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" + arb_fourier_filter_mmB_file="Wn_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" + arb_real_filter_mm_p_file="Tp_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" + arb_real_filter_mm_m_file="Tm_@BV:THETAMINXI@_to_@BV:THETAMAXXI@_?.table" + + arb_fourier_filter_gm_file="Qgm_@BV:THETAMINGT@_to_@BV:THETAMAXGT@_?.table" + arb_real_filter_gm_file="Wn_psigm_@BV:THETAMINGT@_to_@BV:THETAMAXGT@_?.table" + + arb_fourier_filter_gg_file="Ugg_@BV:THETAMINWT@_to_@BV:THETAMAXWT@_?.table" + arb_real_filter_gg_file="Wn_psigg_@BV:THETAMINWT@_to_@BV:THETAMAXWT@_?.table" + + arb_base=@RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/cosebis/ + ;; + "BANDPOWERS") n_arb_ee=@BV:NBANDPOWERS@ - theta_lo_lensing=`echo 'e(l(@BV:THETAMINXI@)+@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` - theta_up_lensing=`echo 'e(l(@BV:THETAMAXXI@)-@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` - t_lo_mm=`printf "%.2f" $theta_lo_lensing` - t_up_mm=`printf "%.2f" $theta_up_lensing` - arb_fourier_filter_mmE_file_@BV:STATISTIC@="fourier_weight_bandpowers_mmE_?.table" - arb_fourier_filter_mmB_file_@BV:STATISTIC@="fourier_weight_bandpowers_mmB_?.table" - arb_real_filter_mm_p_file_@BV:STATISTIC@="real_weight_bandpowers_mmE_?.table" - arb_real_filter_mm_m_file_@BV:STATISTIC@="real_weight_bandpowers_mmB_?.table" n_arb_ne=@BV:NBANDPOWERSNE@ - theta_lo_ggl=`echo 'e(l(@BV:THETAMINGT@)+@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` - theta_up_ggl=`echo 'e(l(@BV:THETAMAXGT@)-@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` - t_lo_gm=`printf "%.2f" $theta_lo_ggl` - t_up_gm=`printf "%.2f" $theta_up_ggl` - arb_fourier_filter_gm_file_@BV:STATISTIC@="fourier_weight_bandpowers_gm_?.table" - arb_real_filter_gm_file_@BV:STATISTIC@="real_weight_bandpowers_gm_?.table" n_arb_nn=@BV:NBANDPOWERSNN@ - theta_lo_clustering=`echo 'e(l(@BV:THETAMINWT@)+@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` - theta_up_clustering=`echo 'e(l(@BV:THETAMAXWT@)-@BV:APODISATIONWIDTH@/2)' | bc -l | awk '{printf "%.9f", $0}'` - t_lo_gg=`printf "%.2f" $theta_lo_clustering` - t_up_gg=`printf "%.2f" $theta_up_clustering` - arb_fourier_filter_gg_file_@BV:STATISTIC@="fourier_weight_bandpowers_gg_?.table" - arb_real_filter_gg_file_@BV:STATISTIC@="real_weight_bandpowers_gg_?.table" - arb_base=@RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/bandpowers/ -else - #ERROR: Unknown statistic {{{ - _message "Unknown statistic: ${STATISTIC^^}\n" - exit 1 - #}}} -fi + theta_lo_lensing=$(echo "e(l(@BV:THETAMINXI@)+@BV:APODISATIONWIDTH@/2)" | bc -l) + theta_up_lensing=$(echo "e(l(@BV:THETAMAXXI@)-@BV:APODISATIONWIDTH@/2)" | bc -l) + t_lo_mm=$(printf "%.2f" "$theta_lo_lensing") + t_up_mm=$(printf "%.2f" "$theta_up_lensing") + + theta_lo_ggl=$(echo "e(l(@BV:THETAMINGT@)+@BV:APODISATIONWIDTH@/2)" | bc -l) + theta_up_ggl=$(echo "e(l(@BV:THETAMAXGT@)-@BV:APODISATIONWIDTH@/2)" | bc -l) + t_lo_gm=$(printf "%.2f" "$theta_lo_ggl") + t_up_gm=$(printf "%.2f" "$theta_up_ggl") + + theta_lo_clustering=$(echo "e(l(@BV:THETAMINWT@)+@BV:APODISATIONWIDTH@/2)" | bc -l) + theta_up_clustering=$(echo "e(l(@BV:THETAMAXWT@)-@BV:APODISATIONWIDTH@/2)" | bc -l) + t_lo_gg=$(printf "%.2f" "$theta_lo_clustering") + t_up_gg=$(printf "%.2f" "$theta_up_clustering") + + arb_fourier_filter_mmE_file="fourier_weight_bandpowers_mmE_?.table" + arb_fourier_filter_mmB_file="fourier_weight_bandpowers_mmB_?.table" + arb_real_filter_mm_p_file="real_weight_bandpowers_mmE_?.table" + arb_real_filter_mm_m_file="real_weight_bandpowers_mmB_?.table" + + arb_fourier_filter_gm_file="fourier_weight_bandpowers_gm_?.table" + arb_real_filter_gm_file="real_weight_bandpowers_gm_?.table" + + arb_fourier_filter_gg_file="fourier_weight_bandpowers_gg_?.table" + arb_real_filter_gg_file="real_weight_bandpowers_gg_?.table" + + arb_base=@RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/bandpowers/ + ;; + *) + _message "Unknown statistic: ${STATISTIC^^}\n" + exit 1 + ;; +esac run_arbitrary=False -for i in $(seq -f "%02g" 1 $n_arb_ee) -do - file=`echo ${arb_fourier_filter_mmE_file_@BV:STATISTIC@} | sed "s/?/${i}/g"` - file2=`echo ${arb_fourier_filter_mmB_file_@BV:STATISTIC@} | sed "s/?/${i}/g"` - file3=`echo ${arb_real_filter_mm_p_file_@BV:STATISTIC@} | sed "s/?/${i}/g"` - file4=`echo ${arb_real_filter_mm_m_file_@BV:STATISTIC@} | sed "s/?/${i}/g"` - if [ ! -f $arb_base${file} ] || [ ! -f $arb_base${file2} ] || [ ! -f $arb_base${file3} ] || [ ! -f $arb_base${file4} ] - then - run_arbitrary=True - _message "One or more arbitrary input files do not exist. Calculating filters now!\n" - break - else - cp ${arb_base}/{$file,$file2,$file3,$file4} ${outfold} - fi -done -for i in $(seq -f "%02g" 1 $n_arb_ne) -do - file=`echo ${arb_fourier_filter_gm_file_@BV:STATISTIC@} | sed "s/?/${i}/g"` - file2=`echo ${arb_real_filter_gm_file_@BV:STATISTIC@} | sed "s/?/${i}/g"` - if [ ! -f $arb_base${file} ] || [ ! -f $arb_base${file2} ] - then - run_arbitrary=True - _message "One or more arbitrary input files do not exist. Calculating filters now!\n" - break - else - cp ${arb_base}/{$file,$file2} ${outfold} - fi -done -for i in $(seq -f "%02g" 1 $n_arb_nn) -do - file=`echo ${arb_fourier_filter_gg_file_@BV:STATISTIC@} | sed "s/?/${i}/g"` - file2=`echo ${arb_real_filter_gg_file_@BV:STATISTIC@} | sed "s/?/${i}/g"` - if [ ! -f $arb_base${file} ] || [ ! -f $arb_base${file2} ] - then - run_arbitrary=True - _message "One or more arbitrary input files do not exist. Calculating filters now!\n" - break - else - cp ${arb_base}/{$file,$file2} ${outfold} - fi -done - - -if [ "${run_arbitrary}" == "True" ] -then - if [ "${STATISTIC^^}" == "2PCF" ] - then - _message " -> @BLU@Generating arbitrary statistic weights for 2pcfs @DEF@" - cd @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/script_weights/ - @PYTHON3BIN@ @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/script_weights/get_weights_realspace.py \ - -n @BV:NTHREADS@ \ - -nf 100000 \ - -nt 100000 \ - --theta_lo_mm @BV:THETAMINXI@ \ - --theta_up_mm @BV:THETAMAXXI@ \ - --t_bins_mm @BV:NXIPM@ \ - --t_type_mm "log" \ - --theta_lo_gm @BV:THETAMINGT@ \ - --theta_up_gm @BV:THETAMAXGT@ \ - --t_bins_gm @BV:NGT@ \ - --t_type_gm "log" \ - --theta_lo_gg @BV:THETAMINWT@\ - --theta_up_gg @BV:THETAMAXWT@\ - --t_bins_gg @BV:NWT@ \ - --t_type_gg "log" 2>&1 - - cd @RUNROOT@ - cp -a @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/rcf/. ${outfold} - - elif [ "${STATISTIC^^}" == "COSEBIS" ] - then - _message " -> @BLU@Generating arbitrary statistic weights for cosebis / psi stats @DEF@" - cd @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/script_weights/ - @PYTHON3BIN@ @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/script_weights/get_weights_cosebis.py \ - -n @BV:NTHREADS@ \ - -nf 100000 \ - -nt 10000 \ - --Nmax_mm @BV:NMAXCOSEBIS@ \ - --tmin_mm @BV:THETAMINXI@ \ - --tmax_mm @BV:THETAMAXXI@ \ - --Nmax_gm @BV:NMAXCOSEBISNE@ \ - --tmin_gm @BV:THETAMINGT@ \ - --tmax_gm @BV:THETAMAXGT@ \ - --Nmax_gg @BV:NMAXCOSEBISNN@ \ - --tmin_gg @BV:THETAMINWT@ \ - --tmax_gg @BV:THETAMAXWT@ 2>&1 - - cd @RUNROOT@ - cp -a @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/cosebis/. ${outfold} - - - elif [ "${STATISTIC^^}" == "BANDPOWERS" ] - then - _message " -> @BLU@Generating arbitrary statistic weights for bandpowers @DEF@" - cd @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/script_weights/ - @PYTHON3BIN@ @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/script_weights/get_weights_bandpowers.py \ - -n @BV:NTHREADS@ \ - -nf 10000 \ - -nt 10000 \ - --delta_ln_theta_mm @BV:APODISATIONWIDTH@ \ - --theta_lo_mm ${t_lo_mm} \ - --theta_up_mm ${t_up_mm} \ - --L_min_mm @BV:LMINBANDPOWERS@ \ - --L_max_mm @BV:LMAXBANDPOWERS@ \ - --L_bins_mm @BV:NBANDPOWERS@ \ - --L_type_mm "log" \ - --delta_ln_theta_gm @BV:APODISATIONWIDTH@ \ - --theta_lo_gm ${t_lo_gm} \ - --theta_up_gm ${t_up_gm} \ - --L_min_gm @BV:LMINBANDPOWERSNE@ \ - --L_max_gm @BV:LMAXBANDPOWERSNE@ \ - --L_bins_gm @BV:NBANDPOWERSNE@ \ - --L_type_gm "log" \ - --delta_ln_theta_gg @BV:APODISATIONWIDTH@ \ - --theta_lo_gg ${t_lo_gg} \ - --theta_up_gg ${t_up_gg} \ - --L_min_gg @BV:LMINBANDPOWERSNN@ \ - --L_max_gg @BV:LMAXBANDPOWERSNN@ \ - --L_bins_gg @BV:NBANDPOWERSNN@ \ - --L_type_gg "log" 2>&1 - - cd @RUNROOT@ - cp -a @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/bandpowers/. ${outfold} - fi -fi -_message " - @RED@Done! (`date +'%a %H:%M'`)@DEF@\n" +# Function to check and copy files +check_and_copy_files() { + local n=$1 + shift + local files=("$@") + + for i in $(seq -f "%02g" 1 "$n"); do + missing=False + expanded_files=() + for f in "${files[@]}"; do + file="${f//\?/$i}" + expanded_files+=("$file") + if [ ! -f "$arb_base$file" ]; then + missing=True + fi + done + + if [ "$missing" == "True" ]; then + run_arbitrary=True + _message "One or more arbitrary input files do not exist. Calculating filters now!\n" + break + else + for f in "${expanded_files[@]}"; do + cp "$arb_base$f" "$outfold" + done + fi + done +} +# Check files +check_and_copy_files "$n_arb_ee" "$arb_fourier_filter_mmE_file" "$arb_fourier_filter_mmB_file" "$arb_real_filter_mm_p_file" "$arb_real_filter_mm_m_file" +check_and_copy_files "$n_arb_ne" "$arb_fourier_filter_gm_file" "$arb_real_filter_gm_file" +check_and_copy_files "$n_arb_nn" "$arb_fourier_filter_gg_file" "$arb_real_filter_gg_file" + +# Run scripts if needed +if [ "$run_arbitrary" == "True" ]; then + cd @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/script_weights/ + case "${STATISTIC^^}" in + "2PCF") + _message " -> @BLU@Generating arbitrary statistic weights for 2pcfs @DEF@" + @PYTHON3BIN@ get_weights_realspace.py \ + -n @BV:NTHREADS@ \ + -nf 100000 \ + -nt 100000 \ + --theta_lo_mm @BV:THETAMINXI@ \ + --theta_up_mm @BV:THETAMAXXI@ \ + --t_bins_mm @BV:NXIPM@ \ + --t_type_mm "log" \ + --theta_lo_gm @BV:THETAMINGT@ \ + --theta_up_gm @BV:THETAMAXGT@ \ + --t_bins_gm @BV:NGT@ \ + --t_type_gm "log" \ + --theta_lo_gg @BV:THETAMINWT@ \ + --theta_up_gg @BV:THETAMAXWT@ \ + --t_bins_gg @BV:NWT@ \ + --t_type_gg "log" 2>&1 + cp -a @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/rcf/. "$outfold" + ;; + "COSEBIS") + _message " -> @BLU@Generating arbitrary statistic weights for cosebis / psi stats @DEF@" + @PYTHON3BIN@ get_weights_cosebis.py \ + -n @BV:NTHREADS@ \ + -nf 100000 \ + -nt 10000 \ + --Nmax_mm @BV:NMAXCOSEBIS@ \ + --tmin_mm @BV:THETAMINXI@ \ + --tmax_mm @BV:THETAMAXXI@ \ + --Nmax_gm @BV:NMAXCOSEBISNE@ \ + --tmin_gm @BV:THETAMINGT@ \ + --tmax_gm @BV:THETAMAXGT@ \ + --Nmax_gg @BV:NMAXCOSEBISNN@ \ + --tmin_gg @BV:THETAMINWT@ \ + --tmax_gg @BV:THETAMAXWT@ 2>&1 + cp -a @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/cosebis/. "$outfold" + ;; + "BANDPOWERS") + _message " -> @BLU@Generating arbitrary statistic weights for bandpowers @DEF@" + @PYTHON3BIN@ get_weights_bandpowers.py \ + -n @BV:NTHREADS@ \ + -nf 10000 \ + -nt 10000 \ + --delta_ln_theta_mm @BV:APODISATIONWIDTH@ \ + --theta_lo_mm ${t_lo_mm} \ + --theta_up_mm ${t_up_mm} \ + --L_min_mm @BV:LMINBANDPOWERS@ \ + --L_max_mm @BV:LMAXBANDPOWERS@ \ + --L_bins_mm @BV:NBANDPOWERS@ \ + --L_type_mm "log" \ + --delta_ln_theta_gm @BV:APODISATIONWIDTH@ \ + --theta_lo_gm ${t_lo_gm} \ + --theta_up_gm ${t_up_gm} \ + --L_min_gm @BV:LMINBANDPOWERSNE@ \ + --L_max_gm @BV:LMAXBANDPOWERSNE@ \ + --L_bins_gm @BV:NBANDPOWERSNE@ \ + --L_type_gm "log" \ + --delta_ln_theta_gg @BV:APODISATIONWIDTH@ \ + --theta_lo_gg ${t_lo_gg} \ + --theta_up_gg ${t_up_gg} \ + --L_min_gg @BV:LMINBANDPOWERSNN@ \ + --L_max_gg @BV:LMAXBANDPOWERSNN@ \ + --L_bins_gg @BV:NBANDPOWERSNN@ \ + --L_type_gg "log" 2>&1 + cp -a @RUNROOT@/INSTALL/OneCovariance/input/arbitrary_summary/bandpowers/. "$outfold" + ;; + esac + cd @RUNROOT@ +fi + +_message " - @RED@Done! (`date +'%a %H:%M'`)@DEF@\n" diff --git a/scripts/run_covariance.sh b/scripts/run_covariance.sh index 9113559..ce81f9f 100644 --- a/scripts/run_covariance.sh +++ b/scripts/run_covariance.sh @@ -41,9 +41,19 @@ _message " >@RED@ Done! (`date +'%a %H:%M'`)@DEF@\n" if [ "${SECONDSTATISTIC^^}" == "XIPM" ] || [ "${SECONDSTATISTIC^^}" == "2PCF" ] || [ "${SECONDSTATISTIC^^}" == "COSEBIS" ] || [ "${SECONDSTATISTIC^^}" == "BANDPOWERS" ] then - _write_datablock "covariance_@BV:STATISTIC@_@BV:SECONDSTATISTIC@" "covariance_matrix_${non_linear_model}.mat" + if [ -f @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_@BV:STATISTIC@_@BV:SECONDSTATISTIC@/covariance_matrix_${non_linear_model}_reduced.mat ] + then + _write_datablock "covariance_@BV:STATISTIC@_@BV:SECONDSTATISTIC@" "covariance_matrix_${non_linear_model}_reduced.mat" + else + _write_datablock "covariance_@BV:STATISTIC@_@BV:SECONDSTATISTIC@" "covariance_matrix_${non_linear_model}.mat" + fi else - _write_datablock "covariance_@BV:STATISTIC@" "covariance_matrix_${non_linear_model}.mat" + if [ -f @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_@BV:STATISTIC@/covariance_matrix_${non_linear_model}_reduced.mat ] + then + _write_datablock "covariance_@BV:STATISTIC@" "covariance_matrix_${non_linear_model}_reduced.mat" + else + _write_datablock "covariance_@BV:STATISTIC@" "covariance_matrix_${non_linear_model}.mat" + fi fi #Clean up the temporary input folder diff --git a/scripts/run_measure_statistics_cats2stats.py b/scripts/run_measure_statistics_cats2stats.py index a38cf3d..b64bd9e 100644 --- a/scripts/run_measure_statistics_cats2stats.py +++ b/scripts/run_measure_statistics_cats2stats.py @@ -155,7 +155,7 @@ # Load the input 2pt correlation function data file=open(inputfile) -header=file.readline().strip('#').split() +header = file.readline().lstrip('# ').split() tpcf_in=np.loadtxt(file,comments='#') tpcf_data={} for i, col in enumerate(header): diff --git a/scripts/save_and_check_sacc.py b/scripts/save_and_check_sacc.py index f89bedd..d051434 100644 --- a/scripts/save_and_check_sacc.py +++ b/scripts/save_and_check_sacc.py @@ -146,16 +146,54 @@ def add_2pt_points(sacc_data, statistic, type, auto, n1, n2, min_val, max_val, n def add_1pt_points(sacc_data, files): + dt = "galaxy_stellarmassfunction" + grid_resolution = 10000 # Number of points in mass grid for window functions + for i, file in enumerate(files): - # Load SMF + + tracer_name = f"lens_{i}" + mass, value, extra = np.loadtxt(file).T - mass_min = mass - 0.5 * (mass[1] - mass[0]) - mass_max = mass + 0.5 * (mass[1] - mass[0]) - for m, mmin, mmax, v in zip(mass, mass_min, mass_max, value): - tracer_name = f"lens_{i}" - dt = "galaxy_stellarmassfunction" - sacc_data.add_data_point(dt, (tracer_name,), v, mass=m, mass_min=mmin, mass_max=mmax) + # Bin edges + log_mass = np.log10(mass) + + # Compute log bin edges + dlog = log_mass[1] - log_mass[0] + log_mass_min = log_mass - 0.5 * dlog + log_mass_max = log_mass + 0.5 * dlog + + # Mass grid for window functions + log_grid = np.linspace(log_mass_min.min(), log_mass_max.max(), grid_resolution) + + mass_grid = 10**log_grid + + # Window array + w = np.zeros((len(mass), grid_resolution)) + + # Build windows + for j in range(len(mass)): + in_bin = np.where( + (log_grid >= log_mass_min[j]) & + (log_grid < log_mass_max[j]) + )[0] + w[j, in_bin] = 1.0 + w /= w.sum(axis=1)[:, None] # Normalize + window = sacc.Window(values=mass_grid, weight=w.T) + + # Add data points + for j, (lm, lmmin, lmmax, v) in enumerate( + zip(log_mass, log_mass_min, log_mass_max, value) + ): + sacc_data.add_data_point( + dt, (tracer_name,), v, + mass=10**lm, + mass_min=10**lmmin, + mass_max=10**lmmax, + window=window, + window_ind=j + ) + def process_2pt_data(mode, nangle, min_val, max_val, n1, n2, datavec_files, statistic, sacc_data, sacc_data_no_mbias, auto=None): diff --git a/scripts/save_and_check_sacc.sh b/scripts/save_and_check_sacc.sh index cd66935..c7cc6a2 100644 --- a/scripts/save_and_check_sacc.sh +++ b/scripts/save_and_check_sacc.sh @@ -47,13 +47,24 @@ then else input_datavector_nn= fi - input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_matrix_${non_linear_model}.mat" - #input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_list_${non_linear_model}.dat" - if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + if [ -f @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_matrix_${non_linear_model}_reduced.mat ] then - filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} - input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_matrix_${non_linear_model}${filename_extension}.mat - #input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_list_${non_linear_model}${filename_extension}.dat + input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_matrix_${non_linear_model}_reduced.mat" + if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + then + filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} + input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_matrix_${non_linear_model}_reduced${filename_extension}.mat + fi + #input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_list_${non_linear_model}_reduced.dat" + else + input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_matrix_${non_linear_model}.mat" + #input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_list_${non_linear_model}.dat" + if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + then + filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} + input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_matrix_${non_linear_model}${filename_extension}.mat + #input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_cosebis/covariance_list_${non_linear_model}${filename_extension}.dat + fi fi #}}} elif [ "${STATISTIC^^}" == "COSEBIS_DIMLESS" ] #{{{ @@ -88,11 +99,21 @@ then else input_datavector_nn= fi - input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_bandpowers/covariance_matrix_${non_linear_model}.mat" - if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + if [ -f @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_bandpowers/covariance_matrix_${non_linear_model}_reduced.mat ] then - filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} - input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_bandpowers/covariance_matrix_${non_linear_model}${filename_extension}.mat + input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_bandpowers/covariance_matrix_${non_linear_model}_reduced.mat" + if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + then + filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} + input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_bandpowers/covariance_matrix_${non_linear_model}_reduced${filename_extension}.mat + fi + else + input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_bandpowers/covariance_matrix_${non_linear_model}.mat" + if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + then + filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} + i nput_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_bandpowers/covariance_matrix_${non_linear_model}${filename_extension}.mat + fi fi #}}} elif [ "${STATISTIC^^}" == "2PCF" ] #{{{ @@ -115,11 +136,21 @@ then else input_datavector_nn= fi - input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_2pcf/covariance_matrix_${non_linear_model}.mat" - if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + if [ -f @RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_2pcf/covariance_matrix_${non_linear_model}_reduced.mat ] then - filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} - input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_2pcf/covariance_matrix_${non_linear_model}${filename_extension}.mat + input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_2pcf/covariance_matrix_${non_linear_model}_reduced.mat" + if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + then + filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} + input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_2pcf/covariance_matrix_${non_linear_model}_reduced${filename_extension}.mat + fi + else + input_covariance="@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_2pcf/covariance_matrix_${non_linear_model}.mat" + if [ -n "$ITERATION" ] && [ "$ITERATION" -eq "$ITERATION" ] + then + filename_extension=${CHAINSUFFIX}_iteration_${ITERATION} + input_covariance_iterative=@RUNROOT@/@STORAGEPATH@/@DATABLOCK@/covariance_2pcf/covariance_matrix_${non_linear_model}${filename_extension}.mat + fi fi elif [ "${STATISTIC^^}" == "XIEB" ] #{{{ then