Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Producing DESI-Y1 Lya mocks with quickquasars. #578

Merged
merged 17 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bin/gen_qso_catalog
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python

"""
Generate the quasar catalog to input quickquasars
"""

import sys
from desisim.scripts.gen_qso_catalog import main
sys.exit(main())
216 changes: 216 additions & 0 deletions doc/nb/generate_survey_release_catalogs.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Usual Imports\n",
"import os\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from desisim.survey_release import SurveyRelease\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Observed data\n",
"catdir='/global/cfs/cdirs/desi/science/lya/y1-kp6/iron-tests/catalogs/'\n",
"cat_name='QSO_cat_iron_main_dark_healpix_zlya-altbal_zwarn_cut_20230918.fits'\n",
"cat_path = os.path.join(catdir,cat_name)\n",
"\n",
"# Master catalog\n",
"mastercatalog = '/global/cfs/cdirs/desi/mocks/lya_forest/london/v9.0/v9.0.0/master.fits'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Generate mock catalog"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This function may be introduced intoo a for loop\n",
"\n",
"After making this catalog its path should be passed to quickquasars with the `--from_catalog` flag.\n",
"\n",
"Other flags like `--desi-footprint` are allowed but not needed with this approach.\n",
"\n",
"To include the 440nm dip in the throughput use `--year1-throughput` in quickquasars."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Read master catalog and prepare data catalog, takes a little bit of time if data catalg is provided.\n",
"# Y5 mocks do not need a catalog path unless you want to use Y1 distributions for magnitudes. \n",
"# Pass invert = True if you want to invert the random numbers generated: 1-random_number.\n",
"# This allows generating independent mocks from the same seed.\n",
"# TODO: Should probably refactor the class to make it clearer what refers to data and what to mocks.\n",
"survey=SurveyRelease(mastercatalog=mastercatalog,seed=0, \n",
" qso_only=True, data_file=cat_path,invert=False)\n",
"# Apply redshift distribution\n",
"# Note: For Y1 mocks (and probably Y5 too) the target selection redshift distribution from Chaussidon et al. 2022 works better to match QSO targets Iron catalog.\n",
"# The option distribution='from_data' should be a better option once I finish implementing it.\n",
"survey.apply_redshift_dist(distribution='target_selection',zmin=1.8)\n",
"# Apply NPASS geometry:\n",
"survey.apply_data_geometry(release='iron') # Pass release = None for Y5 mocks.\n",
"# Assign magnitudes \n",
"survey.assign_rband_magnitude(from_data=True) # Pass from_data = False for Y5 mocks. Unless you want to use the Y1 magnitude distributions.\n",
"# Assign exposures\n",
"survey.assign_exposures(exptime=None) # Pass exptime = 4000 for Y5 mocks.\n",
"\n",
"# Write mock catalog uncomment if needed\n",
"#survey.mockcatalog.write('/path/to/output/outputcat_name.fits')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Quality check on mock catalog"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Redshift distribution"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dndz=plt.hist(survey.mockcatalog['Z'],bins=np.arange(1.8,4,0.1),histtype='step',label='mockcat',lw=2)\n",
"plt.hist(survey.data['Z'],bins=np.arange(1.8,4,0.1),histtype='step',label=' data cat',lw=2)\n",
"plt.legend(loc='best')\n",
"plt.xlabel('Redshift')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Magnitude distribution"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"get_magnitude = lambda f: 22.5-2.5*np.log10(f)\n",
"plt.hist(get_magnitude(survey.mockcatalog['FLUX_R']),bins=np.arange(18,24,0.1),histtype='step',label='mockcat',lw=2)\n",
"plt.hist(get_magnitude(survey.data['FLUX_R']),bins=np.arange(18,24,0.1),histtype='step',label='data cat',lw=2)\n",
"plt.legend(loc='best')\n",
"plt.xlabel('r-band Magnitude')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Footprint"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(15,10))\n",
"plt.plot(survey.mockcatalog['RA'],survey.mockcatalog['DEC'],'.',label='mockcat',ms=0.1)\n",
"plt.xlabel('RA')\n",
"plt.ylabel('DEC')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Npasses"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(15,10))\n",
"plt.scatter(survey.mockcatalog['RA'],survey.mockcatalog['DEC'],c=survey.mockcatalog['NPASS'],s=0.001,cmap='jet')\n",
"plt.colorbar(label='NPASS')\n",
"plt.xlabel('RA')\n",
"plt.ylabel('DEC')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exposure time"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(15,10))\n",
"plt.scatter(survey.mockcatalog['RA'],survey.mockcatalog['DEC'],c=survey.mockcatalog['EXPTIME'],s=0.0001,cmap='jet')\n",
"plt.colorbar(label='EXPTIME')\n",
"plt.xlabel('RA')\n",
"plt.ylabel('DEC')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "DESI main",
"language": "python",
"name": "desi-main"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
99 changes: 99 additions & 0 deletions py/desisim/data/redshift_dist_chaussidon2022.ecsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# %ECSV 0.9
# ---
# datatype:
# - {name: z, datatype: float64}
# - {name: dndz_23, datatype: float64}
# - {name: dndz_err_23, datatype: float64}
# - {name: dndz_227, datatype: float64}
# - {name: dndz_err_227, datatype: float64}
# schema: astropy-2.0
z dndz_23 dndz_err_23 dndz_227 dndz_err_227
0.07500000000000001 0.05422394462528952 0.006481000992710996 0.04337915570023161 0.005796783512778162
0.125 0.06274485020926358 0.0069716500232515095 0.05267468906456696 0.00638774431793462
0.17500000000000002 0.06429410576998613 0.007057194941541409 0.05499857240565079 0.006527129695787295
0.225 0.10457475034877263 0.009000361478546548 0.0836598002790181 0.00805016803524024
0.275 0.14485539492755914 0.010592875579656904 0.12703895597924972 0.009920075830840227
0.32500000000000007 0.23471221744946746 0.013483864580547924 0.2192196618422419 0.013031256273452916
0.375 0.38266612349847173 0.017216962852520654 0.3749198456948589 0.01704181116794813
0.42500000000000004 0.4965364072115797 0.01961200894826611 0.48801550162760565 0.019443002978132985
0.475 0.6584336133070869 0.02258408661848704 0.6491380799427516 0.022424102880918916
0.525 0.894695086317277 0.026325950482633958 0.8861741807333029 0.026200288903653585
0.5750000000000001 1.0991968203326545 0.02917993134183937 1.0868027758468741 0.02901495514290416
0.625 1.4779898049293199 0.033836252185917376 1.4570748548595653 0.03359599173473076
0.675 1.8598813006474304 0.03795676123770266 1.822699167190089 0.03757543626023269
0.7250000000000001 2.226280240758315 0.04152756339301389 2.184450340618806 0.041135579717113326
0.775 2.569440347458362 0.04461344946450996 2.5338074695617427 0.04430302084519115
0.8250000000000001 3.0582304768663287 0.048672274306099356 3.0156259489464583 0.04833205597977671
0.875 3.340194988917834 0.05086656888605018 3.275126255367487 0.05036867857705087
0.925 3.6159624787264493 0.052924710568557076 3.533851934008154 0.0523203581769673
0.9750000000000001 3.715114834612693 0.053645420663121744 3.6221595009693397 0.05297004223474243
1.025 4.054401802410933 0.05604152272105344 3.948277796501438 0.055303215690894775
1.0750000000000002 4.3549573811911095 0.058081588905263576 4.2511572586226976 0.057385229033381405
1.125 4.488193359413249 0.0589633721884571 4.396787281330618 0.05835986268367874
1.1750000000000003 5.046699989053732 0.06252450728050547 4.9351535886817075 0.06182966173401331
1.225 5.06993882246457 0.06266829706169783 4.950646144288933 0.061926634286909685
1.275 5.508378146149053 0.06532183966134157 5.369719773464385 0.0644944502207809
1.3250000000000002 5.574996135260124 0.06571565172604817 5.3914093513145005 0.06462457318101059
1.375 5.738442596916353 0.06667201100596806 5.569573740797594 0.06568368552686812
1.4250000000000003 5.932099542006673 0.06778767661682164 5.726048552430573 0.06659997207514586
1.475 5.841468091704403 0.06726784864947159 5.614502152058549 0.0659480806383532
1.525 6.083151959177123 0.06864530937899353 5.79731430822381 0.06701313837327791
1.5750000000000002 6.142798298264941 0.0689810279061715 5.791117285980921 0.06697731204707481
1.625 6.151319203848915 0.06902885441010298 5.726823180210934 0.06660447679104096
1.6750000000000003 6.121883348195186 0.06886349475333874 5.66407833000167 0.06623860222379102
1.725 5.931324914226312 0.06778325053365825 5.453379573743403 0.06499491760650511
1.775 6.021956364528581 0.06829915586657898 5.547109535167118 0.06555108806608315
1.8250000000000002 5.764005313668275 0.06682034601913905 5.317045084399817 0.06417733892745538
1.875 5.467322873789906 0.06507795465626069 4.994799927769526 0.06220217666124541
1.9250000000000003 5.495984101663273 0.06524831005912948 5.020362644521448 0.06236114472918477
1.975 5.213244961831406 0.06354781171105015 4.790298193754148 0.06091549931746779
2.0250000000000004 4.9312804497799005 0.06180539482239373 4.522276981749146 0.05918683452045095
2.075 4.7035398823536845 0.060361350704804355 4.30073343656582 0.05771886689716384
2.125 4.574951670813713 0.05953053550928759 4.14348399715248 0.056653841985135525
2.175 4.283691625397871 0.057604396842030656 3.859195601759891 0.054675772724043635
2.225 4.131864580447061 0.056574350095295774 3.7608178736540085 0.0539743828293722
2.2750000000000004 3.93743300757638 0.055227212413629254 3.5865266230727206 0.05270885274066828
2.325 3.7639163847754538 0.05399661280676834 3.406812978028904 0.051371314712361886
2.375 3.473430967139974 0.05187114920949572 3.1411156493649854 0.04932743094187732
2.4250000000000003 3.2495635386155644 0.05017172700895114 2.9513318431764723 0.047814052691539884
2.475 3.011752810044652 0.04830100821144143 2.7685196870112105 0.04630952666607591
2.5250000000000004 2.72591515909134 0.04595181834421884 2.5012731027865693 0.04401767408313311
2.575 2.588031414187032 0.04477455784122231 2.3881774468538226 0.04301102875734597
2.625 2.3486714300553975 0.04265379393045551 2.134099534895323 0.04065873566388903
2.6750000000000003 2.1162830959470136 0.040488661094552514 1.9683291898980093 0.039047694828133056
2.725 1.8513603950634563 0.03786971340631964 1.719673672402039 0.03649804104056162
2.7750000000000004 1.7769961281487736 0.037101355318350175 1.670097494458917 0.03596809579501873
2.825 1.7584050614201028 0.0369067664487678 1.6429855221462724 0.03567495239220206
2.875 1.5647481163297832 0.03481518864198544 1.4857360827329327 0.03392480573223777
2.9250000000000003 1.3966538879913857 0.03289204920931071 1.3215149932963417 0.03199503439553231
2.975 1.2192641262886528 0.030732326039873928 1.147998370495415 0.029820654412591758
3.0250000000000004 1.1286326759863832 0.02956806088742619 1.0635639424360357 0.02870306910421806
3.075 1.0658878257771196 0.028734410044332553 1.0186355311750817 0.028090271990696095
3.125 0.8799771584904127 0.02610851878314918 0.8373726305705423 0.025468649397919478
3.1750000000000003 0.8319502361080134 0.025386054533294306 0.7854725692863367 0.02466675643210809
3.225 0.7250516024181569 0.02369905300699936 0.6816724467179254 0.02297917349111035
3.2750000000000004 0.686320213400093 0.023057378505007744 0.653011218844558 0.022490901071423822
3.325 0.5871678575138494 0.021326896965227753 0.5569573740797594 0.02077100513791402
3.375 0.4996349183330248 0.01967310569735495 0.4849169905061605 0.01938118087256962
3.4250000000000003 0.39273628464316834 0.017442030743020517 0.3764691012555815 0.017076985222228676
3.475 0.3299914344339048 0.015988137239646465 0.31992127328920816 0.015742296713579417
3.5250000000000004 0.27964062871042167 0.014717927826864296 0.2765421175889765 0.014636160928479731
3.575 0.24168386747271897 0.01368265463313029 0.23858535635127387 0.013594662372309657
3.625 0.21689577850115807 0.012962001985421991 0.21302263959935167 0.012845748498220975
3.6750000000000003 0.19210768952959714 0.012198850483986001 0.19133306174923587 0.012174231184454239
3.725 0.17351662280092645 0.011593567025556323 0.17351662280092645 0.011593567025556323
3.7750000000000004 0.18048827282417795 0.01182417989371922 0.1789390172634554 0.011773322970292585
3.825 0.1464046504882817 0.010649371316763561 0.14485539492755914 0.010592875579656904
3.875 0.1433061393668366 0.01053607690983113 0.14253151158647528 0.010507562441012152
3.9250000000000003 0.10844788925057904 0.009165519501645382 0.10844788925057904 0.009165519501645382
3.975 0.11232102815238543 0.009327753680580284 0.11232102815238543 0.009327753680580284
4.025 0.1022508670076888 0.008899795624068133 0.1022508670076888 0.008899795624068133
4.075 0.044153783480592894 0.00584831149068893 0.044153783480592894 0.00584831149068893
4.125 0.04647766682167673 0.006000240985697699 0.04647766682167673 0.006000240985697699
4.175000000000001 0.03873138901806394 0.005477445563889438 0.03873138901806394 0.005477445563889438
4.225 0.049576177943121844 0.0061970222428902304 0.049576177943121844 0.0061970222428902304
4.275 0.03330899455553499 0.005079574048935598 0.03330899455553499 0.005079574048935598
4.325 0.020914950069754527 0.00402508401762012 0.020914950069754527 0.00402508401762012
4.375 0.016267183387586856 0.003549790438921187 0.016267183387586856 0.003549790438921187
4.425000000000001 0.013943300046503019 0.0032864673383336622 0.013943300046503019 0.0032864673383336622
4.475 0.0069716500232515095 0.002323883341083836 0.0069716500232515095 0.002323883341083836
Binary file added py/desisim/data/releases_pixmap.fits
Binary file not shown.
Loading
Loading