Ejemplo n.º 1
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]
Ejemplo n.º 2
0
### Alott time series
year1 = 1900
year2 = 2000
years = np.arange(year1,year2+1,1)

### Call arguments
varnames = ['Z500','Z30','SLP','T2M','U10','U500','U300','SWE','THICK','P',
            'EGR','WAFZ850','WAFZ150','WAFY850','WAFY150']
runnames = [r'HIT',r'FIT',r'FICT']
experiments = [r'\textbf{FIT--HIT}',r'\textbf{FIT--HIT}',r'\textbf{FIT--HIT}',
               r'\textbf{FICT--HIT}',r'\textbf{FICT--HIT}',r'\textbf{FICT--HIT}']
qbophase = ['pos','non','neg']
period = 'F'
for v in range(len(varnames)):
    ### Call function for surface temperature data from reach run
    lat,lon,time,lev,tashit = MO.readExperiAll('%s' % varnames[v],'HIT',
                                               'surface')
    lat,lon,time,lev,tasfit = MO.readExperiAll('%s' % varnames[v],'FIT',
                                               'surface')
    lat,lon,time,lev,tasfict = MO.readExperiAll('%s' % varnames[v],'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]
Ejemplo n.º 3
0
titletime = currentmn + '/' + currentdy + '/' + currentyr
print('\n' '----Plotting QBO profile regional comparisons - %s----' % titletime)

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

runnames = [r'CIT',r'FSUB',r'FPOL']
experiments = [r'\textbf{FSUB--CIT}',r'\textbf{FSUB--CIT}',r'\textbf{FSUB--CIT}',
               r'\textbf{FPOL--CIT}',r'\textbf{FPOL--CIT}',r'\textbf{FPOL--CIT}']
qbophase = ['pos','non','neg']
period = 'N'

### Call function for vertical temperature data
lat,lon,time,lev,epy_h = MO.readExperiAll('EPY','CIT','profile')
lat,lon,time,lev,epz_h = MO.readExperiAll('EPZ','CIT','profile')
lat,lon,time,lev,div_h = MO.readExperiAll('DEPF','CIT','profile')

lat,lon,time,lev,epy_f = MOR.readExperiAllRegional('EPY','FSUB','profile')
lat,lon,time,lev,epz_f = MOR.readExperiAllRegional('EPZ','FSUB','profile')
lat,lon,time,lev,div_f = MOR.readExperiAllRegional('DEPF','FSUB','profile')

lat,lon,time,lev,epy_fpol = MOR.readExperiAllRegional('EPY','FPOL','profile')
lat,lon,time,lev,epz_fpol = MOR.readExperiAllRegional('EPZ','FPOL','profile')
lat,lon,time,lev,div_fpol = MOR.readExperiAllRegional('DEPF','FPOL','profile')

### Separate per month
if period == 'N':
    epy_moh = epy_h[:,-2,:,:] 
    epz_moh = epz_h[:,-2,:,:] 
Ejemplo n.º 4
0
def readVariables(varnames, period, location):
    ### 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_mohitnon = tas_mo[0][non_hit, :, :]
    tas_mofictnon = tas_mo[1][non_fict, :, :]

    tas_mohitneg = tas_mo[0][neg_hit, :, :]
    tas_mofictneg = tas_mo[1][neg_fict, :, :]

    ### Compute comparisons for months - select region
    if varnames == 'SLP':
        lonq = np.where((lon >= 80) & (lon <= 120))[0]
        ficthitpos = tas_mofictpos[:, :, lonq]
        ficthitnon = tas_mofictnon[:, :, lonq]
        ficthitneg = tas_mofictneg[:, :, lonq]
        latq = np.where((lat >= 40) & (lat <= 65))[0]
        ficthitpos = ficthitpos[:, latq]
        ficthitnon = ficthitnon[:, latq]
        ficthitneg = ficthitneg[:, latq]
        lat2sq = lat2[latq, :]
        lat2s = lat2sq[:, lonq]
        ficthitpos = UT.calc_weightedAve(ficthitpos, lat2s)
        ficthitnon = UT.calc_weightedAve(ficthitnon, lat2s)
        ficthitneg = UT.calc_weightedAve(ficthitneg, lat2s)
    diffruns = [
        ficthitpos.squeeze(),
        ficthitnon.squeeze(),
        ficthitneg.squeeze()
    ]

    return diffruns, lat, lon, lev
Ejemplo n.º 5
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
Ejemplo n.º 6
0
titletime = currentmn + '/' + currentdy + '/' + currentyr
print('\n' '----Plotting linear interference - %s----' % titletime)

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

historicalforced = []
futureforced = []
lonss = []
varnames = ['GEOPxwave_all','GEOPxwave1','GEOPxwave2']
period = 'D'
for v in range(len(varnames)):
    ### Call function for wave data from reach run
    lat,lon1,time,lev,varcit = MO.readExperiAll('%s' % varnames[v],
                                             'CIT','profile')
    lat,lon1,time,lev,varfpol = MOR.readExperiAllRegional('%s' % varnames[v],
                                             'FPOL','profile')
    
    ### Missing data
    varcit[np.where(varcit<-100000)]=np.nan

    ### Modify lons 
    lon1[-1] = 360

    ### Create 2d array of latitude and longitude
    lon2,lat2 = np.meshgrid(lon1,lat)
    
    ### Concatonate runs
    runnames = [r'CIT',r'FPOL']
    experiments = [r'\textbf{FPOL--CIT}']
year2 = 2000
years = np.arange(year1, year2 + 1, 1)

historicalforcedpos = []
futureforcedpos = []
historicalforcednon = []
futureforcednon = []
historicalforcedneg = []
futureforcedneg = []
lonssq = []
varnames = ['GEOPxwave_all', 'GEOPxwave1', 'GEOPxwave2']
qbophase = ['pos', 'non', 'neg']
period = 'N'
for v in range(len(varnames)):
    ### Call function for surface temperature data from reach run
    lat, lon1, time, lev, tashit = MO.readExperiAll('%s' % varnames[v], 'HIT',
                                                    'profile')
    lat, lon1, time, lev, tasfict = MO.readExperiAll('%s' % varnames[v],
                                                     'FICT', 'profile')

    ### Modify lons
    lon1[-1] = 360

    ### Create 2d array of latitude and longitude
    lon2, lat2 = np.meshgrid(lon1, 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]
Ejemplo n.º 8
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
Ejemplo n.º 9
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')
    lat,lon,time,lev,tasfit = MO.readExperiAll('%s' % varnames,'FIT',
                                                '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]
    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')+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]
    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')+101)
    neg_fict = np.append(np.genfromtxt(filenamefictn,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamefictn2,unpack=True,usecols=[0],dtype='int')+101)
    
    filenamefitp = directorydata + 'FIT/monthly/QBO_%s_FIT.txt' % qbophase[0]
    filenamefitn = directorydata + 'FIT/monthly/QBO_%s_FIT.txt' % qbophase[2]
    filenamefitp2 = directorydata2 + 'FIT/monthly/QBO_%s_FIT.txt' % qbophase[0]
    filenamefitn2 = directorydata2 + 'FIT/monthly/QBO_%s_FIT.txt' % qbophase[2]
    pos_fit = np.append(np.genfromtxt(filenamefitp,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamefitp2,unpack=True,usecols=[0],dtype='int')+101)
    neg_fit = np.append(np.genfromtxt(filenamefitn,unpack=True,usecols=[0],dtype='int'),
                        np.genfromtxt(filenamefitn2,unpack=True,usecols=[0],dtype='int')+101)
    
    ### Concatonate runs
    runs = [tashit,tasfict,tasfit]
    
    ### 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_mofitpos = tas_mo[2][pos_fit,:,:]
    
    tas_mohitneg = tas_mo[0][neg_hit,:,:]
    tas_mofictneg = tas_mo[1][neg_fict,:,:]
    tas_mofitneg = tas_mo[2][neg_fit,:,:]
    
    
    ### Slice U10 at 65N
    latq = np.where((lat >= 64.5) & (lat <= 65.5))[0]
    lat = lat[latq].squeeze()
    tas_mohitpos = tas_mohitpos[:,latq,:].squeeze()
    tas_mohitneg = tas_mohitneg[:,latq,:].squeeze()
    tas_mofictpos = tas_mofictpos[:,latq,:].squeeze()
    tas_mofictneg = tas_mofictneg[:,latq,:].squeeze()
    tas_mofitpos = tas_mofitpos[:,latq,:].squeeze()
    tas_mofitneg = tas_mofitneg[:,latq,:].squeeze()
    
    ### Take zonal mean
    hitpos = np.nanmean(tas_mohitpos,axis=1)
    hitneg = np.nanmean(tas_mohitneg,axis=1)
    fictpos = np.nanmean(tas_mofictpos,axis=1)
    fictneg = np.nanmean(tas_mofictneg,axis=1)
    fitpos = np.nanmean(tas_mofitpos,axis=1)
    fitneg = np.nanmean(tas_mofitneg,axis=1)
    
    runs = [hitpos,hitneg,fictpos,fictneg,fitpos,fitneg]
    
    return runs,lat,lon
Ejemplo n.º 10
0
def procData(varnames, period, qbophase):
    """
    Function reads in zonal wind data for listed experiments. It then 
    post-processes the data for calculating the zero-wind line

    Parameters
    ----------
    varnames : list of strings
        list of variables to download
    period : list of strings
        month(s) to calculate
    qbophase : list of strings
        list of qbo phases

    Returns
    -------
    avez : list of arrays
        arrays for post-processed data for each experiment
    lat : 1d array
        latitude

    Usage
    -----
    avez,lat = procData(varnames,period,qbophase)
    """
    print('\n>>> Using procData function!')

    ### Read in data
    for v in range(len(varnames)):
        ### Call function for surface temperature data from reach run
        lat, lon, time, lev, tashit = MO.readExperiAll('%s' % varnames[v],
                                                       'HIT', 'profile')
        lat, lon, time, lev, tasfit = MO.readExperiAll('%s' % varnames[v],
                                                       'FIT', 'profile')
        lat, lon, time, lev, tasfict = MO.readExperiAll(
            '%s' % varnames[v], '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]
        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')
            + 101)
        neg_hit = np.append(
            np.genfromtxt(filenamehitn, unpack=True, usecols=[0], dtype='int'),
            np.genfromtxt(filenamehitn2, unpack=True, usecols=[0], dtype='int')
            + 101)

        filenamefitp = directorydata + 'FIT/monthly/QBO_%s_FIT.txt' % qbophase[
            0]
        filenamefitn = directorydata + 'FIT/monthly/QBO_%s_FIT.txt' % qbophase[
            2]
        filenamefitp2 = directorydata2 + 'FIT/monthly/QBO_%s_FIT.txt' % qbophase[
            0]
        filenamefitn2 = directorydata2 + 'FIT/monthly/QBO_%s_FIT.txt' % qbophase[
            2]
        pos_fit = np.append(
            np.genfromtxt(filenamefitp, unpack=True, usecols=[0], dtype='int'),
            np.genfromtxt(filenamefitp2, unpack=True, usecols=[0], dtype='int')
            + 101)
        neg_fit = np.append(
            np.genfromtxt(filenamefitn, unpack=True, usecols=[0], dtype='int'),
            np.genfromtxt(filenamefitn2, unpack=True, usecols=[0], dtype='int')
            + 101)

        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') + 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, tasfit, tasfict]

        ### Separate per periods (ON,DJ,FM)
        if 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', 17)
        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! (DJF)')

        ### Concatonate runs with selected level
        levq = np.where(lev == 30)[0]  # selected at 10 hPa
        tas_mo = [
            tas_mo[0][:, levq, :, :], tas_mo[1][:, levq, :, :],
            tas_mo[2][:, levq, :, :]
        ]

        ### Composite by QBO phase
        tas_mofitpos = tas_mo[1][pos_fit, :, :].squeeze()
        tas_mohitpos = tas_mo[0][pos_hit, :, :].squeeze()
        tas_mofictpos = tas_mo[2][pos_fict, :, :].squeeze()

        tas_mofitneg = tas_mo[1][neg_fit, :, :].squeeze()
        tas_mohitneg = tas_mo[0][neg_hit, :, :].squeeze()
        tas_mofictneg = tas_mo[2][neg_fict, :, :].squeeze()

        ### Compute meridional average
        tas_mofitposz = np.nanmean(tas_mofitpos, axis=2)
        tas_mohitposz = np.nanmean(tas_mohitpos, axis=2)
        tas_mofictposz = np.nanmean(tas_mofictpos, axis=2)

        tas_mofitnegz = np.nanmean(tas_mofitneg, axis=2)
        tas_mohitnegz = np.nanmean(tas_mohitneg, axis=2)
        tas_mofictnegz = np.nanmean(tas_mofictneg, axis=2)

        avez = [
            tas_mofitposz, tas_mohitposz, tas_mofictposz, tas_mofitnegz,
            tas_mohitnegz, tas_mofictnegz
        ]

        print('\n*Completed: Finished procData function!')
        return avez, lat
Ejemplo n.º 11
0
currenttime = currentmn + '_' + currentdy + '_' + currentyr
titletime = currentmn + '/' + currentdy + '/' + currentyr
print('\n' '----Plotting QBO profile - %s----' % titletime)

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

### Call arguments
varnames = ['U']
runnames = [r'HIT', 'CTLQ']
qbophase = ['pos', 'non', 'neg']
v = 0
### HIT -- Call function for surface temperature data from reach run
lat, lon, time, lev, uhitq = MO.readExperiAll('%s' % varnames[v], 'HIT',
                                              'profile')
uhitq = np.asarray(uhitq)
uhitq[np.where(uhitq < -999)] = np.nan

### Create 2d array of latitude and longitude
monthq = [0, 1, 2, 8, 9, 10, 11]

latq = np.where((lat >= -5) & (lat <= 5))[0]
uhit = np.nanmean(uhitq[:, :, :, latq, :], axis=3)
uhitzonal = np.nanmean(uhit[:, :, :, :], axis=3)

### Calculate anomalies
meanu = np.nanmean(uhitzonal, axis=0)
anom = uhitzonal - meanu

ustack = np.reshape(
Ejemplo n.º 12
0
years = np.arange(year1, year2 + 1, 1)

### Call arguments
varnames = ['Z300']
runnames = [r'CIT', r'FSUB', r'FPOL']
experiments = [
    r'\textbf{FSUB--CIT}', r'\textbf{FSUB--CIT}', r'\textbf{FSUB-CIT}',
    r'\textbf{FPOL--CIT}', r'\textbf{FPOL--CIT}', r'\textbf{FPOL--CIT}'
]
qbophase = ['pos', 'non', 'neg']
period = 'N'
wv = 'Z300xwave2'
MASK = False
for v in range(len(varnames)):
    ### Call function for data from reach run
    lat, lon, time, lev, tascit = MO.readExperiAll('%s' % varnames[v], 'CIT',
                                                   'surface')
    lat, lon, time, lev, tasfsub = MOR.readExperiAllRegional(
        '%s' % varnames[v], 'FSUB', 'surface')
    lat, lon, time, lev, tasfpol = MOR.readExperiAllRegional(
        '%s' % varnames[v], 'FPOL', 'surface')

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

    ### Read in QBO phases
    filenamecitp = directorydata + 'CIT/monthly/QBO_%s_CIT.txt' % qbophase[0]
    filenamecitno = directorydata + 'CIT/monthly/QBO_%s_CIT.txt' % qbophase[1]
    filenamecitn = directorydata + 'CIT/monthly/QBO_%s_CIT.txt' % qbophase[2]
    filenamecitp2 = directorydata2 + 'CIT/monthly/QBO_%s_CIT.txt' % qbophase[0]
    filenamecitno2 = directorydata2 + 'CIT/monthly/QBO_%s_CIT.txt' % qbophase[1]
    filenamecitn2 = directorydata2 + 'CIT/monthly/QBO_%s_CIT.txt' % qbophase[2]
Ejemplo n.º 13
0
titletime = currentmn + '/' + currentdy + '/' + currentyr
print('\n' '----Plotting QBO profile comparisons - %s----' % titletime)

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

runnames = [r'HIT',r'FIT',r'FICT']
experiments = [r'\textbf{FIT--HIT}',r'\textbf{FIT--HIT}',r'\textbf{FIT--HIT}',
               r'\textbf{FICT--HIT}',r'\textbf{FICT--HIT}',r'\textbf{FICT--HIT}']
qbophase = ['pos','non','neg']
period = 'N'

### Call function for vertical temperature data
lat,lon,time,lev,epy_h = MO.readExperiAll('EPY','HIT','profile')
lat,lon,time,lev,epz_h = MO.readExperiAll('EPZ','HIT','profile')
lat,lon,time,lev,div_h = MO.readExperiAll('DEPF','HIT','profile')

lat,lon,time,lev,epy_f = MO.readExperiAll('EPY','FIT','profile')
lat,lon,time,lev,epz_f = MO.readExperiAll('EPZ','FIT','profile')
lat,lon,time,lev,div_f = MO.readExperiAll('DEPF','FIT','profile')

lat,lon,time,lev,epy_fict = MO.readExperiAll('EPY','FICT','profile')
lat,lon,time,lev,epz_fict = MO.readExperiAll('EPZ','FICT','profile')
lat,lon,time,lev,div_fict = MO.readExperiAll('DEPF','FICT','profile')

### Separate per month
if period == 'N':
    epy_moh = epy_h[:,-2,:,:] 
    epz_moh = epz_h[:,-2,:,:] 
currenttime = currentmn + '_' + currentdy + '_' + currentyr
titletime = currentmn + '/' + currentdy + '/' + currentyr
print('\n' '----Plotting Heat Flux Comparison Regional - %s----' % titletime)

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

### Call arguments
varnames = 'RNET'
runnames = [r'CIT', r'FSUB', r'FPOL']
experiments = [r'\textbf{FSUB--CIT}', r'\textbf{FPOL--CIT}']

### Call function for rnet data from reach run
lat, lon, time, lev, tascit = MO.readExperiAll('%s' % varnames, 'CIT',
                                               'surface')
lat, lon, time, lev, tasfsub = MOR.readExperiAllRegional(
    '%s' % varnames, 'FSUB', 'surface')
lat, lon, time, lev, tasfpol = MOR.readExperiAllRegional(
    '%s' % varnames, 'FPOL', 'surface')

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

### Calculate Oct-Mar
tascitmo = np.append(tascit[:, 9:, :, :], tascit[:, :3, :, :], axis=1)
tasfsubmo = np.append(tasfsub[:, 9:, :, :], tasfsub[:, :3, :, :], axis=1)
tasfpolmo = np.append(tasfpol[:, 9:, :, :], tasfpol[:, :3, :, :], axis=1)

### Take difference
fsubcit = np.nanmean(tasfsubmo - tascitmo, axis=0)
def readVar(varnames,runnames,qbophase,period):
    for v in range(len(varnames)):
        ### Call function for surface temperature data from reach run
        lat,lon,time,lev,tashit = MO.readExperiAll('%s' % varnames[v],'HIT',
                                                   'surface')
        lat,lon,time,lev,tasfit = MO.readExperiAll('%s' % varnames[v],'FIT',
                                                   'surface')
        lat,lon,time,lev,tasfict = MO.readExperiAll('%s' % varnames[v],'FIT',
                                                    '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]
        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')+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]
        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')+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,tasfit,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:
            print(ValueError('Wrong period selected!'))
            
        ### Composite by QBO phase    
        vhitpos = tas_mo[0][pos_hit,:,:]
        vfictpos = tas_mo[2][pos_fict,:,:]
        
        vhitneg = tas_mo[0][neg_hit,:,:]
        vfictneg = tas_mo[2][neg_fict,:,:]
        
        ### Compute comparisons for months - taken ensemble average
        ficthitpos = np.nanmean(vfictpos - vhitpos,axis=0)
        ficthitneg = np.nanmean(vfictneg - vhitneg,axis=0)
    return vhitpos,vfictpos,vhitneg,vfictneg,ficthitpos,ficthitneg,lat,lon