{"id":21494128,"url":"https://github.com/grburgess/cosmogrb","last_synced_at":"2025-08-22T13:19:42.788Z","repository":{"id":40445725,"uuid":"218670798","full_name":"grburgess/cosmogrb","owner":"grburgess","description":"A cosmological GRB light curve simulator. Because, why not?","archived":false,"fork":false,"pushed_at":"2023-01-25T15:50:51.000Z","size":60900,"stargazers_count":5,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-01-29T21:12:10.697Z","etag":null,"topics":["cosmology","fermi-science","grb","light-curves","population-synthesis","simulation"],"latest_commit_sha":null,"homepage":"https://cosmogrb.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grburgess.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-31T02:47:08.000Z","updated_at":"2023-09-25T17:01:57.000Z","dependencies_parsed_at":"2023-02-14T09:02:16.013Z","dependency_job_id":null,"html_url":"https://github.com/grburgess/cosmogrb","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grburgess%2Fcosmogrb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grburgess%2Fcosmogrb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grburgess%2Fcosmogrb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grburgess%2Fcosmogrb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grburgess","download_url":"https://codeload.github.com/grburgess/cosmogrb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226064533,"owners_count":17568034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cosmology","fermi-science","grb","light-curves","population-synthesis","simulation"],"created_at":"2024-11-23T15:49:11.254Z","updated_at":"2024-11-23T15:49:12.549Z","avatar_url":"https://github.com/grburgess.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Travis CI w/ Logo](https://img.shields.io/travis/grburgess/cosmogrb/master.svg?logo=travis)](https://travis-ci.org/grburgess/cosmogrb)\r\n[![codecov](https://codecov.io/gh/grburgess/cosmogrb/branch/master/graph/badge.svg)](https://codecov.io/gh/grburgess/cosmogrb)\r\n## status\r\n![GitHub last commit (branch)](https://img.shields.io/github/last-commit/grburgess/cosmogrb/master?style=for-the-badge)\r\n![GitHub issues](https://img.shields.io/github/issues/grburgess/cosmogrb?style=for-the-badge)\r\n![GitHub pull requests](https://img.shields.io/github/issues-pr/grburgess/cosmogrb?style=for-the-badge)\r\n![GitHub contributors](https://img.shields.io/github/contributors/grburgess/cosmogrb?style=for-the-badge)\r\n\r\n# cosmogrb\r\n![alt text](https://raw.githubusercontent.com/grburgess/cosmogrb/master/logo.png)\r\n## Idea\r\nThis simulates a cosmological population of **GRBs** in the Universe from a given space and luminosity distribution.\r\n\r\n### Light curves / lightcurves\r\n\r\nAfter simulation, a realistic background and temporally evolving spectrum are created. These are then sampled at the single photon level, pushed through the detector responses, simulated with real dead time, and pushed into FITS Event files. \r\n\r\nCool?\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n%matplotlib inline\r\nfrom jupyterthemes import jtplot\r\n\r\nimport cosmogrb\r\n```\r\n\r\n    You do not have threeML installed\r\n\r\n\r\n# Demo of Creating a GBM GRB\r\n\r\n## Instantiate the GRB with its parameters\r\n\r\n\r\n```python\r\ngrb = cosmogrb.GBMGRB_CPL(\r\n    ra=312.0,\r\n    dec=-62.0,\r\n    z=1.0,\r\n    peak_flux=5e-7,\r\n    alpha=-0.66,\r\n    ep=500.0,\r\n    tau=2.0,\r\n    trise=1.0,\r\n    tdecay=1.,\r\n    duration=80.0,\r\n    T0=0.1,\r\n)\r\n```\r\n\r\n## Examine the latent lightcurve\r\n\r\n\r\n```python\r\ntime = np.linspace(0, 20, 100)\r\n\r\ngrb.display_energy_integrated_light_curve(time);\r\n\r\n\r\n```\r\n\r\n\r\n![png](demo_files/demo_5_0.png)\r\n\r\n\r\n\r\n```python\r\nenergy = np.logspace(1, 3, 100)\r\n\r\ngrb.display_energy_dependent_light_curve(time, energy, cmap='magma')\r\n```\r\n\r\n\r\n![png](demo_files/demo_6_0.png)\r\n\r\n\r\n## Simulate the GRB \r\n\r\n\r\n```python\r\ngrb.go(n_cores=6)\r\n```\r\n\r\n## Save the GRB to an HDF5 file\r\n\r\n\r\n```python\r\ngrb.save('test_grb.h5')\r\n```\r\n\r\n## Reload the GRB\r\n\r\n\r\n```python\r\ngrb_reload = cosmogrb.GRBSave.from_file('test_grb.h5')\r\n```\r\n\r\n\r\n```python\r\nfig, axes = plt.subplots(4,4,sharex=True,sharey=False,figsize=(15,15))\r\nrow=0\r\ncol = 0\r\nfor key in grb_reload.keys:\r\n    ax = axes[row][col]\r\n    \r\n    lightcurve = grb_reload[key]['lightcurve']\r\n    \r\n    lightcurve.display_lightcurve(dt=2, ax=ax,lw=.8)\r\n    lightcurve.display_source(ax=ax,lw=.8)\r\n    lightcurve.display_background(ax=ax,lw=.8)\r\n    \r\n    if col \u003c 3:\r\n        col+=1\r\n    else:\r\n        row+=1\r\n        col=0\r\n    \r\n    \r\n```\r\n\r\n\r\n![png](demo_files/demo_13_0.png)\r\n\r\n\r\n\r\n```python\r\nfig, axes = plt.subplots(4,4,sharex=False,sharey=False,figsize=(15,15))\r\nrow=0\r\ncol = 0\r\n\r\nfor key in grb_reload.keys:\r\n    ax = axes[row][col]\r\n    \r\n    lightcurve = grb_reload[key]['lightcurve']\r\n    \r\n    lightcurve.display_count_spectrum(tmin=0, tmax=5, ax=ax)\r\n    lightcurve.display_count_spectrum_source(tmin=0, tmax=5, ax=ax)\r\n    lightcurve.display_count_spectrum_background(tmin=0, tmax=5, ax=ax)\r\n\r\n    if col \u003c 3:\r\n        col+=1\r\n    else:\r\n        row+=1\r\n        col=0\r\n```\r\n\r\n\r\n![png](demo_files/demo_14_0.png)\r\n\r\n\r\n## Convert HDF5 to standard FITS files \r\n\r\n\r\n```python\r\ncosmogrb.grbsave_to_gbm_fits(\"test_grb.h5\")\r\n!ls SynthGRB_*\r\n```\r\n\r\n    SynthGRB_b0.fits      SynthGRB_n3.fits      SynthGRB_n7rsp_n7.rsp\r\n\r\n    SynthGRB_b0.rsp       SynthGRB_n3.rsp       SynthGRB_n8.fits\r\n\r\n    SynthGRB_b0rsp_b0.rsp SynthGRB_n3rsp_n3.rsp SynthGRB_n8.rsp\r\n\r\n    SynthGRB_b1.rsp       SynthGRB_n4.fits      SynthGRB_n8rsp_n8.rsp\r\n\r\n    SynthGRB_b1rsp_b1.rsp SynthGRB_n4.rsp       SynthGRB_n9.fits\r\n\r\n    SynthGRB_n0.fits      SynthGRB_n4rsp_n4.rsp SynthGRB_n9.rsp\r\n\r\n    SynthGRB_n0.rsp       SynthGRB_n5.fits      SynthGRB_n9rsp_n9.rsp\r\n\r\n    SynthGRB_n0rsp_n0.rsp SynthGRB_n5.rsp       SynthGRB_na.fits\r\n\r\n    SynthGRB_n1.fits      SynthGRB_n5rsp_n5.rsp SynthGRB_na.rsp\r\n\r\n    SynthGRB_n1.rsp       SynthGRB_n6.fits      SynthGRB_narsp_na.rsp\r\n\r\n    SynthGRB_n1rsp_n1.rsp SynthGRB_n6.rsp       SynthGRB_nb.fits\r\n\r\n    SynthGRB_n2.fits      SynthGRB_n6rsp_n6.rsp SynthGRB_nb.rsp\r\n\r\n    SynthGRB_n2.rsp       SynthGRB_n7.fits      SynthGRB_nbrsp_nb.rsp\r\n\r\n    SynthGRB_n2rsp_n2.rsp SynthGRB_n7.rsp\r\n\r\n\r\n\r\n\r\n```python\r\n\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrburgess%2Fcosmogrb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrburgess%2Fcosmogrb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrburgess%2Fcosmogrb/lists"}