JCSDA-internal / ioda-converters

Various converters for getting obs data in and out of IODA
9 stars 4 forks source link

Update VIIRS L1b Albedo converter #1522

Closed weiwilliam closed 3 months ago

weiwilliam commented 3 months ago

Description

This PR adds the needed sensorViewAngle and sensorScanPosition in VIIRS L1b IODA file for UFO CRTM passive radiance simulation.

We may need to revisit whether the stored reflectance need to convert to true reflectance with divide by cosine of solar zenith angle at Line 188.

Dependencies

No dependencies

Impact

No impacts on other repos

Checklist

weiwilliam commented 3 months ago

@gthompsnJCSDA I have added an input argument to decide whether the obsvals should multiply the secant of the solar zenith angle.

jeromebarre commented 3 months ago

Looks good to me I haven't tested it.

weiwilliam commented 3 months ago

Here is a sample image processed for 2021 August 5 04-05Z. Used ncks to pick every 70 points. image

weiwilliam commented 3 months ago

@BenjaminRuston @gthompsnJCSDA I would like to leave the sec_term calculation as it was because it will never be the case to get zero from np.cos with using np.pi inside. I understand that the cosine of 0.5 pi is zero mathematically, but np.pi won't be exactly the mathematical pi. So the np.cos(0.5 * np.pi) is very close to zero but not zero. But I will take Ben's suggestion to update the code in the channel loop.

gthompsnJCSDA commented 3 months ago

@BenjaminRuston @weiwilliam This conversation about possible divide by zero is going on way too long. Remember, you could have an angle times PI that results in the division by zero. It's not that PI will never be exact, but what about the angle being just the magic number needed so that the COS function gives the zero. So perhaps the true safe way to work is testing for 90 +- epsilon to avoid any chance for floating point exception.

The one-line IF-tests are really, really hard to read compared to the original idea of sec_term = 1.0 then reassign new value if using the option. That truly is far more readable if you ask me.

Otherwise we are wasting a lot of time just discussing such a minor issue.

weiwilliam commented 3 months ago

@gthompsnJCSDA Agree, now I make it calculate sectant solar za when cosine za is not zero. Then it should be able to avoid any magic numbers make cosine zero.

And I quickly gave it a try with 200,000 values between 89 to 91 degrees. There is no zero value in np.cos results.