コード例 #1
0
ファイル: meridhov_plot_anom.py プロジェクト: vnoel/clouds_ia
def main(infile='series_40.npz'):

    npz = np.load(infile)
    nprof = npz['nprof']
    vcm = npz['vcm']
    time = npz['time']
    lon = npz['lon']
    altmin = npz['altmin']

    # exchange time and altmin axes
    vcm = vcm.swapaxes(0, 1)
    # now vcm[altmin,time,lon]

    # average year
    # find the vector of julian days for a typical year
    jdays = []
    time_avg = []
    for d in time:
        if d.year == 2007:
            jdays.append((d - datetime(2007, 1, 1)).days)
            time_avg.append(d)

    nprof_avg = np.zeros([len(jdays), vcm.shape[2]])
    vcm_avg = dict()
    for ialtmin in range(len(altmin)):
        vcm_avg[ialtmin] = np.zeros([len(jdays), vcm.shape[2]])
    cf_anom = np.zeros_like(vcm, dtype='float64')

    for i, jday in enumerate(jdays):

        idx = np.array(
            [jday == (date - datetime(date.year, 1, 1)).days for date in time])
        print jday, ' - found {} days'.format(idx.sum())
        nprof_avg[i, :] = np.sum(nprof[idx, :], axis=0)

        for ialtmin in 0, 1, 2:

            vcm_avg[ialtmin][i, :] = np.sum(vcm[ialtmin, idx, :], axis=0)
            cf_avg = 1. * vcm_avg[ialtmin][i, :] / nprof_avg[i, :]
            actual_cf = 1. * vcm[ialtmin, idx, :] / nprof[idx, :]
            cf_anom[ialtmin, idx, :] = actual_cf - cf_avg

    for ialtmin in 0, 1, 2:

        cf = 100. * vcm_avg[ialtmin] / nprof_avg
        pcolor_meridhov(
            time_avg, lon, cf,
            'clouds above %2d km - Average year' % (altmin[ialtmin]))
        nice.savefig(infile[:-4] + '_avg_above%02dkm.png' % (altmin[ialtmin]))

        pcolor_meridhov(time,
                        lon,
                        cf_anom[ialtmin],
                        'clouds above > %2d km - Anomaly' % (altmin[ialtmin]),
                        anom=True)
        nice.savefig(infile[:-4] + '_anom_above%02dkm.png' % (altmin[ialtmin]))

    plt.show()
コード例 #2
0
def main(year=2007):

    import glob

    year = int(year)
    mask = './out/%04d/*nc4' % (year)

    grid_files = glob.glob(mask)
    grid_files.sort()

    show_files(grid_files, '2007')

    nice.savefig('zonal_cf_%04d.png' % (year))
    plt.show()
コード例 #3
0
def main(year, month):

    import glob

    year = int(year)
    month = int(month)
    mask = './out.40/%04d/vcm_zonal_%04d%02d*.nc4' % (year, year, month)

    grid_files = glob.glob(mask)
    assert len(grid_files) > 0
    grid_files.sort()

    show_files(grid_files, 'bof')

    nice.savefig('zonal_cf_%04d%02d.png' % (year, month))
    plt.show()
コード例 #4
0
ファイル: meridhov_plot.py プロジェクト: vnoel/clouds_ia
def main(infile='series_40.npz'):

    npz = np.load(infile)
    nprof = npz['nprof']
    vcm = npz['vcm']
    time = npz['time']
    lon = npz['lon']
    altmin = npz['altmin']
    vcm = vcm.swapaxes(0, 1)

    pcolor_meridhov(time, lon, nprof, 'Number of profiles')
    nice.savefig('%s_nprof.png' % (infile[:-4]))

    for ialtmin in 0, 1, 2:
        cf = 1. * vcm[ialtmin, ...] / nprof
        pcolor_meridhov(time, lon, 100. * cf,
                        'Above %2d km' % (altmin[ialtmin]))
        nice.savefig('%s_above%02dkm.png' % (infile[:-4], altmin[ialtmin]))

    plt.show()
コード例 #5
0
def main(infile='tropic_width_40.npz'):

    npz = np.load(infile)
    tmin, tmax, time = npz['tmin'], npz['tmax'], npz['datetimes']

    tmin = np.array(tmin).item()
    tmax = np.array(tmax).item()

    newdates, tmin_amean, tmax_amean, tsize_amean = average_year(
        time, tmin, tmax)

    fig = plt.figure()

    plt.subplot(2, 1, 1)

    for vcm_min in vcm_mins:
        tmin = np.ma.masked_invalid(tmin_amean[vcm_min])
        tmax = np.ma.masked_invalid(tmax_amean[vcm_min])
        plt.fill_between(newdates, tmin, tmax, alpha=0.3)
        plt.text(vcm_x[vcm_min], vcm_y[vcm_min], 'CF > %4.2f' % vcm_min)
    plt.gca().xaxis.set_major_formatter(fmt)
    plt.title('Average 2006-2014')
    plt.grid()
    fig.autofmt_xdate()

    plt.subplot(2, 1, 2)

    for vcm_min in vcm_mins:
        tsize = np.ma.masked_invalid(tsize_amean[vcm_min])
        plt.fill_between(newdates, tsize, alpha=0.3)
    plt.gca().xaxis.set_major_formatter(fmt)
    plt.title('Average 2006-2014')
    plt.grid()
    fig.autofmt_xdate()

    nice.savefig('width_avg_year.pdf')

    plt.show()
コード例 #6
0
ファイル: show_width.py プロジェクト: vnoel/clouds_ia
def main(infile='tropic_width_40.npz'):
    npz = np.load(infile)
    tmin, tmax, time = npz['tmin'], npz['tmax'], npz['datetimes']

    tmin = np.array(tmin).item()
    tmax = np.array(tmax).item()

    plt.figure(figsize=[24, 7])
    plt.subplot(2, 1, 1)
    for vcm_min in vcm_mins:
        this_tmin = np.array(tmin[vcm_min])
        this_tmin = np.ma.masked_where(this_tmin < -90, this_tmin)
        this_tmax = np.array(tmax[vcm_min])
        this_tmax = np.ma.masked_where(this_tmax < -90, this_tmax)
        # plt.plot(time, this_tmin, colors[vcm_min])
        # plt.plot(time, this_tmax, colors[vcm_min])
        plt.fill_between(time, this_tmin, this_tmax, alpha=0.3)
    plt.ylabel('Latitude')
    plt.legend(loc='center right')
    plt.grid()

    plt.subplot(2, 1, 2)
    for vcm_min in vcm_mins:
        this_tmin = np.array(tmin[vcm_min])
        this_tmin = np.ma.masked_where(this_tmin < -90, this_tmin)
        this_tmax = np.array(tmax[vcm_min])
        this_tmax = np.ma.masked_where(this_tmax < -90, this_tmax)
        # plt.plot(time, this_tmax - this_tmin, colors[vcm_min])
        plt.fill_between(time, 0, this_tmax - this_tmin, alpha=0.3)
    plt.ylim(0, 50)
    plt.ylabel('Tropics meridional height')
    plt.grid()

    nice.savefig(infile[:-4] + '.pdf')

    plt.show()
コード例 #7
0
ファイル: cf_show.py プロジェクト: vnoel/clouds_ia
def main():

    npz = np.load('ceilings_40.npz')
    dt = npz['datetimes']
    nprof = npz['nprof']
    cprof = npz['cprof']
    lat = npz['lat']

    idx = (lat > -82) & (lat < 82)
    nprof = nprof[0:len(dt), idx]
    cprof = cprof[0:len(dt), idx]
    lat = lat[idx]
    nprof = nprof.sum(axis=1)
    cprof = cprof.sum(axis=1)

    plt.figure(figsize=[20, 5])
    plt.plot(dt, nprof, label='Total profiles')
    plt.plot(dt, cprof, label='Cloudy profiles')
    plt.legend()
    plt.grid()

    cf = 100. * cprof / nprof
    badidx = (cf < 57) | (nprof < 1.7e7)

    plt.figure(figsize=[24, 4])
    plt.plot(dt, cf)
    plt.plot(dt[badidx], cf[badidx], 'r*')
    plt.grid()
    plt.ylabel('Cloud Fraction [%]')
    plt.title('2006-2014')
    nice.savefig('cf.png')

    avgdt, avgnprof = average_year(dt, nprof)
    avgdt, avgcprof = average_year(dt, cprof)
    avgcf = 100. * avgcprof / avgnprof

    plt.figure(figsize=[10, 5])
    plt.plot(avgdt, avgcf)
    plt.grid()
    plt.ylabel('Cloud Fraction [%]')
    plt.title('Average 2006-2014')
    nice.savefig('cf_avg.png')
    plt.gca().xaxis.set_major_formatter(fmt)

    cfanom = anomalies(avgdt, avgcf, dt, cf)
    cfanom = np.ma.masked_where(badidx, cfanom)

    plt.figure(figsize=[24, 4])
    plt.plot(dt, cfanom)
    plt.fill_between(dt, 0, cfanom, alpha=0.2)
    plt.grid()
    plt.ylabel('Cloud Fraction Anomalies [%]')
    plt.title('2006-2014')
    nice.savefig('cf_anom.png')

    plt.figure(figsize=[24, 4])
    plt.plot(dt, cf, label='Cloud Fraction')
    plt.plot(dt, cf - cfanom, color='grey', label='Average 2006-2014')
    cfavg = cf - cfanom
    cfred = np.ma.masked_where(cfanom < 0, cf)
    plt.fill_between(dt, cfred, cfred - cfanom, color='red', alpha=0.2)
    cfblue = np.ma.masked_where(cfanom > 0, cf)
    plt.fill_between(dt, cfblue, cfblue - cfanom, color='blue', alpha=0.2)
    plt.grid()
    plt.legend()
    plt.ylabel('Cloud Fraction [%]')
    plt.title('2006-2014')
    nice.savefig('cf_anom_bluered.png')

    plt.show()
コード例 #8
0
def main():

    npz = np.load('ceilings_40.npz')
    dt = npz['datetimes']
    nprof = npz['nprof']
    cprof = npz['cprof']
    lat = npz['lat']

    dtnum = mdates.date2num(dt)

    nprof = nprof[0:len(dt), :]
    cprof = cprof[0:len(dt), :]

    nprofl = np.sum(nprof, axis=0)
    cfl = 100. * np.sum(cprof, axis=0) / nprofl
    plt.figure()
    plt.plot(lat, cfl)

    nproft = np.sum(nprof, axis=1)
    cft = 100. * np.sum(cprof, axis=1) / nproft
    badidx = (cft < 57) | (nproft < 1.7e7)

    cf = 100. * cprof / nprof
    cf[badidx, :] = np.nan
    cf = np.ma.masked_where(nprof == 0, cf)
    cf = np.ma.masked_invalid(cf)

    print dtnum.shape, lat.shape, cf.shape
    avgdt, avgcf = average_year(dt, nprof, cprof)
    avgdtnum = mdates.date2num(avgdt)

    plt.figure(figsize=[24, 4])
    plt.pcolormesh(dtnum, lat, cf.T)
    plt.xlim(dtnum[0], dtnum[-1])
    plt.ylim(-60, 60)
    plt.gca().xaxis.axis_date()
    plt.grid()
    plt.clim(30, 100)
    plt.title('Cloud Fraction')
    plt.colorbar()
    nice.savefig('cfz.png')

    plt.figure(figsize=[10, 5])
    plt.pcolormesh(avgdtnum, lat, avgcf.T)
    plt.xlim(avgdtnum[0], avgdtnum[-1])
    plt.ylim(-60, 60)
    plt.gca().xaxis.axis_date()
    plt.gca().xaxis.set_major_formatter(fmt)
    plt.clim(30, 100)
    plt.title('Cloud Fraction average 2006-2014')
    plt.colorbar()
    plt.grid()
    nice.savefig('cfz_avg.png')

    anom = anomalies(avgdt, avgcf, dt, cf)

    plt.figure(figsize=[24, 4])
    plt.pcolormesh(dtnum, lat, anom.T, cmap='RdBu_r')
    plt.xlim(dtnum[0], dtnum[-1])
    plt.ylim(-60, 60)
    plt.gca().xaxis.axis_date()
    plt.grid()
    plt.clim(-10, 10)
    plt.title('Cloud Fraction Anomalies [%]')
    plt.colorbar()
    nice.savefig('cfz_anom.png')

    plt.show()