def _get_comparison_data_swe(    start_date = datetime(1980,1,1),
                                 end_date = datetime(1997, 12, 31),
    crcm4_data_folder = "/home/huziy/skynet1_rech3/crcm4_data/aex_p1sno",
    swe_obs_data_path = "data/swe_ross_brown/swe.nc",
    swe_var_name = "swe", season_to_months = None, crcm4_id = "aex"):

    cache_file = "seasonal_bias_{0}.bin".format(swe_var_name)

    if not os.path.isfile(cache_file):
        #get crcm4 data
        crcm4_data_store = {}
        for season, month_list in season_to_months.iteritems():
            data = ccc_analysis.get_seasonal_mean(crcm4_data_folder, start_date=start_date,
                end_date=end_date, months=month_list
            )

            crcm4_data_store[season] = data

        #get cru data
        cru_data_store = {}
        cru = CruReader(path=swe_obs_data_path, var_name=swe_var_name, transpose_xy_dimensions=False)
        lons2d_amno, lats2d_amno = polar_stereographic.lons, polar_stereographic.lats
        for season, month_list in season_to_months.iteritems():
            data = cru.get_seasonal_mean_field(months=month_list, start_date=start_date, end_date=end_date)

            nneighbors = 1 if swe_var_name in ["pre", "swe"] else 4
            data = cru.interpolate_data_to(data, lons2d_amno, lats2d_amno, nneighbors=nneighbors)
            cru_data_store[season] = data
        data_list = [cru_data_store, crcm4_data_store]
        pickle.dump(data_list, open(cache_file, "w"))
    else:
        data_list = pickle.load(open(cache_file))

    cru_data_store, crcm4_data_store = data_list
    return cru_data_store, crcm4_data_store
def _get_comparison_data(    start_date = datetime(1970,1,1),
    end_date = datetime(1999, 12, 31),
    crcm4_data_folder = "data/ccc_data/aex/aex_p1st",
    cru_data_path = "data/cru_data/CRUTS3.1/cru_ts_3_10.1901.2009.tmp.dat.nc",
    cru_var_name = "tmp", season_to_months = None, crcm4_id = "aex"):



    cache_file = "seasonal_bias_{0}.bin".format(cru_var_name)

    if not os.path.isfile(cache_file):
        #get crcm4 data
        crcm4_data_store = {}
        day_seconds = 24.0 * 60.0 * 60.0
        dt = members.id_to_step[crcm4_id]
        crcm4_coef = day_seconds
        for season, month_list in season_to_months.iteritems():
            data = ccc_analysis.get_seasonal_mean(crcm4_data_folder, start_date=start_date,
                end_date=end_date, months=month_list
            )

            if cru_var_name == "pre":
                data *= crcm4_coef

            crcm4_data_store[season] = data

        #get cru data
        cru_data_store = {}
        cru = CruReader(path=cru_data_path, var_name=cru_var_name)
        lons2d_amno, lats2d_amno = polar_stereographic.lons, polar_stereographic.lats
        dt = cru.get_time_step()
        cru_coef = day_seconds / (dt.seconds + dt.days * day_seconds)
        for season, month_list in season_to_months.iteritems():
            data = cru.get_seasonal_mean_field(months=month_list, start_date=start_date, end_date=end_date)

            nneighbors = 1 if cru_var_name == "pre" else 4

            data = cru.interpolate_data_to(data, lons2d_amno, lats2d_amno, nneighbors=nneighbors)

            if cru_var_name == "pre":
                data *= cru_coef

            cru_data_store[season] = data

        data_list = [cru_data_store, crcm4_data_store]
        pickle.dump(data_list, open(cache_file, "w"))
    else:
        data_list = pickle.load(open(cache_file))

    cru_data_store, crcm4_data_store = data_list
    return cru_data_store, crcm4_data_store