{"id":38903982,"url":"https://github.com/cgosmeyer/lacosmic","last_synced_at":"2026-01-17T15:05:47.277Z","repository":{"id":275072741,"uuid":"95252621","full_name":"cgosmeyer/lacosmic","owner":"cgosmeyer","description":"Python wrapper to LACOSMIC IRAF task, specifically for cleaning cosmic rays from FITS images of single white dwarf stars.","archived":false,"fork":false,"pushed_at":"2017-06-27T18:43:55.000Z","size":2748,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-10T00:31:49.651Z","etag":null,"topics":["astronomy","cosmic-rays","iraf","lacosmic","pyraf"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cgosmeyer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-23T20:05:59.000Z","updated_at":"2017-06-28T17:20:09.000Z","dependencies_parsed_at":"2025-01-31T02:45:32.767Z","dependency_job_id":null,"html_url":"https://github.com/cgosmeyer/lacosmic","commit_stats":null,"previous_names":["cgosmeyer/lacosmic"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cgosmeyer/lacosmic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgosmeyer%2Flacosmic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgosmeyer%2Flacosmic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgosmeyer%2Flacosmic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgosmeyer%2Flacosmic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cgosmeyer","download_url":"https://codeload.github.com/cgosmeyer/lacosmic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgosmeyer%2Flacosmic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28510928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astronomy","cosmic-rays","iraf","lacosmic","pyraf"],"created_at":"2026-01-17T15:05:42.904Z","updated_at":"2026-01-17T15:05:47.243Z","avatar_url":"https://github.com/cgosmeyer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"LACosmic Wrapper\n================\n\nAuthor: C. Gosmeyer, 2015\n\nLast Updated: 29 Sep. 2015\n\n\nAbout\n-----\n\nThe script `run_lacosmic.py` wraps the IRAF task `LACosmic`, written by Pieter G. van Dokkum (http://www.astro.yale.edu/dokkum/lacosmic/). The wrapper is tweaked specifically for Hubble WFC3/UVIS FITS-format images of single white dwarf stars. If you use it for other targets/instruments, expect some experimentation!\n\nIt generates cosmic-ray cleaned FITS (`*clean.fits`) and the cosmic-ray mask FITS  (`*mask.fits`), and a diagnostic PNG file that displays on a single page the original image, the mask, and the cosmic-ray cleaned image.  It presently assumes the source is at the center (usually true in my white dwarf data) so it also displays ‘zoomed-in’ panels of the image center.  Using this PNG you can quickly diagnose whether `LACosmic` did a good job masking the cosmic-rays or did poorly enough that you need adjust parameters and run the script again.\n\nThere is, in fact, a Python version, which is faster than IRAF (yes, crazy, I know!).  But unfortunately it is not smart about how it handles the headers of multi-extension FITS. Besides that caveat, the output images of both versions look the same in all my tests.  On a distant future day I may fix the Python version and incorporate it into the wrapper.\n\nAlso included in this package are a script that iterates through different permutations of parameters so that you can with relative ease find the best for your WFC3/UVIS data. This script is named `run_lacosmic_tester.py`.\n\nSee the doc strings for further information on inputs and outputs for `run_lacosmic.py` and `run_lacosmic_tester.py`.\n\n\nInstall ‘lacosmic’ Package\n---------------------------\n\n1. git clone the ‘lacosmic’ package to desired location\n\n2. To install the package, type\n\n    \u003e make setup\n\n3. Finally add the PYTHONPATH to your .cshrc file with something like\n\n    setenv PYTHONPATH ${PYTHONPATH}:/your/path/to/lacosmic/\n\nIf the installation went smoothly, you should have the following in\nthe `lacosmic` directory: \n   `__init__.py`\n   `count_masked_pixels.py`\n   `init_setup_lacosmic.py`\n   `lacos_im.cl`\n   `lacosmic_tools.py`\n   `run_lacosmic.py`\n   `run_lacosmic_tester.py`\n   `examples/`\n\n\nSetup ‘lacosmic’ Package\n--------------------------\n\nActually, as long as you ran the makefile, you shouldn't need to do anything more. The ‘make setup’ command runs `setup.py` and  `init_setup_lacosmic.py`, which does the following:\n\n1. Creates ‘set_paths.py’, which just contains a dictionary of the absolute\n   path to the directory where you put `lacosmic`. \n\n2. Creates ‘img_scale.py’, which is written from a script available on the\n   internet. I did not write it so I did not include it in the `lacosmic`\n   package.\n\nYou may, after an initial run, need adjust for your different filters the \n    ``LACosmic`` parameters in the `run_lacosmic.py` function \n    `lacosmic_param_dictionary`. You can find these parameters by your own \n    trial and error or by using an already-built tester, `run_lacosmic_tester.py`.\n\n\nRun\n---\n\nInstallation and setup should ideally need be done only once. Now you\nare free to run the LACosmic wrapper on a whim. Hooray!\n\n1. To run the bare `run_lacosmic.py`, cd into the directory containing the\n   FLTs you want cosmic ray cleaned.  If your PYTHONPATH is correct, then\n   you need just do\n\n   \u003e python run_lacosmic.py\n\n2. Wait. For a WFC3/UVIS subarray, it takes 30-40 seconds each. You might speed it \n   up by decreasing the ‘niter’ param. (By default it is set to the highest, 5). \n\n3. An error-free run should have created the following directories:\n\n   flt_cleans/\n   flt_masks/\n   png_masks_cleans/   \n\n   Containing, respectively, for each of your original FLTs,\n\n   \u003crootname\u003e.clean.fits\n   \u003crootname\u003e.mask.fits\n   \u003crootname\u003e.png\n\n   The .clean.fits file is the cleaned FLT with which you want to do your \n   analyses.\n\n\n4. But first look through all the diagnostic plots in ‘png_masks_cleans’. \n   If you see that LACosmic \"blew up\" (overflags and masks pixels) on an \n   image, move its clean, mask, and diagnostic plot to a ‘flags’ \n   directory. Then adjust parameters and re-run. You can compare your new\n   runs with the old you stored in ‘flags’.\n\n   See the plots in `examples` for good and bad runs. All images of the \n   (post-flashed!) white dwarf GRW+70 in the WFC3/UVIS filter F218W. \n\n‘good.png’ — Close to what you want to see. Only cosmic rays masked. ‘sigclip’ \n    appropriately high to account for post-flash.\n‘center_overflagged.png’ — The star’s center is masked. Try increasing ‘sigclip’\n     and ‘objlim’.\n‘sigclip_too_low.png’ — Background flagged everywhere! Try increasing ‘sigclip’\n     to about 9.5.\n\n   Sometimes LACosmic blows up for no reason, no matter how you adjust the \n   parameters. If you are doing a big batch that spans multiple visits, expect \n   about 5% of your images to do this.  But if more than ~5% are getting over-\n   flagged in the PSF or the background, you’ll probably need to toss out this \n   run and start again with adjusted parameters. See Tips Section below.\n\nTips\n-----\n\nLACosmic’s four parameters are\n    sigclip : Detection limit for cosmic rays.\n    sigfrac : Detection limit for adjacent pixels.\n    objlim : Max number of objects desired in image.      \n    niter : Number of iterations of cosmic ray finder. \n\nIn general, for the standard white dwarf GRW+70, I use\n    sigclip = 5.5 (9.5 if post-flashed)\n    sigfrac = .3 (I rarely vary this)\n    objlim = 2 or 5 \n    niter = 5  (Also rarely vary)\n\nNarrow band filters generally work better with ‘sigclip’ about 4.5.\nLong pass filters generally work better with ’sigclip’ \u003e 5.5.\n\n \nIf you notice LACosmic is over-flagging pixels\n\n1. Check whether your images are post-flashed. \n   For post-flashed images, you may need bump the 'sigclip' up to near\n   10.0. Non-post-flashed images are good around 'sigclip' 5.0, 5.5. \n\n2. Increase ‘sigclip’ even if not post-flashed.\n\n3. Increase ‘objlim’. \n\n\nIf you notice it is not flagging /enough/ pixels\n\n1. Decrease ‘objlim’.\n\n2. Decrease ‘sigclip’.\n\nYou’ll find that you’re more often over-flagging than under-flagging.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgosmeyer%2Flacosmic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcgosmeyer%2Flacosmic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgosmeyer%2Flacosmic/lists"}