{"id":13734234,"url":"https://github.com/samsammurphy/6S_emulator","last_synced_at":"2025-05-08T10:31:10.199Z","repository":{"id":50263228,"uuid":"72054740","full_name":"samsammurphy/6S_emulator","owner":"samsammurphy","description":"Atmospheric correction in Python using a 6S emulator","archived":false,"fork":false,"pushed_at":"2020-08-07T21:27:38.000Z","size":8075,"stargazers_count":83,"open_issues_count":2,"forks_count":27,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-15T02:34:36.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","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/samsammurphy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-27T00:01:33.000Z","updated_at":"2024-10-24T09:02:53.000Z","dependencies_parsed_at":"2022-08-25T13:40:51.704Z","dependency_job_id":null,"html_url":"https://github.com/samsammurphy/6S_emulator","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/samsammurphy%2F6S_emulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsammurphy%2F6S_emulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsammurphy%2F6S_emulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsammurphy%2F6S_emulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samsammurphy","download_url":"https://codeload.github.com/samsammurphy/6S_emulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253045662,"owners_count":21845747,"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":[],"created_at":"2024-08-03T03:00:53.715Z","updated_at":"2025-05-08T10:31:09.920Z","avatar_url":"https://github.com/samsammurphy.png","language":"HTML","funding_links":[],"categories":["`Python` processing of optical imagery (non deep learning)","Atmospheric Correction"],"sub_categories":["Processing imagery - post processing"],"readme":"## Introduction\n\nThe 6S emulator is an open-source atmospheric correction tool. It is based on the [6S](http://modis-sr.ltdri.org/pages/6SCode.html) radiative transfer model but it **runs 100x faster** with minimal additional error (i.e. \u003c 0.5 %).\n\nThis speed increase is acheived by building interpolated look-up tables. This trades set-up time for execution time. The look-up tables take a long time (i.e. hours) to build, here are some prebuilts for: [Sentinel 2](https://www.dropbox.com/s/aq873gil0ph47fm/S2A_MSI.zip?dl=1), [Landsat 8](https://www.dropbox.com/s/49ikr48d2qqwkhm/LANDSAT_OLI.zip?dl=1), [Landsat 7](https://www.dropbox.com/s/z6vv55cz5tow6tj/LANDSAT_ETM.zip?dl=1) \u0026 [Landsat 4 and 5](https://www.dropbox.com/s/uyiab5r9kl50m2f/LANDSAT_TM.zip?dl=1). You only need to build (or download) a look-up table once.\n \nInterpolated look-up tables are the core of the 6S emulator. Essentially, they are used to calculate atmospheric correction coefficients (a, b) which convert at-sensor radiance (L) to surface reflectance (ρ) as follows:\n\nρ = (L - a) / b\n\n### Installation\n\n##### Quick note\n\nThe installation instructions (below) are for building look-up tables. To use a pre-existing look-up table, all that is required are python3.x, numpy and scipy.\n\nWe interact with 6S through an excellent Python wrapper called [Py6S](http://py6s.readthedocs.io/en/latest/index.html) and share the same dependencies. \n\n#### Recommended installation\n\nThe [recommended installation](http://py6s.readthedocs.io/en/latest/installation.html) method is to use the [conda](https://conda.io/docs/install/quick.html) package and environment manager.\n\n`$ conda create -n py6s-env -c conda-forge py6s`\n\nThis will create a new environment that needs to be activated.\n\n#### Alternative 1: add conda-forge channel\n\nYou could permanently add the conda-forge channel if you prefer to avoid (de)activating environments.\n\n`$ conda config --add channels conda-forge`\n\n`$ conda install py6s`\n\n#### Alternative 2: docker\n\nYou could optionally run the following [docker](https://www.docker.com/) container instead, which has all dependencies pre-installed\n\n`$ docker run -it samsammurphy/ee-python3-jupyter-atmcorr:v1.0`\n\nthen clone this repository into the container\n\n`# git clone https://github.com/samsammurphy/6S_emulator`\n\n#### Alternative 3: manual install\n\nHere are a list of all [dependencies](https://github.com/samsammurphy/6S_emulator/wiki/Dependencies) for manual installation.\n\n### Usage\n\n#### Quick Start\n\nSee the [jupyter notebook](https://github.com/samsammurphy/6S_emulator/blob/master/jupyter_notebooks/atmcorr_example.ipynb) for a quick start example of atmospheric correction. \n\n#### Building your own interpolated look-up tables\n\nIt is much more bandwidth efficient to send  and receive look-up tables, and then interpolate them locally, which is why building and interpolating are handled by separate modules. To see a more complete list of examples of how to build a look-up table (for any satellite mission) see this [wiki](https://github.com/samsammurphy/6S_emulator/wiki/Build-examples). Here is a short example.\n\n`$ python3 LUT_build.py --wavelength 0.42`\n\nwhich will build a look-up table for a wavelength of 0.42 microns, it can be interpolated as follows\n\n`$ python3 LUT_interpolate.py  path/to/LUT_directory`\n\nwhere the 'path/to/LUT_directory' is the full path to the look-up table files ('.lut').\n\n#### Using interpolated look-up tables\n\nAn interpolated look-up tables is a [pickle](https://docs.python.org/3/library/pickle.html) file of a [scipy](https://www.scipy.org/) linear n-dimensional [interpolator](https://docs.scipy.org/doc/scipy-0.19.0/reference/generated/scipy.interpolate.LinearNDInterpolator.html). It can be loaded like this:\n\n```\nimport pickle\n\nfpath = 'path/to/interpolated_lookup_table.ilut'\n\nwith open(fpath,\"rb\") as ilut_file:\n    iLUT = pickle.load(ilut_file)\n```\n\nAn interpolated look-up table requires the following input variables (in order) to provide atmospheric correction coefficients:\n\n1. solar zentith [degrees] (0 - 75)\n2. water vapour [g/m2] (0 - 8.5)\n3. ozone [cm-atm] (0 - 0.8)\n4. aerosol optical thickness [unitless] (0 - 3)\n5. surface altitude [km] (0 - 7.75)\n\nIn code it might look something like this\n\n`a, b = iLUT(solar_z, h2o, o3, aot, km)`\n\nwhere a and b are the atmospheric correction coefficients at perihelion. The look-up tables are built at perihelion (i.e. January 4th) to save space because Earth's elliptical orbit can be corrected as follows:\n\n```\nimport math\n\nelliptical_orbit_correction = 0.03275104*math.cos(doy/59.66638337) + 0.96804905\na *= elliptical_orbit_correction\nb *= elliptical_orbit_correction\n```\n\nSurface reflectance can then be calculated from at-sensor radiance:\n\n`surface_reflectance = (L - a) / b`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsammurphy%2F6S_emulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamsammurphy%2F6S_emulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsammurphy%2F6S_emulator/lists"}