Beispiel #1
0
def compute_targoffset(ncicedt,dosia=True,dospatial=False,verb=True):
    """ dospatial supercedes dosia

    """
    sies={}
    for case in ncicedt.keys():
        if verb:
            print case
            
        icetmp = np.mean(ncicedt[case],axis=0)#/100.

            
        if dospatial: # this is for spatial scaling
            verb=False
            sies[case] = icetmp/100.
        else:
            if dosia:
                print 'icetmp.shape ' + str(icetmp.shape) # @@@@@@@@@@@@@@@22
                if last=='last200':
                    sies[case] = icetmp #@@ test
                else:
                    sies[case],_ = cutl.calc_totseaicearea(icetmp/100.,lat,lon,model=None,isarea=False)
            else:
                if last=='last200':
                    print 'SIE for last200 not implemented! @@@'
                else:
                    sies[case],_ = cutl.calc_seaiceextent(icetmp/100.,lat,lon,model=None)
            
    fullchange = sies['2xco22xco2ice'] - sies['preipreiice']
    
    pctoffsets={}; offsets={}
    offsets['icecold'] = (sies['2xco22xco2ice'] - sies['prei2xco2iceb'])/1e12
    pctoffsets['icecold'] = (sies['2xco22xco2ice'] - sies['prei2xco2iceb']) / fullchange * 100
    # for co2lo: how much deviation is the sea ice from climo (here an increase 
    #            --> except still means co2 isolation contaminated by sea ice loss)
    offsets['co2lo'] = (sies['2xco22xco2ice']-sies['prei2xco2iceb'])/1e12
    pctoffsets['co2lo'] = (sies['2xco22xco2ice']-sies['prei2xco2iceb'])/sies['2xco22xco2ice']*100
    #pctoffsets['co2lo'] = pctoffsets['icecold']
    offsets['icewarm'] = (sies['2xco2preiice'] - sies['preipreiice'])/1e12
    pctoffsets['icewarm'] = (sies['2xco2preiice'] - sies['preipreiice']) / fullchange * 100
    # for co2hi: how much deviation is the sea ice from climo (here a decrease)
    offsets['co2hi'] = (sies['2xco2preiice'] - sies['preipreiice'])/1e12
    pctoffsets['co2hi'] = (sies['2xco2preiice'] - sies['preipreiice'])/sies['preipreiice']*100
    #pctoffsets['co2hi'] = pctoffsets['icewarm']
    
    if verb:
        print '\n   CO2hi: CO2 isolation has a effect from ice melt (ice not grown enough): ' +\
            str(pctoffsets['co2hi']) + '% of climo'
        print '   CO2lo: CO2 isolation has a effect from ice melt (ice not melted enough): ' +\
            str(pctoffsets['co2lo']) + '% of climo'
        print '   ICEwarm: sea ice melt effect is underestimated (ice not grown enough): ' +\
            str(pctoffsets['icewarm']) + '% of full change'
        print '   ICEcold: sea ice melt effect is underestimated (ice not melted enough): ' +\
            str(pctoffsets['icecold']) + '% of full change\n'
         
    return offsets,pctoffsets
Beispiel #2
0
            lon=cnc.getNCvar(fname,'lon')
            
        fld = cnc.getNCvar(fname,field,timesel=timesel,seas=sea)
        # select a given time period and keep maps
        fldsel = cnc.getNCvar(fname,field,timesel=timesel2,seas=sea)
        nt = fldsel.shape[0]
        nlon=fldsel.shape[2]
        nlat=fldsel.shape[1]
        fldre = fldsel.reshape((nt,nlon*nlat))

        xx=np.arange(0,nt)
        
        #ensseldt[eii] = fldsel

        if field=='sic':
            ensnhdt[eii],ensshdt[eii] = cutl.calc_totseaicearea(fld/100.,lat,lon,isarea=False)
            fldsel=cutl.calc_seaicearea(fldsel,lat,lon)
            fldre=fldsel.reshape((nt,nlon*nlat))
        else:
            ensgmdt[eii] = cutl.global_mean_areawgted3d(fld,lat,lon)
            ensrmdt[eii] = cutl.calc_regmean(fld,lat,lon,region)

    
        #slope[eii], intercept, r_value, p_value, std_err = sp.stats.linregress(xx,dat) # not good for 3d data?
        # this is just the second timesel (ie 2002-2012)
        slope,intercept = np.polyfit(xx,fldre,1) # supposedly can do w/ higher dims?
        
        enstrnddt[eii] = slope #.reshape((nlat,nlon)) # reshape later @@

        # also save all trends into one dictionary (don't differentiate by seed/base run)
        alltrnddt[superii] = slope
# RMSE averaged >60N for each relaxation run (preI nudged to 2xco2 ice) compared to gregory_2xco2

# <codecell>

# calc total sea ice area/volume, plot it

mons = np.arange(1, 13)

fldpltdt = {}
fldplttsdt = {}
fldpltclimdt = {}
if field == "sicn":

    for skey in sims:
        fldpltclimdt[skey], sh = cutl.calc_totseaicearea(fldclimdt[skey], lat, lon)
        fldplttsdt[skey], sh = cutl.calc_totseaicearea(flddt[skey], lat, lon)

    tstr = "SIA (millions of km^2)"
    divby = np.float(1e12)  # convert sea ice area to millions of km2

elif field == "sic":
    # need sea ice area to calc volume
    field = "sicn"
    ncfield = field.upper()
    conv = 1

    for skey in sims:
        fname = basepath + skey + subdir + skey + "_" + field + "_" + timeperdt[skey] + "_ts.nc"
        flds = cnc.getNCvar(fname, ncfield, timesel=timeseldt[skey]) * conv  # sea ice conc
        fldplttsdt[skey], sh = cutl.calc_totseaicevol(flddt[skey], flds, lat, lon)  # time series of ice vol
    for ii in range(0,6):

        simfld=flddiff[ii]
        simcfld=fldcavg[ii]
        simpfld=fldpavg[ii]

        if field=='sicn':

            if sie:
                pstr='SIEnh'
                plotfldc,_ = cutl.calc_seaiceextent(simcfld,lat,lon,model=None)
                plotfldp,_ = cutl.calc_seaiceextent(simpfld,lat,lon,model=None)
            else: # sia
                pstr='SIAnh'
                tlabs['sicn'] = 'SIA (millions of km$^2$)'
                plotfldc,_ = cutl.calc_totseaicearea(simcfld,lat,lon,model=None)
                plotfldp,_ = cutl.calc_totseaicearea(simpfld,lat,lon,model=None)

            plotfld = plotfldp-plotfldc
            #plotfld,_ = cutl.calc_totseaicearea(simfld,lat,lon,model=None)
        elif field=='sic':
            tmpc=fldcdat['sicn'][ii]
            tmpp=fldpdat['sicn'][ii]
            plotfldc,_ = cutl.calc_totseaicevol(simcfld*conv,tmpc,lat,lon)
            plotfldp,_ = cutl.calc_totseaicevol(simpfld*conv,tmpp,lat,lon)
            plotfld = plotfldp-plotfldc
            #print conv
            #print 'plotfldc,plotfldp' + str(plotfldc)+',' + str(plotfldp)
        else:
            print '@@ field ' + field + ' not recognized' 
            break