Esempio n. 1
0
def calcVarResp(varnames):
    ### Call function for variable data from each run
    lat, lon, time, lev, varhit = MO.readExperi(directorydata, '%s' % varnames,
                                                'HIT', 'surface')
    lat, lon, time, lev, varfit = MO.readExperi(directorydata, '%s' % varnames,
                                                'FIT', 'surface')
    lat, lon, time, lev, varcit = MO.readExperi(directorydata, '%s' % varnames,
                                                'CIT', 'surface')
    lat, lon, time, lev, varfic = MO.readExperi(directorydata, '%s' % varnames,
                                                'FIC', 'surface')

    ### Concatonate runs
    runs = [varhit, varfit, varcit, varfic]

    ### Separate per periods (ON,DJ,FM)
    var_djf = np.empty(
        (4, varhit.shape[0] - 1, varhit.shape[2], varhit.shape[3]))
    for i in range(len(runs)):
        var_djf[i], var_djf[i] = UT.calcDecJanFeb(runs[i], runs[i], lat, lon,
                                                  'surface', 1)

    ### Compute comparisons for FM - taken ensemble average
    diff_FITHIT = np.nanmean(var_djf[1] - var_djf[0], axis=0)
    diff_FICCIT = np.nanmean(var_djf[3] - var_djf[2], axis=0)
    diffruns_djf = [diff_FITHIT, diff_FICCIT]

    ### Calculate significance for FM
    stat_FITHIT, pvalue_FITHIT = UT.calc_indttest(var_djf[1], var_djf[0])
    stat_FICCIT, pvalue_FICCIT = UT.calc_indttest(var_djf[3], var_djf[2])
    pruns_djf = [pvalue_FITHIT, pvalue_FICCIT]

    return diffruns_djf, pruns_djf, lat, lon
Esempio n. 2
0
def readTemp(varnames):
    """
    Read in temperature data for selected variables and calculate differences
    between experiments
    """
    for v in range(len(varnames)):
        ### Call function for T2M data from reach run
        lat, lon, time, lev, varhit = MO.readExperi(directorydata,
                                                    '%s' % varnames[v], 'HIT',
                                                    'surface')
        lat, lon, time, lev, varfit = MO.readExperi(directorydata,
                                                    '%s' % varnames[v], 'FIT',
                                                    'surface')
        lat, lon, time, lev, varcit = MO.readExperi(directorydata,
                                                    '%s' % varnames[v], 'CIT',
                                                    'surface')
        lat, lon, time, lev, varfic = MO.readExperi(directorydata,
                                                    '%s' % varnames[v], 'FIC',
                                                    'surface')
        lat, lon, time, lev, varfict = MO.readExperi(directorydata,
                                                     '%s' % varnames[v],
                                                     'FICT', 'surface')

        ### Create 2d array of latitude and longitude
        lon2, lat2 = np.meshgrid(lon, lat)

        ### Concatonate runs
        runs = [varhit, varfit, varcit, varfic, varfict]

        ### Separate per periods (DJF)
        var_djf = np.empty(
            (5, varhit.shape[0] - 1, varhit.shape[2], varhit.shape[3]))
        for i in range(len(runs)):
            var_djf[i], var_djf[i] = UT.calcDecJanFeb(runs[i], runs[i], lat,
                                                      lon, 'surface', 1)

        ### Compute comparisons for FM - taken ensemble average
        diff_FITHIT = np.nanmean(var_djf[1] - var_djf[0], axis=0)
        diff_FICCIT = np.nanmean(var_djf[3] - var_djf[2], axis=0)
        diff_FICTHIT = np.nanmean(var_djf[4] - var_djf[0], axis=0)
        diffruns_djf = [diff_FITHIT, diff_FICCIT, diff_FICTHIT]

        ### Calculate significance for FM
        stat_FITHIT, pvalue_FITHIT = UT.calc_indttest(var_djf[1], var_djf[0])
        stat_FICCIT, pvalue_FICCIT = UT.calc_indttest(var_djf[3], var_djf[2])
        stat_FICTHIT, pvalue_FICTHIT = UT.calc_indttest(var_djf[4], var_djf[0])
        pruns_djf = [pvalue_FITHIT, pvalue_FICCIT, pvalue_FICTHIT]

    return diffruns_djf, pruns_djf, lat, lon
Esempio n. 3
0
def readDataPeriods(varnames):
    ### Call function for 4d variable data
    lat, lon, lev, varfuture = MO.readExperiAll(varnames, 'Future', 'surface')
    lat, lon, lev, varpast = MO.readExperiAll(varnames, 'Current', 'surface')

    ### Create 2d array of latitude and longitude
    lon2, lat2 = np.meshgrid(lon, lat)

    ### Remove missing data
    varfuture[np.where(varfuture <= -1e10)] = np.nan
    varpast[np.where(varpast <= -1e10)] = np.nan

    ### Rearrange months (N,D,J,F,M,A)
    varfuturem = np.append(varfuture[:, -2:, :, :],
                           varfuture[:, :4, :, :],
                           axis=1)
    varpastm = np.append(varpast[:, -2:, :, :], varpast[:, :4, :, :], axis=1)

    ### Calculate relative change
    relativem = ((np.nanmean(varfuturem,axis=0) - np.nanmean(varpastm,axis=0)) \
                /np.abs(np.nanmean(varpastm,axis=0))) * 100.

    ### Calculate significance for each month
    stat = np.empty((varpastm.shape[1], len(lat), len(lon)))
    pvalue = np.empty((varpastm.shape[1], len(lat), len(lon)))
    for i in range(varpastm.shape[1]):
        stat[i], pvalue[i] = UT.calc_indttest(varfuturem[:, i, :, :],
                                              varpastm[:, i, :, :])

    return relativem, pvalue, lat, lon
Esempio n. 4
0
def readHeatFlux():
    ### Call arguments
    varnames = 'RNET'
    experiments = [r'\textbf{FIT--HIT}', r'\textbf{FICT--HIT}']

    ### Call function for rnet data from reach run
    lat, lon, time, lev, tashit = MO.readExperiAll('%s' % varnames, 'HIT',
                                                   'surface')
    lat, lon, time, lev, tasfict = MO.readExperiAll('%s' % varnames, 'FICT',
                                                    'surface')

    ### Create 2d array of latitude and longitude
    lon2, lat2 = np.meshgrid(lon, lat)

    ### Calculate Oct-Mar
    tashitmo = np.append(tashit[:, 9:, :, :], tashit[:, :3, :, :], axis=1)
    tasfictmo = np.append(tasfict[:, 9:, :, :], tasfict[:, :3, :, :], axis=1)

    ### Take difference
    ficthit = np.nanmean(tasfictmo - tashitmo, axis=0)

    ### Statistical Test
    stat_FICTHIT, pvalue_FICTHIT = UT.calc_indttest(tasfictmo, tashitmo)

    return ficthit[:3], lat, lon, pvalue_FICTHIT[:3]
def readDataPeriods(varnames, sliceq):
    ### Call function for 4d variable data
    lat, lon, lev, varfuture = MO.readExperiAll(varnames, 'Future', 'profile')
    lat, lon, lev, varpast = MO.readExperiAll(varnames, 'Current', 'profile')

    ### Select ensemble mean period
    if sliceq == 'Mean':
        varfuture = varfuture[:, :, :, :, :]
        varpast = varpast[:, :, :, :, :]
    elif sliceq == 'A':
        varfuture = varfuture[:100, :, :, :, :]
        varpast = varpast[:100, :, :, :, :]
    elif sliceq == 'B':
        varfuture = varfuture[100:200, :, :, :, :]
        varpast = varpast[100:200, :, :, :, :]
    elif sliceq == 'C':
        varfuture = varfuture[200:, :, :, :, :]
        varpast = varpast[200:, :, :, :, :]

    ### Create 2d array of latitude and longitude
    lon2, lat2 = np.meshgrid(lon, lat)

    ### Remove missing data
    varfuture[np.where(varfuture <= -1e10)] = np.nan
    varpast[np.where(varpast <= -1e10)] = np.nan

    ### Rearrange months (N,D,J,F,M,A)
    varfuturem = np.append(varfuture[:, -2:, :, :, :],
                           varfuture[:, :4, :, :, :],
                           axis=1)
    varpastm = np.append(varpast[:, -2:, :, :, :],
                         varpast[:, :4, :, :, :],
                         axis=1)

    ### Calculate zonal means
    varfuturemz = np.nanmean(varfuturem, axis=4)
    varpastmz = np.nanmean(varpastm, axis=4)

    ### Calculate anomalies
    anompi = varfuturemz - varpastmz

    ### Calculate ensemble mean
    anompim = np.nanmean(anompi, axis=0)
    zdiffruns = anompim

    ### Calculate climatologies
    zclimo = np.nanmean(varpastmz, axis=0)

    ### Calculate significance for each month
    stat_past = np.empty((varpastmz.shape[1], len(lev), len(lat)))
    pvalue_past = np.empty((varpastmz.shape[1], len(lev), len(lat)))
    for i in range(varpastmz.shape[1]):
        stat_past[i], pvalue_past[i] = UT.calc_indttest(
            varfuturemz[:, i, :, :], varpastmz[:, i, :, :])

    pruns = pvalue_past

    return zdiffruns, zclimo, pruns, lat, lon, lev
Esempio n. 6
0
def readDataPeriods(varnames,sliceq):
    ### Call function for 4d variable data
    lat,lon,lev,varfuture = MO.readExperiAll(varnames,'Future','surface')
    lat,lon,lev,varpast = MO.readExperiAll(varnames,'Past','surface')
    
    ### Select ensemble mean period
    if sliceq == 'Mean':
        varfuture = varfuture[:,:,:,:]
        varpast = varpast[:,:,:,:]
    elif sliceq == 'A':
        varfuture = varfuture[:100,:,:,:]
        varpast = varpast[:100,:,:,:]
    elif sliceq == 'B':
        varfuture = varfuture[100:200,:,:,:]
        varpast = varpast[100:200,:,:,:]
    elif sliceq == 'C':
        varfuture = varfuture[200:,:,:,:]
        varpast = varpast[200:,:,:,:]
    
    ### Create 2d array of latitude and longitude
    lon2,lat2 = np.meshgrid(lon,lat)
    
    ### Remove missing data
    varfuture[np.where(varfuture <= -1e10)] = np.nan
    varpast[np.where(varpast <= -1e10)] = np.nan
    
    ### Rearrange months (N,D,J,F,M,A)
    varfuturem = np.append(varfuture[:,-2:,:,:],varfuture[:,:4,:,:],
                           axis=1)
    varpastm = np.append(varpast[:,-2:,:,:],varpast[:,:4,:,:],axis=1)
    
    ### Calculate anomalies
    anom = varfuturem - varpastm
    
    ### Calculate ensemble mean
    anomm = np.nanmean(anom,axis=0)
    pastm = np.nanmean(varpastm,axis=0)
    
    ### Calculate zonal mean
    anommz = np.nanmean(anomm,axis=2)
    climoz = np.nanmean(pastm,axis=2)
    
    ### Calculate significance for each month
    stat = np.empty((varpastm.shape[1],len(lat)))
    pvalue = np.empty((varpastm.shape[1],len(lat)))
    for i in range(varpastm.shape[1]):
        stat[i],pvalue[i] = UT.calc_indttest(
                                    np.nanmean(varfuturem[:,i,:],axis=2),
                                    np.nanmean(varpastm[:,i,:],axis=2))
    
    return anommz,climoz,lat,lon,pvalue
Esempio n. 7
0
 zdiff_HITCIT = np.nanmean(diff_HITCIT,axis=2)
 zdiff_FICCIT = np.nanmean(diff_FICCIT,axis=2)
 zdiff_FICTFIT = np.nanmean(diff_FICTFIT,axis=2)
 zdiff_FICTHIT = np.nanmean(diff_FICTHIT,axis=2)
 zdiffruns_djf = np.asarray([zdiff_FITHIT,zdiff_FITCIT,zdiff_HITCIT,
                             zdiff_FICCIT,zdiff_FICTFIT,zdiff_FICTHIT])
 
 ## Calculate climo
 zclimo_hit = np.apply_over_axes(np.nanmean,var_djf[0],(0,3)).squeeze()
 zclimo_fit = np.apply_over_axes(np.nanmean,var_djf[1],(0,3)).squeeze()
 zclimo_cit = np.apply_over_axes(np.nanmean,var_djf[2],(0,3)).squeeze()
 zclimo_fic = np.apply_over_axes(np.nanmean,var_djf[3],(0,3)).squeeze()
 zclimo_fict = np.apply_over_axes(np.nanmean,var_djf[4],(0,3)).squeeze()
 
 ### Calculate significance for FM
 stat_FITHIT,pvalue_FITHIT = UT.calc_indttest(np.nanmean(var_djf[1],axis=3),
                                              np.nanmean(var_djf[0],axis=3))
 stat_FITCIT,pvalue_FITCIT = UT.calc_indttest(np.nanmean(var_djf[1],axis=3),
                                              np.nanmean(var_djf[2],axis=3))
 stat_HITCIT,pvalue_HITCIT = UT.calc_indttest(np.nanmean(var_djf[0],axis=3),
                                              np.nanmean(var_djf[2],axis=3))
 stat_FICCIT,pvalue_FICCIT = UT.calc_indttest(np.nanmean(var_djf[3],axis=3),
                                              np.nanmean(var_djf[2],axis=3))
 stat_FICTFIT,pvalue_FICTFIT = UT.calc_indttest(np.nanmean(var_djf[4],axis=3),
                                              np.nanmean(var_djf[1],axis=3))
 stat_FICTHIT,pvalue_FICTHIT = UT.calc_indttest(np.nanmean(var_djf[4],axis=3),
                                              np.nanmean(var_djf[0],axis=3))
 pruns_djf = np.asarray([pvalue_FITHIT,pvalue_FITCIT,pvalue_HITCIT,
                        pvalue_FICCIT,pvalue_FICTFIT,pvalue_FICTHIT])
 
 ###########################################################################
 ###########################################################################
Esempio n. 8
0
def calcVarResp(varnames,period,qbophase):
    ### Call function for surface temperature data from reach run
    lat,lon,time,lev,tashit = MO.readExperiAll('%s' % varnames,'HIT',
                                               'surface')
    lat,lon,time,lev,tasfict = MO.readExperiAll('%s' % varnames,'FICT',
                                                'surface')
    
    ### Create 2d array of latitude and longitude
    lon2,lat2 = np.meshgrid(lon,lat)
    
    ### Read in QBO phases 
    filenamehitp = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[0]
    filenamehitno = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[1]
    filenamehitn = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    filenamehitp2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[0]
    filenamehitno2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[1]
    filenamehitn2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    pos_hit = np.append(np.genfromtxt(filenamehitp,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamehitp2,unpack=True,usecols=[0],dtype='int')+101)
    non_hit = np.append(np.genfromtxt(filenamehitno,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamehitno2,unpack=True,usecols=[0],dtype='int')+101)
    neg_hit = np.append(np.genfromtxt(filenamehitn,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamehitn2,unpack=True,usecols=[0],dtype='int')+101)    
    
    filenamefictp = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[0]
    filenamefictno = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[1]
    filenamefictn = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[2]
    filenamefictp2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[0]
    filenamefictno2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[1]
    filenamefictn2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[2]
    pos_fict = np.append(np.genfromtxt(filenamefictp,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamefictp2,unpack=True,usecols=[0],dtype='int')+101)
    non_fict = np.append(np.genfromtxt(filenamefictno,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamefictno2,unpack=True,usecols=[0],dtype='int')+101)
    neg_fict = np.append(np.genfromtxt(filenamefictn,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamefictn2,unpack=True,usecols=[0],dtype='int')+101)
    
    ### Concatonate runs
    runs = [tashit,tasfict]
    
    ### Separate per periods (ON,DJ,FM)
    if period == 'ON': 
        tas_mo = np.empty((3,tashit.shape[0],tashit.shape[2],tashit.shape[3]))
        for i in range(len(runs)):
            tas_mo[i] = np.nanmean(runs[i][:,9:11,:,:],axis=1) 
    elif period == 'DJ':     
        tas_mo = np.empty((3,tashit.shape[0]-1,tashit.shape[2],tashit.shape[3]))
        for i in range(len(runs)):
            tas_mo[i],tas_mo[i] = UT.calcDecJan(runs[i],runs[i],lat,
                                                lon,'surface',1) 
    elif period == 'FM':
        tas_mo= np.empty((3,tashit.shape[0],tashit.shape[2],tashit.shape[3]))
        for i in range(len(runs)):
            tas_mo[i] = np.nanmean(runs[i][:,1:3,:,:],axis=1)
    elif period == 'DJF':
        tas_mo= np.empty((3,tashit.shape[0]-1,tashit.shape[2],tashit.shape[3]))
        for i in range(len(runs)):
            tas_mo[i],tas_mo[i] = UT.calcDecJanFeb(runs[i],runs[i],lat,
                                                  lon,'surface',1)   
    elif period == 'M':
        tas_mo= np.empty((3,tashit.shape[0],tashit.shape[2],tashit.shape[3]))
        for i in range(len(runs)):
            tas_mo[i] = runs[i][:,2,:,:]
    elif period == 'D':
        tas_mo= np.empty((3,tashit.shape[0],tashit.shape[2],tashit.shape[3]))
        for i in range(len(runs)):
            tas_mo[i] = runs[i][:,-1,:,:]
    elif period == 'N':
        tas_mo= np.empty((3,tashit.shape[0],tashit.shape[2],tashit.shape[3]))
        for i in range(len(runs)):
            tas_mo[i] = runs[i][:,-2,:,:]
    elif period == 'ND':
        tas_mo= np.empty((3,tashit.shape[0],tashit.shape[2],tashit.shape[3]))
        for i in range(len(runs)):
            tas_mo[i] = np.nanmean(runs[i][:,-2:,:,:],axis=1)
    else:
        ValueError('Wrong period selected! (ON,DJ,FM)')
        
    ### Composite by QBO phase    
    tas_mohitpos = tas_mo[0][pos_hit,:,:]
    tas_mofictpos = tas_mo[1][pos_fict,:,:]
    
    tas_mohitneg = tas_mo[0][neg_hit,:,:]
    tas_mofictneg = tas_mo[1][neg_fict,:,:]

    ### Compute climatology    
    climohitpos = np.nanmean(tas_mohitpos,axis=0)
    climohitneg = np.nanmean(tas_mohitneg,axis=0)
    climo = [climohitpos,climohitneg]
    
    ### Compute comparisons for months - taken ensemble average
    ficthitpos = np.nanmean(tas_mofictpos - tas_mohitpos,axis=0)
    ficthitneg = np.nanmean(tas_mofictneg - tas_mohitneg,axis=0)
    
    diffruns = [ficthitpos,ficthitneg]
    
    ### Calculate significance for ND
    stat_FICTHITpos,pvalue_FICTHITpos = UT.calc_indttest(tas_mo[1][pos_fict,:,:],
                                                       tas_mo[0][pos_hit,:,:])
    stat_FICTHITnon,pvalue_FICTHITnon = UT.calc_indttest(tas_mo[1][non_fict,:,:],
                                                   tas_mo[0][non_hit,:,:])
    stat_FICTHITneg,pvalue_FICTHITneg = UT.calc_indttest(tas_mo[1][neg_fict,:,:],
                                               tas_mo[0][neg_hit,:,:])

    pruns = [pvalue_FICTHITpos,pvalue_FICTHITneg]
    
    return diffruns,pruns,climo,lat,lon
Esempio n. 9
0
titletime = currentmn + '/' + currentdy + '/' + currentyr
print('\n' '----Plotting Daily Temperature Profile - %s----' % titletime)

#### Alott time series
year1 = 1900
year2 = 2000
years = np.arange(year1, year2 + 1, 1)

### Call function for zonal wind profile data for polar cap
lat, lon, time, lev, U_h = DO.readMeanExperi(directorydata, 'U', 'HIT',
                                             'profile')
lat, lon, time, lev, U_f = DO.readMeanExperi(directorydata, 'U', 'FIT',
                                             'profile')

#### Calculate significance
stat, pvalue = UT.calc_indttest(U_h, U_f)

### Calculate ensemble mean
U_diff = np.nanmean(U_f - U_h, axis=0)
U_climo = np.nanmean(U_h, axis=0)

############################################################################
############################################################################
############################################################################
##### Plot zonal wind profile
plt.rc('text', usetex=True)
plt.rc('font', **{'family': 'sans-serif', 'sans-serif': ['Avant Garde']})

### Set limits for contours and colorbars
limit = np.arange(-3, 3.1, 0.1)
barlim = np.arange(-3, 4, 1)
Esempio n. 10
0
        print('Completed: Sigma of QBO-E for %s member!' % ens)

    ### Compute comparisons for days - taken ensemble average
    fithitpos = np.nanmean(ten_wfitpos - ten_whitpos, axis=0)
    fithitnon = np.nanmean(ten_wfitnon - ten_whitnon, axis=0)
    fithitneg = np.nanmean(ten_wfitneg - ten_whitneg, axis=0)

    ficthitpos = np.nanmean(ten_wfictpos - ten_whitpos, axis=0)
    ficthitnon = np.nanmean(ten_wfictnon - ten_whitnon, axis=0)
    ficthitneg = np.nanmean(ten_wfictneg - ten_whitneg, axis=0)
    diffruns = [
        fithitpos, fithitnon, fithitneg, ficthitpos, ficthitnon, ficthitneg
    ]

    ### Calculate significance for DJF
    stat_fithitpos, pvalue_fithitpos = UT.calc_indttest(
        ten_wfitpos, ten_whitpos)
    stat_fithitnon, pvalue_fithitnon = UT.calc_indttest(
        ten_wfitnon, ten_whitnon)
    stat_fithitneg, pvalue_fithitneg = UT.calc_indttest(
        ten_wfitneg, ten_whitneg)

    stat_ficthitpos, pvalue_ficthitpos = UT.calc_indttest(
        ten_wfictpos, ten_whitpos)
    stat_ficthitnon, pvalue_ficthitnon = UT.calc_indttest(
        ten_wfictnon, ten_whitnon)
    stat_ficthitneg, pvalue_ficthitneg = UT.calc_indttest(
        ten_wfictneg, ten_whitneg)

    pruns = [
        pvalue_fithitpos, pvalue_fithitnon, pvalue_fithitneg,
        pvalue_ficthitpos, pvalue_ficthitnon, pvalue_ficthitneg
Esempio n. 11
0
def readWAF(varnames, runnames, experiments, qbophase):
    """
    Function reads in WAF data for listed experiments

    Parameters
    ----------
    varnames : string
        variable to download
    runnames : list of strings
        model experiments to read in
    experiments : list of strings
        model simulations to compare
    qbophase : list of strings
        list of qbo phases

    Returns
    -------
    diffruns : list of arrays
        arrays for each experiment variable
    pruns : list of arrays
        arrays of p-values for each experiment variable
    lev : 1d array
        leves

    Usage
    -----
    diffruns,pruns,lev = readWAF(varnames,runnames,experiments,qbophase)
    """
    print('\n>>> Using readWAF function!')

    ### Call functions for variable profile data for polar cap
    lat, lon, time, lev, varhit = DO.readMeanExperiAll('%s' % varnames, 'HIT',
                                                       'profile3')
    lat, lon, time, lev, varfict = DO.readMeanExperiAll(
        '%s' % varnames, 'FICT', 'profile3')

    ### Create 2d array of latitude and longitude
    lon2, lat2 = np.meshgrid(lon, lat)

    ### Read in QBO phases
    filenamehitp = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[0]
    filenamehitno = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[1]
    filenamehitn = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    filenamehitp2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[0]
    filenamehitno2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[1]
    filenamehitn2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    pos_hit = np.append(
        np.genfromtxt(filenamehitp, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamehitp2, unpack=True, usecols=[0], dtype='int') +
        100)
    non_hit = np.append(
        np.genfromtxt(filenamehitno, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamehitno2, unpack=True, usecols=[0], dtype='int') +
        100)
    neg_hit = np.append(
        np.genfromtxt(filenamehitn, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamehitn2, unpack=True, usecols=[0], dtype='int') +
        100)

    filenamefictp = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[0]
    filenamefictno = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        1]
    filenamefictn = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[2]
    filenamefictp2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        0]
    filenamefictno2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        1]
    filenamefictn2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        2]
    pos_fict = np.append(
        np.genfromtxt(filenamefictp, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamefictp2, unpack=True, usecols=[0], dtype='int') +
        100)
    non_fict = np.append(
        np.genfromtxt(filenamefictno, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamefictno2, unpack=True, usecols=[0], dtype='int') +
        100)
    neg_fict = np.append(
        np.genfromtxt(filenamefictn, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamefictn2, unpack=True, usecols=[0], dtype='int') +
        100)

    ### Concatonate runs
    var_mo = [varhit, varfict]

    ### Save memory
    del varhit
    del varfict

    ### Composite by QBO phase
    var_mohitpos = var_mo[0][pos_hit, :]
    var_mofictpos = var_mo[1][pos_fict, :]

    var_mohitnon = var_mo[0][non_hit, :]
    var_mofictnon = var_mo[1][non_fict, :]

    var_mohitneg = var_mo[0][neg_hit, :]
    var_mofictneg = var_mo[1][neg_fict, :]

    ### Compute comparisons for months - taken ensemble average
    ficthitpos = np.nanmean(var_mofictpos - var_mohitpos, axis=0)
    ficthitnon = np.nanmean(var_mofictnon - var_mohitnon, axis=0)
    ficthitneg = np.nanmean(var_mofictneg - var_mohitneg, axis=0)

    ficthitposa = UT.calc_weightedAve(ficthitpos, lat2)
    ficthitnona = UT.calc_weightedAve(ficthitnon, lat2)
    ficthitnega = UT.calc_weightedAve(ficthitneg, lat2)

    diffruns = [ficthitposa, ficthitnona, ficthitnega]

    ### Calculate significance for days
    stat_FICTHITpos, pvalue_FICTHITpos = UT.calc_indttest(
        var_mo[1][pos_fict, :], var_mo[0][pos_hit, :])
    stat_FICTHITnon, pvalue_FICTHITnon = UT.calc_indttest(
        var_mo[1][non_fict, :], var_mo[0][non_hit, :])
    stat_FICTHITneg, pvalue_FICTHITneg = UT.calc_indttest(
        var_mo[1][neg_fict, :], var_mo[0][neg_hit, :])

    pvalue_FICTHITposa = UT.calc_weightedAve(pvalue_FICTHITpos, lat2)
    pvalue_FICTHITnona = UT.calc_weightedAve(pvalue_FICTHITnon, lat2)
    pvalue_FICTHITnega = UT.calc_weightedAve(pvalue_FICTHITneg, lat2)

    pruns = [pvalue_FICTHITposa, pvalue_FICTHITnona, pvalue_FICTHITnega]

    print('\n*Completed: Finished readWAF function!')
    return diffruns, pruns, lev
Esempio n. 12
0
    ### Separate per periods (DJF)
    var_djf = np.empty(
        (5, varhit.shape[0] - 1, varhit.shape[2], varhit.shape[3]))
    for i in range(len(runs)):
        var_djf[i], var_djf[i] = UT.calcDecJanFeb(runs[i], runs[i], lat, lon1,
                                                  'surface', 1)

    ### Compute comparisons for FM - taken ensemble average
    diff_FITHIT = np.nanmean(var_djf[1] - var_djf[0], axis=0)
    diff_FICCIT = np.nanmean(var_djf[3] - var_djf[2], axis=0)
    diff_FICTHIT = np.nanmean(var_djf[4] - var_djf[0], axis=0)
    diffruns_djf = [diff_FITHIT, diff_FICCIT, diff_FICTHIT]

    ### Calculate significance for FM
    stat_FITHIT, pvalue_FITHIT = UT.calc_indttest(var_djf[1], var_djf[0])
    stat_FICCIT, pvalue_FICCIT = UT.calc_indttest(var_djf[3], var_djf[2])
    stat_FICTHIT, pvalue_FICTHIT = UT.calc_indttest(var_djf[4], var_djf[0])
    pruns_djf = [pvalue_FITHIT, pvalue_FICCIT, pvalue_FICTHIT]

    ### Read in wave number
    lat, lon, time, lev, wavef = MO.readExperi(directorydata,
                                               '%sxwave1' % varnames[v], 'FIT',
                                               'surface')
    lat, lon, time, lev, wavefc = MO.readExperi(directorydata,
                                                '%sxwave1' % varnames[v],
                                                'FIC', 'surface')
    lat, lon, time, lev, wavefict = MO.readExperi(directorydata,
                                                  '%sxwave1' % varnames[v],
                                                  'FICT', 'surface')
Esempio n. 13
0
slpf_on = np.nanmean(slpf[:, 9:11, :, :], axis=1)

slph_dj, slpf_dj = UT.calcDecJan(slph, slpf, lat, lon, 'surface', 1)

slph_fm = np.nanmean(slph[:, 1:3, :, :], axis=1)
slpf_fm = np.nanmean(slpf[:, 1:3, :, :], axis=1)

### Calculate period differenceds
diff_on = np.nanmean((slpf_on - slph_on), axis=0)
diff_dj = np.nanmean((slpf_dj - slph_dj), axis=0)
diff_fm = np.nanmean((slpf_fm - slph_fm), axis=0)
diff_onq = slpf_on - np.nanmean(slph_on, axis=0)
diff_djq = slpf_dj - np.nanmean(slph_dj, axis=0)
diff_fmq = slpf_fm - np.nanmean(slph_fm, axis=0)

stat_on, pvalue_on = UT.calc_indttest(slph_on, slpf_on)
stat_dj, pvalue_dj = UT.calc_indttest(slph_dj, slpf_dj)
stat_fm, pvalue_fm = UT.calc_indttest(slph_fm, slpf_fm)

###########################################################################
###########################################################################
###########################################################################
### Plot sea level pressure data
plt.rc('text', usetex=True)
plt.rc('font', **{'family': 'sans-serif', 'sans-serif': ['Avant Garde']})

### Set limits for contours and colorbars
limit = np.arange(-6, 6.1, 0.5)
barlim = np.arange(-6, 7, 3)

### Begin figure
Esempio n. 14
0
    ### Compare experiments
    experiments = [
        r'\textbf{$\Delta$SIT}', r'\textbf{$\Delta$SIC}',
        r'\textbf{$\Delta$NET}'
    ]
    runs = [varhit, varfit, varcit, varfic, varfict]

    ### Compute comparisons for experiments - take ensemble average
    diff_FITHIT = np.nanmean(varfit - varhit, axis=0)
    diff_FICCIT = np.nanmean(varfic - varcit, axis=0)
    diff_FICTHIT = np.nanmean(varfict - varhit, axis=0)
    diffruns = np.asarray([diff_FITHIT, diff_FICCIT, diff_FICTHIT])

    ### Calculate significance for FM
    stat_FITHIT, pvalue_FITHIT = UT.calc_indttest(varfit, varhit)
    stat_FICCIT, pvalue_FICCIT = UT.calc_indttest(varfic, varcit)
    stat_FICTHIT, pvalue_FICTHIT = UT.calc_indttest(varfict, varhit)
    pruns = np.asarray([pvalue_FITHIT, pvalue_FICCIT, pvalue_FICTHIT])

    ############################################################################
    ############################################################################
    ############################################################################
    ##### Plot daily profile with height for selected variable
    plt.rc('text', usetex=True)
    plt.rc('font', **{'family': 'sans-serif', 'sans-serif': ['Avant Garde']})

    ### Set limits for contours and colorbars
    if varnames[v] == 'GEOP':
        limit = np.arange(-150, 150.1, 10)
        barlim = np.arange(-150, 151, 75)
 fpolcitnon = np.nanmean(tas_mofpolnon - tas_mocitnon,axis=0)
 fpolcitneg = np.nanmean(tas_mofpolneg - tas_mocitneg,axis=0)
 
 ### Take zonal mean of experiments
 zfsubcitpos = np.nanmean(fsubcitpos,axis=2)
 zfsubcitnon = np.nanmean(fsubcitnon,axis=2)
 zfsubcitneg = np.nanmean(fsubcitneg,axis=2)
 zfpolcitpos = np.nanmean(fpolcitpos,axis=2)
 zfpolcitnon = np.nanmean(fpolcitnon,axis=2)
 zfpolcitneg = np.nanmean(fpolcitneg,axis=2)
 diffruns_mo = [zfsubcitpos,zfsubcitnon,zfsubcitneg,
                zfpolcitpos,zfpolcitnon,zfpolcitneg]
 
 ### Calculate significance for FM
 stat_fsubcitpos,pvalue_fsubcitpos = UT.calc_indttest(
         np.nanmean(tas_mo[1][pos_fsub,:,:,:],axis=3),
         np.nanmean(tas_mo[0][pos_cit,:,:,:],axis=3))
 stat_fsubcitnon,pvalue_fsubcitnon = UT.calc_indttest(
         np.nanmean(tas_mo[1][non_fsub,:,:,:],axis=3),
         np.nanmean(tas_mo[0][non_cit,:,:,:],axis=3))
 stat_fsubcitneg,pvalue_fsubcitneg = UT.calc_indttest(
         np.nanmean(tas_mo[1][neg_fsub,:,:,:],axis=3),
         np.nanmean(tas_mo[0][neg_cit,:,:,:]))
 
 stat_fpolcitpos,pvalue_fpolcitpos = UT.calc_indttest(
         np.nanmean(tas_mo[2][pos_fpol,:,:,:],axis=3),
         np.nanmean(tas_mo[0][pos_cit,:,:,:],axis=3))
 stat_fpolcitnon,pvalue_fpolcitnon = UT.calc_indttest(
         np.nanmean(tas_mo[2][non_fpol,:,:,:],axis=3),
         np.nanmean(tas_mo[0][non_cit,:,:,:],axis=3))
 stat_fpolcitneg,pvalue_fpolcitneg = UT.calc_indttest(
    ### Take zonal mean of experiments
    zfithitpos = np.nanmean(fithitpos, axis=2)
    zfithitnon = np.nanmean(fithitnon, axis=2)
    zfithitneg = np.nanmean(fithitneg, axis=2)
    zficthitpos = np.nanmean(ficthitpos, axis=2)
    zficthitnon = np.nanmean(ficthitnon, axis=2)
    zficthitneg = np.nanmean(ficthitneg, axis=2)
    diffruns_mo = [
        zfithitpos, zfithitnon, zfithitneg, zficthitpos, zficthitnon,
        zficthitneg
    ]

    ### Calculate significance for FM
    stat_FITHITpos, pvalue_FITHITpos = UT.calc_indttest(
        np.nanmean(tas_mo[1][pos_fit, :, :, :], axis=3),
        np.nanmean(tas_mo[0][pos_hit, :, :, :], axis=3))
    stat_FITHITnon, pvalue_FITHITnon = UT.calc_indttest(
        np.nanmean(tas_mo[1][non_fit, :, :, :], axis=3),
        np.nanmean(tas_mo[0][non_hit, :, :, :], axis=3))
    stat_FITHITneg, pvalue_FITHITneg = UT.calc_indttest(
        np.nanmean(tas_mo[1][neg_fit, :, :, :], axis=3),
        np.nanmean(tas_mo[0][neg_hit, :, :, :]))

    stat_FICTHITpos, pvalue_FICTHITpos = UT.calc_indttest(
        np.nanmean(tas_mo[2][pos_fict, :, :, :], axis=3),
        np.nanmean(tas_mo[0][pos_hit, :, :, :], axis=3))
    stat_FICTHITnon, pvalue_FICTHITnon = UT.calc_indttest(
        np.nanmean(tas_mo[2][non_fict, :, :, :], axis=3),
        np.nanmean(tas_mo[0][non_hit, :, :, :], axis=3))
    stat_FICTHITneg, pvalue_FICTHITneg = UT.calc_indttest(
Esempio n. 17
0
diff_dj = np.nanmean((uf_dj-uh_dj),axis=0)
diff_fm = np.nanmean((uf_fm-uh_fm),axis=0)

### Calculate zonal mean
zdiff_on = np.nanmean((diff_on),axis=2)
zdiff_dj = np.nanmean((diff_dj),axis=2)
zdiff_fm = np.nanmean((diff_fm),axis=2)

## Calculate climo
zclimo_on = np.apply_over_axes(np.nanmean,uh_on,(0,3)).squeeze()
zclimo_dj = np.apply_over_axes(np.nanmean,uh_dj,(0,3)).squeeze()
zclimo_fm = np.apply_over_axes(np.nanmean,uh_fm,(0,3)).squeeze()


### Calculate significance
stat_on,pvalue_on = UT.calc_indttest(np.nanmean(uh_on,axis=3),
                                     np.nanmean(uf_on,axis=3))
stat_dj,pvalue_dj = UT.calc_indttest(np.nanmean(uh_dj,axis=3),
                                     np.nanmean(uf_dj,axis=3))
stat_fm,pvalue_fm = UT.calc_indttest(np.nanmean(uh_fm,axis=3),
                                     np.nanmean(uf_fm,axis=3))

###########################################################################
###########################################################################
###########################################################################
#### Plot U
plt.rc('text',usetex=True)
plt.rc('font',**{'family':'sans-serif','sans-serif':['Avant Garde']}) 

### Set limits for contours and colorbars
limit = np.arange(-3,3.1,0.1)
barlim = np.arange(-3,4,1)
Esempio n. 18
0
def readWAFy(varnames, qbophase):
    lat, lon, time, lev, tashit = MO.readExperiAll('%s' % varnames[0], 'HIT',
                                                   'profile')
    lat, lon, time, lev, tasfict = MO.readExperiAll('%s' % varnames[0], 'FICT',
                                                    'profile')

    ### Create 2d array of latitude and longitude
    lon2, lat2 = np.meshgrid(lon, lat)

    ### Read in QBO phases
    filenamehitp = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[0]
    filenamehitno = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[1]
    filenamehitn = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    filenamehitp2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[0]
    filenamehitno2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[1]
    filenamehitn2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    pos_hit = np.append(
        np.genfromtxt(filenamehitp, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamehitp2, unpack=True, usecols=[0], dtype='int') +
        101)
    non_hit = np.append(
        np.genfromtxt(filenamehitno, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamehitno2, unpack=True, usecols=[0], dtype='int') +
        101)
    neg_hit = np.append(
        np.genfromtxt(filenamehitn, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamehitn2, unpack=True, usecols=[0], dtype='int') +
        101)

    filenamefictp = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[0]
    filenamefictno = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        1]
    filenamefictn = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[2]
    filenamefictp2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        0]
    filenamefictno2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        1]
    filenamefictn2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        2]
    pos_fict = np.append(
        np.genfromtxt(filenamefictp, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamefictp2, unpack=True, usecols=[0], dtype='int') +
        101)
    non_fict = np.append(
        np.genfromtxt(filenamefictno, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamefictno2, unpack=True, usecols=[0], dtype='int') +
        101)
    neg_fict = np.append(
        np.genfromtxt(filenamefictn, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamefictn2, unpack=True, usecols=[0], dtype='int') +
        101)
    ### Concatonate runs
    runs = [tashit, tasfict]

    ### Separate per periods (ON,DJ,FM)
    if period == 'ON':
        tas_mo = np.empty((3, tashit.shape[0], tashit.shape[2],
                           tashit.shape[3], tashit.shape[4]))
        for i in range(len(runs)):
            tas_mo[i] = np.nanmean(runs[i][:, 9:11, :, :, :], axis=1)
    elif period == 'DJ':
        tas_mo = np.empty((3, tashit.shape[0] - 1, tashit.shape[2],
                           tashit.shape[3], tashit.shape[4]))
        for i in range(len(runs)):
            tas_mo[i], tas_mo[i] = UT.calcDecJan(runs[i], runs[i], lat, lon,
                                                 'profile', 1)
    elif period == 'FM':
        tas_mo = np.empty((3, tashit.shape[0], tashit.shape[2],
                           tashit.shape[3], tashit.shape[4]))
        for i in range(len(runs)):
            tas_mo[i] = np.nanmean(runs[i][:, 1:3, :, :, :], axis=1)
    elif period == 'DJF':
        tas_mo = np.empty((3, tashit.shape[0] - 1, tashit.shape[2],
                           tashit.shape[3], tashit.shape[4]))
        for i in range(len(runs)):
            tas_mo[i], tas_mo[i] = UT.calcDecJanFeb(runs[i], runs[i], lat, lon,
                                                    'profile', 1)
    elif period == 'M':
        tas_mo = np.empty((3, tashit.shape[0], tashit.shape[2],
                           tashit.shape[3], tashit.shape[4]))
        for i in range(len(runs)):
            tas_mo[i] = runs[i][:, 2, :, :, :]
    elif period == 'D':
        tas_mo = np.empty((3, tashit.shape[0], tashit.shape[2],
                           tashit.shape[3], tashit.shape[4]))
        for i in range(len(runs)):
            tas_mo[i] = runs[i][:, -1, :, :, :]
    elif period == 'N':
        tas_mo = np.empty((3, tashit.shape[0], tashit.shape[2],
                           tashit.shape[3], tashit.shape[4]))
        for i in range(len(runs)):
            tas_mo[i] = runs[i][:, -2, :, :, :]
    elif period == 'ND':
        tas_mo = np.empty((3, tashit.shape[0], tashit.shape[2],
                           tashit.shape[3], tashit.shape[4]))
        for i in range(len(runs)):
            tas_mo[i] = np.nanmean(runs[i][:, -2:, :, :, :], axis=1)
    else:
        ValueError('Wrong period selected! (ON,DJ,FM)')

    ### Composite by QBO phase
    tas_mohitposq = tas_mo[0][pos_hit, :, :]
    tas_mofictposq = tas_mo[1][pos_fict, :, :]

    tas_mohitnonq = tas_mo[0][non_hit, :, :]
    tas_mofictnonq = tas_mo[1][non_fict, :, :]

    tas_mohitnegq = tas_mo[0][neg_hit, :, :]
    tas_mofictnegq = tas_mo[1][neg_fict, :, :]

    ### Take zonal average
    tas_mohitpos = np.nanmean(tas_mohitposq, axis=3)
    tas_mofictpos = np.nanmean(tas_mofictposq, axis=3)

    tas_mohitnon = np.nanmean(tas_mohitnonq, axis=3)
    tas_mofictnon = np.nanmean(tas_mofictnonq, axis=3)

    tas_mohitneg = np.nanmean(tas_mohitnegq, axis=3)
    tas_mofictneg = np.nanmean(tas_mofictnegq, axis=3)

    ficthitpos = np.nanmean(tas_mofictpos - tas_mohitpos, axis=0) / np.nanstd(
        tas_mofictpos, axis=0)
    ficthitnon = np.nanmean(tas_mofictnon - tas_mohitnon, axis=0) / np.nanstd(
        tas_mofictnon, axis=0)
    ficthitneg = np.nanmean(tas_mofictneg - tas_mohitneg, axis=0) / np.nanstd(
        tas_mofictneg, axis=0)
    diffruns_mo = [ficthitneg, ficthitpos, ficthitneg - ficthitpos]

    ### Calculate significance
    stat_FICTHITpos, pvalue_FICTHITpos = UT.calc_indttest(
        tas_mohitpos, tas_mofictpos)
    stat_FICTHITnon, pvalue_FICTHITnon = UT.calc_indttest(
        tas_mohitnon, tas_mofictnon)
    stat_FICTHITneg, pvalue_FICTHITneg = UT.calc_indttest(
        tas_mohitneg, tas_mofictneg)

    pruns_mo = [pvalue_FICTHITneg, pvalue_FICTHITpos, pvalue_FICTHITneg]
    return diffruns_mo, pruns_mo, lat, lon, lev
Esempio n. 19
0
    anompim = np.nanmean(anompi, axis=0)
    anomcum = np.nanmean(anomcu, axis=0)
    zdiffruns = np.append(anompim, anomcum, axis=0)

    ### Calculate climatologies
    zclimo = np.append(np.nanmean(varpastmz, axis=0),
                       np.nanmean(varcurrentmz, axis=0),
                       axis=0)

    ### Calculate significance for each month
    stat_past = np.empty((varpastmz.shape[1], len(lev), len(lat)))
    stat_current = np.empty((varpastmz.shape[1], len(lev), len(lat)))
    pvalue_past = np.empty((varpastmz.shape[1], len(lev), len(lat)))
    pvalue_current = np.empty((varpastmz.shape[1], len(lev), len(lat)))
    for i in range(varpastmz.shape[1]):
        stat_past[i], pvalue_past[i] = UT.calc_indttest(
            varfuturemz[:, i, :, :], varpastmz[:, i, :, :])
        stat_current[i], pvalue_current[i] = UT.calc_indttest(
            varfuturemz[:, i, :, :], varcurrentmz[:, i, :, :])

    pruns = np.append(pvalue_past, pvalue_current, axis=0)

    ###########################################################################
    ###########################################################################
    ###########################################################################
    #### Plot U
    plt.rc('text', usetex=True)
    plt.rc('font', **{'family': 'sans-serif', 'sans-serif': ['Avant Garde']})

    ### Set limits for contours and colorbars
    if varnames[v] == 'U':
        limit = np.arange(-2, 2.1, 0.1)
 climofict = np.nanmean(tas_dj[4],axis=0)
 
 climo = [climohit,climocit,climocit,climocit,climofit,climohit]
 
 ### Compute comparisons for FM - taken ensemble average
 diff_FITHIT = np.nanmean(tas_fm[1] - tas_fm[0],axis=0)
 diff_FITCIT = np.nanmean(tas_fm[1] - tas_fm[2],axis=0)
 diff_HITCIT = np.nanmean(tas_fm[0] - tas_fm[2],axis=0)
 diff_FICCIT = np.nanmean(tas_fm[3] - tas_fm[2],axis=0)
 diff_FICTFIT = np.nanmean(tas_fm[4] - tas_fm[1],axis=0)
 diff_FICTHIT = np.nanmean(tas_fm[4] - tas_fm[0],axis=0)
 diffruns_fm = np.asarray([diff_FITHIT,diff_FITCIT,diff_HITCIT,diff_FICCIT,
                           diff_FICTFIT,diff_FICTHIT])
 
 ### Calculate significance for FM
 stat_FITHIT,pvalue_FITHIT = UT.calc_indttest(tas_fm[1],tas_fm[0])
 stat_FITCIT,pvalue_FITCIT = UT.calc_indttest(tas_fm[1],tas_fm[2])
 stat_HITCIT,pvalue_HITCIT = UT.calc_indttest(tas_fm[0],tas_fm[2])
 stat_FICCIT,pvalue_FICCIT = UT.calc_indttest(tas_fm[3],tas_fm[2])
 stat_FICTFIT,pvalue_FICTFIT = UT.calc_indttest(tas_fm[4],tas_fm[1])
 stat_FICTHIT,pvalue_FICTHIT = UT.calc_indttest(tas_fm[4],tas_fm[0])
 pruns_fm = np.asarray([pvalue_FITHIT,pvalue_FITCIT,pvalue_HITCIT,pvalue_FICCIT,
                        pvalue_FICTFIT,pvalue_FICTHIT])
 
 ###########################################################################
 ###########################################################################
 ###########################################################################
 ### Plot surface temperature
 plt.rc('text',usetex=True)
 plt.rc('font',**{'family':'sans-serif','sans-serif':['Avant Garde']}) 
 
Esempio n. 21
0
### Separate per periods (ON,DJ,FM)
Z50h_on = np.nanmean(Z50h[:, 9:11, :, :], axis=1)
Z50f_on = np.nanmean(Z50f[:, 9:11, :, :], axis=1)

Z50h_dj, Z50f_dj = UT.calcDecJan(Z50h, Z50f, lat, lon, 'surface', 1)

Z50h_fm = np.nanmean(Z50h[:, 1:3, :, :], axis=1)
Z50f_fm = np.nanmean(Z50f[:, 1:3, :, :], axis=1)

### Calculate period differenceds
diff_on = np.nanmean((Z50f_on - Z50h_on), axis=0)
diff_dj = np.nanmean((Z50f_dj - Z50h_dj), axis=0)
diff_fm = np.nanmean((Z50f_fm - Z50h_fm), axis=0)

### Calculate significance
stat_on, pvalue_on = UT.calc_indttest(Z50h_on, Z50f_on)
stat_dj, pvalue_dj = UT.calc_indttest(Z50h_dj, Z50f_dj)
stat_fm, pvalue_fm = UT.calc_indttest(Z50h_fm, Z50f_fm)

###########################################################################
###########################################################################
###########################################################################
### Plot 50 mb heights
plt.rc('text', usetex=True)
plt.rc('font', **{'family': 'sans-serif', 'sans-serif': ['Avant Garde']})

### Set limits for contours and colorbars
limit = np.arange(-100, 100.1, 1)
barlim = np.arange(-100, 101, 50)

### Begin plot
### Calculate difference 
var1a = var1r[:71,:,:] - var1c[:71,:,:] 
var1b = var1r[71:,:,:] - var1c[71:,:,:]

var2a = var2r[:71,:,:] - var2c[:71,:,:] 
var2b = var2r[71:,:,:] - var2c[71:,:,:]

### Calculate ensemble means
var1ma = np.nanmean(var1a,axis=0)
var1mb = np.nanmean(var1b,axis=0)
var2ma = np.nanmean(var2a,axis=0)
var2mb = np.nanmean(var2b,axis=0)

### Calculate statistical significance
statvar1,pvaluevar1 = UT.calc_indttest(var1a,var1b)
statvar2,pvaluevar2 = UT.calc_indttest(var2a,var2b)

###########################################################################
###########################################################################
###########################################################################
### Plot variable data 
plt.rc('text',usetex=True)
plt.rc('font',**{'family':'sans-serif','sans-serif':['Avant Garde']}) 

if var1q == 'Z500':
    limitvar1c = np.arange(-50,51,5)
    barlimvar1c = np.arange(-50,51,25)
elif var1q == 'U10':
    limitvar1c = np.arange(-6,6.1,0.5)
    barlimvar1c = np.arange(-6,6.1,2)
Esempio n. 23
0
    experiments = [r'\textbf{FIT--HIT}', r'\textbf{FIC--CIT}']
    runs = [varhit, varfit, varfic, varcit]

    ### Separate per 2 month periods
    varmo_djf = np.empty(
        (4, varhit.shape[0] - 1, varhit.shape[2], varhit.shape[3]))
    for i in range(len(runs)):
        varmo_djf[i], varmo_djf[i] = UT.calcDecJanFeb(runs[i], runs[i], lat,
                                                      lon, 'surface', 1)

    ### Calculate differences [FIT-HIT and FICT - FIT]
    diff_fithit_djf = np.nanmean(varmo_djf[1] - varmo_djf[0], axis=0)
    diff_ficcit_djf = np.nanmean(varmo_djf[2] - varmo_djf[3], axis=0)

    ### Calculate significance
    stat_FITHITdjf, pvalue_FITHITdjf = UT.calc_indttest(
        varmo_djf[1], varmo_djf[0])
    stat_FICCITdjf, pvalue_FICCITdjf = UT.calc_indttest(
        varmo_djf[2], varmo_djf[3])

    ### Create mask of significant values
    pvalue_FITHITdjf[np.where(np.isnan(pvalue_FITHITdjf))] = 0.0
    pvalue_FICCITdjf[np.where(np.isnan(pvalue_FICCITdjf))] = 0.0

    pvalue_FITHIT = pvalue_FITHITdjf
    pvalue_FICCIT = pvalue_FICCITdjf

    ### Keep only values significant in both SIT and SIC responses
    diff_fithit_djfq = diff_fithit_djf * pvalue_FITHITdjf

    diff_ficcit_djfq = diff_ficcit_djf * pvalue_FICCITdjf
Esempio n. 24
0
def readDataGEOP(varnames):
    lat, lon, time, lev, varhit = DO.readMeanExperiAll('%s' % varnames, 'HIT',
                                                       'profileregional')
    lat, lon, time, lev, varfict = DO.readMeanExperiAll(
        '%s' % varnames, 'FICT', 'profileregional')

    ### Create 2d array of latitude and longitude
    lon2, lat2 = np.meshgrid(lon, lat)

    ### Read in QBO phases
    filenamehitp = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[0]
    filenamehitn = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    filenamehitp2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[0]
    filenamehitn2 = directorydata2 + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    pos_hit = np.append(
        np.genfromtxt(filenamehitp, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamehitp2, unpack=True, usecols=[0], dtype='int') +
        100)
    neg_hit = np.append(
        np.genfromtxt(filenamehitn, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamehitn2, unpack=True, usecols=[0], dtype='int') +
        100)

    filenamefictp = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[0]
    filenamefictn = directorydata + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[2]
    filenamefictp2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        0]
    filenamefictn2 = directorydata2 + 'FICT/monthly/QBO_%s_FICT.txt' % qbophase[
        2]
    pos_fict = np.append(
        np.genfromtxt(filenamefictp, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamefictp2, unpack=True, usecols=[0], dtype='int') +
        100)
    neg_fict = np.append(
        np.genfromtxt(filenamefictn, unpack=True, usecols=[0], dtype='int'),
        np.genfromtxt(filenamefictn2, unpack=True, usecols=[0], dtype='int') +
        100)
    ### Concatonate runs
    var_mo = [varhit, varfict]

    ### Composite by QBO phase
    var_mohitpos = var_mo[0][pos_hit, :]
    var_mofictpos = var_mo[1][pos_fict, :]

    var_mohitneg = var_mo[0][neg_hit, :]
    var_mofictneg = var_mo[1][neg_fict, :]

    ### Compute comparisons for months - taken ensemble average
    ficthitpos = np.nanmean(var_mofictpos - var_mohitpos, axis=0)
    ficthitneg = np.nanmean(var_mofictneg - var_mohitneg, axis=0)

    diffruns = [ficthitpos, ficthitneg]

    ### Calculate significance
    stat_FICTHITpos, pvalue_FICTHITpos = UT.calc_indttest(
        var_mo[1][pos_fict, :], var_mo[0][pos_hit, :])
    stat_FICTHITneg, pvalue_FICTHITneg = UT.calc_indttest(
        var_mo[1][neg_fict, :], var_mo[0][neg_hit, :])

    pruns = [pvalue_FICTHITpos, pvalue_FICTHITneg]
    return diffruns, pruns, lev
Esempio n. 25
0
ficthitneg = np.nanmean(tas_mofictneg - tas_mohitneg,axis=0)/np.nanstd(tas_mofictneg,axis=0)
#fithitpos = np.nanmean(sts.zscore(tas_mofitpos,axis=0) - sts.zscore(tas_mohitpos,axis=0),axis=0)
#fithitnon = np.nanmean(sts.zscore(tas_mofitnon,axis=0) - sts.zscore(tas_mohitnon,axis=0),axis=0)
#fithitneg = np.nanmean(sts.zscore(tas_mofitneg,axis=0) - sts.zscore(tas_mohitneg,axis=0),axis=0)
#
#ficthitpos = np.nanmean(sts.zscore(tas_mofictpos,axis=0) - sts.zscore(tas_mohitpos,axis=0),axis=0)
#ficthitnon = np.nanmean(sts.zscore(tas_mofictnon,axis=0) - sts.zscore(tas_mohitnon,axis=0),axis=0)
#ficthitneg = np.nanmean(sts.zscore(tas_mofictneg,axis=0) - sts.zscore(tas_mohitneg,axis=0),axis=0)
diffruns_mo = [fithitneg,fithitpos,fithitneg-fithitpos,
               ficthitneg,ficthitpos,ficthitneg-ficthitpos]

#diffruns_mo = [sts.zscore(fithitneg),sts.zscore(fithitpos),sts.zscore(fithitneg)-sts.zscore(fithitpos),
#               sts.zscore(ficthitneg),sts.zscore(ficthitpos),sts.zscore(ficthitneg)-sts.zscore(ficthitpos)]

### Calculate significance for FM
stat_FITHITpos,pvalue_FITHITpos = UT.calc_indttest(tas_mohitpos,
                                                   tas_mofitpos)
stat_FITHITnon,pvalue_FITHITnon = UT.calc_indttest(tas_mohitnon,
                                                   tas_mofitnon)
stat_FITHITneg,pvalue_FITHITneg = UT.calc_indttest(tas_mohitneg,
                                                   tas_mofitneg)

stat_FICTHITpos,pvalue_FICTHITpos = UT.calc_indttest(tas_mohitpos,
                                                     tas_mofictpos)
stat_FICTHITnon,pvalue_FICTHITnon = UT.calc_indttest(tas_mohitnon,
                                                     tas_mofictnon)
stat_FICTHITneg,pvalue_FICTHITneg = UT.calc_indttest(tas_mohitneg,
                                                     tas_mofictneg)

pruns_mo = [pvalue_FITHITneg,pvalue_FITHITpos,pvalue_FITHITneg,
            pvalue_FICTHITneg,pvalue_FICTHITpos,pvalue_FICTHITneg]
Esempio n. 26
0
        print('Completed: 10th perc of QBO-E for %s member!' % ens)

    ### Compute comparisons for days - taken ensemble average
    fsubcitpos = np.nanmean(ten_wfsubpos - ten_wcitpos, axis=0)
    fsubcitnon = np.nanmean(ten_wfsubnon - ten_wcitnon, axis=0)
    fsubcitneg = np.nanmean(ten_wfsubneg - ten_wcitneg, axis=0)

    fpolcitpos = np.nanmean(ten_wfpolpos - ten_wcitpos, axis=0)
    fpolcitnon = np.nanmean(ten_wfpolnon - ten_wcitnon, axis=0)
    fpolcitneg = np.nanmean(ten_wfpolneg - ten_wcitneg, axis=0)
    diffruns = [
        fsubcitpos, fsubcitnon, fsubcitneg, fpolcitpos, fpolcitnon, fpolcitneg
    ]

    ### Calculate significance for DJF
    stat_fsubcitpos, pvalue_fsubcitpos = UT.calc_indttest(
        ten_wfsubpos, ten_wcitpos)
    stat_fsubcitnon, pvalue_fsubcitnon = UT.calc_indttest(
        ten_wfsubnon, ten_wcitnon)
    stat_fsubcitneg, pvalue_fsubcitneg = UT.calc_indttest(
        ten_wfsubneg, ten_wcitneg)

    stat_fpolcitpos, pvalue_fpolcitpos = UT.calc_indttest(
        ten_wfpolpos, ten_wcitpos)
    stat_fpolcitnon, pvalue_fpolcitnon = UT.calc_indttest(
        ten_wfpolnon, ten_wcitnon)
    stat_fpolcitneg, pvalue_fpolcitneg = UT.calc_indttest(
        ten_wfpolneg, ten_wcitneg)

    pruns = [
        pvalue_fsubcitpos, pvalue_fsubcitnon, pvalue_fsubcitneg,
        pvalue_fpolcitpos, pvalue_fpolcitnon, pvalue_fpolcitneg
    climo = [climohitpos,climohitnon,climohitneg,
             climohitpos,climohitnon,climohitneg]
    
    ### Compute comparisons for months - taken ensemble average
    fithitpos = np.nanmean(tas_mofitpos - tas_mohitpos,axis=0)
    fithitnon = np.nanmean(tas_mofitnon - tas_mohitnon,axis=0)
    fithitneg = np.nanmean(tas_mofitneg - tas_mohitneg,axis=0)
    
    ficthitpos = np.nanmean(tas_mofictpos - tas_mohitpos,axis=0)
    ficthitnon = np.nanmean(tas_mofictnon - tas_mohitnon,axis=0)
    ficthitneg = np.nanmean(tas_mofictneg - tas_mohitneg,axis=0)
    diffruns_mo = [fithitpos,fithitnon,fithitneg,
                   ficthitpos,ficthitnon,ficthitneg]
    
    ### Calculate significance for FM
    stat_FITHITpos,pvalue_FITHITpos = UT.calc_indttest(tas_mo[1][pos_fit,:,:],
                                                       tas_mo[0][pos_hit,:,:])
    stat_FITHITnon,pvalue_FITHITnon = UT.calc_indttest(tas_mo[1][non_fit,:,:],
                                                   tas_mo[0][non_hit,:,:])
    stat_FITHITneg,pvalue_FITHITneg = UT.calc_indttest(tas_mo[1][neg_fit,:,:],
                                               tas_mo[0][neg_hit,:,:])
    
    stat_FICTHITpos,pvalue_FICTHITpos = UT.calc_indttest(tas_mo[2][pos_fict,:,:],
                                                       tas_mo[0][pos_hit,:,:])
    stat_FICTHITnon,pvalue_FICTHITnon = UT.calc_indttest(tas_mo[2][non_fict,:,:],
                                                   tas_mo[0][non_hit,:,:])
    stat_FICTHITneg,pvalue_FICTHITneg = UT.calc_indttest(tas_mo[2][neg_fict,:,:],
                                               tas_mo[0][neg_hit,:,:])

    pruns_mo = [pvalue_FITHITpos,pvalue_FITHITnon,pvalue_FITHITneg,
                pvalue_FICTHITpos,pvalue_FICTHITnon,pvalue_FICTHITneg]
    
Esempio n. 28
0
    negs = np.reshape(np.asarray(negs), (3, 64, 17, varcit.shape[1] - (N - 1)))

    ### Compute comparisons for months - taken ensemble average
    fsubcitpos = np.nanmean(var_mofsubpos - var_mocitpos, axis=0)
    fsubcitnon = np.nanmean(var_mofsubnon - var_mocitnon, axis=0)
    fsubcitneg = np.nanmean(var_mofsubneg - var_mocitneg, axis=0)

    fpolcitpos = np.nanmean(var_mofpolpos - var_mocitpos, axis=0)
    fpolcitnon = np.nanmean(var_mofpolnon - var_mocitnon, axis=0)
    fpolcitneg = np.nanmean(var_mofpolneg - var_mocitneg, axis=0)
    diffruns = [
        fsubcitpos, fsubcitnon, fsubcitneg, fpolcitpos, fpolcitnon, fpolcitneg
    ]

    ### Calculate significance for time
    stat_fsubcitpos, pvalue_fsubcitpos = UT.calc_indttest(poss[0], poss[1])
    stat_fsubcitnon, pvalue_fsubcitnon = UT.calc_indttest(nons[0], nons[1])
    stat_fsubcitneg, pvalue_fsubcitneg = UT.calc_indttest(negs[0], negs[1])

    stat_fpolcitpos, pvalue_fpolcitpos = UT.calc_indttest(poss[2], poss[1])
    stat_fpolcitnon, pvalue_fpolcitnon = UT.calc_indttest(nons[2], nons[1])
    stat_fpolcitneg, pvalue_fpolcitneg = UT.calc_indttest(negs[2], negs[1])

    pruns = [
        pvalue_fsubcitpos, pvalue_fsubcitnon, pvalue_fsubcitneg,
        pvalue_fpolcitpos, pvalue_fpolcitnon, pvalue_fpolcitneg
    ]

    ############################################################################
    ############################################################################
    ############################################################################
Esempio n. 29
0
    climo = [var_mohitnegz,var_mohitposz,var_mofictnegz,
             var_mohitnegz,var_mohitposz,var_mofictnegz]
    
    ### Compute comparisons for months - taken ensemble average
    fithitpos = np.nanmean(var_mofitposz - var_mohitposz,axis=0)
    fithitnon = np.nanmean(var_mofitnonz - var_mohitnonz,axis=0)
    fithitneg = np.nanmean(var_mofitnegz - var_mohitnegz,axis=0)
    
    ficthitpos = np.nanmean(var_mofictposz - var_mohitposz,axis=0)
    ficthitnon = np.nanmean(var_mofictnonz - var_mohitnonz,axis=0)
    ficthitneg = np.nanmean(var_mofictnegz - var_mohitnegz,axis=0)
    
    diffruns = [fithitneg,fithitpos,fithitneg-fithitpos,ficthitneg,ficthitpos,ficthitneg-ficthitpos]
    
    ### Calculate significance for FM
    stat_FITHITpos,pvalue_FITHITpos = UT.calc_indttest(var_mo[1][pos_fit],
                                                       var_mo[0][pos_hit,])
    stat_FITHITnon,pvalue_FITHITnon = UT.calc_indttest(var_mo[1][non_fit],
                                                       var_mo[0][non_hit])
    stat_FITHITneg,pvalue_FITHITneg = UT.calc_indttest(var_mo[1][neg_fit],
                                                       var_mo[0][neg_hit])
    
    stat_FICTHITpos,pvalue_FICTHITpos = UT.calc_indttest(var_mo[2][pos_fict],
                                                         var_mo[0][pos_hit])
    stat_FICTHITnon,pvalue_FICTHITnon = UT.calc_indttest(var_mo[2][non_fict],
                                                         var_mo[0][non_hit])
    stat_FICTHITneg,pvalue_FICTHITneg = UT.calc_indttest(var_mo[2][neg_fict],
                                                         var_mo[0][neg_hit])

    pruns = [pvalue_FITHITpos,pvalue_FITHITnon,pvalue_FITHITneg,
#                pvalue_FICTHITpos,pvalue_FICTHITnon,pvalue_FICTHITneg]
    
    filenamehitn = directorydata + 'HIT/monthly/QBO_%s_HIT.txt' % qbophase[2]
    pos_hit = np.genfromtxt(filenamehitp,unpack=True,usecols=[0],dtype='int')
    non_hit = np.genfromtxt(filenamehitno,unpack=True,usecols=[0],dtype='int')
    neg_hit = np.genfromtxt(filenamehitn,unpack=True,usecols=[0],dtype='int')
    
    varf_f = runs[1][:,1,:,:]
#    varf_f = varf_f[pos_hit,:,:]
    varf_m = runs[1][:,2,:,:]
#    varf_m = varf_m[pos_hit,:,:]
    
    ### Compute comparisons for FM - taken ensemble average
    diff_feb = np.nanmean(varf_f - varh_f,axis=0)
    diff_mar = np.nanmean(varf_m - varh_m,axis=0)
    
    ### Calculate significance for FM
    stat_feb,pvalue_feb = UT.calc_indttest(varfit[:,1,:,:],varhit[:,1,:,:])
    stat_mar,pvalue_mar = UT.calc_indttest(varfit[:,1,:,:],varhit[:,1,:,:])
    
    ### Read in wave number 
    lat,lon,time,lev,waveh= MO.readExperi(directorydata,
                                        '%sxwave1' % varnames[v],'HIT',
                                        'surface')
#    lat,lon,time,lev,wavef = MO.readExperi(directorydata,
#                                        '%sxwave1' % varnames[v],'FIT',
#                                        'surface')
    
    climowaveh_feb = np.nanmean(waveh[:,1,:,:],axis=0)
    climowaveh_mar = np.nanmean(waveh[:,2,:,:],axis=0)
    
    ###########################################################################
    ###########################################################################