コード例 #1
0
def get_tax_from_files(fnames):

    minyear = int(fnames[0].split(".")[-2])
    maxyear = int(fnames[-1].split(".")[-2])
    L = maxyear - minyear + 1
    tax = cdms.createAxis(np.arange(L * 12))
    tax.designateTime()
    tax.id = "time"
    tax.units = "months since " + str(minyear) + "-1-1"
    cdutil.setAxisTimeBoundsMonthly(tax)
    return tax
コード例 #2
0
def get_tax(experiment, L=None):
    if experiment.find("hist") == 0:
        if L is None:
            L = 165
        tax = cdms.createAxis(np.arange(L * 12))
        tax.designateTime()
        tax.id = "time"
        tax.units = "months since 1850-1-1"
    elif experiment.find("ssp") == 0:
        if L is None:
            L = 86
        tax = cdms.createAxis(np.arange(L * 12))
        tax.designateTime()
        tax.id = "time"
        tax.units = "months since 1850-1-1"
    elif experiment.find("piControl") == 0:
        if L is None:
            L = 500
        tax = cdms.createAxis(np.arange(L * 12))
        tax.designateTime()
        tax.id = "time"
        tax.units = "months since 0001-1-1"
    cdutil.setAxisTimeBoundsMonthly(tax)
    return tax
コード例 #3
0
src = sys.argv[1]

x = regression.init()

polar = vcsaddons.getpolar("annual_cycle")
polar.markers = ["dot"]
polar.markersizes = [3]

polar.magnitude_tick_angle = numpy.pi / 8

import cdms2, cdutil

f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
clt = f("clt")
cdutil.setAxisTimeBoundsMonthly(clt.getTime())
averaged_time = cdutil.averager(clt, axis="t")
averaged_time = averaged_time.reshape(
    (1, averaged_time.shape[0], averaged_time.shape[1]))
averaged_time_for_departures = numpy.repeat(averaged_time, len(clt), axis=0)

clt_departures = clt - averaged_time_for_departures
clt_departures.setAxisList(clt.getAxisList())
avg_departures = cdutil.averager(clt_departures, axis="xy")

theta = range(1, len(clt) + 1)
magnitude = avg_departures
polar.plot(magnitude, theta, bg=True, x=x)

fnm = "test_vcs_addons_polar_annual.png"
x.png(fnm)
コード例 #4
0
import sys, os
src = sys.argv[1]
import vcs.testing.regression as regression
import vcs
import vcsaddons, numpy, MV2
import cdms2, cdutil, cdtime

x = regression.init()

f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
# Trim first few months and last month so we have even number of seasons
cloudiness = f('clt', time=(11, 119))
cdutil.setAxisTimeBoundsMonthly(cloudiness.getTime())
cloudiness_time_axis = cloudiness.getTime()
averaged_seasons = MV2.zeros((36, 46, 72))
# Average the seasons in cloudiness
for i in range(36):
    averaged_seasons[i] = cdutil.averager(
        cloudiness(time=(cloudiness_time_axis[i * 3],
                         cloudiness_time_axis[(i + 1) * 3])),
        axis="t")

averaged_seasons.setAxis(1, cloudiness.getLatitude())
averaged_seasons.setAxis(2, cloudiness.getLongitude())

regions = {
    "north_polar": (66, 90),
    "north_temperate": (22, 66),
    "tropics": (-22, 22),
    "south_temperate": (-66, -22),
    "south_polar": (-90, -66)
コード例 #5
0
src = sys.argv[1]

x = regression.init()

polar = vcsaddons.getpolar("annual_cycle")
polar.markers = ["dot"]
polar.markersizes = [3]

polar.magnitude_tick_angle = numpy.pi / 8

import cdms2, cdutil

f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
clt = f("clt")
cdutil.setAxisTimeBoundsMonthly(clt.getTime())
averaged_time = cdutil.averager(clt, axis="t")
averaged_time = averaged_time.reshape((1, averaged_time.shape[0], averaged_time.shape[1]))
averaged_time_for_departures = numpy.repeat(averaged_time, len(clt), axis=0)

clt_departures = clt - averaged_time_for_departures
clt_departures.setAxisList(clt.getAxisList())
avg_departures = cdutil.averager(clt_departures, axis="xy")

theta = range(1, len(clt) + 1)
magnitude = avg_departures
polar.plot(magnitude, theta, bg=True, x=x)

fnm = "test_vcs_addons_polar_annual.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
コード例 #6
0
import sys,os
src = sys.argv[1]
import vcs.testing.regression as regression
import vcs
import vcsaddons, numpy, MV2
import cdms2, cdutil, cdtime

x = regression.init()

f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
# Trim first few months and last month so we have even number of seasons
cloudiness = f('clt', time=(11, 119))
cdutil.setAxisTimeBoundsMonthly(cloudiness.getTime())
cloudiness_time_axis = cloudiness.getTime()
averaged_seasons = MV2.zeros((36, 46, 72))
# Average the seasons in cloudiness
for i in range(36):
    averaged_seasons[i] = cdutil.averager(cloudiness(time=(cloudiness_time_axis[i * 3], cloudiness_time_axis[(i+1) * 3])), axis="t")

averaged_seasons.setAxis(1, cloudiness.getLatitude())
averaged_seasons.setAxis(2, cloudiness.getLongitude())

regions = {
    "north_polar": (66, 90),
    "north_temperate": (22, 66),
    "tropics": (-22, 22),
    "south_temperate": (-66, -22),
    "south_polar": (-90, -66)
}

def get_region_avg(var, r, axis="xy"):