pytroll / fogpy

Satellite based fog and low stratus detection and nowcasting
http://fogpy.readthedocs.io/en/latest
GNU General Public License v3.0
20 stars 10 forks source link

What to do when margin is colder than cloud top? #10

Open gerritholl opened 5 years ago

gerritholl commented 5 years ago

In fogpy.algorithms.LowCloudHeightAlgorithm.procedure:

https://github.com/gerritholl/fogpy/blob/2c9aa9436e4924f55879d52a9de14817d370df5a/fogpy/algorithms.py#L648-L651

When zcenter==0 and (zneigh==0).all(), this causes zmargin==[0.0, 0.0, 0.0], delta_z==0, which means that apply_lapse_rate returns nan. Not sure what to do about it.

This causes the RuntimeWarning: Mean of empty slice warning referred to in #9.

gerritholl commented 5 years ago

This is covered by:

https://github.com/gerritholl/fogpy/blob/2c9aa9436e4924f55879d52a9de14817d370df5a/fogpy/algorithms.py#L689-L691

So the implementation does appear to consider this, which means the warning must have been there before.

gerritholl commented 5 years ago

Actually, it rather seems to happen when the cloud top temperature is higher (warmer) than the centre pixel.

gerritholl commented 5 years ago

Example of an extreme case:

ipdb> p tcenter, tmargin
(256.846, [249.6363525390625, 253.1262664794922])

This would place the cloud top height at -1335 metre and -689 metre, which is why it gets set to nan:

https://github.com/gerritholl/fogpy/blob/2c9aa9436e4924f55879d52a9de14817d370df5a/fogpy/algorithms.py#L909-L917

And then np.nanmean([nan, nan]) gives the RuntimeWarning.

Now why is the cloud top temperature here so warm?

gerritholl commented 5 years ago

So, in summary:

  1. Channel 108 measures higher temperature at cloud top than at first pixel outside cloud
  2. Fogpy calculates negative cloud top height (in the case where topography does not allow cloud top height calculation)
  3. Fogpy then sets cloud top height to nan
  4. Those nans later cause a RuntimeWarning in nanmean