<commit_before># Create a plot of age vs Jz.
# Create a plot of rotation period vs age.

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

import os

DATA_DIR = "/export/bbq2/angusr/granola/granola/data"
RESULTS_DIR = "/export/bbq2/angusr/granola/granola/results"

# load metcalfe and silva catalogues and merge.
met = pd.read_csv(os.path.join(DATA_DIR, "metcalfe.csv"))
sil = pd.read_csv(os.path.join(DATA_DIR, "silva_aguirre.csv"))

print(met.keys())
print(sil.keys())
data = pd.merge(met, sil, on="KIC", how="right")
print(data.keys())

# load samples.
with h5py.File(os.path.join(RESULTS_DIR, "")
for i, kic in enumerate(data.KIC.values):


# calculate their ages.

# plot rotation period vs age<commit_msg>plot of age vs rotation<commit_after># Create a plot of age vs Jz.
# Create a plot of rotation period vs age.

from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import h5py
import random

import os

import barnes_age as ba
import teff_bv as tb

DATA_DIR = "/export/bbq2/angusr/granola/granola/data"
RESULTS_DIR = "/export/bbq2/angusr/granola/granola/seismology/results"

# load van Saders catalogue
vs = pd.read_csv(os.path.join(DATA_DIR, "vanSaders.txt"))

# load metcalfe and silva catalogues and merge.
met = pd.read_csv(os.path.join(DATA_DIR, "metcalfe.csv"))
sil = pd.read_csv(os.path.join(DATA_DIR, "silva_aguirre.csv"))
data = pd.merge(met, sil, on=["KIC", "age"], how="right")

print(data.keys())

# make a plot of rotation period vs asteroseismic age.
plt.clf()
for i, kic in enumerate(data.KIC.values):
    m = data.KIC.values == int(kic)
    mv = vs.KIC.values == int(kic)
    in_vs = False
    if len(vs.KIC.values[mv]):  # is it in the van Saders catalogue?
        in_vs = True
    print(int(kic))
    if os.path.exists(os.path.join(RESULTS_DIR, "{}.h5".format(int(kic)))):
        with h5py.File(os.path.join(RESULTS_DIR,
                       "{}.h5".format(int(kic))), "r") as f:
            samples = f["samples"][...]
            nw, ns, nd = np.shape(samples)
            psamps = random.sample(np.reshape(samples[:, :, 4], nw*ns), 500)
            p = np.median(psamps)
            perrp = np.percentile(psamps, 84) - p
            perrm = p - np.percentile(psamps, 16)
            plt.errorbar(data.age.values[m], p, yerr=perrm, fmt="k.")
            if in_vs:
                plt.errorbar(data.age.values[m], p, yerr=perrm, fmt="r.")

plt.xlabel("Age (Gyr)")
plt.ylabel("Period (days)")
plt.savefig("age_period")

# calculate their ages.

# plot rotation period vs age
{'fraction_non_alphanumeric': 0.14396284829721362, 'fraction_numerical': 0.006578947368421052, 'mean_word_length': 3.4188034188034186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1522086', 'n_tokens_mistral': 986, 'n_tokens_neox': 947, 'n_words': 240}