{"id":50290444,"url":"https://github.com/zaitra/mag1c","last_synced_at":"2026-05-28T05:34:47.506Z","repository":{"id":343945777,"uuid":"849350275","full_name":"zaitra/mag1c","owner":"zaitra","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-12T12:18:38.000Z","size":1359,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-28T05:34:39.325Z","etag":null,"topics":["third-party","trend9"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zaitra.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-29T12:47:18.000Z","updated_at":"2026-04-27T06:32:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/zaitra/mag1c","commit_stats":null,"previous_names":["zaitra/mag1c"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/zaitra/mag1c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaitra%2Fmag1c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaitra%2Fmag1c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaitra%2Fmag1c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaitra%2Fmag1c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaitra","download_url":"https://codeload.github.com/zaitra/mag1c/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaitra%2Fmag1c/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33596316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["third-party","trend9"],"created_at":"2026-05-28T05:34:46.787Z","updated_at":"2026-05-28T05:34:47.501Z","avatar_url":"https://github.com/zaitra.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MAG1C-SAS: Matched filter with Albedo correction and reweiGhted L1 Sparsity, Sped up with Additional Sparsity\n\nThis repository is a fork of **MAG1C**, modified slightly to create **MAG1C-SAS**. Three additional flags are now available:\n\n- `--save-target-spectrum-centers`  \n  Saves the centers and target spectrum values as two separate NumPy arrays.\n\n- `--sample [value from 0 to 1]`  \n  Instead of running the classic MAG1C, MAG1C-SAS is executed with a specified sample size (given as a fraction between 0 and 1).\n\n- `--use-all-bands`  \n  Defaultly some water vapour regions like 1350-1420 nm are excluded, with this option, they are included.\n\nAdditional timing measurements are included (similar to those used for our other filters). This only records the time taken by the core filter function, excluding preprocessing.\n\nIf you find **Mag1c-SAS** useful in your research, please cite the article where it was presented:\n```bibtex\n@misc{herec2025optimizingmethanedetectionboard,\n      title={Optimizing Methane Detection On Board Satellites: Speed, Accuracy, and Low-Power Solutions for Resource-Constrained Hardware}, \n      author={Jonáš Herec and Vít Růžička and Rado Pitoňák},\n      year={2025},\n      eprint={2507.01472},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV},\n      url={https://arxiv.org/abs/2507.01472}, \n}\n```\n\nEverything else remains unchanged, so below is original README:\n\n[![Article DOI:10.1109/TGRS.2020.2976888](https://img.shields.io/badge/Article%20DOI-10.1109%2FTGRS.2020.2976888-blue)](https://doi.org/10.1109/TGRS.2020.2976888) [![ArXiv:2003.02978](https://img.shields.io/badge/arXiv-2003.02978-blue)](https://arxiv.org/abs/2003.02978) ![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/markusfoote/mag1c?include_prereleases\u0026sort=semver) ![PyPI](https://img.shields.io/pypi/v/mag1c) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mag1c) ![PyPI - License](https://img.shields.io/pypi/l/mag1c)\n\nFast concentration estimation and detection of trace gas absorption from imaging spectrometer data.\n\n\n## Citation\nIf you use this tool in a program or publication, please acknowledge our paper about this method:\n\nFoote, M. D., *et al.* \"Fast and Accurate Retrieval of Methane Concentration from Imaging Spectrometer Data Using Sparsity Prior\" IEEE Transactions on Geoscience and Remote Sensing. 2020.\n* bibTeX:\n  ```\n  @ARTICLE{9034492,\n  author={M. D. {Foote} and P. E. {Dennison} and A. K. {Thorpe} and D. R. {Thompson} and S. {Jongaramrungruang} and C. {Frankenberg} and S. C. {Joshi}},\n  journal={IEEE Transactions on Geoscience and Remote Sensing},\n  title={Fast and Accurate Retrieval of Methane Concentration From Imaging Spectrometer Data Using Sparsity Prior},\n  year={2020},\n  volume={},\n  number={},\n  pages={1-13},\n  keywords={Airborne Visible InfraRed Imaging Spectrometer-Next Generation (AVIRIS-NG);greenhouse gas emissions;methane mapping;plume detection.},\n  doi={10.1109/TGRS.2020.2976888},\n  ISSN={1558-0644},\n  month={},}\n  ```\nGet the article from:\n* IEEE DOI: [10.1109/TGRS.2020.2976888](https://doi.org/10.1109/TGRS.2020.2976888)\n* arXiv: [2003.02978](https://arxiv.org/abs/2003.02978)\n## Installation\n``pip install mag1c``\n\n## Requirements\nmag1c depends on these software packages for math routines and data I/O. \n\nPython 3.6 (or newer) and the following python packages and versions:\n- [`numpy`](https://www.numpy.org/)\n- [`spectral`](https://www.spectralpython.net/)\n- [`torch`](https://pytorch.org) 1.3+\n- [`scikit-image`](https://scikit-image.org/)\n\n## GPU Processing\nIf available, this code uses a compatible GPU for accelerated computation. See [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/) for details on how to install pytorch with gpu support for your system. You will then need to install the other dependencies.\n\nThe `--gpu` flag must be used to enable GPU acceleration.\n### CPU-Only\nIf you know that you will **not** use a GPU, you can install the CPU-only version of pytorch. See [https://pytorch.org/get-started/locally/#no-cuda-1](https://pytorch.org/get-started/locally/#no-cuda-1) for how to install the CPU-only version. At time of writing, the install command for cpu-only torch and mag1c together through pip is: \n```\npip3 install mag1c torch==1.3.1+cpu -f https://download.pytorch.org/whl/torch_stable.html\n```\n\n## Advanced Installation\nThe simplest way to obtain this program is through `pip`. To get the latest release:\n```bash\npip install mag1c\n```\nor, to install a specific released version:\n```\npip install magic==x.y.z\n```\nor, to get a specific point in history directly from github:\n```\npip install git+https://github.com/markusfoote/mag1c@tag#egg=mag1c\n```\nwhere ``tag`` is any tag (e.g. ``v1.2.0``), branch name (e.g. ``master``) or commit hash. [PyPA has more detailed instructions.](https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support)\n\nThis will install required dependencies (most notably, [pytorch](https://pytorch.org)) on linux systems. For Windows, or specific installation flavors of pytorch (like CPU-only), follow your choice of instructions on [PyTorch's website](https://pytorch.org/get-started/locally/), then install mag1c. Mag1c is compatible with PyTorch installed through `conda`, just make sure you are using the **environment's** `pip` to install mag1c, and activate the conda environment whenever you wish to run `mag1c`.\n\n## Usage\n### Entrypoints\nThis program can be invoked in multiple ways: \n1. `python /path/to/mag1c.py` works whenever you have a copy of the `mag1c.py` script. The versioning metadata may not work well with a standalone script.\n2. `python -m mag1c` works when you install the python package (i.e. via `pip`).\n3. `mag1c` is a direct entry point to the program when you install via `pip`.\n4. `sparsemf` is exactly the same as `mag1c`, just with a debatably-more-readable name.\n\n### Runtime Options\nThere are numerous options/flags that can be provided to modify processing behavior. Run `mag1c --help` for a full description of the available arguments.\n\n## Examples\n### Process a single file with defaults:\n```bash\npython mag1c.py /my/radiance --spec /my/target --out /some/output\n```\n\n### Process a single file with bash variables and some custom options, including GPU:\n```bash\nexport CUDA_VISIBLE_DEVICES=0 # Restrict processing to the first GPU in the system\nRDNFILE=\"/path/to/my/radiance data with spaces in filename\"\nTEMPLATE=/path/to/my/templatespectrum\nOUTPUT=/path/to/outputfile_date_time_iteration25_grouping5\nGLT=/path/to/my/gltfile\npython mag1c.py \"$RDNFILE\" --spec $TEMPLATE --out $OUTPUT --outputgeo $GLT --iter 25 --group 5 --gpu -t 2 -b16\n```\n\n### Process all files in a folder:\n```bash\nTEMPLATE=/path/to/template.txt\nfor f in /path/to/folder/ang*_rdn_*_clip; do \\\n    python mag1c.py \"${f}\" \"${TEMPLATE}\" \"/output/folder/$(basename \"${f/rdn/mag1c}\")\" --iter 20\ndone;\n```\n\n### Process a file with detector saturation detection/masking:\nFor a geocorrected file:\n```bash\nsparsemf ${RDN_FILE} \\\n  --out $OUTPUTFOLDER$(basename ${b/_rdn_/_ch4_cmfr_}) \\\n  --geo ${RDN_FILE/img/glt} \\\n  --group 1 \\\n  --saturation \\\n  --saturationthreshold 6.0 \\\n  --maskgrowradius 150m \\\n  --mingrowarea 5 \\\n  --hfdi \\\n  --threads 8 \\\n  --gpu \\\n  --no-albedo-output \\\n  --visible-mask-growing-threshold 9.0\n```\nor for a non-geocorrected file:\n```bash\nsparsemf ${RDN_FILE} \\\n  --out $OUTPUTFOLDER$(basename ${b/_rdn_/_ch4_cmfr_}) \\\n  --outputgeo ${RDN_FILE/img/glt} \\\n  --group 1 \\\n  --saturation \\\n  --saturationthreshold 6.0 \\\n  --maskgrowradius 12px \\\n  --mingrowarea 5 \\\n  --hfdi \\\n  --threads 8 \\\n  --gpu \\\n  --no-albedo-output \\\n  --visible-mask-growing-threshold 9.0\n```\nNotice that the non-geocorrected file requires a **`maskgrowradius` in pixels**, as the file has no spatial metadata.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaitra%2Fmag1c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaitra%2Fmag1c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaitra%2Fmag1c/lists"}