<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 K2SC Lightkurve Interface
Let's go through how you would use k2sc with its lightkurve interface to detrend the light curve of WASP-55. First, we import some things!
Step1:  Reading in data.
Let's search MAST for the long-cadence light curve file of WASP-55 using the lightkurve API, and do some very basic filtering for data quality.
Step2:  Let's now try K2SC!
As a quick hack for now, let's just clobber the lightkurve object class to our k2sc standalone.
Step3:  Now we run with default values!
The tqdm progress bar will show a percentage of the maximum iterations of the differential evolution optimizer, but it will usually finish early.
Step4:  Now we plot! See how the k2sc lightcurve has such better quality than the uncorrected data.
Careful with astropy units - flux and time are dimensionful quantities in lightkurve 2.0, so we have to use .value to render them as numbers.
Step5:  Now we save the data.
<ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib 
import matplotlib as mpl
import lightkurve  as lk
import k2sc
from k2sc.standalone import k2sc_lc
from astropy.io import fits
%pylab inline --no-import-all
matplotlib.rcParams['image.origin'] = 'lower'
matplotlib.rcParams['figure.figsize']=(10.0,10.0)    #(6.0,4.0)
matplotlib.rcParams['font.size']=16              #10 
matplotlib.rcParams['savefig.dpi']= 300             #72 
colours = mpl.rcParams['axes.prop_cycle'].by_key()['color']
import warnings
warnings.filterwarnings('ignore')
print(lk.__version__)
print(k2sc.__version__)
Explanation: K2SC Lightkurve Interface
Let's go through how you would use k2sc with its lightkurve interface to detrend the light curve of WASP-55. First, we import some things!
End of explanation
lc = lk.search_lightcurve('EPIC 212300977')[1].download()
lc = lc.remove_nans()
lc = lc[lc.quality==0]
Explanation: Reading in data.
Let's search MAST for the long-cadence light curve file of WASP-55 using the lightkurve API, and do some very basic filtering for data quality.
End of explanation
lc.__class__ = k2sc_lc
Explanation: Let's now try K2SC!
As a quick hack for now, let's just clobber the lightkurve object class to our k2sc standalone.
End of explanation
lc.k2sc()
Explanation: Now we run with default values!
The tqdm progress bar will show a percentage of the maximum iterations of the differential evolution optimizer, but it will usually finish early.
End of explanation
fig = plt.figure(figsize=(12.0,8.0))
plt.plot(lc.time.value,lc.flux.value,'.',label="Uncorrected")
detrended = lc.corr_flux-lc.tr_time + np.nanmedian(lc.tr_time)
plt.plot(lc.time.value,detrended.value,'.',label="K2SC")
plt.legend()
plt.xlabel('BJD')
plt.ylabel('Flux')
plt.title('WASP-55',y=1.01)
Explanation: Now we plot! See how the k2sc lightcurve has such better quality than the uncorrected data.
Careful with astropy units - flux and time are dimensionful quantities in lightkurve 2.0, so we have to use .value to render them as numbers.
End of explanation
extras = {'CORR_FLUX':lc.corr_flux.value,
          'TR_TIME':lc.tr_time.value,
          'TR_POSITION':lc.tr_position.value}
out = lc.to_fits(extra_data=extras,path='test.fits',overwrite=True)
Explanation: Now we save the data.
End of explanation
<END_TASK>