Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 65e56c7b authored by DUVERNE Pierre-Alexandre's avatar DUVERNE Pierre-Alexandre
Browse files

Delete interpolate.py

parent f00ced35
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 26 16:50:27 2021
@author: duverne, IJClab, Orsay, duverne@protonmail.com
"""
import numpy as np
from astropy.table import Table
import matplotlib.pyplot as plt
B_band = Table.read('/home/duverne/Documents/agatha_pipeline/results/B_muphoten.dat',
format='ascii.commented_header')
g_band = Table.read('/home/duverne/Documents/agatha_pipeline/results/g_muphoten.dat',
format='ascii.commented_header')
r_band = Table.read('/home/duverne/Documents/agatha_pipeline/results/r_muphoten.dat',
format='ascii.commented_header')
from scipy.interpolate import UnivariateSpline
from scipy.interpolate import CubicSpline
# interpolate g band
spl = UnivariateSpline(g_band['time'], g_band['gmag'],
1/g_band['error_tot'],
k=2,
s=1000)
# spl.set_smoothing_factor(0.1)
# Derive interpolation for g
dspl = spl.derivative()
# interpolate B band
spl2 = UnivariateSpline(B_band['time'], np.array(B_band['BMag']),
1/B_band['error_tot'],
k=1.0,s=75)#,
# s=1)
# spl2.set_smoothing_factor(0.1)
# derive interpolation for B
dspl2 = spl2.derivative()
# r_band['time'].sort
spl3 = UnivariateSpline(r_band['time'], np.array(r_band['rmag']),
1/r_band['error_tot'],
k=2.0,s=900)
xnew1 = np.linspace(np.min(r_band['time']), np.max(r_band['time']), 10000)
dspl3 = spl3.derivative()
fig, main_axes = plt.subplots(2,1, figsize=(7.5, 15), sharex=True)
plt.gcf().subplots_adjust(left = 0.1, bottom = 0.05,
right = 0.95, top = 0.95, wspace = 0.5, hspace = 0.2)
main_axes[0].errorbar(r_band['time'], r_band['rmag'],
yerr=r_band['error_tot'],
label= r'Muphoten r band',
marker = 'o', linestyle = 'none',
color = 'blue',
ms=5)
main_axes[0].plot(xnew1, spl3(xnew1), color = 'black')
main_axes[0].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[0].set_ylabel(r'$Magnitude$')
main_axes[0].set_title(r'$Lightcurve$ $the$ $Cow$ $r$')
main_axes[0].legend()
main_axes[0].invert_yaxis()
main_axes[1].plot(xnew1, dspl3(xnew1), color = 'black',
label = 'r band')#, linestyle='none', marker='o', ms=6)
main_axes[1].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[1].set_ylabel(r'Decay Rate [mag/day]')
main_axes[1].set_title(r'Decay Rate r')
main_axes[1].legend()
fig, main_axes = plt.subplots(3,1, figsize=(7.5, 15), sharex=True)
plt.gcf().subplots_adjust(left = 0.1, bottom = 0.05,
right = 0.95, top = 0.95, wspace = 0.5, hspace = 0.2)
sup = np.max((np.max(g_band['time']), np.max(r_band['time'])))
inf = np.min((np.min(g_band['time']), np.min(r_band['time'])))
xnew3 = np.linspace(inf, sup, 100)
spl4 = spl(xnew3) - spl3(xnew3)
main_axes[0].plot(xnew3,spl4)
main_axes[0].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[0].set_ylabel(r'$g-r$')
main_axes[0].set_title(r'Color Evolution the Cow')
main_axes[1].errorbar(r_band['time'], r_band['rmag'],
yerr=r_band['error_tot'],
label= r'Muphoten r band',
marker = 'o', linestyle = 'none',
color = 'blue',
ms=5)
main_axes[1].plot(xnew3, spl3(xnew3), color = 'black')
main_axes[1].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[1].set_ylabel(r'$Magnitude$')
main_axes[1].set_title(r'$Lightcurve$ $the$ $Cow$ $r$')
main_axes[1].legend()
main_axes[1].invert_yaxis()
main_axes[2].errorbar(g_band['time'], g_band['gmag'],
yerr=g_band['error_tot'],
label= r'Muphoten g band',
marker = 'o', linestyle = 'none',
color = 'blue',
ms=5)
main_axes[2].plot(xnew3, spl(xnew3), color = 'black')
main_axes[2].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[2].set_ylabel(r'$Magnitude$')
main_axes[2].set_title(r'$Lightcurve$ $the$ $Cow$ $g$')
main_axes[2].legend()
main_axes[2].invert_yaxis()
# Find the extrema of x axis
sup = np.max((np.max(g_band['time']), np.max(B_band['time'])))
inf = np.min((np.min(g_band['time']), np.min(B_band['time'])))
xnew = np.linspace(inf, sup, 100)
xnew2 = np.linspace(np.min(B_band['time']), np.max(B_band['time']), 100000)
# plot the interpolations and color evolution
fig, main_axes = plt.subplots(3,1, figsize=(7.5, 15), sharex=True)
plt.gcf().subplots_adjust(left = 0.1, bottom = 0.05,
right = 0.95, top = 0.95, wspace = 0.5, hspace = 0.2)
main_axes[0].errorbar(g_band['time'], g_band['gmag'],
yerr=g_band['error_tot'],
label= r'Muphoten g band',
marker = 'o', linestyle = 'none',
color = 'blue',
ms=5)
main_axes[0].plot(xnew, spl(xnew), color = 'black')
main_axes[0].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[0].set_ylabel(r'$Magnitude$')
main_axes[0].set_title(r'$Lightcurve$ $the$ $Cow$ $g$')
main_axes[0].legend()
main_axes[0].invert_yaxis()
main_axes[1].errorbar(B_band['time'], B_band['BMag'],
yerr=B_band['error_tot'],
label= r'Muphoten B band',
marker = 'o', linestyle = 'none',
color = 'blue',
ms=5)
main_axes[1].plot(xnew, spl2(xnew), color = 'black')
main_axes[1].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[1].set_ylabel(r'$Magnitude$')
main_axes[1].set_title(r'$Lightcurve$ $the$ $Cow$ $B$')
main_axes[1].legend()
main_axes[1].invert_yaxis()
spl3 = spl2(xnew) - spl(xnew)
main_axes[2].plot(xnew,spl3)
main_axes[2].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[2].set_ylabel(r'$B-g$')
main_axes[2].set_title(r'Color Evolution the Cow')
##### Plot the decay rate #####
fig, main_axes = plt.subplots(2,1, figsize=(7.5, 15), sharex=True)
plt.gcf().subplots_adjust(left = 0.1, bottom = 0.05,
right = 0.95, top = 0.95, wspace = 0.5, hspace = 0.2)
main_axes[0].plot(xnew, dspl(xnew), color = 'black', label = 'g band')
main_axes[0].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[0].set_ylabel(r'Decay Rate [mag/day]')
main_axes[0].set_title(r'Decay Rate g')
main_axes[0].legend()
main_axes[1].plot(xnew2, dspl2(xnew2), color = 'black',
label = 'B band')#, linestyle='none', marker='o', ms=6)
main_axes[1].set_xlabel(r'$Time$ $-$ $MJD$ $58285.441$ $(days)$')
main_axes[1].set_ylabel(r'Decay Rate [mag/day]')
main_axes[1].set_title(r'Decay Rate B')
main_axes[1].legend()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment