Ejemplo n.º 1
0
    def test_read_file_to_df_funct(self):
        """
        Create df with index and 10 rows
        Save that to a csv file
        Read that csv file
        Check the index 0 is correct
        Check index 0 dtype is a timestamp
        Check length of df is correct.
        :return:
        """
        # check reads file correctly
        # use the function to read the file.
        df_testread = preprocessing.read_file_to_df(self.save_str)

        # check index [0] is correct
        first_index = (df_testread.index[0])
        self.assertEqual(str(first_index), self.start)

        # check index is a timestamp.
        self.assertEqual(type(first_index), pd.Timestamp)

        # check length is correct
        self.assertEqual(len(df_testread), 100)
Ejemplo n.º 2
0
        "xlabel": "Time",
        "ylabel": "Days",
        "interval": 6,
        "title": "Double Plotted Actogram",
    }

    return fig, ax[-1], params_dict


# read in the data file

file_dir = pathlib.Path("/Users/angusfisk/Documents/01_PhD_files/01_projects"
                        "/01_thesisdata/04_ageing"
                        "/01_datafiles/01_activity")
file = sorted(file_dir.glob("*.csv"))[0]
df = prep.read_file_to_df(file, index_col=0)

# resample to hourly so can actually work with this data
df_h = df.resample("H").mean()

# try and do a loop with one for each

actogram_kwargs = {
    "drop_level": False,
    "set_file_title": False,
    "linewidth": 0.1,
}

fig, ax = plt.subplots(nrows=3, ncols=2)

for anim, subplot in enumerate(ax.flatten()):
Ejemplo n.º 3
0
file_dir = pathlib.Path(
    "/Users/angusfisk/Documents/01_PhD_files/01_projects"
    "/01_thesisdata/04_ageing"
    "/01_datafiles/01_activity/03_single_housed/01_concat"
)
save_dir = pathlib.Path(
    "/Users/angusfisk/Documents/"
    "01_PhD_files/01_projects/01_thesisdata/04_ageing/"
    "03_analysisoutputs/01_figures"
)

save_fig = save_dir / "04_fig4.png"

files = sorted(file_dir.glob("*.csv"))
file_names = [x.stem.upper() for x in files]
df_list = [prep.read_file_to_df(x, index_col=[0, 1]) for x in files]
df_dict = dict(zip(file_names, df_list))
all_df = pd.concat(df_dict, sort=False)

# PIRS 6-11 look like they had LL for a few weeks from the actograms
# No notes to support what actually happened but unsure so excluding
all_df.loc[idx["LD"], "7":"12"] = np.nan
all_df.loc[idx["SJ"], "10"] = np.nan

# JUST use LD for now? - redo as new figure for DD
light_df = all_df.loc[idx[:, "ld", :], :].copy()
light_df.index = light_df.index.droplevel(1)
all_df = light_df.copy()

# constants
conditions = all_df.index.get_level_values(0).unique()
Ejemplo n.º 4
0
    0, "/Users/angusfisk/Documents/01_PhD_files/"
    "07_python_package/actiPy")
import actiPy.preprocessing as prep
import actiPy.actogram_plot as aplot

# read in the data files
file_dir = pathlib.Path("/Users/angusfisk/Documents/01_PhD_files/01_projects"
                        "/01_thesisdata/04_ageing"
                        "/01_datafiles/01_activity")
save_dir = pathlib.Path("/Users/angusfisk/Documents/"
                        "01_PhD_files/01_projects/01_thesisdata/04_ageing/"
                        "03_analysisoutputs/01_figures")

files = sorted(file_dir.glob("*.csv"))
file_names = [x.stem for x in files]
df_list = [prep.read_file_to_df(x, index_col=0) for x in files]
df_dict = dict(zip(file_names, df_list))
all_df = pd.concat(df_dict, sort=False)

# read in the post_disrupted files
post_file_dir = pathlib.Path(
    "/Users/angusfisk/Documents/01_PhD_files/01_projects"
    "/01_thesisdata/04_ageing"
    "/01_datafiles/01_activity/01_post_disrupt")
post_files = sorted(post_file_dir.glob("*.csv"))
post_file_names = [x.stem for x in post_files]
post_list = [prep.read_file_to_df(x, index_col=0) for x in post_files]
post_dict = dict(zip(post_file_names, post_list))
post_df = pd.concat(post_dict, sort=False)

# shift to lights on