<jupyter_start><jupyter_text>Example of lightcurve generation<jupyter_code>import os
import pickle
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
from sso_tools import catalogs
from sso_tools import lightcurves as lcc
from sso_tools import ztf
# Read (previously pulled from database) alert data
datadir = '/epyc/projects/sso-lc/notebooks/jan_04'
alertdata = ztf.read_alert_datafile(os.path.join(datadir, 'ztf_alerts_sso.csv'))
# Identify candidates -- just minimum # of observations, per object
objnames = ztf.identify_candidates(alertdata, min_obs=50, dist_cutoff=10)
print('Alerts ranging from %s to %s' % (alertdata.obsdate.min(), alertdata.obsdate.max()))
print("Total SSO alerts %d" % len(alertdata))
print("Number of different objects %d" % len(alertdata.groupby('ssnamenr')))
print("Number of nights included %d" % len(alertdata.groupby('nid')))
print("Looking for %d objects in this set." % (len(objnames)))
name = '68950'
# Generate oorb-corrected magnitudes (and pull JPL database)
# Note when pulling out observations here, the only outlier rejection is based on ssdistnr
print(name)
ast = ztf.AsteroidObj(magcol='magpsf')
ast(alertdata, name, minJD=None, maxJD=None)
# Look at the orbit info (from JPL) - this is a pandas Series
ast.orbit
# Look at the information in the observations - this is a pandas DataFrame
print(ast.obs.columns.values)
ast.obs[0:3]
# Can check the ZTF predicted astrometric residuals (ssdistnr)
fig = ast.check_astrometry()
# Look at the photometry and oorb predicted magnitudes
fig = ast.vis_psf_ap_photometry()
# Add visualization of outlier rejection here too? 
# Fit the lightcurve. 
lc = lcc.LCObject(min_period=1.0/24.0, max_period=60.0/24.0, 
                  nsigma=3, Nterms_base=2, Nterms_band=0)
df = ast.translate_df()
# lightcurve fitting with gatspy.periodic.LombScargleMultiband - 
# multiple band, multi-component lightcurve fitting using LS methods
figs = lc(df, ast.offsets)
# See the individual methods, if 
help(lc)<jupyter_output>Help on LCObject in module sso_tools.lightcurves.lc_utils object:

class LCObject(builtins.object)
 |  Methods defined here:
 |  
 |  __call__(self, lcobs, photoffsets=None, outfile=None)
 |      Call self as a function.
 |  
 |  __init__(self, min_period=0.041666666666666664, max_period=2.5, nsigma=3, Nterms_base=2, Nterms_band=0)
 |      Parameters
 |      ----------
 |      min_period: float, opt
 |          Minimum period to fit for, in days.
 |      max_period: float, opt
 |          Maximum period to fit for, in days.
 |      nsigma: int, opt
 |          Number of standard deviations to allow around the mean, before rejecting input data points.
 |      Nterms_base: int, opt
 |          Number of terms for the base LS fit. Default 2.
 |      Nterms_band: int, opt
 |          Number of terms to allow between bandpasses. Default 1.
 |  
 |  calc_chisq(self, period=None)
 |  
 |  fit_model(self)
 |      Fit the lightcurve data using periodic.LombScargleMultiband.
 |  
 |  make_auto_p[...]
{'fraction_non_alphanumeric': 0.09973666886109282, 'fraction_numerical': 0.017445687952600396, 'mean_word_length': 4.107563025210084, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '379972', 'license': 'MIT', 'n_tokens_mistral': 1063, 'n_tokens_neox': 991, 'n_words': 307, 'path': 'ZTF_objdata.ipynb', 'repo_name': 'dirac-institute/sso_tools_notebook', 'size': '3038'}