Code Monkey home page Code Monkey logo

pyosoaa's Introduction

Build Status Coverage Status

pyOSOAA

pyOSOAA is a python interface for the Ocean Successive Orders with Atmosphere - Advanced (OSOAA) radiative transfer. The OSOAA is a radiative transfer code developed in the Sorbonne Université by Pr. Malik Chami group and supported by the CNES.

The coded is based in the successive orders of scattering method and the OSOA code developed by Malik Chami in 2001 that included the computation of the radiance and polarization for the ocean-atmosphere system with a flat surface.

The OSOAA code simulates:

  • Atmospheric and sea profiles: The atmosphere can be and sea profiles can be defined by the user both for the molecules and aerosol in the atmosphere and the water column, chlorophyll and mineral-like particles in the sea. Detritus and yellow substance absorption can also be modelled.
  • Aerosol models: Aerosol models include WMO, LND, Junge mono-modal, bimodal LND and Shettle and Fenn.
  • Hydrosol models: For phytoplankton and mineral-like particles including scattering and absorbing properties.
  • Sea surface interface: Both for a flat surface or by a rough surface using Cox and Munk model.

The pyOSOAA interface aims to incorporate the creation of run scripts and parsing of output results for the OSOAA model. It also incorporates helpers to perform common tasks like calculating the radiance for a certain band instead of a wavelength or running the model for multiple wavelengths.

This code was inspired by py6S by Robin Wilson.

You can find the full pyOSOAA manual here.

Installation

The installation of the pyOSOAA has two parts.

First, you need to install the OSOAA software package from https://github.com/CNES/RadiativeTransferCode-OSOAA.

Second, install pyOSOAA. There are two ways to install pyOSOAA.

Install pyOSOAA from pypi

pip install pyOSOAA

Install pyOSOAA from source code

Download the last version of the pyOSOAA from github.

Once downloaded decompress it, go to the folder containing the code and run

python setup.py install

To then check that software installed correctly

# Load pyOSOAA module
import pyOSOAA
# Run the test suite
pyOSOAA.test()

the following output should appear at the end of the screen

OSOAA wrapper script by Francisco Nemiña
Inspired by Py6S wrapper by Robin Wilson
Using OSOAA located at /home/.../OSOAA_V1.5
Running OSOAA using a set of test parameters
The results are:
Expected result: 0.128266
Actual result: 0.128266
#### Results agree PyOSOAA is working correctly

pyosoaa's People

Contributors

fengqiaogh avatar fnemina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pyosoaa's Issues

Define helper to run several wavelengths for one angle

Should have as input:

  • The OSOAA object
  • The wavelengths for which we want to run the simulation as an iterable
  • The view angle for which to run the simulation
  • The expected output from the vsVZA file
    the output are the wavelengths for which the values are calculated, the angles and the output value.

Problems in generating lookup tables

You know, we need a range of solar zenith angles and sensor zenith angles to generate a lookup table. When i change solar zenith angle, problem arise.

1 No Output file

When i run the following code, it works normally.

import numpy as np
import pyOSOAA
from pyOSOAA.osoaahelpers import RunWavelengths

s = pyOSOAA.OSOAA()
view = 0
wavelengths = np.array([412, 443, 490, 510, 555, 670, 765, 865])/1000

s.view.phi = 90
s.ang.thetas = 60

# Sea bottom configuration
s.sea.depth = 0.05
s.sea.bottype = 1
s.sea.botalb = 0

# Sea particles configuration
s.phyto.chl = 0
s.sed.csed = 0
s.det.abs440 = 0
s.ys.abs440 = 0

# Sea surface configuration
s.sea.wind = 10

# Small optical thickness
s.aer.aotref = 0.00001

s.ap.SetPressure(1013.25)

# Set view level at TOA
s.view.level = 1
rhor = RunWavelengths(s, wavelengths, view)/np.cos(np.pi*view/180.0)

I change the s.ang.thetas = 40. The output is ⬇️

==> Angles calculation
 ==> Aerosols radiative properties computation
 Aerosols --> Mie files repertory : /usr/local/OSOAA/DATABASE/MIE_AER
 Aerosols --> Mie files repertory : /usr/local/OSOAA/DATABASE/MIE_AER
 ==> Hydrosols radiative properties computation
 ==> Atmospheric and sea profiles computation
 ==> Sea / atmosphere interface matrices computation
 Surface matrices repertory : /usr/local/OSOAA/DATABASE/SURF_MATR
 Matrix RAA : RAA-1.340-10.0-RadMU48-NB80
 -- RAA Matrix file is being calculated
   OSOAA_MISE_FORMAT : ERROR_991 on a file opening
   OSOAA_SURFACE_CASE : ERROR_998  
       on subroutine OSOAA_MISE_FORMAT
       for case : RAA
   OSOAA_SURFACE : ERROR_3000  
       on subroutine OSOAA_SURFACE_RAA
   OSOAA_MAIN : ERROR_8000 on subroutine OSOAA_SURFACE
Traceback (most recent call last):
  File "/home/qiaofeng/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "/home/qiaofeng/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 434, in main
    run()
  File "/home/qiaofeng/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 312, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/usr/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/qiaofeng/Documents/Atmospheric-correction-for-GOCI/test.py", line 81, in <module>
    results = RunWavelengths(s, wavelengths, view)/np.cos(np.pi*view/180.0)
  File "/usr/local/lib/python3.6/dist-packages/pyOSOAA-1.1-py3.6.egg/pyOSOAA/osoaahelpers.py", line 75, in RunWavelengths
  File "/usr/local/lib/python3.6/dist-packages/pyOSOAA-1.1-py3.6.egg/pyOSOAA/osoaa.py", line 1311, in run
  File "/usr/local/lib/python3.6/dist-packages/pyOSOAA-1.1-py3.6.egg/pyOSOAA/outputs.py", line 429, in __init__
  File "/usr/local/lib/python3.6/dist-packages/pyOSOAA-1.1-py3.6.egg/pyOSOAA/outputs.py", line 68, in __init__
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/OSOAA/results/M39N3x3dFo0ULQV4/Standard_outputs/LUM_vsVZA.txt'

When i change s.ang.thetas = 40 to s.ang.thetas = 80, the problem still exists. I don't know why and how to do.

2 RunWavelengths(s, wavelengths, view) not support numpy

I use this sensor_zenith_angles = np.arange(60,90,2) to create a range of sensor zenith angles.
Then in the for loop run RunWavelengths(s, wavelengths, view)

for solar_zenith_angle in solar_zenith_angles:
    s.ang.thetas = solar_zenith_angle
    results = RunWavelengths(s, wavelengths, view)

Errors are reported as follows ⬇️:

 ==> Angles calculation
 ==> Aerosols radiative properties computation
 Aerosols --> Mie files repertory : /usr/local/OSOAA/DATABASE/MIE_AER
 Aerosols --> Mie files repertory : /usr/local/OSOAA/DATABASE/MIE_AER
 ==> Hydrosols radiative properties computation
 ==> Atmospheric and sea profiles computation
 ==> Sea / atmosphere interface matrices computation
 Surface matrices repertory : /usr/local/OSOAA/DATABASE/SURF_MATR
 ==> Radiative transfer computation
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG IEEE_DENORMAL
Traceback (most recent call last):
  File "/home/qiaofeng/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "/home/qiaofeng/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 434, in main
    run()
  File "/home/qiaofeng/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 312, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/usr/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/qiaofeng/Documents/Atmospheric-correction-for-GOCI/test.py", line 83, in <module>
    results = RunWavelengths(s, wavelengths, view)/np.cos(np.pi*view/180.0)
  File "/usr/local/lib/python3.6/dist-packages/pyOSOAA-1.1-py3.6.egg/pyOSOAA/osoaahelpers.py", line 80, in RunWavelengths
**IndexError: invalid index to scalar variable.**

3 Can your boss let you share the code that generates the lookup table?

Make an example python notebook

Follow

Gordon, Howard R., and Menghua Wang. "Retrieval of water-leaving radiance and aerosol optical thickness over the oceans with SeaWiFS: a preliminary algorithm." Applied optics 33.3 (1994): 443-452.

Comparison of RRS between HydroLight and OSOAA

I made a comparison between the results from OSOAA and HydroLight and found that there was a big gap between them.

  • The spectral shapes of the two are similar, but the order of magnitude is quite different.
  • When the concentration difference is large, the simulation results of OSOAA are relatively concentrated.
    This shows that the sensitivity of remote sensing reflectance simulated by OSOAA is not as high as that of HydroLight.
  • The simulated value of HydroLight is closer to the measured value.

Here are some detailed comparisons:

  1. Remote sensing reflectance curves of different chlorophyll concentrations

图片
图片

  1. The absorption coefficient of yellow matter = 0.3m-1, the concentration of inorganic suspended particles = 30mg / L, and the effect of chlorophyll concentration on water spectrum

图片
图片

  1. Remote sensing reflectance curve of inorganic suspended sediment with different concentrations
    图片
    图片

  2. The concentration of chlorophyll is 20mg / m3, the absorption coefficient of the yellow matter is 0.3m-1, and the influence of the concentration of inorganic suspended particles on the spectrum of the water body

图片
图片

  1. Remote sensing reflectance curves of CDOM with different concentrations
    图片
    图片

  2. The concentration of chlorophyll is 20mg / m3, the concentration of inorganic suspended particles is 20mg / L, and the influence of the absorption coefficient of yellow matter on water spectrum
    图片
    图片

The figure above of each example is simulated by HydroLight, and the figure below is simulated by OSOAA.

I believe in the results of HydroLight more because it is closer to the measured results. What do you think is the problem with OSOAA?

Rayleigh and Aerosol LUTs

Hello,

From the previous comments from OSOAA and pyOSOAA repositories, I understand that you were able to generate Rayleigh and Aerosol LUTs for Atmospheric Correction in SeaDAS. Can you please tell about the steps involved in generating those LUTs using OSOAA..?

Regards,
Suhail

lookup tables

Hello developers, I have some questions that I need your help with.
I want to generate lookup tables, so when I am using the runwavelengths function in pyosoaa, I set the solar zenith angle to 0-80° at 10° intervals and the relative azimuth to 0-180° at 5° intervals, resulting in an advanced and standard output file for each band and each angle under the OSOAA_ROOT results, so it takes up up all my ubuntu space.
What should I do? It seems that in order to use the pyOSOAA code you must have OSOAA simulate the results file, can you share the code for the lookup table?

Write readme file

Should include library description, required python libraries and OSOAA installation details.

documentation and parameter setting

Hi @fnemina, I am a new user to pyOSOAA and I think it is a really useful software. Thanks for sharing it!

I'd like to ask if a list of the various possibilities to update parameters is documented somewhere.
For example, I am not sure if the aerosol height scale ap.ha

self.ha = ha
can be modified.

Thank you

Mie scattering calculation

Hi, Have you ever tried to check the results of OSOAA MIE scattering calculation? I found in the log_aer.txt (/Advanced_outputs/log_aer.txt) that there is a difference between the calculated aerosol phase function and the calculated result of the Giss's FORTRAN code (https://www.giss.nasa.gov/staff/mmishchenko/ftpcode/spher.pbrf.f). For details, you can check the results of the Scattering cross-section and Asymmetry factor. Do you have any idea?

ERROR: no such file LUM_vsVZA.txt'

This error often occurs.

Exception has occurred: FileNotFoundError
[Errno 2] No such file or directory: '/home/lwk/RadiativeTransferCode-OSOAA/results/91f656cc11413214c60126e44f8389c2/Standard_outputs/LUM_vsVZA.txt'

can not run test with python3.7 on mac

import pyOSOAA
pyOSOAA.test()
Traceback (most recent call last):
File "", line 1, in
File "/Users/bjiang/Documents/pyOSOAA/pyOSOAA/osoaa.py", line 1386, in test
s = OSOAA()
File "/Users/bjiang/Documents/pyOSOAA/pyOSOAA/osoaa.py", line 1020, in init
self.dirmie = DIRMIE(osoaaroot=self.root)
File "/Users/bjiang/Documents/pyOSOAA/pyOSOAA/osoaa.py", line 198, in init
self.hyd = os.path.join(osoaaroot, hid)
File "/Users/bjiang/opt/anaconda3/envs/osoaa/lib/python3.7/posixpath.py", line 80, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Why not add the function to output Q & U ?

We know that the polarization component is becoming more and more important in the study of atmospheric radiative transport, so why not add the function of the output polarization component Q and U respectively?
(There seem to be "OSOAA.ResFile.Adv.Up" in the OSOAA code that output Q and U.)

Incorrect value handling with scientific notation

When writing values to the albedo variables (s.sea.botalb y s.sea.surfalb) the values are written in scientific notation by the script if they are small enough. If this happens but the number of number in the mantissa is to big OSOAA code doesn't read the value of the exponent and only the mantissa.

A general solution for this should be implemented by changing the precision of the written number in OSOAA.

Here a minimal example is shown

import pyOSOAA
import numpy as np
s = pyOSOAA.OSOAA()
s.sea.surfalb = np.pi/1e5
s.view.level = 1
s.run()
print(s.outputs.vsvza.I.max())

give us 5.68087 which is greater than 1 the maximum expected value. If we do

import pyOSOAA
import numpy as np
s = pyOSOAA.OSOAA()
s.sea.surfalb = np.round(np.pi/1e5,8)
s.view.level = 1
s.run()
print(s.outputs.vsvza.I.max())

we have 0.342374, the real value we were looking for.

pyOSOAA package run on windows

dear author:
I want to use pyOSOAA package on windows platform to calculate IOPS of inland water,and coupled with other model. The manual of pyOSOAA guide for Ubuntu, if something wrong with my computer environment variable path or gfortran?(error display just when i runing pyOSOAA.test()); in addition, may i get your email for further question.

Radiative transport process in water body

Hi fnemina~
I would like to ask whether it is possible to use OSOAA to simulate the underwater reflection process. For example, I put a known object 1 meter underwater and want to know the radiation field in 3 meters of water. Can OSOAA do this? If the model can do this, how should I set the parameters? Looking forward to your reply.

SED class has no default value

When i set sediment concentration s.sed.csed = 0.2.
Error:

OSOAA_MAIN : ERROR_2640 on parameters
   -->  Junge model for Mineral-Like Particles
        is required (-Keyword Value)  : 
           -SED.JD.slope (Float): Slope.
           -SED.JD.MRwa (Float): 
                real part of refractive index.
           -SED.JD.MIwa (Float): 
                imaginary part of refractive index.
           -SED.JD.rate (Float): Ratio of this mode
                for Mineral-Like Particles.

There is no default value for this value in your source code, can you add it?

I use the method you mentioned to compare NASA Seawifs Rayleigh lookup table with OSOAA Rayleigh scattering.

I use the method you mentioned to compare NASA Seawifs Rayleigh lookup table with OSOAA Rayleigh scattering.
But there are some differences between my results and yours.
My results:
fig_Relative error
Relative error is as high as 10%.
My code is here
So, i have some question:

  1. The tau which in NASA Seawifs Rayleigh lookup table cannot be used to calculate transmittance because OSOAA has its own Tau.

  2. What is the step size of the parameters in the Rayleigh scattering lookup table you generated? Can you share your code?

Originally posted by @QiaoFeng0419 in https://github.com/fnemina/AtmosphericCorrection/issues/1#issuecomment-512065537

How to compute whitecaps reflectance?

I see your case study. Simple radiative transfer equation: 𝜌𝑡 = 𝜌𝑟 + 𝜌𝑎 + 𝜌𝑟𝑎 + 𝜌𝑔 + 𝑡𝜌𝑤. But no whitecaps reflectance included. How to compute whitecaps reflectance?

Deleted package detected

I'm a Cyber Security researcher and developer of PackjGuard [1] to address open-source software supply chain attacks.

Issue

During my research, I detected a deleted package in this repository.

Details

Specifically, the package pyOSOAA mentioned in file README at line 27 does not exist on the public PyPI registry. A bad actor can hijack this package to propagate malicious code.

Impact

Not only your apps/services using https://github.com/fnemina/pyOSOAA repo code are vulnerable to this attack, but the users of your open-source Github repo could also fall victim.

You could read more about such attacks here: https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610

Remediation

Please highlight this in file README and register a placeholder package for pyOSOAA on public PyPI soon to remediate.

To automatically fix such issues in future, please install PackjGuard Github app [1].

Thanks!

  1. PackjGuard is a Github app that monitors your repos 24x7, detects vulnerable/malicious/risky open-source dependencies, and creates pull requests for auto remediation: https://github.com/marketplace/packjguard

RunWavelengths() got an unexpected keyword argument 'tau'

When i run rho_toa, tau = RunWavelengths(s, wl/1e3, angle=view, tau=True),
i get a exception TypeError: RunWavelengths() got an unexpected keyword argument 'tau'.
I find function RunWavelengths in your source code, but not see tau parameters.
If you update your local code, but not update to github?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.