CFMIP / COSPv2.0

COSP - The CFMIP (Cloud Feedbacks Model Intercomparison Project) Observation Simulator Package
42 stars 40 forks source link

Masking fix in cosp_diag_warmrain? #63

Closed dustinswales closed 2 years ago

dustinswales commented 2 years ago

cosp_diag_warmrain relies on the MODIS LWP(IWP)'s to determine when to perform a retrieval, https://github.com/CFMIP/COSPv2.0/blob/master/src/cosp_stats.F90#L345

However, the MODIS LWP is set to R_UNDEF, -999, for non-sunlit points prior to this routine being called. In these cases, zeros are being assigned for some of the diagnostics, where they should be set to R_UNDEF and omitted for the statistics.

This came up in an unrelated PR from 2019 (https://github.com/CFMIP/COSPv2.0/pull/36).

dustinswales commented 2 years ago

The wrinkle to this is cloud-free scenes and dark scenes are both set to R_UNDEF in the modis-simulator. We want to include to former, but not the latter.

takmichibata commented 2 years ago

@dustinswales I apporogize for this bug and late reply. The warm rain diagnostics did intend to use only daytime cloudy scenes, but actually the current code did not explicitly exclude dark-scene columns from the analysis. To fix this bug, I will change the following two places as suggested by @brhillman and @dustinswales at the previous PR from 2019 (#36).

https://github.com/CFMIP/COSPv2.0/blob/master/src/cosp_stats.F90#L338

!! initialize
 do i = 1, Npoints
    if ( lwp(i) .eq. R_UNDEF ) then  ! for non-sunlit columns
       cfodd_ntotal(i,:,:,:) = R_UNDEF
       wr_occfreq_ntotal(i,:) = R_UNDEF
       icod(i,:,:) = R_UNDEF
    else
       cfodd_ntotal(i,:,:,:)  = 0._wp
       wr_occfreq_ntotal(i,:) = 0._wp
       icod(i,:,:) = 0._wp
    endif
 enddo

https://github.com/CFMIP/COSPv2.0/blob/master/src/cosp_stats.F90#L345

    if ( ( lwp(i)   .le.  CWP_THRESHOLD  .and. lwp(i)  .ne.  R_UNDEF  ) .or.  &

I think this change will work appropriately for the issue. I push the bug-fix later via pull request.

takmichibata commented 2 years ago

@dustinswales I think that we can now close this thread, as we have corrected this bug in the recent PR (#73). Thank you for your support.

dustinswales commented 2 years ago

@takmichibata Excellent! Thanks for your work on this!