<jupyter_start><jupyter_text>Use the *freq* method to estimate a white dwarf age ========================================== In this tutotial we will estimate the age of two white dwarfs using the *freq* method in *wdwarfdate*. We will start by importing the packages we need.<jupyter_code>import wdwarfdate  
import numpy as np
import time<jupyter_output><empty_output><jupyter_text>Then we set up the effective temperatures and surface gravity that *wdwarfdate* needs to run. The values used in this tutorial are from Cummings,J.D. et al. 2018.<jupyter_code>#Define data for the white dwarf
teffs = np.array([19250,20250])
teffs_err = np.array([500,850])
loggs = np.array([8.16,8.526])
loggs_err = np.array([0.084,0.126])<jupyter_output><empty_output><jupyter_text>Now we run the age estimation using the *freq* method and take the time it takes to run. We are going to explicitly indicate the models we wanted to use:1) `model_wd = 'DA'`, for type of white dwarf2) `model_ifmr = 'Cummings_2018_MIST'`, for the initial-to-final mass relation 3) `feh = 'p0.00'` and `vvcrit='0.0'`, for the isochrone of the progenitor starThese are the default models so we do not need to do it in this case, but we will write them down to be clear. We will also specify the high and low percentiles we want to use to calculate the errors for each parameter. With the `data_type = 'Gyr'` parameters we will select the units of the resulting ages to be Gyr. Finally we will select `return_distributions = True` so we obtain the distributions for each of the resulting parameters. We will leave `plot = False` (default) because we are going to plot the distributions by hand, but if it is set to True, the code will save the distributions automatically.<jupyter_code>start = time.time()
results = wdwarfdate.calc_wd_age(teffs,teffs_err,loggs,loggs_err,
                                 method='freq',
                                 model_wd='DA',feh='p0.00',vvcrit='0.0',
                                 model_ifmr = 'Cummings_2018_MIST', 
                                 high_perc = 84, low_perc = 16,
                                 datatype='Gyr',
                                 return_distributions=True)
end = time.time()
print('{}s'.format(end - start))<jupyter_output>0.26989316940307617s<jupyter_text>We can see that the *freq* method takes a few seconds to run two white dwarfs. Let's take a look to see how the results looks like:<jupyter_code>results<jupyter_output><empty_output><jupyter_text>As we selected `return_distributions = True`, last the five columns are the distributions of the parameters, and we will use the `wdwarfdate.plot_distributions()` function to plot them. If we use the parameter name to give the file a name, we can save the figure as name_distributions.png, but we won't do that now, we just want it displayed. We need to make sure to select the same `data_type='Gyr'` we used to calculate the distributions and it is recommended to use the same high and low percentiles.<jupyter_code>print('teff:{}, logg:{}'.format(teffs[0],loggs[0]))
distributions0 = results['ms_age_dist','cooling_age_dist','total_age_dist','initial_mass_dist','final_mass_dist'][0]
wdwarfdate.plot_distributions(*distributions0,datatype='Gyr',high_perc=84,low_perc=16)
print('teff:{}, logg:{}'.format(teffs[1],loggs[1]))
distributions1 = results['ms_age_dist','cooling_age_dist','total_age_dist','initial_mass_dist','final_mass_dist'][1]
wdwarfdate.plot_distributions(*distributions1,datatype='Gyr',high_perc=84,low_perc=16)<jupyter_output>teff:20250, logg:8.526
{'fraction_non_alphanumeric': 0.10508569822983985, 'fraction_numerical': 0.02950266928912616, 'mean_word_length': 4.502318392581143, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '170649', 'license': 'MIT', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1073, 'n_words': 381, 'path': 'docs/source/tutorials/.ipynb_checkpoints/fast_test-checkpoint.ipynb', 'repo_name': 'rkiman/wdwarfdate', 'size': '3559'}