Beispiel #1
0
def read_cci_ctth(cci_nc):
    """Read cloud top: temperature, height and pressure from filename
    """
    ctth = CtthObj()
    cth = cci_nc.variables['cth'][::]
    if hasattr(cth, 'mask'):
        cth_data = np.where(cth.mask, ATRAIN_MATCH_NODATA, cth.data)
    else:
        cth_data = cth.data  # already scaled!

    logger.info("Setting ctth for non cloudy pixels do nodata ...")
    cth_data[cci_nc.variables['cc_total'][::] < 0.5] = ATRAIN_MATCH_NODATA

    cth_corr = cci_nc.variables['cth_corrected'][::]
    if hasattr(cth_corr, 'mask'):
        cth_data_corr = np.where(cth_corr.mask, ATRAIN_MATCH_NODATA, cth_corr.data)
    else:
        cth_data_corr = cth_corr.data  # already scaled!
    logger.debug("Setting ctth for non cloudy pixels do nodata ...")
    cth_data_corr[cci_nc.variables['cc_total'][::] < 0.5] = ATRAIN_MATCH_NODATA

    ctth.h_gain = 1.0
    ctth.h_intercept = 0.0
    ctth.h_nodata = ATRAIN_MATCH_NODATA
    ctth.height = 1000*cth_data
    ctth.height_corr = 1000*cth_data_corr

    ctt = cci_nc.variables['ctt'][::]
    if hasattr(ctt, 'mask'):
        ctt_data = np.where(ctt.mask, ATRAIN_MATCH_NODATA, ctt.data)
    else:
        ctt_data = ctt.data
    logger.debug("Setting ctth for non cloudy pixels do nodata ...")
    ctt_data[cci_nc.variables['cc_total'][::] < 0.5] = ATRAIN_MATCH_NODATA

    ctth.t_gain = 1.0
    ctth.t_intercept = 0.0
    ctth.t_nodata = ATRAIN_MATCH_NODATA
    ctth.temperature = ctt_data

    ctp = cci_nc.variables['ctp'][::]
    if hasattr(ctp, 'mask'):
        ctp_data = np.where(ctp.mask, ATRAIN_MATCH_NODATA, ctp.data)  # Upscaled
    else:
        ctp_data = ctp.data
    ctth.p_gain = 1.0
    ctth.p_intercept = 0.0
    ctth.p_nodata = ATRAIN_MATCH_NODATA
    logger.debug("Setting ctth for non cloudy pixels do nodata ...")
    ctp_data[cci_nc.variables['cc_total'][::] < 0.5] = ATRAIN_MATCH_NODATA
    ctth.pressure = ctp_data

    return ctth
Beispiel #2
0
def read_patmosx_ctype_cmask_ctth(patmosx_nc):
    """Read cloudtype and flag info from filename."""
    ctth = CtthObj()
    ctype = CtypeObj()
    cma = CmaObj()
    ctth.height = patmosx_nc.variables['cld_height_acha'][0, :, :].astype(np.float)
    ctth.h_nodata = patmosx_nc.variables['cld_height_acha']._FillValue
    if np.ma.is_masked(ctth.height):
        ctth.height.data[ctth.height.mask] = ATRAIN_MATCH_NODATA
        ctth.height = ctth.height.data
    ctth.height = 1000*ctth.height
    cf = patmosx_nc.variables['cloud_fraction'][0, :, :].astype(np.float)
    cma.cma_ext = np.where(cf >= 0.5, 1, 0)
    if np.ma.is_masked(cf):
        cma.cma_ext[cf.mask] = 255
    ctype.phaseflag = None
    ctype.ct_conditions = None
    return ctype, cma, ctth
Beispiel #3
0
def read_patmosx_ctype_cmask_ctth_hdf(patmosx_hdf):
    """Read cloudtype and flag info from filename."""
    ctth = CtthObj()
    ctype = CtypeObj()
    cma = CmaObj()
    name = 'cld_height_acha'
    height_unscaled = np.array(patmosx_hdf.select(name).get())
    offset = patmosx_hdf.select(name).attributes()['add_offset']
    gain = patmosx_hdf.select(name).attributes()['scale_factor']
    ctth.height = height_unscaled * gain + offset
    ctth.h_nodata = patmosx_hdf.select(name)._FillValue
    # ctth.height = 1000*ctth.height
    ctth.height[height_unscaled == ctth.h_nodata] = ATRAIN_MATCH_NODATA
    name = 'cloud_fraction'
    cf_unscaled = np.array(patmosx_hdf.select(name).get())
    offset = patmosx_hdf.select(name).attributes()['add_offset']
    gain = patmosx_hdf.select(name).attributes()['scale_factor']
    cf = cf_unscaled * gain + offset
    cf[cf_unscaled == patmosx_hdf.select(name)._FillValue] = ATRAIN_MATCH_NODATA
    cma.cma_ext = np.where(cf >= 0.5, 1, 0)
    ctype.phaseflag = None
    ctype.ct_conditions = None
    return ctype, cma, ctth