Ejemplo n.º 1
0
def read_primary_dataset(variq,dataset,lat_bounds,lon_bounds):
    data,lats,lons = df.readFiles(variq,dataset,monthlychoice)
    datar,lats,lons = df.getRegion(data,lats,lons,lat_bounds,lon_bounds)
    print('\nOur dataset: ',dataset,' is shaped',data.shape)
    return datar,lats,lons

for i in range(len(variq)):
    ### Read in data for selected region                
    lat_bounds,lon_bounds = UT.regions(reg_name)
    dataall,lats,lons = read_primary_dataset(variq[i],dataset,
                                              lat_bounds,lon_bounds)
    
    ### Remove ensemble mean
    if rm_ensemble_mean == True:
        data= dSS.remove_ensemble_mean(dataall)
        print('*Removed ensemble mean*')
    elif rm_ensemble_mean ==  False:
        data = dataall
        
    ### Calculate ensemble mean
    meandata = np.nanmean(data,axis=0)
    del data #save storage
    
    ### Composite over selected period (x2)
    if monthlychoice == 'DJF':
        years = np.arange(meandata.shape[0]) + 1921
    else:
        years = np.arange(meandata.shape[0]) + 1920
        
    length = years.shape[0]//2
                test_output_mat = np.empty(
                    (np.max(expList) + 1, foldsN, 180 * int(
                        np.round(
                            np.shape(data_all)[0] *
                            (1.0 - segment_data_factor)))))

                for exp in expList:
                    # get the data together
                    data, data_obs, = data_all, data_obs_all,
                    if rm_annual_mean == True:
                        data, data_obs = dSS.remove_annual_mean(
                            data, data_obs, lats, lons, lats_obs, lons_obs)
                        print('*Removed annual mean*')

                    if rm_ensemble_mean == True:
                        datae = dSS.remove_ensemble_mean(data)
                        print('*Removed ensemble mean*')

                    if rm_standard_dev == True:
                        data = dSS.rm_standard_dev(datae, window)
                        print('*Removed standard deviation*')

                    if land_only == True:
                        data, data_obs = dSS.remove_ocean(
                            data, data_obs, lat_bounds, lon_bounds)

                    if ocean_only == True:
                        data, data_obs = dSS.remove_land(
                            data, data_obs, lat_bounds, lon_bounds)

                #     ### Loop over folds