Esempio n. 1
0
    if V[:3] == "3d_":
        var_is_3d = True

    if not var_is_3d:
        var = V
        vname = V
    else:
        var = V[3:-3]
        vname = V[3:]
        pressure = int(V[-3:]) * 100

    for n, date in enumerate(date_list):
        print date

        # Find the file and open it
        nc_path, nc_file = findClimoFile(grep + date + "*", directory)
        nc = ncgoda(nc_path)

        # Read in the variable data
        if var == "PRECT_d18O":
            nc.PRECT_d18O(box)
        elif var == "PRECT_dD":
            nc.PRECT_dD(box)
        elif var == "PRECT_dxs":
            nc.PRECT_dxs(box)
        elif var == "QFLX_d18O":
            nc.QFLX_d18O(box)
        elif var == "QFLX_dD":
            nc.QFLX_dD(box)
        elif var == "fluxDelta":
            nc.fluxDelta(box)
Esempio n. 2
0
showfig = ARGS.showfig
raw = ARGS.raw
removeMeans = True
if raw:
    removeMeans = False
if ARGS.developer_mode:
    print "\nRunning in dev mode. No files will be saved, no directories will be created, and all plots will be printed to the screen."
    savfig = False
    showfig = True

# Extract the dates
dates = camdates(start, end, months, days)

for n, date in enumerate(dates):
    # Find the file for this date
    cfull_path, cfname = findClimoFile(
        "*" + grep_pre + "*" + date + "*" + grep_post + "*", cdir)
    tfull_path, tfname = findClimoFile(
        "*" + grep_pre + "*" + date + "*" + grep_post + "*", tdir)
    if cfname != 0:
        print cfname
    if tfname != 0:
        print tfname
    # Open the file
    cnc = camgoda(cfull_path)
    tnc = camgoda(tfull_path)
    is3d, var, vname = cnc.ExtractData(variable, box)
    is3d, var, vname = tnc.ExtractData(variable, box)
    if n == 0:
        nlats, nlons = cnc.data.shape
        boxlat = cnc.boxlat
        boxlon = cnc.boxlon
Esempio n. 3
0
top = lat + delta
left = lon - delta
if left < 0:
    left += 360
right = lon + delta
if right > 360:
    right -= 360

region = [bottom, top, left, right]
box = [int(l) for l in ARGS.box]
southern_lat, northern_lat, left_lon, right_lon = box
if left_lon > right_lon:
    left_lon -= 360

for date_idx, date in enumerate(dates):
    cpath, cfilename = findClimoFile(grep_pre + '*' + date + '*' + grep_post,
                                     cdir)
    tpath, tfilename = findClimoFile(grep_pre + '*' + date + '*' + grep_post,
                                     tdir)
    print cfilename
    print tfilename
    # Open the file
    cnc = camgoda(cpath)
    tnc = camgoda(tpath)
    if date_idx == 0:
        data = np.zeros(shape=(len(dates), 2, len(cnc.lat), len(cnc.lon), 2))
    data[date_idx, 0, ...] = cnc.ExtractData(lv + "," + fv, returnData=True)
    data[date_idx, 1, ...] = tnc.ExtractData(lv + "," + fv, returnData=True)

# Box out the lv
lv_ts = np.nanmean(boxOut(data[..., 0], region), axis=(-2, -1))
# Four proxy region in the warm pool
if (region == "4P") | (region == "FourProxies"):
	region_name = "FourProxies"
	southern_lat = -25
	northern_lat = 30
	left_lon = 85
	right_lon = 160

box = (southern_lat, northern_lat, left_lon, right_lon)

tloc_var_master = []
cloc_var_master = []

for n, d in enumerate(dates):
	# Find the file
	cpath, cfilename = findClimoFile('*' + grep + "*" + d + '*', directory = cdir)
	tpath, tfilename = findClimoFile('*' + grep + "*" + d + '*', directory = tdir)
	print tfilename
	print cfilename
	
	# Open the file
	cnc = camgoda(cpath)
	tnc = camgoda(tpath)
	
	if n == 0:
		cnc.ExtractData(v1, box) # This sets boxlat and boxlon
		lats = cnc.boxlat
		lons = cnc.boxlon
		hold = np.zeros(shape = (len(lats), len(lons), len(dates), 2, 2)) # lat, lon, dates, var, state

	hold[:,:,n,0,0] = cnc.ExtractData(v1, box, returnData = True)
Esempio n. 5
0
    # Is the variable 2 or 3 dimensions
    var_is_3d = False
    if V[:3] == "3d_":
        var_is_3d = True

    if not var_is_3d:
        var = V
        vname = V
    else:
        var = V[3:-3]
        vname = V[3:]
        pressure = int(V[-3:]) * 100

    for n, date in enumerate(date_list):
        print date
        c_nc_path, c_nc_file = findClimoFile(grep + date + "*",
                                             control_directory)
        t_nc_path, t_nc_file = findClimoFile(grep + date + "*", test_directory)
        #print c_nc_path
        #print t_nc_path
        c_nc = camgoda(c_nc_path)
        t_nc = camgoda(t_nc_path)

        # Extract the variable data
        # Special variables
        if var == "PRECT_d18O":
            t_nc.PRECT_d18O(box)
            c_nc.PRECT_d18O(box)

        elif var == "PRECT_dD":
            t_nc.PRECT_dD(box)
            c_nc.PRECT_dD(box)
Esempio n. 6
0
        print "Created directory " + "DiffPopMap"

    # Create the region directory if it doesn't already exist
    if not os.path.exists("DiffPopMap/" + region_name):
        os.mkdir("DiffPopMap/" + region_name)
        print "Created directory " + "DiffPopMap/" + region_name

    # Create grep directory inside region directory
    if not os.path.exists("DiffPopMap/" + region_name + "/" + grep):
        os.mkdir("DiffPopMap/" + region_name + "/" + grep)
        print "Created directory " + "DiffPopMap/" + region_name + "/" + grep

if findFile:
    # Look for the climo files in the root directory
    print "\nLooking for control " + grep + " files in " + controldir
    controldatafname, controlfn = findClimoFile("*" + grep + "*", controldir)
    if not controldatafname:
        sys.exit()
    print "Found control file: " + controlfn
    print "\nLooking for test " + grep + " files in " + testdir
    testdatafname, testfn = findClimoFile("*" + grep + "*", testdir)
    if not testdatafname:
        sys.exit()
    print "Found test file: " + testfn
else:
    print "\nControl file is " + controldatafname
    print "\nTest file is " + testdatafname
    controlfn = os.path.splitext(os.path.split(controldatafname)[1])[0]
    testfn = os.path.splitext(os.path.split(testdatafname)[1])[0]

# Read the data
Esempio n. 7
0
box = [bottom_lat, top_lat, left_lon, right_lon]
variables = [str(V) for V in ARGS.variable]
savefig = ARGS.savefig
showfig = ARGS.showfig

mkdir = True
if ARGS.developer_mode:
    print "\nRunning in dev mode. No files will be saved, no directories will be created, and all plots will be printed to the screen."
    savefig = False
    showfig = True
    mkdir = False

# Find the file
if (cfile is None) or (tfile is None):
    print "\nLooking for control " + grep + " files in " + cdir + "..."
    cfile, controlfn = findClimoFile("*" + grep + "*", cdir)
    if not controldatafname:
        sys.exit()
    else:
        print "Found file " + controlfn
    print "\nLooking for test " + grep + " files in " + tdir + "..."
    tfile, testfn = findClimoFile("*" + grep + "*", tdir)
    if not testdatafname:
        sys.exit()
    else:
        print "Found file " + testfn

else:
    controlfn = os.path.splitext(os.path.split(cfile)[1])[0]
    testfn = os.path.splitext(os.path.split(tfile)[1])[0]
    print "\nControl file is " + controlfn
Esempio n. 8
0
    print "\nRunning in dev mode. No files will be saved, no directories will be created, and all plots will be printed to the screen."
    savfig = False
    showfig = True
    mkdir = False

##################
# Main algorithm #
##################

# Creates the master array of the correct shape
var_master = np.zeros(shape=(len(dates), len(variables)))
long_name = []
units = []
for n, d in enumerate(dates):
    # Find the file for this date
    full_path, fname = findClimoFile("*" + grep + "*" + d + "*",
                                     directory=ARGS.directory)
    if fname != 0:
        print fname
    # Open the file
    nc = camgoda(full_path)
    for m, v in enumerate(variables):
        # Read the data
        var_is_3d, var, pressure = nc.ExtractData(v, box)
        data = nc.data
        # Average the data
        data_avg = np.nanmean(data)
        var_master[n, m] = data_avg
        if n == 0:
            long_name.append(nc.long_name)
            units.append(nc.units)
Esempio n. 9
0
	savfig = False
	showfig = True
	mkdir = False

##################
# Main algorithm #
##################

# Creates the master array of the correct shape
cvar_master = np.zeros(shape = (len(dates), len(variables)))
tvar_master = np.zeros(shape = (len(dates), len(variables)))
long_name = []
units = []
for n, d in enumerate(dates):
	# Find the file for this date
	cfull_path, cfname = findClimoFile("*"+grep+"*"+d+"*", directory = cdir)
	tfull_path, tfname = findClimoFile("*"+grep+"*"+d+"*", directory = tdir)
	if cfname != 0:
		print cfname
	if tfname != 0:
		print tfname
	# Open the file
	cnc = camgoda(cfull_path)
	tnc = camgoda(tfull_path)
	for m, v in enumerate(variables):
		# Read the data
		var_is_3d, var, pressure = cnc.ExtractData(v, box)
		var_is_3d, var, pressure = tnc.ExtractData(v, box)
		cdata = cnc.data
		tdata = tnc.data
		# Average the data
Esempio n. 10
0
    left += 360
right = lon + delta
if right > 360:
    right -= 360

region = [bottom, top, left, right]
box = [int(l) for l in ARGS.box]

# These are mapping variable
southern_lat, northern_lat, left_lon, right_lon = box
if left_lon > right_lon:
    left_lon -= 360

for date_idx, date in enumerate(dates):
    # Find the file
    path, filename = findClimoFile(grep_pre + '*' + date + '*' + grep_post,
                                   directory)
    print filename
    # Open the file
    nc = camgoda(path)
    if date_idx == 0:
        data = np.zeros(shape=(len(dates), len(nc.lat), len(nc.lon), 2))
    data[date_idx, ...] = nc.ExtractData(lv + "," + fv, returnData=True)
#
# Extract the lv timeseries
lv_ts = np.nanmean(boxOut(data[..., 0], region), axis=(-2, -1))

# Box out the fv
fv_boxed_ts, lats, lons = boxOut(data[..., 1], box, returnGrid=True)

corr_array = corr_2d(np.expand_dims(np.expand_dims(lv_ts, -1), -1),
                     fv_boxed_ts,
Esempio n. 11
0
showfig = ARGS.showfig
if ARGS.developer_mode:
    print "\nRunning in dev mode. No files will be saved, no directories will be created, and all plots will be printed to the screen."
    savfig = False
    showfig = True
raw = ARGS.raw
removeMeans = True
if raw:
	removeMeans = False

# Extract the dates
dates = camdates(start, end, months)

for n, date in enumerate(dates):
	# Find the file for this date
	full_path, fname = findClimoFile("*"+grep_pre+"*"+date+"*"+grep_post+"*", directory)
	if fname != 0:
		print fname
	# Open the file
	nc = camgoda(full_path)
	is3d, var, vname = nc.ExtractData(variable, box)
	if n == 0:
		nlats, nlons = nc.data.shape
		boxlat = nc.boxlat
		boxlon = nc.boxlon
		d = np.zeros(shape = (len(dates), nlats*nlons))
	d[n,:] = np.ndarray.flatten(nc.data)

# Compute the amplitude timeseries and EOF spatial distributions of the data array
print "Computing the EOF..."
EOF = Eof(d, center = removeMeans)