Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8d88df5
Merge pull request #42 from CheerfulUser/master
CheerfulUser May 1, 2025
bb67362
current working
CheerfulUser May 31, 2025
ef8139f
trying to fix errors
CheerfulUser Jun 24, 2025
ae6130e
added option to remove lightkurve cache files from tesscut
CheerfulUser Jul 1, 2025
20c8f87
disabling a broken test
CheerfulUser Jul 1, 2025
c226db2
messing with errors
CheerfulUser Aug 6, 2025
90bea12
messing with errors
CheerfulUser Aug 6, 2025
71edda3
messing with errors
CheerfulUser Aug 6, 2025
c8a426c
added in errors from the error array
CheerfulUser Aug 7, 2025
c236beb
added in new functions for the qe correction. Now will capture variat…
CheerfulUser Aug 12, 2025
3ffef88
small change
CheerfulUser Aug 12, 2025
f546db0
fix
CheerfulUser Aug 13, 2025
0a9cb42
some changes to straps and added in a new parameter for column offset
CheerfulUser Aug 14, 2025
5a127b8
reverting qe correction to previous stable state
CheerfulUser Aug 14, 2025
44ab58d
fix
CheerfulUser Aug 15, 2025
c283a32
winding back qe changes...
CheerfulUser Aug 15, 2025
a6b9ca5
fix
CheerfulUser Aug 15, 2025
1f50ae9
attempt to make things work again
CheerfulUser Aug 15, 2025
22d18ba
fix to moving mask
CheerfulUser Aug 15, 2025
09195f1
small fix
CheerfulUser Aug 17, 2025
88ef021
small fix
CheerfulUser Aug 17, 2025
d5c0b1a
update before freeze
CheerfulUser Aug 17, 2025
9881e6f
dissabled check_trend
CheerfulUser Aug 20, 2025
931f3cd
updated sector times
CheerfulUser Aug 20, 2025
275d80c
added an option to include the error image for memory concerns
CheerfulUser Aug 20, 2025
844c43e
fix
CheerfulUser Aug 20, 2025
0e4a6ac
scale of the differenced mask generation was not implemented correctly
CheerfulUser Aug 20, 2025
26dcd83
small shifts to the tessprf call
CheerfulUser Sep 13, 2025
235adbf
last bad PRF call
CheerfulUser Sep 19, 2025
e32755f
fixes with psf creation
CheerfulUser Sep 23, 2025
302cf23
fixed bug with prf model indexing
CheerfulUser Nov 7, 2025
6960540
fixes to get ztf data and the sn_lookup
CheerfulUser Nov 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 238 additions & 0 deletions development/update_tess_sectors.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "f699122a",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd \n",
"from astropy.time import Time"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "07bebdbf",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/db/hdghk6ts5g11hr10jq0ss625nf1ny2/T/ipykernel_10556/1019568273.py:1: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support skipfooter; you can avoid this warning by specifying engine='python'.\n",
" data = pd.read_csv('https://tess.mit.edu/public/files/TESS_orbit_times.csv',skipfooter=1)\n"
]
}
],
"source": [
"data = pd.read_csv('https://tess.mit.edu/public/files/TESS_orbit_times.csv',skipfooter=1)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "3ebad035",
"metadata": {},
"outputs": [],
"source": [
"sectors = data['Sector'].unique()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "6d49e9f4",
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame()\n",
"for sector in sectors:\n",
" s = data.loc[data['Sector'] == sector]\n",
" start = Time(s['Start of Orbit'].values[0])\n",
" end = Time(s['End of Orbit'].values[1])\n",
" entry = pd.DataFrame()\n",
" entry['Sector'] = [sector]\n",
" entry['mjd_start'] = [start.mjd]\n",
" entry['mjd_end'] = [end.mjd]\n",
" df = pd.concat([df,entry])"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "dfc55f06",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Sector</th>\n",
" <th>mjd_start</th>\n",
" <th>mjd_end</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>58324.815972</td>\n",
" <td>58352.684028</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2</td>\n",
" <td>58353.607639</td>\n",
" <td>58381.020833</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>3</td>\n",
" <td>58382.225694</td>\n",
" <td>58408.875000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4</td>\n",
" <td>58410.406250</td>\n",
" <td>58436.357639</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>5</td>\n",
" <td>58437.482639</td>\n",
" <td>58463.795139</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>93</td>\n",
" <td>60829.357639</td>\n",
" <td>60842.638889</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>94</td>\n",
" <td>60855.763889</td>\n",
" <td>60868.236111</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>95</td>\n",
" <td>60881.833333</td>\n",
" <td>60894.173611</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>96</td>\n",
" <td>60907.274306</td>\n",
" <td>60919.989583</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>97</td>\n",
" <td>60933.159722</td>\n",
" <td>60946.371528</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>97 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" Sector mjd_start mjd_end\n",
"0 1 58324.815972 58352.684028\n",
"0 2 58353.607639 58381.020833\n",
"0 3 58382.225694 58408.875000\n",
"0 4 58410.406250 58436.357639\n",
"0 5 58437.482639 58463.795139\n",
".. ... ... ...\n",
"0 93 60829.357639 60842.638889\n",
"0 94 60855.763889 60868.236111\n",
"0 95 60881.833333 60894.173611\n",
"0 96 60907.274306 60919.989583\n",
"0 97 60933.159722 60946.371528\n",
"\n",
"[97 rows x 3 columns]"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8efcc1f6",
"metadata": {},
"outputs": [],
"source": [
"def update_sector_times():\n",
" import pandas as pd \n",
" from astropy.time import Time\n",
" data = pd.read_csv('https://tess.mit.edu/public/files/TESS_orbit_times.csv',skipfooter=1)\n",
" sectors = data['Sector'].unique()\n",
" df = pd.DataFrame()\n",
" for sector in sectors:\n",
" s = data.loc[data['Sector'] == sector]\n",
" start = Time(s['Start of Orbit'].values[0])\n",
" end = Time(s['End of Orbit'].values[1])\n",
" entry = pd.DataFrame()\n",
" entry['Sector'] = [sector]\n",
" entry['mjd_start'] = [start.mjd]\n",
" entry['mjd_end'] = [end.mjd]\n",
" df = pd.concat([df,entry])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# What packages are required for this module to be executed?
REQUIRED = ['lightkurve>=2.0.0',
'numpy',
'numpy<2.0.0',
'photutils>=1.4',
'pandas',
'scipy!=1.4.0,!=1.4.1,>=0.19.0',
Expand Down
4 changes: 2 additions & 2 deletions tessreduce/calibration_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def Tonry_reduce(Data,plot=False,savename=None,system='ps1'):
colours = Make_colours(dat.iloc[ind],tonry,compare,Extinction = res.x, Tonry = True,system=system)
clip = Tonry_clip(colours,tonry)
#clips += [clip]
dat['locus'].iloc[ind] = clip
dat2 = dat.iloc[dat['locus'].values > 0]
dat.loc[ind,'locus'] = clip * 1
dat2 = dat.loc[dat['locus'] > 0]
#print('Pass ' + str(i+1) + ': ' + str(res.x[0]))
#clips[0][clips[0]] = clips[1]
if plot:
Expand Down
31 changes: 18 additions & 13 deletions tessreduce/cat_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def circle_app(rad):
"""
Makes a kinda circular aperture, probably not worth using.
"""
mask = np.zeros((int(rad*2+.5)+1,int(rad*2+.5)+1))
mask = np.zeros((int(np.round(rad*2,0))+1,int(np.round(rad*2))+1))
c = rad
x,y =np.where(mask==0)
dist = np.sqrt((x-c)**2 + (y-c)**2)
Expand All @@ -42,8 +42,8 @@ def ps1_auto_mask(table,Image,scale=1):
image = np.zeros_like(Image)
x = table.x.values
y = table.y.values
x = (x+.5).astype(int)
y = (y+.5).astype(int)
x = (np.round(x,0)).astype(int)
y = (np.round(y,0)).astype(int)
m = table.mag.values
ind = size_limit(x,y,image)
x = x[ind]; y = y[ind]; m = m[ind]
Expand Down Expand Up @@ -91,8 +91,8 @@ def gaia_auto_mask(table,Image,scale=1):
image = np.zeros_like(Image)
x = table.x.values
y = table.y.values
x = (x+.5).astype(int)
y = (y+.5).astype(int)
x = (np.round(x,0)).astype(int)
y = (np.round(y,0)).astype(int)
m = table.mag.values
ind = size_limit(x,y,image)
x = x[ind]; y = y[ind]; m = m[ind]
Expand All @@ -105,10 +105,15 @@ def gaia_auto_mask(table,Image,scale=1):
mags = [[18,17],[17,16],[16,15],[15,14],[14,13.5],[13.5,12],[12,10],[10,9],[9,8],[8,7]]
size = (np.array([3,4,5,6,7,8,10,14,16,18])*scale).astype(int)
for i, mag in enumerate(mags):
m = ((magim > mag[1]) & (magim <= mag[0])) * 1.
k = np.ones((size[i],size[i]))
conv = fftconvolve(m, k,mode='same')#.astype(int)
masks[str(mag[0])] = (conv >.1) * 1.
ind = (m > mag[1]) & (m <= mag[0])
magim = np.zeros_like(image)
magim[y[ind],x[ind]] = 1.
if size[i] >0:
k = np.ones((size[i],size[i]))
conv = fftconvolve(magim, k,mode='same')#.astype(int)
masks[str(mag[0])] = (conv >.1) * 1.
else:
conv = magim
masks['all'] = np.zeros_like(image,dtype=float)
for key in masks:
masks['all'] += masks[key]
Expand Down Expand Up @@ -143,8 +148,8 @@ def Big_sat(table,Image,scale=1):
sat = table.iloc[i]
x = sat.x.values
y = sat.y.values
x = (x+.5).astype(int)
y = (y+.5).astype(int)
x = (np.round(x,0)).astype(int)
y = (np.round(y,0)).astype(int)
m = sat.mag.values
ind = size_limit(x,y,image)

Expand Down Expand Up @@ -217,7 +222,7 @@ def Strap_mask(Image,col,size=4):
big_strap = fftconvolve(strap_mask,np.ones((size,size)),mode='same') > .5
return big_strap

def Cat_mask(tpf,catalogue_path=None,maglim=19,scale=1,strapsize=3,ref=None,sigma=3):
def Cat_mask(tpf,catalogue_path=None,maglim=19,scale=1,strapsize=3,ref=None,sigma=3,col_offset=0):

"""
Make a source mask from the PS1 and Gaia catalogs.
Expand Down Expand Up @@ -277,7 +282,7 @@ def Cat_mask(tpf,catalogue_path=None,maglim=19,scale=1,strapsize=3,ref=None,sigm
sat = (np.nansum(sat,axis=0) > 0).astype(int) * 2 # assign 2 bit

if strapsize > 0:
strap = Strap_mask(image,tpf.column,strapsize).astype(int) * 4 # assign 4 bit
strap = Strap_mask(image,tpf.column+col_offset,strapsize).astype(int) * 4 # assign 4 bit
else:
strap = np.zeros_like(image,dtype=int)

Expand Down
14 changes: 7 additions & 7 deletions tessreduce/delta_function_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from scipy.optimize import minimize

def Delta_basis(Size = 11):
kernel = np.zeros((Size,Size))
def Delta_basis(size = 11):
kernel = np.zeros((size,size))
x,y = np.where(kernel==0)
middle = int(len(x)/2)
basis = []
Expand All @@ -22,17 +22,17 @@ def Delta_basis(Size = 11):
coeff = np.ones(len(basis))
return basis, coeff

def Delta_kernel(reference,image,Size=11,mask=None):
def Delta_kernel(reference,image,size=11,mask=None):
if mask is None:
mask = np.ones_like(image)
mask[mask == 0] = np.nan
Basis, coeff_0 = Delta_basis(Size)
Basis, coeff_0 = Delta_basis(size)
bds = []
for i in range(len(coeff_0)):
bds += [(0,1)]
coeff_0 *= 0.01
coeff_0[Size//2+1] = 0.95
res = minimize(optimize_delta, coeff_0, args=(Basis,reference,image,Size,mask),
coeff_0[size//2+1] = 0.95
res = minimize(optimize_delta, coeff_0, args=(Basis,reference,image,size,mask),
bounds=bds,method='Powell')
k = np.nansum(res.x[:,np.newaxis,np.newaxis]*Basis,axis=0)
return k
Expand All @@ -50,7 +50,7 @@ def optimize_delta(Coeff, Basis, reference, image,size,mask):


def parallel_delta_diff(image,reference,mask=None,size=11):
kernel = Delta_kernel(reference,image,Size=11,mask=mask)
kernel = Delta_kernel(reference,image,size=size,mask=mask)
template = signal.fftconvolve(reference, kernel, mode='same')
diff = image - template
return diff, kernel
Expand Down
Loading