New to polymer

Post Reply
pubali
Posts: 1
Joined: Sun Jul 23, 2023 10:30 am
company / institution: KAUST University Saudi Arabia
Location: Saudi Arabia

New to polymer

Post by pubali »

can anyone please help me with the command to produce atmospherically corrected SEN3 data from level 1b?
I am new to polymer using it for the first time
sakvaka_env
Posts: 25
Joined: Mon Mar 07, 2022 9:54 am
company / institution: Finnish Environment Institute
Location: Helsinki, Finland

Re: New to polymer

Post by sakvaka_env »

Here's an example on how it could be done in Python.

Code: Select all

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os

from polymer.main import run_atm_corr
from polymer.level1 import Level1
from polymer.level2 import Level2
from polymer.ancillary import Ancillary_NASA

def set_earthdata():
    """ This is just a helper method
        to overwrite the ~/.netrc and ~/.urs_cookies files
        with Nasa Earthdata username and password, which are read from
        the environment variables EARTHDATA_U and EARTHDATA_P.
    """
    home_dir = os.path.expanduser('~')
    uid = os.getenv('EARTHDATA_U')
    password = os.getenv('EARTHDATA_P')
    with open(os.open(os.path.join(home_dir, '.netrc'),
              os.O_CREAT | os.O_WRONLY, 0o600), 'w') as fp:
        fp.write(f'machine urs.earthdata.nasa.gov login {uid} password {password}')
    with open(os.path.join(home_dir, '.urs_cookies'), 'w') as fp:
        pass

def main():
    # The following command will overwrite what you already have in the
    # ~/.netrc and ~/.urs_cookies files. If you are ok with this, uncomment the line below.
    # Alternatively, you can create the files yourself manually.
   
    # set_earthdata()

    # adjust input path
    input_dir = '/data/S3A_OL_1_EFR____20160908T093311_20160908T093611_20180307T160225_0179_008_250_1800_LR2_R_NT_002.SEN3'
    
    # Level-1 parameters
    level1_params = {
        'ancillary': Ancillary_NASA()  # requires ~/.netrc and ~/.urs_cookies to be configured
    }
    
    # Level-2 parameters
    level2_params = {
        'outdir': '/data'
    }
    
    # processing parameters, adjust based on your needs
    processing_params = {
        # use as many threads as there are vCPU cores
        'multiprocessing': -1,
        # disable Level-1B lands masking
        'landmask': None,
        # add 1020 nm to improve in extreme waters
        'bands_corr': [443, 490, 510, 560, 620, 665, 754, 779, 865, 1020],
        'bands_oc': [443, 490, 510, 560, 620, 665, 754, 779, 865, 1020],
        # output all OLCI wavelengths
        'bands_rw': [400, 412, 443, 490, 510, 560, 620, 665, 674, 681, 709, 754,
                     760, 764, 767, 779, 865, 885, 900, 940, 1020],
        # disable the Polymer cloud masking
        'thres_Rcloud': -1,
        'thres_Rcloud_std': -1,
        # expand optimization bounds for logchl and logfb
        'bounds': [[-2, 4], [-2, 3.5]]
    }

    run_atm_corr(
        Level1(input_dir, **level1_params),
        Level2(**level2_params),
        **processing_params)

if __name__ == "__main__":
    main()
To use Nasa's ancillary data for atmospheric correction, you need to create Earthdata user account here and create the files ~/.netrc and ~/.urs_cookies in the user's home directory, but there's also a helper method showing how to create those.
Post Reply