Package: mag1c
MAG1C:  Matched filter with Albedo correction and reweiGhted L1 sparsity CodeFast concentration estimation and detection of trace gas absorption from imaging spectrometer data.CitationIf you use this tool in a program or publication, please acknowledge our paper about this method:Foote, 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.bibTeX:@ARTICLE{9034492,
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}},
journal={IEEE Transactions on Geoscience and Remote Sensing},
title={Fast and Accurate Retrieval of Methane Concentration From Imaging Spectrometer Data Using Sparsity Prior},
year={2020},
volume={},
number={},
pages={1-13},
keywords={Airborne Visible InfraRed Imaging Spectrometer-Next Generation (AVIRIS-NG);greenhouse gas emissions;methane mapping;plume detection.},
doi={10.1109/TGRS.2020.2976888},
ISSN={1558-0644},
month={},}Get the article from:IEEE DOI:10.1109/TGRS.2020.2976888arXiv:2003.02978Installationpip install mag1cRequirementsmag1c depends on these software packages for math routines and data I/O.Python 3.6 (or newer) and the following python packages and versions:numpyspectraltorch1.3+scikit-imageGPU ProcessingIf available, this code uses a compatible GPU for accelerated computation. Seehttps://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.The--gpuflag must be used to enable GPU acceleration.CPU-OnlyIf you know that you willnotuse a GPU, you can install the CPU-only version of pytorch. Seehttps://pytorch.org/get-started/locally/#no-cuda-1for how to install the CPU-only version. At time of writing, the install command for cpu-only torch and mag1c together through pip is:pip3 install mag1c torch==1.3.1+cpu -f https://download.pytorch.org/whl/torch_stable.htmlAdvanced InstallationThe simplest way to obtain this program is throughpip. To get the latest release:pipinstallmag1cor, to install a specific released version:pip install magic==x.y.zor, to get a specific point in history directly from github:pip install git+https://github.com/markusfoote/mag1c@tag#egg=mag1cwheretagis any tag (e.g.v1.2.0), branch name (e.g.master) or commit hash.PyPA has more detailed instructions.This will install required dependencies (most notably,pytorch) on linux systems. For Windows, or specific installation flavors of pytorch (like CPU-only), follow your choice of instructions onPyTorch's website, then install mag1c. Mag1c is compatible with PyTorch installed throughconda, just make sure you are using theenvironment'spipto install mag1c, and activate the conda environment whenever you wish to runmag1c.UsageEntrypointsThis program can be invoked in multiple ways:python /path/to/mag1c.pyworks whenever you have a copy of themag1c.pyscript. The versioning metadata may not work well with a standalone script.python -m mag1cworks when you install the python package (i.e. viapip).mag1cis a direct entry point to the program when you install viapip.sparsemfis exactly the same asmag1c, just with a debatably-more-readable name.Runtime OptionsThere are numerous options/flags that can be provided to modify processing behavior. Runmag1c --helpfor a full description of the available arguments.ExamplesProcess a single file with defaults:pythonmag1c.py/my/radiance--spec/my/target--out/some/outputProcess a single file with bash variables and some custom options, including GPU:exportCUDA_VISIBLE_DEVICES=0# Restrict processing to the first GPU in the systemRDNFILE="/path/to/my/radiance data with spaces in filename"TEMPLATE=/path/to/my/templatespectrumOUTPUT=/path/to/outputfile_date_time_iteration25_grouping5GLT=/path/to/my/gltfile
pythonmag1c.py"$RDNFILE"--spec$TEMPLATE--out$OUTPUT--outputgeo$GLT--iter25--group5--gpu-t2-b16Process all files in a folder:TEMPLATE=/path/to/template.txtforfin/path/to/folder/ang*_rdn_*_clip;do\pythonmag1c.py"${f}""${TEMPLATE}""/output/folder/$(basename"${f/rdn/mag1c}")"--iter20done;Process a file with detector saturation detection/masking:For a geocorrected file:sparsemf${RDN_FILE}\--out$OUTPUTFOLDER$(basename${b/_rdn_/_ch4_cmfr_})\--geo${RDN_FILE/img/glt}\--group1\--saturation\--saturationthreshold6.0\--maskgrowradius150m\--mingrowarea5\--hfdi\--threads8\--gpu\--no-albedo-output\--visible-mask-growing-threshold9.0or for a non-geocorrected file:sparsemf${RDN_FILE}\--out$OUTPUTFOLDER$(basename${b/_rdn_/_ch4_cmfr_})\--outputgeo${RDN_FILE/img/glt}\--group1\--saturation\--saturationthreshold6.0\--maskgrowradius12px\--mingrowarea5\--hfdi\--threads8\--gpu\--no-albedo-output\--visible-mask-growing-threshold9.0Notice that the non-geocorrected file requires amaskgrowradiusin pixels, as the file has no spatial metadata.