Metadata-Version: 2.4
Name: obpg-orm
Version: 1.1.5
Summary: ORM generates hyperspectral (1nm) or sensor-specific Rrs (or Lwn) spectra using an ocean reflectance model described in:
Author-email: Sean Bailey <sean.w.bailey@nasa.gov>
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: scipy>=1.3.1
Requires-Dist: requests>=2.22.0
Requires-Dist: numpy>=1.17.1
Requires-Dist: netCDF4>=1.5.2

# Ocean Reflectance Model (ORM, clever, aren't we?)
## About
ORM generates hyperspectral (1nm) or sensor-specific Rrs (or Lwn) spectra using the
ocean reflectance model described in:

     P. Jeremy Werdell, Sean W. Bailey, Bryan A. Franz, André Morel, and
     Charles R. McClain, "On-orbit vicarious calibration of ocean color sensors
     using an ocean surface reflectance model" Appl. Opt. 46, 5649-5666 (2007),
     https://doi.org/10.1364/AO.46.005649

## License
NASA Opensource Agreement (NOSA) v1.3 (pending)

## What's in the box
* orm - the driver
* [get_brdf](docs/get_brdf.md) - functions to derive the Morel BRDF correction 
* [get_f0](docs/get_f0.md) - functions to retrieve the extraterrestrial irradiance
* [morel_read](docs/morel_read.md) - functions to read the various look-up tables 

### Running the model from the driver script
```
usage: orm [-h] [--version] [--sensor {modisa,modist,viirsn,viirsj1,seawifs,meris,olcis3a,olcis3b,octs,czcs}] [--output_file OUTPUT_FILE] [--adg [ADG]]
           [--aph [APH]] [--bbp [BBP]] [--bbp_s [BBP_S]] [--solz SOLZ [SOLZ ...]] [--wvl WVL [WVL ...]] [--bandpass BANDPASS] [--lwn] [--disable_iter_limit]
           [--gordon] [--verbose]
           chl [chl ...]

positional arguments:
  chl                   Chlorophyll concentration

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --sensor {modisa,modist,viirsn,viirsj1,seawifs,meris,olcis3a,
  olcis3b,octs,czcs}
                        Sensor to mimic
  --output_file OUTPUT_FILE
                        output netCDF LUT filename; default is STDOUT
  --adg [ADG]           Detrital and Gelbstoff absorption coefficient at 443nm
  --aph [APH]           Phytoplankton absorption coefficient at 443nm
  --bbp [BBP]           Particulate backscattering coefficient at 443nm
  --bbp_s [BBP_S]       Particulate backscattering slope
  --solz SOLZ [SOLZ ...]
                        Solar zenith angle. If provided, it should either be a single value or an array matching the size of the input chlorophyll array. The
                        default is 30 degrees
  --wvl WVL [WVL ...]   Wavelength(s) to generate
  --bandpass BANDPASS   Bandpass width of wavelength(s) to generate
  --lwn                 output normalized Lw instead of Rrs
  --disable_iter_limit  allow MM01 iteration to run to convergence
  --gordon, -g          Use the Gordon quadratic formulation with input IOPs
  --verbose, -v
```

### The "key" functions
    model.gordon_rrs(adg, aph, bbp, bbp_s, chl, lwn=False, wvl=None, bandpass=11)
        Calculate Rrs given chlorophyll and IOPs.
        Uses the Gordon quadratic formulation.

    model.morel_rrs(chl, solz=None, wvl=None, bandpass=11, lwn=False, mm01iter=True, use_fq=False)
        Calculate Rrs given chlorophyll and solar zenith angle.
        Based mostly on Morel and Maritorena 2001
        Rrs = trans * (f / Q) * {bb / (a + bb)}, where (a + bb) ~ mud * Kd

    model.rrs_below_to_above(rrs_s, q=3.141529, gordon=False)
        Compute above-water Rrs from sub-surface rrs.
        Uses Lee et al 2002 or Gordon 1988.

    utils.convolve_rsr(sensor, spectrum, verbose=False)
        Convolve 1nm resolution Rrs with a spectral response function.

### Example: Using the underlying functions in your own script
```
from orm.model import gordon_rrs, morel_rrs
from orm.utils import convolve_rsr 
adg = 0.0045
aph = 0.0063
bbp = 0.00154
bbp_s = 1.985
chl = 0.0603
# Gordon model
spectrum = gordon_rrs(adg, aph, bbp, bbp_s, chl, lwn=True)
(wvl, lwn) = convolve_rsr('seawifs',spectrum)
# Morel model
spectrum = morel_rrs(chl, solz=40,lwn=True, mm01iter=True)
(wvl, lwn) = convolve_rsr('seawifs',spectrum)

```

### A few extra things, not really needed...
* kbio-netCDF - a script to generate a netCDF version of the Morel & Maritorena (2001) kbio tables
* morel_fq_appb-netCDF - a script to generate a netCDF version of the Morel f/Q tables
* mud_f_fp-netCDF - a script to generate a netCDF version of the Morel f, f-prime and mud tables
