def make_pickled_time_series(root,case,x,y,save_folder,overwrite=False):
    import time_data_functions as tdf
    from os.path import join,isfile
    if not overwrite and not isfile(
        join(save_folder,"{0}_px{1}_py{2}.p".format(
            case.replace('.hdf5',''),
            x,
            y
        ))):
        df = tdf.read_hdf5_time_series(
            join(root,case),
            case.replace('.hdf5',''),
            loc=(-y,x)
        )
    else:
        return 0
    if df is not None:
        df['x'] = x
        df['y'] = y
        df.to_pickle(join(save_folder,"{0}_px{1}_py{2}.p".format(
            case.replace('.hdf5',''),
            x,
            y
        )))
        return 0
def load_time_series(device="Sr20R21",alpha='0',phi='0',z='10', p=(-0.1,0.1)):
    from time_data_functions import read_hdf5_time_series
    import os

    #case = "{0}_a{1}_p{2}_U20_z{3}_tr_planar".format(
    #        device,
    #        alpha,
    #        phi,
    #        z
    #)
    case = "{0}_a{1}_p{2}_U20_z{3}_tr_NewProcessing".format(
            device,
            alpha,
            phi,
            z
    )

    hdf5_file = os.path.join(
        root,
        'TimeData_NewProcessing.hdf5'
        #'planar.hdf5'
    )
    
    return read_hdf5_time_series(
            hdf5_file,
            case,
            loc = p
        ).interpolate()
def make_hdf5_time_series(root, case, x, y, save_folder):
    import time_data_functions as tdf
    from os.path import join

    df = tdf.read_hdf5_time_series(join(root, case), case.replace(".hdf5", ""), loc=(-y, x))
    if df is not None:
        df["x"] = x
        df["y"] = y
        df.to_pickle(join(save_folder, "{0}_px{1}_py{2}.p".format(case.replace(".hdf5", ""), x, y)))