Beispiel #1
0
def read_oca_secondlayer_info(oca_nc):
    """Read ctth pressure file, for second layer."""
    ctth2 = CtthObj()
    ctth2.pressure, ctth2.p_nodata = scale_oca_var(
        oca_nc['data']['measurement_data']['ctp'])
    ctth2.temperature, ctth2.t_nodata = scale_oca_var(
        oca_nc['data']['measurement_data']['ctt'])
    aux_dict = {"CTTH2": ctth2}
    aux_obj = AuxiliaryObj(aux_dict)
    return aux_obj
Beispiel #2
0
def read_oca_ctype_cmask_ctth_modis(oca_nc):
    """Read ctth pressure file."""
    ctth = CtthObj()
    ctype = CtypeObj()
    cma = CmaObj()
    ctth.pressure, ctth.p_nodata = scale_oca_var_modis(oca_nc['ctp'])
    ctth.temperature, ctth.t_nodata = scale_oca_var_modis(oca_nc['ctt'])

    cma.cma_ext = np.where(oca_nc['moca_model_final'][:] > 0, 1, 0)
    ctype.phaseflag = None
    ctype.ct_conditions = None
    return ctype, cma, ctth
Beispiel #3
0
def read_oca_ctype_cmask_ctth(oca_nc):
    """Read ctth pressure file."""
    ctth = CtthObj()
    ctype = CtypeObj()
    cma = CmaObj()
    ctth.pressure, ctth.p_nodata = scale_oca_var(
        oca_nc['data']['measurement_data']['ctp'])
    ctth.temperature, ctth.t_nodata = scale_oca_var(
        oca_nc['data']['measurement_data']['ctt'])
    cma.cma_ext = np.where(ctth.pressure > 0, 1, 0)
    ctype.phaseflag = None
    ctype.ct_conditions = None
    return ctype, cma, ctth
Beispiel #4
0
def read_maia_ctype_cmask_ctth(maia_h5):
    """Read cloudtype and flag info from filename
    """
    ctth = CtthObj()
    ctype = CtypeObj()
    cma = CmaObj()
    # ctth = CtthObj()
    cma.cma_ext
    maia_ct_bitflag = maia_h5['DATA']['CloudType'].value  # bit-4-8
    maia_ct = get_maia_ct_flag(maia_ct_bitflag)
    maia_ct[maia_ct == 7] = 6
    maia_ct[maia_ct == 9] = 7
    maia_ct[maia_ct == 11] = 8
    maia_ct[maia_ct == 13] = 9
    maia_ct[maia_ct == 15] = 11
    maia_ct[maia_ct == 16] = 12
    maia_ct[maia_ct == 17] = 13
    maia_ct[maia_ct == 18] = 14
    maia_ct[maia_ct == 19] = 10

    ctype.cloudtype = maia_ct
    cma.cma_ext = 0 * maia_ct
    cma.cma_ext[maia_ct == 0] = 255
    cma.cma_ext[maia_ct == 1] = 0
    cma.cma_ext[maia_ct == 2] = 0
    cma.cma_ext[maia_ct == 3] = 3
    cma.cma_ext[maia_ct == 4] = 3
    cma.cma_ext[np.logical_and(maia_ct > 4, maia_ct < 20)] = 1
    # 0 -nodata
    # 1-2 clear
    # 34 -snow/ice
    # 5-19 cloudy
    ctype.phaseflag = None
    ctype.ct_conditions = None
    ctth.height = 5000.0 * maia_ct
    ctth.temperature = ATRAIN_MATCH_NODATA + 0 * maia_ct
    ctth.pressure = ATRAIN_MATCH_NODATA + 0 * maia_ct
    # ctype.landseaflag =
    return ctype, cma, ctth
Beispiel #5
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
Beispiel #6
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 #7
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