import sys, os
import vcs.testing.regression as regression
import vcs
import vcsaddons, numpy

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
f = cdms2.open(os.path.join(vcs.sample_data, "thermo.nc"))
temp = f('t')
levels = temp.getLevel()
time = temp.getTime()
# Break up temp by level
magnitudes = [temp[:, i] for i in range(temp.shape[1])]
for i, mag in enumerate(magnitudes):
    mag.id = "%0.f %s" % (levels[i], levels.units)

times = []
for t in time:
    reltime = cdtime.relativetime(t, time.units)
    comptime = reltime.tocomponent()
    times.append(comptime.hour)

thetas = [times] * len(magnitudes)

polar = vcsaddons.getpolar("diurnal")
polar.markers = ["dot"]
polar.markersizes = [3]
polar.markercolors = vcs.getcolors(list(levels))

polar.magnitude_tick_angle = numpy.pi / 8

polar.plot(magnitudes, thetas, bg=True, x=x)

fnm = "test_vcs_addons_polar_diurnal.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
sys.exit(ret)
Exemple #3
0
    "tropics": (-22, 22),
    "south_temperate": (-66, -22),
    "south_polar": (-90, -66)
}


def get_region_avg(var, r, axis="xy"):
    avg = cdutil.averager(var(latitude=regions[r]), axis=axis)
    avg.id = r
    return avg


magnitudes = [get_region_avg(averaged_seasons, region) for region in regions]
thetas = [range(4) * 27] * 5

polar = vcsaddons.getpolar("seasonal")
polar.datawc_y1 = 0
polar.datawc_y2 = 100
polar.markers = ["dot"]
polar.markersizes = [3]
polar.markercolors = vcs.getcolors([-90, -66, -22, 22, 66, 90], split=False)

polar.magnitude_tick_angle = numpy.pi / 4

polar.plot(magnitudes, thetas, bg=True, x=x)

fnm = "test_vcs_addons_polar_seasonal.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
sys.exit(ret)
    "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"):
    avg = cdutil.averager(var(latitude=regions[r]), axis=axis)
    avg.id = r
    return avg

magnitudes = [get_region_avg(averaged_seasons, region) for region in regions]
thetas = [range(4) * 27] * 5

polar = vcsaddons.getpolar("seasonal")
polar.datawc_y1 = 0
polar.datawc_y2 = 100
polar.markers = ["dot"]
polar.markersizes = [3]
polar.markercolors = vcs.getcolors([-90, -66, -22, 22, 66, 90], split=False)

polar.magnitude_tick_angle = numpy.pi / 4

polar.plot(magnitudes, thetas, bg=True, x=x)

fnm = "test_vcs_addons_polar_seasonal.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
sys.exit(ret)
import sys,os
import testing.regression as regression
import vcs
import vcsaddons, numpy

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)
import sys
src = sys.argv[1]
import testing.regression as regression
import vcs
import vcsaddons, numpy

x = regression.init()

polar = vcsaddons.getpolar("degrees")
polar.markers = ["dot", "circle"]
polar.markersizes = [3, 5]

polar.magnitude_tick_angle = numpy.pi / 6

theta = numpy.array(range(0, 720, 2))
magnitude = 9 * numpy.sin(5 * 2 * numpy.pi * theta / 360)
polar.datawc_y1 = 0
polar.datawc_y2 = max(magnitude)
polar.plot(magnitude, theta, bg=True, x=x)

fnm = "test_vcs_addons_polar_degrees.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
sys.exit(ret)
f = cdms2.open(os.path.join(vcs.sample_data, "thermo.nc"))
temp = f('t')
levels = temp.getLevel()
time = temp.getTime()
# Break up temp by level
magnitudes = [temp[:,i] for i in range(temp.shape[1])]
for i, mag in enumerate(magnitudes):
    mag.id = "%0.f %s" % (levels[i], levels.units)

times = []
for t in time:
    reltime = cdtime.relativetime(t, time.units)
    comptime = reltime.tocomponent()
    times.append(comptime.hour)

thetas = [times] * len(magnitudes)

polar = vcsaddons.getpolar("diurnal")
polar.markers = ["dot"]
polar.markersizes = [3]
polar.markercolors = vcs.getcolors(list(levels))

polar.magnitude_tick_angle = numpy.pi / 8

polar.plot(magnitudes, thetas, bg=True, x=x)

fnm = "test_vcs_addons_polar_diurnal.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
sys.exit(ret)
f = cdms2.open(os.path.join(vcs.sample_data, "thermo.nc"))
temp = f('t')
levels = temp.getLevel()
time = temp.getTime()
# Break up temp by level
magnitudes = [temp[:,i] for i in range(temp.shape[1])]
for i, mag in enumerate(magnitudes):
    mag.id = "%0.f %s" % (levels[i], levels.units)

times = []
for t in time:
    reltime = cdtime.relativetime(t, time.units)
    comptime = reltime.tocomponent()
    times.append(comptime.hour % 12)

thetas = [times] * len(magnitudes)

polar = vcsaddons.getpolar("semidiurnal")
polar.markers = ["dot"]
polar.markersizes = [3]
polar.markercolors = vcs.getcolors(list(levels))

polar.magnitude_tick_angle = numpy.pi / 8

polar.plot(magnitudes, thetas, bg=True, x=x)

fnm = "test_vcs_addons_polar_semidiurnal.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
sys.exit(ret)
Exemple #9
0
f = cdms2.open(os.path.join(vcs.sample_data, "thermo.nc"))
temp = f('t')
levels = temp.getLevel()
time = temp.getTime()
# Break up temp by level
magnitudes = [temp[:, i] for i in range(temp.shape[1])]
for i, mag in enumerate(magnitudes):
    mag.id = "%0.f %s" % (levels[i], levels.units)

times = []
for t in time:
    reltime = cdtime.relativetime(t, time.units)
    comptime = reltime.tocomponent()
    times.append(comptime.hour % 12)

thetas = [times] * len(magnitudes)

polar = vcsaddons.getpolar("semidiurnal")
polar.markers = ["dot"]
polar.markersizes = [3]
polar.markercolors = vcs.getcolors(list(levels))

polar.magnitude_tick_angle = numpy.pi / 8

polar.plot(magnitudes, thetas, bg=True, x=x)

fnm = "test_vcs_addons_polar_semidiurnal.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
sys.exit(ret)
import sys
src = sys.argv[1]
import vcs.testing.regression as regression
import vcs
import vcsaddons, numpy

x = regression.init()

polar = vcsaddons.getpolar("degrees")
polar.markers = ["dot", "circle"]
polar.markersizes = [3, 5]

polar.magnitude_tick_angle = numpy.pi / 6

theta = numpy.array(range(0, 720, 2))
magnitude = 9 * numpy.sin(5 * 2 * numpy.pi * theta / 360)
polar.datawc_y1 = 0
polar.datawc_y2 = max(magnitude)
polar.plot(magnitude, theta, bg=True, x=x)

fnm = "test_vcs_addons_polar_degrees.png"
x.png(fnm)
ret = regression.check_result_image(fnm, src)
sys.exit(ret)